How can I debug this communication issue to ensure ControlTask always reads the latest data?
@Middleware & OS I'm working on a robotic arm controlled by FreeRTOS with two tasks;
SensorTask
which continuously reads joint angles and stores them in a shared variable (a global array), and ControlTask
which retrieves sensor data and calculates motor commands every 10ms.
ControlTask
sometimes reads outdated data, causing jittery movements. I've verified SensorTask
updates the variable correctly.
Error Message:
How can I debug this communication issue to ensure ControlTask always reads the latest data?Solution:Jump to solution
If you must use a global variable try a semaphore to protect the shared variable during access. The sensor task acquires the semaphore before updating the variable , and the control task acquires it before reading the variable all these are so you can make only one task access the variable at a time. @Marvee Amasi
3 Replies
Do you know how to use
queue
? Instead of using global variable. @Marvee Amasi@UC GEE okay I do in a way , but it's just what I am working with
Solution
If you must use a global variable try a semaphore to protect the shared variable during access. The sensor task acquires the semaphore before updating the variable , and the control task acquires it before reading the variable all these are so you can make only one task access the variable at a time. @Marvee Amasi