Go to Post (i would watch out for those jag's if i were you) - Scott Bahl [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
  #1   Spotlight this post!  
Unread 14-03-2007, 19:05
amirjpl's Avatar
amirjpl amirjpl is offline
Registered User
None #0691
 
Join Date: Feb 2005
Location: Santa Clarita
Posts: 17
amirjpl will become famous soon enough
Exclamation PLEASE HELP!! Need help programming arm??

Now I am an electronics guy not a coder, but I can still do some programming if needed. Our programmer is lazy and never gets things done, so I was wondering if you guys had some ideas of how we could use an encoder (connected to a cim motor to control our arm) to give our arm a smooth and controllable movement. How can we control the speed of the motor based on encoder feedback.
We are planning to use the Y-axis of the joystick to control the direction of the arm.
We are using the Banebots encoders, and are ready to use the divider kits if necessary.

Some example code would be appreciated, because then I could understand the solution better.
Please leave any comments or questions that you have.
Thanks in advance to all the helpers.

P.S to moderators, I made a similar post on a different thread, but I thought my question might get answered much quicker if I started a new thread. (So I have no means of spamming). Thanks
__________________
Amir Rustamzadeh- Team 691 Hart Burn

Go to Hart Burn site

Last edited by amirjpl : 14-03-2007 at 19:09.
  #2   Spotlight this post!  
Unread 14-03-2007, 19:39
David Brinza's Avatar
David Brinza David Brinza is offline
Lead Mentor, Lead Robot Inspector
FRC #0980 (ThunderBots)
Team Role: Mentor
 
Join Date: Feb 2003
Rookie Year: 2003
Location: Glendale, CA
Posts: 1,379
David Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond repute
Re: PLEASE HELP!! Need help programming arm??

If you were to search CD Media (papers) for "PID" - which is "Proportional, Integral and Differential" controls, you'll find several very good resources, including example code. For a very brief description, please look here:

In CD Media Papers "PID"

BTW, it is NOT GP to slam a team member (or anyone, for that matter) in CD. You should consider apologizing, even though you are probably frustrated.
__________________
"There's never enough time to do it right, but always time to do it over."
2003 AZ: Semifinals, Motorola Quality; SoCal: Q-finals, Xerox Creativity; IRI: Q-finals
2004 AZ: Semifinals, GM Industrial Design; SoCal: Winners, Leadership in Controls; Championship: Galileo #2 seed, Q-finals; IRI: Champions
2005 AZ: #1 Seed, Xerox Creativity; SoCal: Finalist, RadioShack Controls; SVR: Winners, Delphi "Driving Tomorrow's Technologies"; Championship: Archimedes Semifinals; IRI: Finalist
2007 LA: Finalist; San Diego: Q-finals; CalGames: Finalist || 2008 San Diego: Q-finals; LA: Winners; CalGames: Finalist || 2009 LA: Semifinals; Las Vegas: Q-finals; IRI: #1 Seed, Finalist
2010 AZ: Motorola Quality; LA: Finalist || 2011 SD: Q-finals; LA: Q-finals || 2013 LA: Xerox Creativity, WFFA, Dean's List Finalist || 2014 IE: Q-finals, LA: Finalist, Dean's List Finalist
2016 Ventura: Q-finals, WFFA, Engineering Inspiration

Last edited by David Brinza : 15-03-2007 at 13:55. Reason: The CD search results expired, I'm now pointing to a 2pg paper on control theory
  #3   Spotlight this post!  
Unread 14-03-2007, 19:39
114Klutz 114Klutz is offline
Registered User
AKA: Li Pi
FRC #2984 (Viking Robotics)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Los Altos
Posts: 152
114Klutz is a jewel in the rough114Klutz is a jewel in the rough114Klutz is a jewel in the rough
Send a message via AIM to 114Klutz
Re: PLEASE HELP!! Need help programming arm??

What are you attempting to do? Do you want the joystick to control the position of the arm, or do you simply want the joystick to control the speed of the arm movement?

If you want the joystick to control the position of the arm, you'll need a PID loop and a way of calculating where the arm is using the encoder. You'll also have to ensure(Unless its an absolute encoder) that the arm starts at the same position every time.

If you want to control the speed, then you'll still need a PID loop

Feel free to talk to me on aim (evil666rat), I'll be happy to help - I'm the programmer who wrote the code controlling our arm. I'll be happy to build some for yours, if you'll contact me with some more details.

Last edited by 114Klutz : 14-03-2007 at 19:47.
  #4   Spotlight this post!  
Unread 14-03-2007, 20:24
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: PLEASE HELP!! Need help programming arm??

The way you code will depend on how the arm works. You need to do things a bit differently if the arm will hold position by itself, or if you need to
continuously apply power to keep it in position.

Early in our season, we had a prototype robot with a pivoting arm and we found that using a pot on an analog input was an easy way to detect the position without the mess of servicing an encoder.

You can still use a PID routine to adjust your speed and maintain a position once you have achieved it.

With an arm that does not hold position by itself, we found we were popping the breakers a lot. We used a big bungee to counteract the force of gravity (so the motor's didn't need to work so hard to maintain a lifted position).

Our PID looked at a target POT value to move the arm to and adjusted the power to the arm motor based on the distance. When we wanted the arm to stay in a position that we had moved it to with the joy stick, we look at the current POT value and set the target value to it. This resulted in an arm that could be pushed or pulled out of position, but which would return to where you wanted it when it was released.

Good luck.
  #5   Spotlight this post!  
Unread 14-03-2007, 23:11
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: PLEASE HELP!! Need help programming arm??

You guys are suggesting PID?!?!

K.I.S.S. 237's arm works off a P loop with a "gain" of 1. If it needed to be more complex it would be, but we found that theres more or less no overshoot or oscillation with this system.

First lets make sure the path of least resistance is closed (open, if you want to use electrical terms ) before we suggest complex closed loop control theory.
__________________
http://www.mikesorrenti.com/
  #6   Spotlight this post!  
Unread 14-03-2007, 23:46
chrisstruttmann chrisstruttmann is offline
Registered User
FRC #0386 (Team Voltage)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Melbourne, Florida
Posts: 18
chrisstruttmann will become famous soon enough
Send a message via AIM to chrisstruttmann
Re: PLEASE HELP!! Need help programming arm??

Team Voltage uses a PD loop with differentiating "goals" depending on what position you want the arm to be in.

--Chris
Lead Programmer
  #7   Spotlight this post!  
Unread 15-03-2007, 00:35
amirjpl's Avatar
amirjpl amirjpl is offline
Registered User
None #0691
 
Join Date: Feb 2005
Location: Santa Clarita
Posts: 17
amirjpl will become famous soon enough
Re: PLEASE HELP!! Need help programming arm??

Thanks for replying guys,
Can someone explain the PID loop in depth, and show an example or something that can help me get started.

Just some more information about the arm.
It will have an encoder, since the encoder gives back feed back can't that be just used to keep the arm at a preset constant speed??

Or is this something that PID has taken into consideration.
The help has been great so far, please keep it coming.
__________________
Amir Rustamzadeh- Team 691 Hart Burn

Go to Hart Burn site
  #8   Spotlight this post!  
Unread 15-03-2007, 00:53
AdamHeard's Avatar
AdamHeard AdamHeard is offline
Lead Mentor
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Atascadero
Posts: 5,509
AdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond repute
Send a message via AIM to AdamHeard
Re: PLEASE HELP!! Need help programming arm??

Read this paper.

Since this is your first PID loop, I would recommend not using "I" if you can avoid it. "I" can really help if the system is perfectly tuned; but it is difficult to get it that way. A PD loop is more forgiving, although it can be slower.
  #9   Spotlight this post!  
Unread 15-03-2007, 13:47
amirjpl's Avatar
amirjpl amirjpl is offline
Registered User
None #0691
 
Join Date: Feb 2005
Location: Santa Clarita
Posts: 17
amirjpl will become famous soon enough
Re: PLEASE HELP!! Need help programming arm??

Are there any downsides of using a PID loop and what success have you guys had using a PID loop on you robots???
__________________
Amir Rustamzadeh- Team 691 Hart Burn

Go to Hart Burn site
  #10   Spotlight this post!  
Unread 15-03-2007, 13:58
AdamHeard's Avatar
AdamHeard AdamHeard is offline
Lead Mentor
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Atascadero
Posts: 5,509
AdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond repute
Send a message via AIM to AdamHeard
Re: PLEASE HELP!! Need help programming arm??

Quote:
Originally Posted by amirjpl View Post
Are there any downsides of using a PID loop and what success have you guys had using a PID loop on you robots???
Downsides.... Hmm... they do take work to tune....

success: Arms that would have been nearly impossible to manually control are quickly and precisely control. Another feature you get almost for free is the ability to go to "preset" positions - the arm position to pickup, score high, etc... - quickly and accurately.

If you get the control on there, I don't think you'll regret it.
  #11   Spotlight this post!  
Unread 15-03-2007, 14:37
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,280
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: PLEASE HELP!! Need help programming arm??

I am going to have to agree with Mike on this one, PID (or even PD) is a bit much, especially since he said he wasn't a programmer. Now before you tell me how much better off you are with PID think about how long it takes for you to tune your loops, now realize that he doesn't have the robot, probably until competition. There is almost no chance that he will be able to get the robot to himself for long enough to get every thing working, especially with it being his first try.

I would reccomend using a pot instead of an encoder, they are much easier to work with.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
  #12   Spotlight this post!  
Unread 15-03-2007, 15:01
JimGRobot JimGRobot is offline
Registered User
AKA: Jim
FRC #1388 (Eagle Robotics)
Team Role: Mentor
 
Join Date: Nov 2006
Rookie Year: 2005
Location: Arroyo Grande, CA
Posts: 29
JimGRobot is just really niceJimGRobot is just really niceJimGRobot is just really niceJimGRobot is just really nice
Re: PLEASE HELP!! Need help programming arm??

I am going to repeat what others have said in this thread...

Using a potentiometer on the arm axis instead of an encoder on the motor will make your task a LOT easier. You can read the pot directly through an RC analog input, but the encoder takes a lot more work to accurately count pulses when the motor is moving...

You can get very good positioning using simple "P", proportional control, which amounts to taking the difference between the position where you want the arm to be, and where it is, and sending that to the arm motor PWM output. Something similar to this would work:

int ArmPosition;
int ArmPostionSetpoint;
int ArmMotorOutput;

// Read the arm position and scale so zero is at a known position,
// like when the arm is horizontal.
ArmPosition = GetAnalogInput(xxx) - 250; // replace 250 with your actual value

// Scale this number down to match the range of the joystick.
ArmPosition /= 4;

// Read the arm joystick and scale so that zero is the normal resting position.
ArmPositionSetpoint = p2_y - 127;

// Take the difference between setpoint and position, and apply a gain factor.
ArmMotorOutput = (ArmPositionSetpoint - ArmPosition) * 4;

// limit the value of ArmMotorOutput to an acceptable range for your drive.
if (ArmMotorOutput > 80) ArmMotorOutput = 80;
if (ArmMotorOutput < -80) ArmMotorOutput = -80;

PWMxx = (char)(ArmMotorOutput + 127 );

This isn't perfect, but it should get you started...

Jim

Last edited by JimGRobot : 15-03-2007 at 16:00.
  #13   Spotlight this post!  
Unread 15-03-2007, 15:11
David Brinza's Avatar
David Brinza David Brinza is offline
Lead Mentor, Lead Robot Inspector
FRC #0980 (ThunderBots)
Team Role: Mentor
 
Join Date: Feb 2003
Rookie Year: 2003
Location: Glendale, CA
Posts: 1,379
David Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond reputeDavid Brinza has a reputation beyond repute
Re: PLEASE HELP!! Need help programming arm??

Quote:
Originally Posted by JamesBrown View Post
I would reccomend using a pot instead of an encoder, they are much easier to work with.
Amir:
You understand that the encoder generates pulses as the arm moves, whereas a pot will provide an analog voltage that corresponds to the position of the arm? If you use the encoder, the software will need to update the position of the arm as pulses are detected. With a pot, each time you read the analog port it is connected to, you get instantaneous position data. This is why teams generally use pots on arms rather than encoders.
__________________
"There's never enough time to do it right, but always time to do it over."
2003 AZ: Semifinals, Motorola Quality; SoCal: Q-finals, Xerox Creativity; IRI: Q-finals
2004 AZ: Semifinals, GM Industrial Design; SoCal: Winners, Leadership in Controls; Championship: Galileo #2 seed, Q-finals; IRI: Champions
2005 AZ: #1 Seed, Xerox Creativity; SoCal: Finalist, RadioShack Controls; SVR: Winners, Delphi "Driving Tomorrow's Technologies"; Championship: Archimedes Semifinals; IRI: Finalist
2007 LA: Finalist; San Diego: Q-finals; CalGames: Finalist || 2008 San Diego: Q-finals; LA: Winners; CalGames: Finalist || 2009 LA: Semifinals; Las Vegas: Q-finals; IRI: #1 Seed, Finalist
2010 AZ: Motorola Quality; LA: Finalist || 2011 SD: Q-finals; LA: Q-finals || 2013 LA: Xerox Creativity, WFFA, Dean's List Finalist || 2014 IE: Q-finals, LA: Finalist, Dean's List Finalist
2016 Ventura: Q-finals, WFFA, Engineering Inspiration
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
I Need Help With An Arm Team ICE #1611 General Forum 4 20-01-2005 14:37
hey need some help with writing a code please help me here magical hands Programming 9 01-01-2004 21:46
I need help, please?!?! archiver 2001 3 23-06-2002 22:46


All times are GMT -5. The time now is 21:17.

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