Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Analog read, external clock USB 6009



I am trying to program a very simple task but I fail and wonder if anyone could help me?


I have a NI USB 6009, which I program with C and use Visual Studios C## 6.0


I want to create a program:


On every TTL-signal coming in to the 6009, it reads an analog value comming in to the 6009. It should not be that it starts to read on the first signal and then reads all samples at once. Instead it should read everytime it receives a TTL-signal.

It should read as the TTL-pulse come, read one analog value and this should be repeted for a pre-determined numbers of times.


I have tryed a number of combinations and in the end I thought this should do it. But it just says that "the task is not supported for this device". I wonder if this, that I want to do, is possible with the 6009?


Is there any other way I could do this with the 6009?


DAQmxErrChk (DAQmxCreateTask("Trigg-analog-read",&taskHandle)); DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL)); DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle," /Dev1/PFI0",11,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1));


DAQmxErrChk (DAQmxStartTask(taskHandle));            for(int i=0; NumSamp>i; i++)           {            DAQmxErrChk (DAQmxReadAnalogScalarF64(taskHandle,-1,&value,NULL));           MeanSamp+=value;           }           cout << "Sum of all voltages: " << MeanSamp << endl << endl; 

//Kind regards, Hanna

0 Kudos
Message 1 of 3

Dear Hanna,


 I do not know about programming in C (I use LabVIEW), but: usb 6009 card does not support any hardware triggering.

You would like to use an external signal (TTL) to start the acquisition. This is not possible with this card.


It is possible to poll the digital input and when the value has changed, you start doing your acquisition. However, some time may pass between detection of TTL value and start of acquisition due to the software.  This time may vary, it will in  depend on your processor load. 


If this time is not critical in your case, you can do it the way I described above. Let me know if this answer suits you.






0 Kudos
Message 2 of 3

Hi Guys,


I just wanted to summarize the terminology we use since this seems to be a common point of confusion:


The behavior you are talking about is using an external sample clock.   Nearly all of our other multifunction products are capable of this configuration, and setting this should give you a single sample on the edge of your external TTL signal (can usually be set to rising or falling).  The USB 6009 does not support using an external sample clock, so this is the cause of the error you are seeing.


The USB 6009 actually does support using an external digital trigger on PFI0.  So, in theory you could re-trigger multiple single sample acquisitions off of this external signal.  However, to rearm the 6009 you actually have to stop and restart the task in software*.  During this software-defined rearm time you might miss external trigger signals, so this solution is less than ideal.


So, the best solution is going to be to use another board that supports using an external sample clock.  If you must use the 6009, the one recommendation I could give would be to explicitly commit the task by calling the DAQmxTaskControl function outside your loop before starting the task.



Here's a few boards that you might look into that allow for external sample clocks for the AI channels:

X Series:  (e.g. PCIe 6320)


Bus-Powered M Series: ( e.g. USB 6210)


M Series: (e.g. USB 6221, PCI 6220)


Non-USB B Series: PCI-6010



My favorite of the above options is the X Series, but this is assuming that PCIe is an acceptable form factor.  The 6210 would be my recommended USB solution, and if you prefer PCI I would go with the PCI 6220.



*Note:  In the external trigger case, all subsystems (AI, AO, DI, DO, Counters) are retriggerable on our new X Series devices without having to restart the task in software.  Before X Series was released, the workaround was to use a counter output (which are retriggerable) to generate a sample clock for the AI task to use.  Unfortunately, the 6009 does not have the capability to generate a counter output or to use an external clock for AI, so you have no choice but to rearm the acquisition in software if you do not purchase new hardware.



Best Regards,



Message Edited by John P on 10-19-2009 05:55 PM
Message Edited by John P on 10-19-2009 05:57 PM
John Passiak
0 Kudos
Message 3 of 3