Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a USB-6009 digital output blink on/off (go high/low) a set number of times at some set nominal rate?

My question is kind of related to this one. I am trying to switch from a counter-generated pulse train to a DO generated pulse train. I have the USB-6221. I need 6 pulse trains of 5 to 220 pulses each at a 2 kHz rate, with precise 200 ms spacing between starts. Currently I use a case structure within a timed loop with finite generation to generate each pulse train of N Pulses at 200 ms intervals, but using finite generation ties up both my counters and I need the counters for other... counting. How would I best implement a stable pulse generation using a DO line on my DAQ?
____
Ryan R.
R&D
0 Kudos
Message 11 of 17
(1,941 Views)
Here is the section of code actually responsible for the generation.
____
Ryan R.
R&D
0 Kudos
Message 12 of 17
(1,938 Views)

Hi morgol,

 

Since you have a M Series device, you should be able to perform correlated digital outputs. A good place to start would be to take a look at one of our shipping examples in the LabVIEW Example Finder, more particularly the Cont Write Dig Port-Ext Clk.vi which can be found under Hardware Input and Output » DAQmx » Digital Generation. This example uses an external clock as the sample clock to the digital output task. Since you are looking for a clock rate of 2 kHz, you can use a 4 kHz clock source to change the digital inputs from low to high and high to low within that one clock period. I would also like to mention that if you do not wish to use an external clock to source your task, you can always import the sample clock from a dummy analog input/output task. The following link should give you a good idea on how to do this.

 

Performing Correlated Digital IO with an M Series Device in LabVIEW

 

Please let us know if you have any questions. I hope this helps.

S_Hong
National Instruments
Applications Engineer
Message 13 of 17
(1,924 Views)
Thanks, this is definitely helpful! 🙂
____
Ryan R.
R&D
0 Kudos
Message 14 of 17
(1,921 Views)

Hello, another question from a Newbie:

 

I found the example about digital pulse generation very helpful but I was wondering if I can have a more detailed explanation of what is actually going on inside the loop.  For example, is this when the state of the digital output channel is set to high?

 

What is the best way to set the duty cycle of the digital pulsing (I would like it to be fixed at ~50%)?  Also, how could I control the number of times that the pulse is executed? 

 

Thanks in advance for any help.

0 Kudos
Message 15 of 17
(1,474 Views)

Hi krissy-

 

     If you are looking at Write Software-Timed Dig Chan 1.vi (the example code attached to the second post in this thread - I assume this is what you are looking at), the loop is actually setup to change the digital line from low to high every other loop.  For example, the code has True constant wired into the timed loop, which sets the digital line high on the first iteration.  There is a "Not" function which changes that boolean to false through the shift register for the next iteration.  That false is written to the digital line and then the "Not" switches it back to True and it starts all over again.  Its a beautiful thing. Smiley Wink

 

     The duty cycle is going to be 50% by default.  The toggling of the digital line is set by the iteration of the Timed loop.  Since the loop iteration time determines when the True/False is written, as long as the loop is running smoothly, your duty cycle is about 50%.  You don't need to change anything.

 

     In this code, you can set the number of times that the pulse is executed by setting the Max Iteration number on the front panel.  This will stop the program as soon as the loop iterations exceed the number you specify.

 

     I hope this helps.  Best of luck with your application!

Gary P.
Applications Engineer
National Instruments
0 Kudos
Message 16 of 17
(1,458 Views)

Thanks so much, that was a really nice explanation Smiley Happy

0 Kudos
Message 17 of 17
(1,453 Views)