Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about NI 9401 and cDAQ-9172

Hi,

 

I have (2) NI 9401 and cDAQ-9172.  I try to setup the NI 9401 to output a single pulse with pulse width of 20ms.  When triggering, NI 9401 would output a square wave ON for 20ms "solid", then turn the square wave OFF after that.

 

I would like to do this repeatedly every 20ms, 50ms, up to 1s in a loop.  I want to be able to set the loop repeat time and the pulse width of the signal.

 

I am wondering if there is a sample program I can follow.  I would appreciate very much if you could help me with a sample program that I could use for this experiment.

 

Thank you very much

-Khoa

 

 

0 Kudos
Message 1 of 4
(3,262 Views)

Hi khoaGNF,

 

There's actually a pretty nice DAQmx shipping examples in LabVIEW that you could refer to. You can view these in your Example Finder by accessing it under Help » Find Examples. The example we are particularly interested in would be under Hardware Input and Output » DAQmx » Generating Digital Pulses » Gen Dig Pulse Train-Continuous.vi. This example allows you to set the frequency of your square pulse as well as specify its duty cycle. With these two parameters, you should be able to obtain the exact functionality you are looking for.

 

One thing to make sure is that you since you will need counters for this task, you will need to access the counters on your cDAQ-9172 from slot 5 or 6. So make sure to have the NI 9401 in these slots. 

 

I hope this helps,

S_Hong
National Instruments
Applications Engineer
0 Kudos
Message 2 of 4
(3,245 Views)

Hi S_Hong,

 

Thank you very much for your guide.  I am able to generate pulses from NI 9401 now.

 

I also have another question regarding this issue.  I would like to generate pulses in a timely control loop.  For example: I would like to generate pulses for 20 milliseconds and pause for 5 seconds.  And I would like to do this over and over again in a loop.

 

Is there an example that I can follow to create this program?  I would very appreciate it if you could help me with a program to do this.

 

Thanks again!

 

-khoaGNF

 

0 Kudos
Message 3 of 4
(3,233 Views)

Hi khoaGNF,

 

Is there any reason why you would like to use a timed loop structure as opposed to using my suggested hardware timed solution? One caveat with using timed loops is that unless you are running LabVIEW on a Real-Time target, your loops will be software timed. So depending on the what your operating system is processing, your loops may take a lower process priority and not execute at exactly the rate you specify. If you are perfectly fine with having delays in your iterations in the order of 10's of milliseconds, you could have your digital lines to be software timed. I have attached a little example code I wrote which does what you are looking for. However, if your application is time critical, I suggest using my earlier solution. Moreover, if you do not want to play around with the duty cycle and period, you can click on your DAQmx Create channel and select Counter Output » Pulse Generation » Time. This way you can specify your pulse in high and low time.

 

I hope this helps.

S_Hong
National Instruments
Applications Engineer
0 Kudos
Message 4 of 4
(3,215 Views)