Here is the idea behind what I'm trying to do (on an Axon, if it matters):
Have the PC monitor the UART1 (which in my case is acting like a com port). The PC will send an encoder position to a DC motor that is being controlled by the Axon. Once the Axon moves to that position, it sends data to the PC and requests more. So the flow of the program should be:
1) SET AXON MODE: Ready to accept data
2) LOOP until PC sends data
3) RECEIVE PC data
4) EXECUTE PC instructions while querying the UART in case the PC sends an interrupt command
5) WHEN FINISHED, return to 1
Now, with the old Axon code, this works perfectly fine, since I have control over my program loops. With Webbot lib, I don't seem to have this control -- the scheduler just keeps calling my appControl function whenever it's done. This leaves me in something of a problem:
I wonder if it's possible to set a global variable that persists outside of a call to appControl, so that when we go back into appControl the Axon can still know which of its execution modes it's supposed to be in. The Axon also has to store the instructions that the PC sent it during the last time through the loop, so that if the motion takes longer than one time through the old setpoints are not lost.
I hate to declare everything as a global variable (I'm not even sure I can in the Axon?) is there an easier way to gain control over my program loops?