LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RPM to duty cycle conversion

Hi Everyone,
I am trying to control the speed of a dc motor with encoder. I have created a pid controller but the output of the pid is RPM. I have to convert this RPM value to duty cycle. I couldn't model the conversion of this two in mathematical way. Is it possible to give me hand please?

0 Kudos
Message 1 of 6
(4,174 Views)

What is the how is RPM equivalent to duty cycle?  One is a speed, the other is a ratio.  What is 0 RPM in terms of a duty cycle?   If you had 50% duty cycle, what is the equivalent RPM?  What about 0%, 25%, 75%, 100%?

 

Perhaps you could attach the VI of what you attempted as that can help us see what direction you were heading and where you got lost.

0 Kudos
Message 2 of 6
(4,146 Views)

I am newbie. I would like to control the speed of the motor with PID. So, only way is to change the duty cycle, isn't it? I am using usb-6008. 

0 Kudos
Message 3 of 6
(4,137 Views)

Okay.  So what duty cycle percentage represents what speed?  Forget about LabVIEW and the PID for the moment.  If you want 0 RPM, is duty cycle 0%?  If you wanted full speed, what is that speed and is that 100% duty cycle?

 

I'm worried that you are using a software time loop writing an on or off to a digital output to define the duty cycle.  That might work just fine, but Windows timing can be unreliable.  If the OS decides to take some cycles away from your process and go do something else like a virus scan, your timing of the duty cycle will get thrown off.  The pulse getting stuck on for a period of time will look like a sudden change to 100% duty cycle.  Ideally, you would use a DAQ device that is smarter than a USB-6008 that has a hardware timed output so you can create a digital output task that is a duty cycle, or PWM - pulse width modulated, so that the hardware controls the timing of the ON/OFF and not the software and the Windows operating system.

 

Let's assume that your USB-6008 will work for you, which I doubt. You do have a problem with your lower loop as it isn't a duty cycle.  The loop toggles a digital output on and off, waiting a given number of milliseconds.  But that math is wrong and the connection to the 20 constant is illogical.

 

If your duty cycle control is 0, then the time off (false will be) 20 milliseconds, and the time on (true) will be 0 milliseconds.  Okay, that sounds like 0%.

If your duty cycle control is 20, then the time off will be 0 milliseconds, and the time on will be  20 milliseconds,  That is actually 100% duty cycle, not 20.

If the duty cycle control is 10, then off for 10, on for 10, that is 50% duty cycle, not 10.

 

If your speed scales from 0 to x RPM  for 0 to 100% duty cycle,  (please give us the numbers), then the RPM output from the PID will need to be divided by Max RPM so you get a number from 0 to 100.  Feed that through an In Range and coerce so you don't get negative numbers nor something bigger than 100.

 

Now take your total duty cycle frequency.  Do you want 20 milliseconds, so 50 Hz pulses?  Duty cycle divided by 100 times 20 milliseconds to get On time.  Off time would be (1 - duty cycle/100) times 20 milliseconds .

0 Kudos
Message 4 of 6
(4,127 Views)

100 duty cycle represents 550 RPM and 0 duty cycle represents 0 RPM. But as expected, it's not linear. Fx; 50 duty cycle is about around 400RPM when I measure. I don't expect to have a very precious control with software time loop. It's a kind of hobby project for me to learn fundamentals of labview. The reason I set it to 20 is that the motor vibrates little bit when I set it to 100. But I will set it back to 100 now. But, mostly I am more concerned about how to model it mathematically so that PID can work.

0 Kudos
Message 5 of 6
(4,121 Views)

If it is non-linear, you may have to test different duty cycles and determine their corresponding speed.  See what the correlation is and fit an equation to it.  Or you can possibly measure a handful of points and do a piecewise linear fit on them.  But overall, I'd think you'd do better with an equation.

 

Collect data and model it.  Perhaps a second, third, or fourth order polynomial.  Maybe something based on an exponential.  You might be able to use PID Gain Scheduling to handle different PID parameters at different speeds, and use the equation to convert from speed to pulse duty cycle.

0 Kudos
Message 6 of 6
(4,093 Views)