Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Control System (http://www.chiefdelphi.com/forums/forumdisplay.php?f=177)
-   -   PID Control algorithm(to control PWM Duty Cycle based on Current) (http://www.chiefdelphi.com/forums/showthread.php?t=106907)

PID 13-06-2012 06:39

PID Control algorithm(to control PWM Duty Cycle based on Current)
 
Hi All,

How to arrive at a proportional gain Kp and ki in a PI control algorithm? We have to control the PWM Duty Cycle to a motor based up on the current drawn by the motor. If the desired current is 5A, & if we measure current as 6A, then how will we know what should be the duty cycle to get the desired current. Because most of the explanation on the web says that desired - measured * Kp gives the duty cycle. How to convert the error which is in terms of current to duty cycle. More over, the current is varying at different voltage levels, i.e the measured current for a 70% and 60% duty cycle at 10V is different than the measured current for 70% and 60% dty cycle at 12V.

efoote868 13-06-2012 09:35

Re: PID Control algorithm(to control PWM Duty Cycle based on Current)
 
The conversion units from amps to duty cycle is included in the constant values Kp and Ki.

e.g. (6A - 5A) * (Kp %/A) = Kp%

To get the duty cycle, add all components:

(error * Kp) + (integrated error * Ki) = duty cycle.

The constants Kp and Ki are usually determined experimentally, through trial and error. I would recommend tuning your motor at a constant voltage to determine Kp (start with Ki = 0), and then changing the voltage to determine Ki.

PID 14-06-2012 00:25

Re: PID Control algorithm(to control PWM Duty Cycle based on Current)
 
Hi,

Thanks for your reply.

We are trying as u said tuning KP but we see lot of oscillation in the current output.

Thanks

efoote868 14-06-2012 08:18

Re: PID Control algorithm(to control PWM Duty Cycle based on Current)
 
You might want to consider using a feedback loop instead of strictly PID.

Think of it this way - when the error drops to zero, you don't want to set your Duty Cycle to zero, you want to keep it exactly the same.

New Duty Cycle = Old Duty Cycle + Error * Constant.

Ether 14-06-2012 09:44

Re: PID Control algorithm(to control PWM Duty Cycle based on Current)
 
Quote:

Originally Posted by efoote868 (Post 1173888)
You might want to consider using a feedback loop instead of strictly PID.

PID uses feedback

Quote:

Think of it this way - when the error drops to zero, you don't want to set your Duty Cycle to zero, you want to keep it exactly the same.
That's what the "I" in PID is for.



efoote868 14-06-2012 12:10

Re: PID Control algorithm(to control PWM Duty Cycle based on Current)
 
Thanks Ether, I originally had it in my mind that the proportional error would be the driving force in the system, but focusing on I should work better.

I should have wrote P instead of PID. ::ouch::

DonRotolo 14-06-2012 16:04

Re: PID Control algorithm(to control PWM Duty Cycle based on Current)
 
Oscillations are a result of a functioning PID loop that is not properly tuned. Play with multipliers for P and I to gauge their effect, as a prelude to proper tuning. Start with 1 for P and 0 for I, and work from there.

P gives you a direction and magnitude for your correction towards setpoint.
I takes care of long-term error, allowing the value to creep towards setpoint when P is small.
D keeps the correction from happening too fast.

Chris Hibner 14-06-2012 16:45

Re: PID Control algorithm(to control PWM Duty Cycle based on Current)
 
Quote:

Originally Posted by PID (Post 1173865)
Hi,

Thanks for your reply.

We are trying as u said tuning KP but we see lot of oscillation in the current output.

Thanks

If it's oscillating, KP is too big.

Keep cutting it in half until it stops oscillating, then bring it up slowly until it just starts to oscillate.

FrankJ 20-06-2012 09:59

Re: PID Control algorithm(to control PWM Duty Cycle based on Current)
 
Realizing if you put 3 controls engineers in a room you will get 4 different way to do tuning. One way to empirically tune a PID.
1) with the Ki & Kd gains set at 0. increase the Kp until the process value, PV, (in your case current) starts to oscillate. Do not confuse noise with oscillation, although the more noise the slower your PID will have to be. Kp will never get you to the set point unless you add a manual offset to the output. Set Kp to about half of that.
2)keeping Kp set to the value in step 1, Do the same to Ki. This will give you starting values that you can tweak to your hearts content.
3)Kd stands for destabling. Most of the time I leave it at 0. But on some systems it can be useful. Start small & work up.
4)Test your tuning by making a step change to set point and watch how it responds. Over tuned will oscillate wildly. Under tuned, it will slowly reach set point with out any over shoot. Classically tuned it will over shoot and then settle on set point with decreasing oscillation.

Hugh Meyer 20-06-2012 11:38

Re: PID Control algorithm(to control PWM Duty Cycle based on Current)
 
This article helped our team. Well worth reading.

http://igor.chudov.com/manuals/Servo...hout-a-PhD.pdf

-Hugh


All times are GMT -5. The time now is 22:23.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi