LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate sequence of pulse trains with DAQmx?

I need to generate a sequence of pulse trains with DAQmx (the card I have is a PXI-6229 card). As an example:

- 10'000 pulses at 20kHz every 5 seconds with an initial offset of 2 seconds (let's say 10 pulse trains in total).

 

If I use the CreateVirtualChannel.vi in "CO pulse ticks" mode, I can only specificy offset, high ticks and low ticks, but not that the sequence of pulses should be repeated after some time. 

 

Now I thought that I could solve this problem if it were possible to multiply two counter outputs: the first counter would generate the pulses (continuously) whereas the second one would switch between low and high on a slower timescale in order to gate the first counter, thereby providing an initial offset and the "off" phases between the pulse trains.

 

Is it somehow possible to multiply two outputs with DAQmx and the card I have? Or is there another solution to the problem?

 

Thanks a lot in advance for any hints!

0 Kudos
Message 1 of 5
(5,362 Views)

Hi dlanger,

 

what you want to do requires a little bit more work. 

 

First look at the example "Gen Dig Pulse Train-Continuous.vi" from the LV example finder.

This example generates a continuous* pulse train. As you see, you need a sample clock VI for setting the sample mode. 

* NOTE: Generating a finite pulse train with a M-series card requires 2 counter.

 

With a pause trigger (DAQmx trigger property node) you can gate the output of that counter.

 

Now you have to generate a gate-signal with the the 2nd counter. That means, only if  Ctr1-out is high Ctr0-out outputs the 20 kHz-signal. 

Maybe you have to adjust the times in my example a bit. 

 

Unfortunately there is just one "small" problem: "let's say 10 pulse trains in total" 

This is not possible, because a 3rd counter would be necessary (*). 

 

As a workaround you can modify the while-loop that both tasks are cleared after 50s. This is not brilliant, but should work fine for you. 

 

 

A more sophisticated way is to perform a correlated DIO. So you can generate custom pattern for multiple outputs. 

 

A good example can you find here: 

 

Retrigger and Repeat Finite Digital Pulse Train in LabVIEW

http://decibel.ni.com/content/docs/DOC-8473 

 

or here:  

 

Generating More Than 2 Pulse Trains Using CompactDAQ

http://decibel.ni.com/content/docs/DOC-2167 

 

 

Hope this helps.

 

 

With best wishes,

 

Ralf N. 

0 Kudos
Message 2 of 5
(5,339 Views)

Here's some good stuff about DAQmx-programming:

 

- LabVIEW-help: "Taking Measurements"

- Getting Started with NI-DAQmx: http://zone.ni.com/devzone/cda/tut/p/id/5434

 

... and of course the 'LabVIEW Data Acquisition und Signal Conditioning' Training Course Smiley Wink

http://www.ni.com/training/

Message Edited by ralfn on 02-11-2010 06:00 PM
Message 3 of 5
(5,334 Views)

Thanks a lot for the help and the nice example VI!:-)

 

Do you know why it is not possible to use one of the two counters in "Finite Samples" instead of "Continuous Samples" mode? Because then it would be possible to limit the generation to 10 pulse trains. Using a while loop to check is unfortunately not an option for me because due to my software architecture I need an approach that works as "fire and forget".

 

If I try to use...

  • ... the first counter (the one generating the pulses) in "Finite Samples" mode, there is a message saying "Measurements: Pause trigger is only valid for continuous pulse generations. Change the sample mode to continuous, or do not use the pause trigger."
  • ... the second counter (the gating one) in "Finite Samples" mode, there is a message stating "The specified resource is reserved. The operation could not be completed as specified.".
0 Kudos
Message 4 of 5
(5,307 Views)

Hi dlanger,

 

sample mode "finite" requires 2 counter (one for generating the pulse and one for "counting" the number of pulses) - and your M-series card doesn't have 3.

 

http://digital.ni.com/public.nsf/allkb/485201B647950BF886257537006CEB89#case3 

 

If clearing the task is not an option for you, you have to use the correlated DIO-example.

 

Cheers,

 

Ralf N.

 

 

Concentrated Knowledge for free:

http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/sn/ssnav:sup,catnav:kb

Message Edited by ralfn on 02-13-2010 12:25 PM
Message 5 of 5
(5,301 Views)