12-09-2015 04:45 AM
Dear all,
I would like to generate a PWM square wave with modulable frequency and duty cycle out of my usb module MCC usb 2408-2ao.
I know thatI could a use while loop with a flat sequence inside to continuosly put on and off a digital output and by changing the duration of the frames of the flat sequence and the time between one and other iteration of the while loop I can vary duty cycles and frequency...but it seems to me a little bit tedious to do.
Is there an automatic way to generate customized a PWM signal and send it to the output of the USB module in Labview?
Thanks to all for your help!
Solved! Go to Solution.
12-09-2015 05:31 AM
12-09-2015 10:28 AM
My USB device does not have PWM generator, it onyl allows you to change digital outputs.
I tried to use timed flat sequence structures, but the thing seems to me not working as I analyze the signal with an oscilloscope and the frequency of the square wave generated does not change and not event the duty cycle.
Here is the VI attached. Anybody can help me please? I am wondering if it is not a hardware problem...
Thanks in advance,
Fabrizio
12-09-2015 12:09 PM - edited 12-09-2015 12:11 PM
Hi fabbro,
WTF are you doing with all those local variables? Don't you have wire left? 😄
- Do you notice all those coercion dots? They have a purpose - read the LabVIEW help on that topic!
- What values are you using for PWM frequency and duty? Did you check the calculation results? Did you use probes for debugging?
- You know the limitations of the WAIT function? (That's why you have coercion dots in your VI!)
- Why is ther no stop button? Why don't you check the error cluster wire?
Your VI could look like this:
You could use the CompoundMath nicely…
And you also notice the reason why many LabVIEW programmers use a simple subVI for the Wait function with additonal error IO connectors!
12-09-2015 01:16 PM
12-09-2015 01:37 PM
12-09-2015 04:12 PM
12-10-2015 01:20 AM
Hi fabbro,
I use local variables because i want the user to be able to chamge frequency and duty cycle instantaneiusly while the vi is running!
I don't see any relation between the parts "I use locals" and "because …"
As said before: Don't overuse local variables!
I like local variable, i use them often despite all specialists do not advise them.
In my view this translates to "I know I do wrong - but it gets better when I do it all the time!"
I don't think I will provide any more help to you when you resist to take advices…
12-10-2015 01:33 AM
Dear Denis,
I am using the MCC USB 2408 2AO:
http://www.mccdaq.com/usb-data-acquisition/USB-2408-Series.aspx
I use its digital output to generate the PWM signal...
I set a frequency of 20 KHz, I don't see any limitation in the frequency of Digital outputs in the datasheet.
I have updated the VI following the advise of Gerd and go to test in a moment.... I'll get back to you guys! Thanks a lot
12-10-2015 01:37 AM - edited 12-10-2015 01:39 AM
Hi fabbro,
I don't see any limitation in the frequency of Digital outputs in the datasheet.
Read the user manual, page 28. It's very explicite on DO sample rate limits!
I set a frequency of 20 KHz
So you did read the LabVIEW help on the Wait function by now?
You know it's limitations?
You know what kind of input value it expects?
Homer says "Doh!" 😄
I say "RTFM"!