LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx clear task using state machine

Hello everyone,

 

I have written a labVIEW program using 9.0 (attached below) which acquires data from 4 sensors.  I need to continuously acquire data and then upon a user input, sample only 5000 samples and perform an analysis on the data.  The problem I am running into is that I can take a measurement fine the first time (take the 5000 samples), but if I want to take another data point I get this error:

 

Error -200429 occurred at DAQmx Read (Analog 1D Wfm NChan NSamp).vi:5

Possible reason(s):

Measurements: Value passed to the Task/Channels In control is an empty string (or I/O control).

The value must refer to a valid task or valid channels.

 

I am not sure if it is a matter of how I am clearing the tasks or not?

 

 

As a matter on the side, I do not know what I changed in my code, but when I select the "Take Measurement" button to initiate taking the 5000 samples and run the analysis on the data, the "Instrument Readings" Table does not display the raw, scaled and averaged data from the instruments from which the analysis was performed using those values.

 

Suggestions and direction would be greatly appreciated!

-Ellen

Download All
0 Kudos
Message 1 of 2
(2,105 Views)

Ellen,

 

In cases 0 and 1 you read some samples then clear the task.  You created the task outside the loop.  So after any iteration which executes case 0 or 1, the task will have been cleared and the next attempt to read will fail with the invalid task error.

 

Clearing the task should be done only after the loop exits.

 

Better would probably be to create a real state machine.  Then the task creation could be in an Initialization state and clearing the task would be in a Shutdown state.  I would have only one state where data was read.  Pass the data to other states via a shift register and perform the analysis and data saving in those states.

 

Lynn

0 Kudos
Message 2 of 2
(2,098 Views)