LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx - Using DIO to output a finite pulse train with certain frequency

Hello,

 

As a totally inexperienced LabVIEW programmer, I would really appreciate your help.

 

I am using a DAQ board PCI-6251 to generate a finite pulse train. I would like to control pretty much everything, frequency, duty cycle, amplitude, total signal duration...

 

So, I followed some sample codes and wrote mine. However, the program doesn't work. Although the data seems correct from the waveform graph, it doesn't look right on an oscilloscope. The shape of the waveform is not a square wave. In addition, the frequency of the output signal is much faster than the one I set.

 

So, I attached my code. Please please take a look and give me some feedback.

 

Thank you so much in advance.

 

Jinyang

0 Kudos
Message 1 of 5
(4,756 Views)

Hello Jinyang,

 

I am glad that you are beggining to use LabVIEW. Let me help you with this application of yours. If you want to generate a finite pulse train, I would advise you to use the Counters, (not Digital Output) tasks, since counters have a much easier way to modify the frequency and duty cycle. However, you will be bound to generate a signal with TTL levels (5V = high, 0V = low). Here is an example VI that shows how to update the duty cycle of a pulse train generation using counters.

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
Message 2 of 5
(4,737 Views)

Hi Dan,

 

Thanks for your quick reply!

 

I tried the answer you suggested but it was not exactly what i am looking for. I need to use 6 different DIO as output and all of them are independent to each other.

 

I found out that I have to use some sample clock for my digital output, no matter it is from external or generated by a counter as an internal clock. This is totally different from an analog input/output channel.

 

I would appreciate if you can give me more example codes for using multiple digital outputs for pulse train generation.

 

Thanks,

Jinyang

0 Kudos
Message 3 of 5
(4,729 Views)

I'm a little confused by your code.  What is your goal?  Are you trying to drive PWM through your digital outputs?

 

I think that the digital write VI you are using is just going to try and switch the Digital Output state as fast as possible based on its input data.  I think you need to look at the Sample Clock DAQmx (timing.vi) as well as what the functionality of the "frequency" input in your "Signal Generator by Duration.vi" is used for because there isn't anything wired to that.

 

If what you are doing is PWM and you don't need very fast response (like you can live with 1ms response times) then it is pretty simple to do this via software timing.

0 Kudos
Message 4 of 5
(4,720 Views)

My goal is to several DIO port to output a finite pulse train with certain duty cycle, frequency, and time duration.

 

I actually figure out the code but encounter a new problem.

 

So, I use "Signal Generator by Duration" to generate a pulse train. When the frequency is less than 2.5KHz, the output looks good. However, I start losing pulse number when the frequency is above 3KHz although the total time duration is still correct. My sampling frequency is always 10x the pulse train frequency.

 

For the DAQ PCI-6251 board I am using, the spec says that the highest sampling rate is 1MHz which is way higher than my current speed. I wonder why do I have this problem? Is there any way to ensure the output waveform?

 

Thanks,

Jinyang

0 Kudos
Message 5 of 5
(4,702 Views)