LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I vary a PWM´s duty cycle inside a while loop?

Hi,
 
I'm using the "Generate Pulse Train.vi" to generate pwm signals in counters 0 and 1 in order to drive a DC motor both ways.
The problem is, I need to control the movement of the dc motor with my PI controller which is inside a while loop. I've tried letting the "generate pulse train.vi" outside the while loop, but the problem is, it only changes the value of the duty cycle when the loop is stopped. I also tried putting it inside the loop, but then it doesn't even work.
So, how can I vary a PWM´s duty cycle inside a while loop?
 
I'm attaching the VI with the PI controller.
 
Thanks for your help!
 
Guilherme
Message 1 of 4
(2,718 Views)

You may not have to stop the loop, but you might have to stop the PWM - or at least make sure that the control to change duty cycle is in the loop.  There might be a property node you can set.

Jason

0 Kudos
Message 2 of 4
(2,707 Views)
Here's some code I threw together a while back to change a duty cycle on the fly. It generates a fixed 5KHz or 25KHz frequency depending on laser selection, then allows duty cycle to be changed continously. Maybe you can use the premise of it for your application.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 3 of 4
(2,707 Views)
Here is a great tutorial on PWM in LabVIEW with NI-DAQmx.  You might want to check it out:)
-Alan A.
0 Kudos
Message 4 of 4
(2,689 Views)