Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronizing Analog Input and Digital Output

Hi,

I am trying to write a VI for an M-Series DAQ in Labview 8.0 using the DAQmx package.  I have set up an Analog In Channel and am using the DAQmx Timing (Sample Clock) VI with a specified sample rate of 1Mhz.  It reads 8 million samples when DAQmx Read is called, and when it is done I have captured 8 seconds worth of data.  There doesn't appear to be any problems with this part of the VI.

At the same time, I need to output 8 samples of digital waveform data, but only at a rate of 1 Hz.  To do this, I have set up a Digital Output Channel and again called the DAQmx Timing (Sample Clock) VI and specified the source as the ai/SampleClock channel.  But what I want to do now is divide the AI Clock down so that this clock is only 1Hz (effectively divide by 1 million).  I have tried using the DAQmx Timing Property Node to specify the SmpClk.TimebaseDiv as 1000000, but I get an error every time.

I realize that the Digital Input/Output functions do not have their own clocks on the M-Series DAQ, but there must be some way to synchronize a 1Mhz AI with a 1Hz DO (such that the DO outputs a new sample for each 1000000 samples read with AI).  I would really appreciate any help that anyone could give!

I've attached what I'm attempting to do although the VI doesn't work.  If you take out the Timing Property node, the VI functions, but the 8 samples of waveform data are written at a rate of 1Mhz, when I need them written at a rate of 1Hz.

Thanks!
Message 1 of 14
(5,397 Views)
Hi warnellg,

One way to do this is to add a counter task into the mix.  Basically we will count the ai/SampleClocks with a counter to create a 1 Hz pulse train, and the DO task will use the counter output as its SampleClock source.  I'll attach a screenshot of my VI.
------
Zach Hindes
NI R&D
0 Kudos
Message 2 of 14
(5,375 Views)
Thanks Zach,

I tried setting up the VI like in your picture, but for the source of my DO Sample Clock I cannot select a "Dev1/Ctr0InternalOutput."  I'm using an NI USB-6259 if that helps at all.  Any other ideas?
0 Kudos
Message 3 of 14
(5,352 Views)
Try right clicking the the source and go down to "I/O Name Filtering".  From there make sure "Include Advanced Terminals" is selected.
------
Zach Hindes
NI R&D
Message 4 of 14
(5,351 Views)
Yep that workedSmiley Very Happy!  Everything functions like I want it to now.  Could you tell me what the function of the options are on the "CO Pulse Ticks" VI (like the 100, 999900, Low, etc) you used for the pulse generation?  I'm going to have to make many similar VIs for my tests and it would be useful to know exactly what it is this VI does so I can modify it myself.  Thanks so much!
0 Kudos
Message 5 of 14
(5,348 Views)
Awesome!  I'm glad that worked for you.

For the counter task we specify a few things.  The CO Pulse Ticks channel creates a pulse train where you specify the number of high ticks and low ticks for the pulses based off of some timebase.  So, for this example our timebase is the ai/SampleClock.  I've specified 100 high ticks and 1000000 - 100 low ticks.  This way the total number of ticks for the pulse is 1000000 or one second since our AI is going 1 MHz.  That way the output of the counter task is a 1 Hz pulse train, exactly what you needed!
------
Zach Hindes
NI R&D
0 Kudos
Message 6 of 14
(5,346 Views)
Thanks so much again Zach.  I really appreciate your help.  I've attached the final VI so maybe if someone else was having the same problem they can see how it's done.
Message 7 of 14
(5,340 Views)

Dear Sir.

 

I am working with NI6251 as well as NI6509 DID daq card,I need to have digital output in 2D Boolean 1st then next Analog Input should trigger after the AI measurement then loop will back to Digital output loop and changes the Boolean value then same procedure next Analog Input then back to Digital Output,like that I need to have 32 loops,so please help how to synchronize the Digital Output as well as Analog Input in a single VI

 

 

Thanking You.

 

Raikar A G

0 Kudos
Message 8 of 14
(4,700 Views)

Hello Raikar,

 

Thanks for posting at NI forums! It is always recommended to start a new forum for a new question. If you want to have alternating tasks between analog input and digital output, you could use a state machine with three cases: Digital Output, Analog Input and Stop. Using the enum constants you can alternate between both of them programmatically and by using shift registers, you can change the Boolean value. I made a very simple example, I hope it helps.

 

Best Regards,

 

Alina M

Download All
0 Kudos
Message 9 of 14
(4,675 Views)

Dear Sir.

 

 

Thanks for posting VI,I need a clarification in your VI Digital output task will be close before AI measurement,I am connecting digital Output port to a MUX adg732 input for changing switch pins between I/p and O/p terminals i am having 32 RTD,i am connecting each one pin of RTD to MUX I/P and from MUX output it is connected to AI0 channel,another side RTD point connected to GND of DAQ,I am going to measure RTD resistance here.

 

 

 

Thanking You.

 

 

Raikar A G

0 Kudos
Message 10 of 14
(4,669 Views)