Go to Post Sometimes you have to eat your vegetables, do your homework, and get some sleep. Otherwise you may get sick, have bad grades, and or fall asleep during the championship. - IKE [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-04-2016, 10:46
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
PID Loop Controller with a Servo

Is it possible to use a servo as the output for for a PIDLoop? I am looking into some test vision tracking. The camera will be mounted to a servo and I wanted the camera to track the center of the target and move with it.
Reply With Quote
  #2   Spotlight this post!  
Unread 17-04-2016, 11:35
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,356
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: PID Loop Controller with a Servo

Great question!
I have not done this myself but I assume you would either need to add\subtract microseconds, or degrees, to your servo position signal in proportion to the error, and get your error from target position in the image.

I know 254 has a continuous rotation servo controlling the elevation of their shooter hood this year. I don't know if they use PID or not.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
Reply With Quote
  #3   Spotlight this post!  
Unread 17-04-2016, 12:02
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID Loop Controller with a Servo

Building off billbo911 post:

I was thinking about it and I have a theory. Grip reports back the distance to the center of the target; x and y. Let's say the distance x was 50. If you did some testing to figure out how much the x error changes for each degree of rotation the servo makes then you could make a ratio. So basically you convert the error into degrees of change and then add it or subtract it to the current angle.

The only problem would be the ratio would change based on the distance from the target. That throws some difficulty in the theory.

Last edited by tomy : 17-04-2016 at 12:05.
Reply With Quote
  #4   Spotlight this post!  
Unread 17-04-2016, 12:12
jkelleyrtp's Avatar
jkelleyrtp jkelleyrtp is offline
Let's just build a robot
AKA: Jon Kelley
FRC #5511 (Cortechs Robotics)
Team Role: Mechanical
 
Join Date: Jul 2015
Rookie Year: 2014
Location: Apex, NC
Posts: 121
jkelleyrtp is a glorious beacon of lightjkelleyrtp is a glorious beacon of lightjkelleyrtp is a glorious beacon of lightjkelleyrtp is a glorious beacon of lightjkelleyrtp is a glorious beacon of lightjkelleyrtp is a glorious beacon of light
Re: PID Loop Controller with a Servo

Depending on the servo and controller (I might be completely wrong, I've only tested this on the arduino) you might run into an error where you receive no real feedback from the servo. Some arduino libraries will only report the last value you've sent to the servo, which makes testing for values useless. It might be worth your time to test this hypothesis out with the hardware you plan on using to make sure it truly reports its absolute location and not what the software thinks.
__________________
Cortechs Robotics 2014-Present
Mechanical, CAD
Reply With Quote
  #5   Spotlight this post!  
Unread 17-04-2016, 12:34
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID Loop Controller with a Servo

I am getting a test bed built to do some testing with it. The current servo angle you could store as a separate variable and use that to update the new location. Then replace the variable with the new location
Reply With Quote
  #6   Spotlight this post!  
Unread 17-04-2016, 12:53
asid61's Avatar
asid61 asid61 is offline
Registered User
AKA: Anand Rajamani
FRC #0115 (MVRT)
Team Role: Mechanical
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Cupertino, CA
Posts: 2,223
asid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond repute
Re: PID Loop Controller with a Servo

Forgive me for not knowing, but how do you get feedback from a hobby servo? Don't they already have PID built in too?
__________________
<Now accepting CAD requests and commissions>

Reply With Quote
  #7   Spotlight this post!  
Unread 17-04-2016, 13:08
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID Loop Controller with a Servo

Quote:
Originally Posted by asid61 View Post
Forgive me for not knowing, but how do you get feedback from a hobby servo? Don't they already have PID built in too?

I think they do. The more I think about this the more I'm thinking of not using a PID loop and using the distance to the target as a ratio of the angle. The only problem is that the distance away from the target will change that ratio. For instance if you are two feet away changing the angle by one degree will be different if you are five feet away
Reply With Quote
  #8   Spotlight this post!  
Unread 17-04-2016, 13:20
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,356
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: PID Loop Controller with a Servo

Angle to center of target is independent of distance.
You will need to make less adjustment the further away you are but the error reported will be less as well.
What you may run into is a lack of resolution to adjust the servo accurately. That's why I mentioned using microseconds instead of degrees. ie. (~ 1000 vs. ~180)
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
Reply With Quote
  #9   Spotlight this post!  
Unread 17-04-2016, 15:00
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID Loop Controller with a Servo

Quote:
Originally Posted by billbo911 View Post
Angle to center of target is independent of distance.
You will need to make less adjustment the further away you are but the error reported will be less as well.
What you may run into is a lack of resolution to adjust the servo accurately. That's why I mentioned using microseconds instead of degrees. ie. (~ 1000 vs. ~180)
Yes resolution would fix that but how would you do that? Also if it's a 180 servo how would you account for it being greater then 180 degrees
Reply With Quote
  #10   Spotlight this post!  
Unread 17-04-2016, 15:47
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,356
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: PID Loop Controller with a Servo

Quote:
Originally Posted by tomy View Post
Yes resolution would fix that but how would you do that? Also if it's a 180 servo how would you account for it being greater then 180 degrees
That would likely dictate that you would need to not direct mount to the servo. You would probably have to build a specific interface with gearing to account for the extra degrees of motion.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
Reply With Quote
  #11   Spotlight this post!  
Unread 17-04-2016, 15:52
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID Loop Controller with a Servo

What I meant is how would you control the servo in code using microseconds?
Reply With Quote
  #12   Spotlight this post!  
Unread 17-04-2016, 17:03
asid61's Avatar
asid61 asid61 is offline
Registered User
AKA: Anand Rajamani
FRC #0115 (MVRT)
Team Role: Mechanical
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Cupertino, CA
Posts: 2,223
asid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond repute
Re: PID Loop Controller with a Servo

Quote:
Originally Posted by tomy View Post
What I meant is how would you control the servo in code using microseconds?
Servos are written a signal that is 1000-2000 uS high, then 20ms low. The number of uS you write is directly proportional to the angle; 1000uS is 0*, 1500uS is 90*, and 2000uS is 180*. There is some error but for relative angle movement (turn 5* to the left) it should be fine.
__________________
<Now accepting CAD requests and commissions>

Reply With Quote
  #13   Spotlight this post!  
Unread 17-04-2016, 17:48
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 494
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: PID Loop Controller with a Servo

Quote:
Originally Posted by asid61 View Post
Servos are written a signal that is 1000-2000 uS high, then 20ms low. The number of uS you write is directly proportional to the angle; 1000uS is 0*, 1500uS is 90*, and 2000uS is 180*. There is some error but for relative angle movement (turn 5* to the left) it should be fine.
Sounds good but how do you control that in Java based programming
Reply With Quote
  #14   Spotlight this post!  
Unread 17-04-2016, 17:54
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
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 Loop Controller with a Servo

Quote:
Originally Posted by tomy View Post
The camera will be mounted to a servo and I wanted the camera to track the center of the target and move with it.
Is the camera indeed mounted to the servo? Or is the camera mounted to a turret which is to be actuated by the servo?


Reply With Quote
  #15   Spotlight this post!  
Unread 17-04-2016, 17:55
asid61's Avatar
asid61 asid61 is offline
Registered User
AKA: Anand Rajamani
FRC #0115 (MVRT)
Team Role: Mechanical
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Cupertino, CA
Posts: 2,223
asid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond repute
Re: PID Loop Controller with a Servo

Quote:
Originally Posted by tomy View Post
Sounds good but how do you control that in Java based programming
There might be a way to access it in the Servo classes for the RIO, but I'm not familiar enough with it to say for sure.
You could also manipulate timers directly and make your own class for interfacing with them.
Or you could send data to an Arduino, which has built-in Servo libraries, at the cost of lag time.
__________________
<Now accepting CAD requests and commissions>

Reply With Quote
Reply


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:22.

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