12-04-2012 08:11 AM
Hello,
I have created a state machine structure which is designed to configure a number of different DAQmx channels for data aqcuisition (the section of code with some analysis indication is attached).
The first time I run this vi, I get an array with the specified task names in (with a blank first line), but subsequent executions throw an error that the task name is already specified, leading me to believe that the tasks are not being correctly closed down, but I'm not sure how to configure the close task vi in this case.
Also in the initialise state, I have placed an empty array which is obviously giving me my blank first line, but if I remove this, it breaks the vi as one of the case terminals is then unwired.
Would someone be able to guide me to a more correct solution, please?
--dave
Solved! Go to Solution.
12-04-2012 08:33 AM - edited 12-04-2012 08:34 AM
Purely given this example, here's a few things I would change:
Use a FOR loop instead of a while loop. No point in the Initialize case. You want to use a Shift Register to add the channels to your task. There should only be a single task for the thermocouples, one task for the oil system, etc. See attached for a quick example.
From this example, I would think your error is coming from the fact that you are creating a 2D array of tasks. And each row must have the same number of elements, and you are getting a bunch of NULL tasks.
12-04-2012 12:17 PM
Thanks for that crossrulz, that makes complete sense to me. I like the approach of having an array of enums on the input to the loop, it seems much cleaner than the standard state machine architecture.
--dave