Go to Post Silly FIRST mentor -- actually spending brain power caring about a sporting event occuring during build season! - Aidan F. Browne [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
  #31   Spotlight this post!  
Unread 13-03-2011, 17:43
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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) doesn't have to be within -1 to +1?
"m" and "b" are constants which you need to calculate and set so that the operating range of the process variable corresponds to the desired operating range of the joystick, be it -1 to +1 or 0 to +1 or whatever.


Quote:
And what exactly does it, the process variable, do?
Read this post, then ask if it's not clear.


  #32   Spotlight this post!  
Unread 13-03-2011, 17:59
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
"m" and "b" are constants which you need to calculate and set so that the operating range of the process variable corresponds to the desired operating range of the joystick, be it -1 to +1 or 0 to +1 or whatever.




Read this post, then ask if it's not clear.

Am I correct about this:

JoyStickYaxis is +1 (operator input)
currentPotValue is 550 (min is 300 and max is 600)

(m*(currentPotValue+b)) = ( (1/150)*(550-450) )
m is 1/150 and b is -450 so that the number is always between -1 and 1
error = 1 - 0.6666;
MotorOutput = k * 0.3333 and say k is 0.75 then the output becomes 0.25
of course, k needs to be adjusted so the error is as close to 0 as possible and/or the arm doesn't oscillate
Good so far? Or did I make a mistake somewhere?

EDIT: I have a feeling I did something wrong
__________________
Champs Schedule Highlighter App [CD Thread]

#### XYZ Regional Finalists

Last edited by PriyankP : 13-03-2011 at 18:01.
  #33   Spotlight this post!  
Unread 13-03-2011, 18:41
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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
JoyStickYaxis is +1 (operator input)
currentPotValue is 550 (min is 300 and max is 600)

(m*(currentPotValue+b)) = ( (1/150)*(550-450) )

m is 1/150 and b is -450 so that the number is always between -1 and 1
That should work, although it's a little different from the standard slope/intercept form that I posted.





Last edited by Ether : 13-03-2011 at 18:49.
  #34   Spotlight this post!  
Unread 13-03-2011, 18:55
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
That should work, although it's a little different from the standard slope/intercept form that I posted.



I think there is something wrong with that pseudo code because if the Yaxis is not touched, a value of 0 is being outputted, the arm will still move. How can I fix that? Do I need to do something like 'if the Yaxis is between -0.05 and +0.05, stop the arm, else run the code' ?
__________________
Champs Schedule Highlighter App [CD Thread]

#### XYZ Regional Finalists
  #35   Spotlight this post!  
Unread 13-03-2011, 19:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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
I think there is something wrong with that pseudo code because if the Yaxis is not touched, a value of 0 is being outputted, the arm will still move. How can I fix that? Do I need to do something like 'if the Yaxis is between -0.05 and +0.05, stop the arm, else run the code' ?
The code is correct. Perhaps you misunderstand what a closed-loop position controller does.

What you have implemented is a closed-loop position controller. The arm will move to a position commanded by the joystick, and stay there as long as the joystick continues to command that position. If you let go of the joystick, the joystick will return to its rest position and will be commanding "go to position zero", which corresponds to a reading of 450 on your pot. So that is where the arm will go.

If that is not the behavior you want, then you need to articulate more clearly what you are trying to accomplish.

For example, if you want the controller to hold the arm in a given position once you have moved it to where you want it to be with the joystick, then you could do something like the following: change the code so that it uses the joystick value for the setpoint only if Button1 is pressed. When Button1 is released, the joystick is ignored and the last joystick value continues to be used for the setpoint. So the driver holds Button1 pressed while he is moving the joystick to put the arm in position, and once the arm is where he wants it, he releases Button1, and the controller will hold the arm at that position, and he can let go of the joystick. When he wants to change the arm position, he holds Button1 pressed and uses the joystick to move the arm to the new position, and then releases Button1.

Or perhaps there is a small set of pre-defined positions from among which you would like to be able to select. For example: floor, level1, level2, level3. You could program 4 buttons so that each button changes the setpoint to the necessary value. The closed-loop controller then moves the arm to that setpoint. In this case, you could dispense with the "m" and "b" constants, and just assign a pot-value setpoint to each of the buttons.





Last edited by Ether : 13-03-2011 at 19:24.
  #36   Spotlight this post!  
Unread 13-03-2011, 19:52
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
The code is correct. Perhaps you misunderstand what a closed-loop position controller does.

What you have implemented is a closed-loop position controller. The arm will move to a position commanded by the joystick, and stay there as long as the joystick continues to command that position. If you let go of the joystick, the joystick will return to its rest position and will be commanding "go to position zero", which corresponds to a reading of 450 on your pot. So that is where the arm will go.

If that is not the behavior you want, then you need to articulate more clearly what you are trying to accomplish.

For example, if you want the controller to hold the arm in a given position once you have moved it to where you want it to be with the joystick, then you could do something like the following: change the code so that it uses the joystick value for the setpoint only if Button1 is pressed. When Button1 is released, the joystick is ignored and the last joystick value continues to be used for the setpoint. So the driver holds Button1 pressed while he is moving the joystick to put the arm in position, and once the arm is where he wants it, he releases Button1, and the controller will hold the arm at that position, and he can let go of the joystick. When he wants to change the arm position, he holds Button1 pressed and uses the joystick to move the arm to the new position, and then releases Button1.

Or perhaps there is a small set of pre-defined positions from among which you would like to be able to select. For example: floor, level1, level2, level3. You could program 4 buttons so that each button changes the setpoint to the necessary value. The closed-loop controller then moves the arm to that setpoint. In this case, you could dispense with the "m" and "b" constants, and just assign a pot-value setpoint to each of the buttons.



Oh I see, regardless of the practical usefulness on the robot, it was worth learning something new.

I already have the four presets that the operator can use, but the only difference is that I'm only using a P loop to reach that target. It works beautifully and doesn't oscillate. The only drawback is that its only accurate to +-5 pot values. But I compensate by increasing the desired value by 5 pot increments that way it gets as close to the target as possible going one way... I didn't really implement I and D because for one, I didn't really know how to use them and secondly, I didn't really have enough time to learn and implement it on the robot to yield some positive results.

Thank you!
__________________
Champs Schedule Highlighter App [CD Thread]

#### XYZ Regional Finalists

Last edited by PriyankP : 13-03-2011 at 19:57.
  #37   Spotlight this post!  
Unread 13-03-2011, 20:01
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: PID Loops

Quote:
Originally Posted by Greg McKaskle View Post
By the way, we are considering including both forms and a number of additional control tools in the future. Any feedback or requests?
Useful additions might be output limits and perhaps rate change limits.
  #38   Spotlight this post!  
Unread 14-03-2011, 15:01
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: PID Loops

Quote:
Originally Posted by Alan Anderson View Post
Useful additions might be output limits and perhaps rate change limits.
The advanced PID VI has output limits. There is also a rate limiter VI in the PID library.
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:52.

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