Quote:
What would be the proper way to set this up? Set up a "Periodic Task" running at 5ms (200Hz) to grab accelerometer data? I wonder how much code the VI would generate for this seemingly simple task? This task would obviously have to preempt Teleop execute in order to run properly.
I would think that the 5ms task would contain a ring buffer to hold the 10 samples, and that's all it would do (to keep it short).
Then, a 20ms task would grab a copy of the ring buffer and do the averaging and other calculations. Instead of a separate 20ms Periodic Task, should this be coded directly in Teleop execute?
What special precautions does the LabVIEW programmer need to take, to assure that the 5ms task is not writing data to the ring buffer while the 20ms task is attempting to read it? Or is that all handled automagically by the LabVIEW compiler and the RTOS?
|
The size of the loop to read the accelerometer data is easily measured as is the time. I suspect it will take between one and two ms to run, and as with camera tasks, it will not have too much trouble preempting the teleop code and vice versa. Since the timing of the accelerometer samples may be important, it may be a good idea to use a timed loop and perhaps to elevate the priority of the loop to cut down on jitter.
If you really want to read the accelerometer with the best timing, you set up a DMA channel to implement the ring or buffer. You can then run your acquisition on multiple channels at 5kHz or so. The RT loop can then do the processing on the buffer.
To the other question, value updates and data transfers are atomic, and that includes arrays, clusters, etc. I wouldn't necessarily say it is automagic, but it is certainly nice, especially when you like correct answers.
Greg McKaskle