Go to Post [Bring] programmers [to Championships], they may be small, quite and easy to miss while leaving for Atlanta but its hard to do anything robotic without them, I've tried. - Simon Strauss [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 06-11-2002, 06:50
wonderdog5 wonderdog5 is offline
Registered User
no team
 
Join Date: Oct 2002
Location: West Bloomfield
Posts: 3
wonderdog5 is an unknown quantity at this point
Question Code for Potentiometer

On our team, we are thinking about using a potentiometer as a feedback mechanism to control our arms movement. I know this is possible but the problem is that I need some help with the program. If anyone knows where I could find some samples for code like this, that would be excellent. The programs function would be just to keep the arm where it should be without falling. I am aware that we should use mechanical counterweights as well and we plan on it. Thanks for the help
  #2   Spotlight this post!  
Unread 06-11-2002, 13:24
srawls's Avatar
srawls srawls is offline
Registered User
#0122 (Nasa Knights)
 
Join Date: Dec 2001
Location: Yorktown
Posts: 507
srawls is an unknown quantity at this point
Send a message via AIM to srawls
It sounds like what you need is some sort of control loop. The one I am most comfortable with is the PID (Proportional Integral Derivitive) Control loop. This will fight back drive for you (i.e. "keep the arm where it should be without falling").

If that sounds like what you need, either e-mail me for more info, or post here and I'll see about putting a white paper up. In the meantime, I'm sure you can google search for "PID control."

Good Luck!
Stephen
  #3   Spotlight this post!  
Unread 06-11-2002, 13:39
wonderdog5 wonderdog5 is offline
Registered User
no team
 
Join Date: Oct 2002
Location: West Bloomfield
Posts: 3
wonderdog5 is an unknown quantity at this point
re: pot code

That sounds like what we need: A pid Loop. IF you could put up some info on that it would be great. thanks so much.
  #4   Spotlight this post!  
Unread 06-11-2002, 14:03
srawls's Avatar
srawls srawls is offline
Registered User
#0122 (Nasa Knights)
 
Join Date: Dec 2001
Location: Yorktown
Posts: 507
srawls is an unknown quantity at this point
Send a message via AIM to srawls
Ok, a PID loop adds the three terms (Proportional, Integral, and Deravitive) to get a drive percentage. 0 percent, don't supply any power, 100 percent, supply full power. (there are certainly other conventions, but this is the one I chose for this post).

Proportional Term:
This is the easiest to understand. You drive the motor proportionally to the distance from the current state to the set point (desired state). The formula for this term is:
Code:
P = ERROR * GAIN = (SET_STATE - CURRENT_STATE) * GAIN
You have to play a little to adjust your gain.

Integral Term:
This is a little harder to understand, perhaps. You are going to take the error, and integrate it over time, and then scale it by some gain (possibly different from the gain above). I won't get too deep into theory, but this term helps to adjust for long term, unexpected impedences to the process you are controlling.

The formula is:
Code:
I = INTEGRAL(ERROR * dt) * GAIN
Derivitive Term:
This helps correct unexpected disturbances that only effect the process momentarily. It's formula is:
Code:
D = d[ERROR] * GAIN
Where d[ERROR] is change in error, or (LAST_ERROR - CURRENT_ERROR).

Then the total drive would be P+I+D

Sorry I don't have time to explain more thouroughly. Interestingly enough, I wrote a paper on this this summer, so I could talk a lot about it But I'll be brief, and I recomend doing some research online or at a library.

Stephen

PS. Sorry, that is only theory above. I'll work on getting some sample code later, but I'm in class right now, so that's all I have time for.
  #5   Spotlight this post!  
Unread 06-11-2002, 15:19
Matt Reiland's Avatar
Matt Reiland Matt Reiland is offline
'The' drive behind the drive
None #0226 (TEC CReW Hammerheads)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1999
Location: Troy Michigan
Posts: 712
Matt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond reputeMatt Reiland has a reputation beyond repute
This is the actual code from our Swerve robot using feedback for the steering. Use the Steer_Gain variable to increase the speed that it closes in on the value . temp1 is the value that you are requesting the arm or steering to go to


' The following is for the output to the steering motor
' Some motion planning is being accomplished by slowing the motor
' as the actual steering angle is approaching the desired
' angle. This will lead to less overshoot
'
' currentsteer is the value from the steering pot on the robot

IF NOT(currentsteer > temp1) THEN STEERFWD
steer=127 - (((currentsteer - temp1)*STEER_GAIN) MAX 60)
goto EndSteeringFeedbackControl

:STEERFWD

steer=127 + (((temp1 - currentsteer)*STEER_GAIN) MAX 60)

EndSteeringFeedbackControl

steer=254-steer ' reverse the steering output
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
What is your most prefered programming language? Hailfire Programming 156 19-01-2005 21:42
Autonomous code PBoss Programming 7 14-01-2003 15:29
Does your team use the Default code. Jeff McCune General Forum 2 09-01-2003 14:46
Rookie Programmer has question about the default code DanL Programming 3 26-01-2002 19:59
Patent source code? Kyle Fenton Chit-Chat 3 20-10-2001 17:53


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

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