LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making NI MyDAQ digital outputs act like counter output

Hi,

I want to be able to output digital pulses that are variable in frequency and duty cycle using the NI MyDAQ. The only problem is the MyDAQ only has one "counter" output, which allows direct manipulation of a pulse's frequency and duty cycle. I am wondering if there is a way to configure the other 7 digital outputs to mimic this. So far the best I can come up with is this:

dig waveform.PNG

 

This allows me to adjust the frequncy with the wait command, but I am thinking there must be a better way of doing this.

Any help or ideas would be great.

Thanks.

0 Kudos
Message 1 of 5
(10,326 Views)

Hi JonnyRandall,

 

Generally this isn't a very good idea in the first place as a hardware counter output would be the most robust solution. This is because if you simulate this functionality in software by using the wait function in a loop, the frequency of the pulses may not be consistent because the processor may execute the code at different speeds depending on how many processes require your computer's resourses.

 

One suggestion that I have if you want to adjust the duty cycle is to use a flat sequence structure with two sections in your while loop. First you want to configure the while loop to execute as fast as possible by taking out the wait (ms) function. In the first part of the sequence structure you would configure high (true), and in the second portion of the sequence structure you would configure low (false). Instead of putting a wait (ms) in the while loop, you would put one in the first section of the sequence structure and another one in the second section of the sequence structure. By having two wait (ms) functions, you can configure the total frequency of the pulse (wait 1 + wait 2) and the length of the duty cycle (wait 1 /(wait 1 + wait 2)).

 

Jason L.

 

 

Product Support Engineer
National Instruments
Message 2 of 5
(10,301 Views)

Thanks for your reply!

 

I agree with you that a hardware output is the best solution. But as I said I am using an NI MyDAQ which only has one hardware counter. I want to be able to have the other 7 remaining Digital Outputs function the same way.

 

So I guess my question is, is what I have done to "simulate" the hardware counter the best solution, or is there another way I could do it?

 

The way I have done it, it works fine when only that is running in its own VI, but when I implement it into my main program which is very large, the frequency becomes inconsistent like you mentioned.

0 Kudos
Message 3 of 5
(10,291 Views)

Some NO DO hardware supports buffered DO operations where the output can be clocked by the counter.

 

But then again...

 

If you have enough analog outputs lines and you have buffered output capability there you can use the AO lines and just write 0/5 volts.

 

Sticking with the less exotic hardware...

 

Timed Loops can give very good results if you manage the other loads on the machine.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 5
(10,287 Views)

As for the other part of my question - How would I convert this switching Boolean into an analog waveform to be displayed on an analog waveform graph?

0 Kudos
Message 5 of 5
(10,271 Views)