Quote:
Originally Posted by DominickC
I did not intend for my loops to be blocking (at least not in this situation). How could I write a value (such as a motor output) then rewrite a value 500ms later without it becoming a blocking loop?
|
#include "taskLib.h"
#include "sysLib.h"
....
taskDelay(sysClkRateGet()/2); // wait 0.50 seconds
The WPILib has a delay function in it also, taskDelay is the native vxWorks function.
We send messages from one task to another and block waiting on the messages. For example the task receiving data from the DS sends a message to the motor task telling it the desired velocity. The motor task calculates the PID setpoints then blocks again waiting for another message, consuming no bandwidth. The PID callbacks are running off a timer of course but that is all in the PID classes. It is relatively simple and efficient.