12-13-2010 07:48 PM
Hi all,
I have a fairly simple data acquisition task (read 8 channels off a USB 6212 at around 1 hz, scale the numbers and save them to a file). I decided to try to use this project to learn more about action engines. I've read through Ben's post many times, and tried out a number of simple examples that seemed to work.
I'm now trying to use an action engine to handle various DAQ tasks in one loop, using a queue to pass the data to my main loop for graphing and saving. I tried to model this on an example I found here: http://forums.ni.com/t5/LabVIEW/TDMS-with-Action-Engine-Functional-Global/td-p/675688 . I've seen a number of posters mention that this is something they use action engines for.
Some parts of my setup seem to work, but not very well. One thing that is tying me up in knots is how to report errors between the two loops. I tried having a case in the AE that didn't do anything but report out the error, but I seem to get stuck in that case. I also have the problem of how to clear errors when I don't need them (e.g., the first time I run this) but have them persist when they are real. Maybe the auto-initializing AE in the above example?
Another big problem I am having is how to reset tasks between runs of the program. I've been getting lots of errors where the program reports the task already exists, so I have gotten rid of naming the task and have been manually resetting the device after every test.
I would appreciate any suggestions as to how to improve this code. I've resorted to throwing in the odd local variable, just because I know that will work, but I was hoping to use the AE to help eliminate these.
Thanks,
mike
12-14-2010 08:41 AM
Mike,
I can see why you may be confused. All the crooked wires and overlapping nodes and wires makes it hard to follow what is going on.
Why not make two AEs, one for the tasks and a separate one for errors? After you are comfortable with the concept, then look to see if it makes sense to combine them.
I would put ALL the DAQ VIs in one place. Do not put some of them in the AE and others in the main loop. I often have a parallel loop with the DAQ stuff. I send commands (and parameters like Task IDs) from the Main loop to the DAQ loop via a queue. I return the data and the status (like errors) via a second queue. If the data is a large array or it gets used several places, I may put it into an AE rather than a queue. Generally it is better to retrieve the data from the queue with the Deqeue function rather than Flush Queue.
Lynn