RPM to duty cycle conversion

Thread Starter

myil

Joined May 2, 2020
145
Hi Everyone,
I have been recently working with labview. 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?
 

click_here

Joined Sep 22, 2020
548
What relationship does the RPM have to the duty cycle? Did you mean it's period?

If so,
RPM = rev/min
1rev/1min * 1min/60sec
=1rev/60sec -> This is frequency in Hz
period = 1/freqency

period = 1/(RPM / 60) = 60/RPM

So
60 RPM = 1sec/rev
120RPM = 0.5sec/rev
ect...
 

LesJones

Joined Jan 8, 2017
4,188
Eric will know everything in your post #6

I think this is what you you are asking.
0% corresponds to 100 RPM
100% corresponds to 550 RPM

so 100% corresponds to 450 RPM

so RPM = 100 + 450/100
so RPM = 100 +(4.5 * % value)

Re-arranged % value =( RPM -100)/4.5

Is that the question you are asking ?

Les.
 

Thread Starter

myil

Joined May 2, 2020
145
Let's say I would like to set RPM to 300(setpoint). When I first start the system, the error will be 300 RPM-0RPM=300 (assuming I only use Kp value and set it to 1). Then, the error will be less and less and will some point reach to 300-300 =0 RPM. If i feed those values to the motor, the motor will first reach the maximum speed with a big error 300-0=300 RPM, then it will start to slow down and stop when it reaches the 300-300=0 RPM. So, I need to find an equation or a simple way that it will first slowly increase the speed and if it reaches 0 RPM, the motor will keep it's current speed fixed. I don't know if I am clear enough for what I want?
 
Last edited:

LesJones

Joined Jan 8, 2017
4,188
Two points.
1 The motor will not instantly reach it's maximum speed as the system has inertia.
2 If you only consider the proportional term the motor will never reach the set speed as it needs an error signal to drive the motor. This why the integral term is added. It integrates the error over time and adds this into the calculation. At this stage the proportional error term is getting smaller so eventually the proportional term reaches zero which means the integration reaches a steady value. This is the whole point of PID control.

Les.
 

Thread Starter

myil

Joined May 2, 2020
145
Two points.
1 The motor will not instantly reach it's maximum speed as the system has inertia.
2 If you only consider the proportional term the motor will never reach the set speed as it needs an error signal to drive the motor. This why the integral term is added. It integrates the error over time and adds this into the calculation. At this stage the proportional error term is getting smaller so eventually the proportional term reaches zero which means the integration reaches a steady value. This is the whole point of PID control.

Les.
That's correct.
 

click_here

Joined Sep 22, 2020
548
Maybe looping through something like this...
Code:
if (SetSpeed > ReadSpeed)
{
    if( NotOutOfBounds( OutputSpeed + 1) )
    {
        OutputSpeed = OutputSpeed + 1;
    }
}
else if (SetSpeed < ReadSpeed)
{
    if( NotOutOfBounds( OutputSpeed - 1) )
    {
        OutputSpeed = OutputSpeed - 1;
    }
}
 
Last edited:

crutschow

Joined Mar 14, 2008
34,407
If 100% PWM duty-cycle equals 550RPM then the simple way to model that is (RPM = %duty-cycle * 5.5) or (%duty-cycle = RPM / 5.5).
Thus if the output of the PID is RPM then you run that through a gain of 1/5.5 to get %duty-cycle.

If the PID parameters are set correctly, then the motor should smoothly accelerate to the desired speed without significant overshoot, and then stay at a constant speed.

If you use If-Then-Else statements as click_here suggested, then you would be doing a form of Fuzzy Logic control, and will likely need more statements to give the fastest response to changes in commanded RPM while still avoiding overshoot and hunting of the desired motor speed.
I like Fuzzy Logic for feedback control, since it is a pure digital approach which makes it generally easier to understand what's happening in the control loop as compared to PID (which is a linear analog control method that suffers from problems like integrator wind-up), and can more readily handle non-linear devices in the loop (which a motor can be).
Here's a good tutorial on using Fuzzy Logic, if you want to go that route.
 
Last edited:
Top