Quote:
Originally Posted by Mark McLeod
You could write this as a state machine in Teleop.vi or you could write it as a sequence in Periodic.vi
It's probably clearer to visualize as a sequence structure in Periodic.vi
|
I understand the real-time consequences of writing it as a state machine in Teleop.
As for "sequence in Periodic vi" I'm not as sure. Here's what I think you mean, in pseudo-code (with line numbers for reference):
10 loop:
15 loop1:
20 watchdog_delay_and_feed(some reasonable polling value, say 40ms?)
25 if you haven't received a kick command from teleop, goto loop1
30 do something here
35 watchdog_delay_and_feed( 2 seconds)
40 do something else here
45 clear the kick command
50 goto loop
Is the above a possible implementation of what you are suggesting? If not, could you give more details please. If so, I have some questions/comments:
The infinite loop (lines 10 and 50) means that this task never terminates. So in that sense it's not "periodic", even though it uses the "machinery" of the periodic vi in the framework. true?
The watchdog delay and feed in line 20 is required so that this "periodic" task does not consume all the CPU resources. It releases the CPU to go do other things. The RTOS recognizes this command as an opportunity to take resources away from this task and use it for other tasks. Is this anywhere close to true? How does the RTOS know when to return to this task? Does the "watchdog delay and feed" command cause the RTOS to suspend the task and set some sort of timer event to wake it back up again?
What's the best way to pass a "kick command" (lines 25 and 45) to this task? Some have suggested using a simple global boolean. What are the benefits/drawbacks of doing this? What are the advantages of using other approaches?
Our team is brand-new to LabVIEW this year, and they have zero prior knowledge/experience with real-time control. I am trying to teach them some fundamentals in language they can understand, but I am hampered by the fact that I know absolutely nothing about LabVIEW and am having difficulty relating it to the real-time knowledge I already have from working with embedded reatime projects using assembly language and C.
Thanks.
~