LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Set to zero after stopping a task

Solved!
Go to solution

Hello,

 

I have a little question. I have a task that generates a signal. Now I have a function that can pause the task. I pause the task with the command DAQmxStopTask and start the task again with DAQmxStartTask. Now I found out when I pause the task the signal level gets hold on the value the signal stopped. (Example: When the signal is high and I stop there the output will stay high)

But for my application it is important to set the signal level to low when I pause the task. But that works not as I like. Following you can see how I stop the task and how I would like to set the output to zero. I start the main program with a different function where I write the correct samples to start the task correct again.

// Pause the task

DAQmxErrChk(DAQmxStopTask(AnalogTask));

// Set output to 0
DAQmxErrChk(DAQmxWriteAnalogScalarF64 (AnalogOutTaskHandle, 0, 10.0, 0, 0));
DAQmxErrChk(DAQmxStartTask (AnalogOutTaskHandle));
DAQmxErrChk(DAQmxStopTask(AnalogOutTaskHandle));
Sometimes it works for the first run but not for the second run. I start my program than I pause the program, set the output to zero. Then I start my main program again and when I pause the task again I get an failure that the generation has stopped to prevent the regeneration of old samples. I did get the failure when I pause the program for the first time too.

So I would like to now if this way is the correct way or if there is a better way?

(It could be that the failure is in another part of the program. I have a register callback function that gets activated when I send samples from the buffer to the device to generate the samples for the main program. Could it be that these callback gets activated because it is the same task I use for setting the channel to zero.)

 

Hope someone can help.

 

Best regards

 

0 Kudos
Message 1 of 3
(2,830 Views)

I forgot to mention that I use the PCIe-6343 and it is not possible to use this command: DAQmxSetChanAttribute (AnalogOut, "", DAQmx_DO_LineStates_PausedState, DAQmx_Val_Low); 

 

Best regards

0 Kudos
Message 2 of 3
(2,796 Views)
Solution
Accepted by topic author Fasching_K

I found the solution for my problem already. It is not very efficient but yeah.

I clear all the task when the break is activated. Then I create the task again with the new settings where I set all the outputs to zero. Start the task and set the output to zero. After this I clear the tasks again and configure them in the state when I break the program. If there is a better solution please tell me.

 

Best regards

0 Kudos
Message 3 of 3
(2,783 Views)