I want to build a limited oscilloscope for PCI-4474 with four analog inputs and analog-level trigger on one of those four analog inputs. With CVI example "Acq-IntClk-AnlgStart" I have most of the code.
Next with a start- and stop-button, I want that it repeats acquisition of 1000 samples at the analog-trigger, plots the four curves, and goes for the next trigger. The option (that I found in this forum) for DAQmxSetTrigAttribute retriggerable is (according CVI debug information) not supported for this board.
Next (probably not unique) ideais to split the example in a few functions with the use of DAQmxRegisterDoneEvent:
// create task with a.o.
DAQmxErrChk (DAQmxSetTrigAttribute (gTaskHandle,DAQmx_AnlgEdge_StartTrig_Hyst,triggerHysteresis));
// start-button with a.o.
// DoneCallback which is called when task has finished the acquisition of its finite number of samples
DAQmxErrChk (DAQmxReadAnalogF64(gTaskHandle, ... ...
DeleteGraphPlot (panelHandle, PANEL_GRAPH, -1, VAL_DELAYED_DRAW);
if( numRead>0 )
PlotY(panelHandle,PANEL_GRAPH,&(gData ... ...
This does NOT work unless I insert in this DoneCallback DAQmxStopTask before start the task. This is not what I has expected because the callback function is called because the task has finished. And this is not what I prefer, because the CVI manual reports that stopping and starting a task will reduce the performance. Therefore I have two questions:
Q: can somebody explain (or refer to a text) what the difference is between task-done and task-stopped in combination with task-start?
Q: what is the best syntax for (not yet found) DAQmxRepeatTask when re-trigger is required for synchonisation and when this special attribute is not supperted for PCI-4474?
Solved! Go to Solution.
Here's what the NI-DAQmx Help says about task done:
If the measurement or generation is finite, the task is done when you acquire or generate the final sample or when you call the Stop Task function/VI. If the measurement or generation is continuous (including on-demand timing), the task is not done until you call the Stop Task function/VI. In addition, the task is done if a fatal error is generated while performing the measurement or generation, or you abort the measurement or generation. Check for errors and warnings to verify the task completed successfully.
> This does NOT work unless I insert in this DoneCallback DAQmxStopTask before start the task. This is not what I has expected because the callback function is called because the task has finished.
The callback function is called because the task is finite and the final sample has been acquired. Acquiring the final sample doesn't automatically transition the task from the "running" state to the "committed" state, so you still have to stop the task before you can start it again. See the section of the NI-DAQmx Help entitled "Task State Model" for an explanation of the different states.
> And this is not what I prefer, because the CVI manual reports that stopping and starting a task will reduce the performance.
Yes, but in this case I think stopping is necessary. In other cases, it's not necessary. For example, you wouldn't want to stop and start the task between every sample.
There is a way to reduce the overhead of stopping and starting the task: commit the task by calling DAQmxTaskControl(..., DAQmx_Val_Task_Commit) up front. This way, you don't waste time uncommitting, unreserving, re-reserving, and re-committing the task every time.
Anyway, does the performance meet your requirements? If not, what are your performance requirements?
Thanks for the clear reply.
Yes, the performance is sufficient for today for viewing the "oscilloscope". However with information packets of typical 1 ms duration, I assume that much of the data is missing. From you answer, I will try a different approach when I need high performance.