OCCRA [more] FRC Kickoff : 25d 09h 43m ...
I understand that Dean Kaymen has now invented a super "sniffer" that can scout-out anyone within hearing distance that is remotely-involved with FIRST. - dhitchco [more]
 Chief Delphi PID Control algorithm(to control PWM Duty Cycle based on Current)
 CD-Events CD-Media CD-Spy FRC-Spy
The Chief Delphi Forums are sponsored by Innovation First International, Inc.

#1
06-13-2012, 06:39 AM
 PID Registered User no team Join Date: Jun 2012 Location: asia Posts: 2
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
06-13-2012, 09:35 AM
 efoote868 foote stepped in AKA: E. Foote no team Team Role: Alumni Join Date: Mar 2006 Rookie Year: 2005 Location: Appleton, WI Posts: 864
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
06-14-2012, 12:25 AM
 PID Registered User no team Join Date: Jun 2012 Location: asia Posts: 2
Re: PID Control algorithm(to control PWM Duty Cycle based on Current)

Hi,

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

Thanks
#4
06-14-2012, 08:18 AM
 efoote868 foote stepped in AKA: E. Foote no team Team Role: Alumni Join Date: Mar 2006 Rookie Year: 2005 Location: Appleton, WI Posts: 864
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
06-14-2012, 09:44 AM
 Ether systems engineer (retired) no team Join Date: Nov 2009 Rookie Year: 1969 Location: US Posts: 5,032
Re: PID Control algorithm(to control PWM Duty Cycle based on Current)

Quote:
 Originally Posted by efoote868 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
06-14-2012, 12:10 PM
 efoote868 foote stepped in AKA: E. Foote no team Team Role: Alumni Join Date: Mar 2006 Rookie Year: 2005 Location: Appleton, WI Posts: 864
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
06-14-2012, 04:04 PM
 DonRotolo Will machine for food. FRC #1676 (Pascack PI Oneers) Team Role: Mentor Join Date: Jan 2005 Rookie Year: 2005 Location: Montvale NJ Posts: 5,797
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
06-14-2012, 04:45 PM
 Chris Hibner 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,310
Re: PID Control algorithm(to control PWM Duty Cycle based on Current)

Quote:
 Originally Posted by PID 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
06-20-2012, 09:59 AM
 FrankJ Robot Mentor FRC #2974 (WALT) Team Role: Mentor Join Date: Feb 2011 Rookie Year: 2009 Location: Marietta GA Posts: 509
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
06-20-2012, 11:38 AM
 Hugh Meyer Registered User FRC #1741 (Red Alert Robotics) Team Role: Mentor Join Date: Feb 2009 Rookie Year: 2008 Location: Greenwood Indiana Posts: 119
Re: PID Control algorithm(to control PWM Duty Cycle based on Current)

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

-Hugh

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     User Announcements FIRST     General Forum         FIRST E-Mail Blast Archive     Rumor Mill     Career     Robot Showcase     Moderated Discussion Technical     Technical Discussion     Robotics Education and Curriculum     Motors     Electrical         CAN     Programming         NI LabVIEW         WindRiver C++         Java         MATLAB & Simulink         Python     intelitek easyC/REC information         easyC v2 for Vex         easyC for FRC         REC/Learnmate         WPILib         easyC PRO     Control System         IFI Control System         FRC Control System         Sensors         USB Chicklet     Pneumatics     Kit & Additional Hardware     CAD         Inventor         SolidWorks         Pro ENGINEER / Creo     IT / Communications         3D Animation and Competition         Website Design/Showcase         Videography and Photography         Computer Graphics     National Instruments LabVIEW and Data Acquisition         LabView and Data Acquisition Competition     Awards         Chairman's Award     Rules/Strategy         Scouting         You Make The Call     Team Organization         Fundraising         Starting New Teams         Finding A Team         College Teams     Championship Event     Regional Competitions     FIRST in Michigan     Mid-Atlantic Robotics     Off-Season Events         Chief Delphi Invitational     Thanks and/or Congrats     FRC Game Design     OCCRA         OCCRA Q&A         OCCRA Programming Other     Unsung FIRST Heroes     Chit-Chat         Games/Trivia             Fantasy FIRST     Car Nack's Corner     College & University Education     Dean Kamen's Inventions     FIRST-related Organizations         Western Region Robotics Forum         Robot Chicks Union (RCU)         Southern California Regional Robotics Forum         FIRST Interactive Rural SupporT         FIRST Scouting Network         The Grand FIRST Team         FloridaFIRST         FIRSTwiki         Ultimate Robot Challenge         Team San Diego         Dream FIRST         The Blue Alliance             Video Archives     FIRST Historians     FIRST-A-Holic's Anonymous Mailbox     FIRST In the News...     FIRST Lego League         Lego Mindstorm Discussion     FIRST Tech Challenge     VEX         VEX Robotics Competition         VEX IQ     Televised Robotics     Math and Science         NASA Discussion ChiefDelphi.com Website     CD Forum Support     Extra Discussion Old Forum Archives     1999     2000     2001

All times are GMT -5. The time now is 02:16 PM.

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

 -- English (12 hour) -- English (24 hour) Contact Us - Chief Delphi - Rules - Archive - Top