LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine and DAQmx

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

0 Kudos
Message 1 of 9
(3,944 Views)

 

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

0 Kudos
Message 2 of 9
(3,933 Views)

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.

0 Kudos
Message 3 of 9
(3,919 Views)

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

0 Kudos
Message 4 of 9
(3,904 Views)

you had not connected an unbundled output (Pulse train)...that's one of your errors!

 

unbundle1.png should beunbundle.png

0 Kudos
Message 5 of 9
(3,903 Views)

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

0 Kudos
Message 6 of 9
(3,901 Views)

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

0 Kudos
Message 7 of 9
(3,896 Views)

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!

0 Kudos
Message 8 of 9
(3,884 Views)

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.

0 Kudos
Message 9 of 9
(3,870 Views)