LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx analog input or output: check if ready to start

I am triggering several analog input / output tasks via a start trigger. How can I ask DAQmx after writing samples (a lot of them, up to 1e6) and starting the task when the tasks can be really started ?

I experienced errors (buffer underflow)  in the analog output when starting immediately, and had to add a delay by hand to overcome them.

 

 

 

0 Kudos
Message 1 of 8
(3,876 Views)

Can you please give more details ? How many analog inputs and outputs ?

 

Is it the same trigger to all Analog I/O ?

 

 

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 2 of 8
(3,868 Views)

I have two DAQ M-series NI-6259 cards, RTSI on them.

I use the same sampleclock on AO and AI of both devices, created by the AO of device 1. This sanpleclock has a start trigger given by a digital; line of device 1 which I use as starttrigger for a scanning microscope setup, and also starts other hardware

the sampleclock is 10Khz, I have 2 channels on AO1 and 3 channels on AO2.

 

 

0 Kudos
Message 3 of 8
(3,861 Views)

OK , in order to better understand how to use the DAQmx AO , AI in CVI you have a set of good examples , 

 

C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C

 

in there you have analog generation and measurement.

 

For example create a software which sets 1 ao & 1 ai at the same time by an external trigger that will give you better understating.

 

For each task use the Dodecahedra (DAQmxCfgDigEdgeStartTrig(gAOtaskHandle,triggerSource,triggerEdge)); function by that you will be able to set the entire system to same trigger.

 

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 4 of 8
(3,856 Views)

The task configuration is not the problem, I have done this already.

I configure all the tasks with the external trigger, and then activate the external trigger.

If I activate the trigger in the code immediately after the Starttask commands, there is an error - if I wait some time after the starttask command (typically a few 100ms), it works.

How can I find out how much data is available on the ao onboard buffer to check how much data has actually been transfered to the device ?

 

 

 

0 Kudos
Message 5 of 8
(3,851 Views)

I see ,

 

I think that waiting or checking the buffer size it's not the best way ( I don't know if there is an option check the buffer size )

 

I simply use DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(gAItaskHandle,DAQmx_Val_Acquired_Into_Buffer,sampsToRead,0,EveryNSamplesCallback,NULL));

 

I'm defining to the Device the number of samples that I want him to receive when he receives it the simply transfer it to my buffer.

 

For example if I'll define 1000 samples and I have 10000 samples he will make 10 events....

 

Look for the DAQmxRegisterEveryNSamplesEvent example it's very clear and don't forget to consider the amount of channels you have. 

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 6 of 8
(3,777 Views)

This does not help as it only gives a callback after samples have been acquired

0 Kudos
Message 7 of 8
(3,774 Views)

Well I'm working with few of the X-Series and other units with external triggers and I had no problems like that.

 

What you need to do is some debug to see which AO / AI making the problem and then face it's config maybe it's something with the clock.

 

Try to use it with only one AO & AI if you still have a problem then it's your definitions....

 

Also maybe some one of NI Engineer can give you better idea's. 

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 8 of 8
(3,758 Views)