Go to Post CNC machine, Something every FIRST kid wants in their bedroom :) - David Kelly [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 13-03-2011, 14:43
Chris27's Avatar
Chris27 Chris27 is offline
Registered User
AKA: Chris Freeman
FRC #1625 (Winnovation)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2004
Location: Mountain View
Posts: 196
Chris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant future
Re: PID Loops

Quote:
Originally Posted by theNerd View Post
when PID loops are used?
An example of a use of PID is our autonomous mode. We want to be able to drive out exactly x inches to our rack in a perfectly straight line to put us in a position to score a tube on the high rack. This isn't so straightforward as a 150lb robot has a lot of momentum and it is easy to overshoot a target distance (and crash into the wall). We can record the distance the robot has traveled by putting an encoder on the right side of the drive train. Using PID, we set the set point to x and read the encoder to get the current position. With our gains set correctly, we arrive at distance x rather smoothly.

However, we also want to drive in a perfectly straight line. If, say there is more friction on one side of the drive train, this will cause the robot to drive in an arc. You can add a gyro to the bot, use PID on it with the set point of whatever heading is defined to be "straight". Add this correction to the speed of the left wheel motors and you are 80% of the way to having a perfect one tube autonomous mode.
  #17   Spotlight this post!  
Unread 13-03-2011, 15:21
PriyankP's Avatar
PriyankP PriyankP is offline
Registered User
FRC #0188 (Woburn Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Toronto, Canada
Posts: 87
PriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud of
Re: PID Loops

I've been reading this thread and could someone please post an example code with P, I and D implemented to control something? I saw the LabView code, but I never learned labview, so could someone please post a C++/Java example?!

EDIT: I did implement P loop to control our arm this year, but only for presets. Is it possible to implement PID loop for manual control? If yes, how so?
__________________
Champs Schedule Highlighter App [CD Thread]

#### XYZ Regional Finalists
  #18   Spotlight this post!  
Unread 13-03-2011, 15:39
archaopteryx archaopteryx is offline
Registered User
FRC #2067
 
Join Date: Mar 2011
Location: Guilford
Posts: 2
archaopteryx is an unknown quantity at this point
Re: PID Loops

I'm not a mathematician, but couldn't
Quote:
Pedal = K * Error
, where K is a constant, simply do without K? If pedal and error have a direct correlation, why can't you just say that pedal = error and leave it at that?
  #19   Spotlight this post!  
Unread 13-03-2011, 15:44
Chris27's Avatar
Chris27 Chris27 is offline
Registered User
AKA: Chris Freeman
FRC #1625 (Winnovation)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2004
Location: Mountain View
Posts: 196
Chris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant future
Re: PID Loops

Quote:
Originally Posted by archaopteryx View Post
I'm not a mathematician, but couldn't , where K is a constant, simply do without K? If pedal and error have a direct correlation, why can't you just say that pedal = error and leave it at that?

If you are trying to move your car at 50 mph and currently, the error from this target is +10 mph, does it make sense to push the pedal down at 10 mph? A correlation does not mean an equivalent 1 to 1 relation. Another example is if you are trying to drive your robot 5 feet forward and the current error is 4 inches. Does it make sense to tell the motors to drive at 4 inches? Built into the k value is unit conversion among other things.

Last edited by Chris27 : 13-03-2011 at 15:48.
  #20   Spotlight this post!  
Unread 13-03-2011, 15:44
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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 Loops

Quote:
Originally Posted by PriyankP View Post
EDIT: I did implement P loop to control our arm this year, but only for presets. Is it possible to implement PID loop for manual control? If yes, how so?
Instead of preset, make the setpoint manually adjustable (like the output of a joystick axis) .


  #21   Spotlight this post!  
Unread 13-03-2011, 15:53
PriyankP's Avatar
PriyankP PriyankP is offline
Registered User
FRC #0188 (Woburn Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Toronto, Canada
Posts: 87
PriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud of
Re: PID Loops

Quote:
Originally Posted by Ether View Post
Instead of preset, make the setpoint manually adjustable (like the output of a joystick axis) .

So it would be something like target = currentPotValue + (Yaxis * 5) right?

I'm multiplying by 5 because the Yaxis is only between -1 and 1 so one would want to have a target that is significantly different compared to the currentPotValue
__________________
Champs Schedule Highlighter App [CD Thread]

#### XYZ Regional Finalists
  #22   Spotlight this post!  
Unread 13-03-2011, 15:54
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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 Loops

Quote:
Originally Posted by archaopteryx View Post
I'm not a mathematician, but couldn't , where K is a constant, simply do without K? If pedal and error have a direct correlation, why can't you just say that pedal = error and leave it at that?
If you are trying to control position, then the error will be in inches (or feet or meters or whatever). In response to this error, you want to choose the appropriate command to your motors, which will be a voltage command... which roughly corresponds to a speed command. So the K is a scaling and gain factor to convert the error to an appropriate motor voltage (speed) command.

On the other hand, suppose you are trying to control motor speed. You want to go 2000 rpm and you are presently going 1900 rpm. So the error is 100 rpm. Would it make sense to give the motor a voltage command which is roughly equal to 100 rpm?


  #23   Spotlight this post!  
Unread 13-03-2011, 15:55
Chris27's Avatar
Chris27 Chris27 is offline
Registered User
AKA: Chris Freeman
FRC #1625 (Winnovation)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2004
Location: Mountain View
Posts: 196
Chris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant future
Re: PID Loops

Quote:
Originally Posted by PriyankP View Post
EDIT: I did implement P loop to control our arm this year, but only for presets. Is it possible to implement PID loop for manual control? If yes, how so?
If a system of your robot has mechanical limits (e.g. an arm) you may want to use PID (or even just P) to not smash into those limits. I can also see PID used for speed control like in Chris's example.
  #24   Spotlight this post!  
Unread 13-03-2011, 16:02
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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 Loops

Quote:
Originally Posted by PriyankP View Post
So it would be something like target = currentPotValue + (Yaxis * 5) right?
Yaxis is your setpoint and (m*currentPotValue+b) is your process variable.

Adjust the gain "m" and the offset "b" so that your process variable corresponds to your Yaxis output.

Then,

error = setpoint - process_variable;

motor_voltage_command = Kp*error;

Kp is your proportional gain which you tune for the desired response.


  #25   Spotlight this post!  
Unread 13-03-2011, 16:14
PriyankP's Avatar
PriyankP PriyankP is offline
Registered User
FRC #0188 (Woburn Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Toronto, Canada
Posts: 87
PriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud of
Re: PID Loops

Quote:
Originally Posted by Ether View Post
Yaxis is your setpoint and (m*currentPotValue+b) is your process variable.

Adjust the gain "m" and the offset "b" so that your process variable corresponds to your Yaxis output.

Then,

error = setpoint - process_variable;

motor_voltage_command = Kp*error;

Kp is your proportional gain which you tune for the desired response.

So (m*(currentPotValue+b)) should have range of -1 to 1? or it doesn't matter because Kp takes care of that?
__________________
Champs Schedule Highlighter App [CD Thread]

#### XYZ Regional Finalists
  #26   Spotlight this post!  
Unread 13-03-2011, 16:28
HarveyAce's Avatar
HarveyAce HarveyAce is offline
Registered User
FRC #3329 (CAMBots)
Team Role: Leadership
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Camden County
Posts: 91
HarveyAce has a brilliant futureHarveyAce has a brilliant futureHarveyAce has a brilliant futureHarveyAce has a brilliant futureHarveyAce has a brilliant futureHarveyAce has a brilliant futureHarveyAce has a brilliant futureHarveyAce has a brilliant futureHarveyAce has a brilliant futureHarveyAce has a brilliant futureHarveyAce has a brilliant future
Re: PID Loops

Quote:
Originally Posted by Ether View Post
What is your total gear ratio from motor to arm (gearbox plus external gears or sprockets or pulleys etc).

We are currently running two denso window motors in tandem to power the joint with a surgical tubing counter balance. I'm just curious because when we ram the fp, it was WAY too fast and couldn't hold the weight in one position, but I've seen teams do it with much success.
__________________
"Though I fly through the Valley of Death I shall fear no evil, for I am at 80,000 feet and climbing."
  #27   Spotlight this post!  
Unread 13-03-2011, 16:52
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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 Loops

Quote:
Originally Posted by PriyankP View Post
So (m*(currentPotValue+b)) should have range of -1 to 1? or it doesn't matter because Kp takes care of that?
Kp does not take care of that. Kp is the tuning constant, and is applied to the error. Take another look.


  #28   Spotlight this post!  
Unread 13-03-2011, 16:53
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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 Loops

Quote:
Originally Posted by HarveyAce View Post
I'm just curious because when we ram the fp,
when you "ran the fp" how did you run it? i.e. what total gear ratio did you use?


  #29   Spotlight this post!  
Unread 13-03-2011, 16:55
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
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 Loops

Quote:
Originally Posted by HarveyAce View Post
We are currently running two denso window motors in tandem to power the joint with a surgical tubing counter balance.
In an earlier post, you mentioned 30-35 ft-lbs of torque on the arm. Was that with or without the surgical tubing in place?


  #30   Spotlight this post!  
Unread 13-03-2011, 17:35
PriyankP's Avatar
PriyankP PriyankP is offline
Registered User
FRC #0188 (Woburn Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Toronto, Canada
Posts: 87
PriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud of
Re: PID Loops

Quote:
Originally Posted by Ether View Post
Kp does not take care of that. Kp is the tuning constant, and is applied to the error. Take another look.


So (m*currentPotValue+b) doesn't have to be within -1 to +1? And what exactly does it, the process variable, do?
__________________
Champs Schedule Highlighter App [CD Thread]

#### XYZ Regional Finalists
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 23:40.

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


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