Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to restart M Series continuous waveform AO and DO as synchronized after stopping them with DAQmx ?

I have an M Series NI 6259 performing simultaneous started and synchronized analog out and clocked digital out continuous waveform generation using DAQmx function calls. The DO clock source is set to the ai/SampleClock. The DO Task is started before the AO Task so that the DO effectively waits for the AO to actually start. Thus when the AO Task is started using StartTask, they start simultaneously and synchronized. I can observe this by having the AO and DO generate pulses.

If the task is stopped using StopTask (perhaps to change some parameters such as waveform length) and then restarted in the above fashion, the AO and DO are no longer synchronized as to thei
r positions in their waveforms. It seems that they begin generating again from where they left off when stopped. Since they cannot be stopped simultaneously, they will be out of sync when restarted. Is there a way to reset the AO and DO wavefrom indexes to their beginning again or do something else to synchronize them ?

Additionally, when a continuous waveform generation task is stopped, is there a way to have it not stop until its current cycle completes instead of stopping immediately ? i.e. have it stop at its last wavefrom array index.
0 Kudos
Message 1 of 7
(4,553 Views)
Steve,

I would love to look at your could if you attach it. We may be able to figure it out if I have it in front of me.

Thanks,
Anuj D.
0 Kudos
Message 2 of 7
(4,553 Views)
I've tested your use case thoroughly, following these steps:

1. create AO task and channel
2. create DO task and channel
3. configure AO timing - continuous
4. configure DO timing - continuous, source: ao/SampleClock
5. write AO Waveform
6. write Digital data
7. Start Digital
8. Start AO
(let it go)
9. Stop AO
10. Stop Digital
11. Write new AO Data (I've tried with and without this step)
12. Goto step 7

Both the AO and the DO get restarted from the beginning of the written data everytime I call start. This has always been the behavior for both tasks in DAQmx (at least since 7.2). I'm using flat sequences to synchronize the start and stop steps.

I'd appreciate if you could attach your VI, or, if you'd prefer, contact me directly through e
-mail. Please let me know what works best for you.
Message 3 of 7
(4,554 Views)
I'm actually using Delphi and calling DAQmx functions in nicaiu.dll.

DAQmxCreateTask('', pointer(AO_TaskHandle) );
DAQmxCreateTask('', pointer(DO_TaskHandle) );

DAQmxCreateAOVoltageChan (AO_TaskHandle, 'Dev1/AO0', nil , -10, 10, {units} 10348, nil);
DAQmxCreateDOChan (DO_TaskHandle, {lines} 'Dev1/port0', {nameToAssignToLines} nil, {lineGrouping} 1);

DAQmxCfgSampClkTiming (AO_TaskHandle, {source} nil, {rate} 100, {activeEdge} 10171 {Falling}, {sampleMode} 10123 {10123=continuous, 10178=finite}, {sampsPerChanToAcquire} 100);
{ DAQmxCfgOutputBuffer is not necessary and results are the same without it }
DAQmxCfgOutputBuffer (AO_TaskHandle, {numSampsPerChan} 100);

DAQmxCfgSampClkTiming (DO_TaskHandle, {source} 'ao/SampleClock', {rate} 100, {activeEdge} 10171 {Falling}, {sampleMode} 10123 {10123=continuous}, {sampsPerChanToAcquire} 100);
{ DAQmxCfgOutputBuffer is not necessary and results are the same without it }
DAQmxCfgOutputBuffer (DO_TaskHandle, {numSampsPerChan} 100);

setlength(AO_wfm, 100);
setlength(DO_wfm, 100);

{ create a pulse consisting of one non-zero data point and the rest zero }
AO_wfm[0] := 2000;
for index := 1 to 99 do AO_wfm[index] := 0;

DO_wfm[0] := 1;
for index := 1 to 99 do DO_wfm[index] := 0;

DAQmxWriteRaw (DO_TaskHandle, {numSamps} 100, {autoStart} 1, {timeout} 1.0, pointer(DO_wfm), pointer(sampsPerChanWritten), {reserved} nil);
DAQmxWriteRaw (AO_TaskHandle, {numSamps} 100, {autoStart} 1, {timeout} 1.0, pointer(AO_wfm), pointer(sampsPerChanWritten), {reserved} nil);

DAQmxStartTask (DO_TaskHandle);
DAQmxStartTask (AO_TaskHandle);

{ the task runs and I can observe synchronized waveforms - their pulses appear at the same point in time }

{ stop the tasks }
DAQmxStartTask (AO_TaskHandle);
DAQmxStartTask (DO_TaskHandle);

{ restart the tasks }
DAQmxStartTask (DO_TaskHandle);
DAQmxStartTask (AO_TaskHandle);

Now the two pulse do not have correct timing with respect to each other. If I again stop and restart the tasks, their pulses appear at different times with respect to each other from the previous stop/restart cycle.

I've been told that LabVIEW actually calls a different dll than nicaiu.dll than Delphi does. Perhaps that other dll is configured to restart from the first data point and nicaiu.dll is not ? I do have LV 7.1 if you'd like to send me your code to try. Or if there's another language that also calls nicaiu.dll (CVI or C++ ?) could you try this with that compiler ? If this gets too involved and should be taken to email then summarized back here, how to contact you by email ? Thanks for your interest.

Steve
0 Kudos
Message 4 of 7
(4,547 Views)
Hi Steve, we can work with your current application a little more before going to other ADEs. I'm assuming that you are calling Stop task instead of start task here

{ stop the tasks }
DAQmxStartTask (AO_TaskHandle);
DAQmxStartTask (DO_TaskHandle);


So, I just need a bit more information from you regarding the behavior of the task. The second time you run the task (the first time the pulses aren't synchronized), does any of them start with the pulse? In other words, one of them is definitely not restarting from the beginning of the waveform, but are both of them starting somewhere else?

Another thing that would help a lot would be to replace the pulses with ramps, and reduce the rate and the number of points in the waveform, so that you can clearly see when each update occurs. The ramps will allow you to see how many points out of phase they are and whether the phase differential increases every time you run it.

In the interest of preventing web bots from getting (and spamming) our e-mail addresses, you can send me an e-mail to this address, so that we can continue discussing the problem and sharing code. We can then write a summary here.
0 Kudos
Message 5 of 7
(4,534 Views)
Yes, I'm actually using StopTask.

The second time run, the AO does indeed restart at its beginning. It is the DO that does not.

I have not noticed a clear pattern of behavior with the DO. Sometimes I think its second-time-run output pulse occurs near wherever in its pattern that I stopped it. i.e. if stopped at point 3 of 10, then when restarted its pulse appears near point #3 (not at point #1 as it should). If stopped near point #8, when restarted it appears near point #8. But when stopped near point #5, it appeared near the end of the waveform, not near #5 ? I could look at this more closely if it would help.
0 Kudos
Message 6 of 7
(4,531 Views)
Steve,

The behavior for DO is not consistent with the behavior for AO on DAQmx 7.3 or earlier, here's the situation.

The problem is that when you start there is data left on the DO FIFO, that is not cleared on task restart, this data can only be deleted by recommiting the Task, that is, by calling DAQmxTaskControl ( taskHandle, DAQmx_Val_Task_Unreserve );
This will increase your DO start time (because it will have to recommit), so I'd suggest you test when it would be best to call start on the DO task. You might get away with something like:

DO Start
do{
AO Start
[get your signals]
AO Stop
DO Stop
DO Unreserve
DO Start
[Do whatever you need before restaring AO]
}while(true);

Please let me know if I can help you with anything else.

Greetings

Daniel
0 Kudos
Message 7 of 7
(4,517 Views)