‎03-07-2012 11:06 AM
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:
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.
‎03-08-2012 12:24 PM
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.
‎03-09-2012 06:42 AM
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.
‎03-09-2012 07:09 AM
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
‎03-09-2012 12:30 PM
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?