OCCRA
Go to Post Stupid programmer question: where does the tread go? - Joel J [more]
Home
Go Back   Chief Delphi > Technical > Control System
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-13-2012, 06:39 AM
PID PID is offline
Registered User
no team
 
Join Date: Jun 2012
Location: asia
Posts: 2
PID is an unknown quantity at this point
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.
  #2   Spotlight this post!  
Unread 06-13-2012, 09:35 AM
efoote868 efoote868 is offline
foote stepped in
AKA: E. Foote
no team
Team Role: Alumni
 
Join Date: Mar 2006
Rookie Year: 2005
Location: Appleton, WI
Posts: 997
efoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond repute
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.
__________________
Former member / mentor of FRC team 868
Go TechHOUNDS!


  #3   Spotlight this post!  
Unread 06-14-2012, 12:25 AM
PID PID is offline
Registered User
no team
 
Join Date: Jun 2012
Location: asia
Posts: 2
PID is an unknown quantity at this point
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
  #4   Spotlight this post!  
Unread 06-14-2012, 08:18 AM
efoote868 efoote868 is offline
foote stepped in
AKA: E. Foote
no team
Team Role: Alumni
 
Join Date: Mar 2006
Rookie Year: 2005
Location: Appleton, WI
Posts: 997
efoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond repute
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.
__________________
Former member / mentor of FRC team 868
Go TechHOUNDS!


  #5   Spotlight this post!  
Unread 06-14-2012, 09:44 AM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 6,164
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PID Control algorithm(to control PWM Duty Cycle based on Current)

Quote:
Originally Posted by efoote868 View Post
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.


  #6   Spotlight this post!  
Unread 06-14-2012, 12:10 PM
efoote868 efoote868 is offline
foote stepped in
AKA: E. Foote
no team
Team Role: Alumni
 
Join Date: Mar 2006
Rookie Year: 2005
Location: Appleton, WI
Posts: 997
efoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond reputeefoote868 has a reputation beyond repute
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.
__________________
Former member / mentor of FRC team 868
Go TechHOUNDS!


  #7   Spotlight this post!  
Unread 06-14-2012, 04:04 PM
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Feeling Honorable
FRC #1676 (Pascack PI Oneers)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Montvale NJ
Posts: 6,467
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
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.
__________________

I am N2IRZ - What's your callsign?
  #8   Spotlight this post!  
Unread 06-14-2012, 04:45 PM
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,404
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: PID Control algorithm(to control PWM Duty Cycle based on Current)

Quote:
Originally Posted by PID View Post
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.
__________________
-
An ounce of perception is worth a pound of obscure.
  #9   Spotlight this post!  
Unread 06-20-2012, 09:59 AM
FrankJ's Avatar
FrankJ FrankJ is offline
Robot Mentor
FRC #2974 (WALT)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: Marietta GA
Posts: 959
FrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond reputeFrankJ has a reputation beyond repute
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.
  #10   Spotlight this post!  
Unread 06-20-2012, 11:38 AM
Hugh Meyer's Avatar
Hugh Meyer Hugh Meyer is offline
Registered User
FRC #1741 (Red Alert Robotics)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Greenwood Indiana
Posts: 137
Hugh Meyer is a splendid one to beholdHugh Meyer is a splendid one to beholdHugh Meyer is a splendid one to beholdHugh Meyer is a splendid one to beholdHugh Meyer is a splendid one to beholdHugh Meyer is a splendid one to beholdHugh Meyer is a splendid one to beholdHugh Meyer is a splendid one to behold
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
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:50 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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