07-18-2012 07:25 AM - edited 07-18-2012 07:27 AM
Dear all,
within a state machine (my first one, yay), I want to do measurements with DAQmx. The idea of my states is:
- Initialize the DAQmx channels (up to the timing VI) - bundle by name to a cluster.
.
.
.
- measurement: Measure 2 different voltages and 1 frequency (n samples).
- logging the data.
- repeating the measurement, logging, and so on.
In my code, the first measurement (state= "messung") runs well, however, when I do the second measurement I get the error that the task does not exist. Probably this is because I cleared the task after the first measurement, but from my understanding, I send the "old" cluster of tasks (meaning with the UNcleared tasks) to the shift register. Apparently this is not the case !?
I'd be thankful for any hints - also the error handling seems not to be solved the best way.
Regards
Jack
07-18-2012 07:38 AM
edit: in the version uploaded, I tried to solve the issue described in my post by not clearing the task but sending the output of the "stopVI" to the cluster and the shift register. However, now I get an error -200479 (operation cannot be performed while still running). Anyhow, a hint how to execute the task multiple times in the "messung"-state would be great.
Regards
Jack
07-18-2012 09:34 AM - edited 07-18-2012 09:39 AM
not knowing where your error occured....use the troubleshooting "highlight execution" on your block diagram(light bulb) and run the vi. Reconcile that error on that function vi...I would merge all your error cluster lines together, there are some that are left untied.
07-18-2012 10:27 AM
To add to apok's reply, do you know which task is erroring? To help with this, you can add a DAQmx Create Task before your calls to DAQmx Create Channel. This would allow you to name each task, and this name would be reported along with any error you receive. While this won't fix the problem, it would help narrow the scope. I'll look a little deeper and see if I can spot what's wrong, however knowing which task was erroring would help this process.
Dan
07-18-2012 10:28 AM - edited 07-18-2012 10:29 AM
you had not connected an unbundled output (Pulse train)...that's one of your errors!
should be
07-18-2012 10:30 AM
Actually, I think I spotted it... You have a CI Freq task (Frequ) which you configure as continuous in 'init'. This task gets started and read in 'messung', however it is not stopped. Therefore the second time you call 'messung' it will already be running and the call to DAQmx Start Task will error.
Dan
07-18-2012 10:38 AM
One other comment about your 'messung' state. I notice that you are not specifying the 'number of samples per channel' input to any of your read VI's. That means DAQmx will default to reading 'all available samples' for continuous tasks (which includes zero samples), and all samples for finite tasks. If it is important for you to read a certain number of samples with each task, you should set the 'number of samples per channel' input to DAQmx Read.
One last thing that should help your tasks execute a little faster. I would recommend that in your 'init' state, you use DAQmx Control task to commit each task. This will advance DAQmx's internal state machine a bit further, and leave less work to do when you start/stop the tasks later.
Dan
07-18-2012 12:14 PM
Thanks to everyone for the help! As it's past working hours here (Europe), I can't try out the hints until tomorrow, but I will report the results, thanks for now!
07-18-2012 03:39 PM
I was able to get your vi running…the error you were getting was from the “change pitch” case statement, you had a “DAQmx Start Task” that was happening multiple times. Delete it and it will run…or properly stop the task.