|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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
|
|||||
|
|||||
|
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
|
|||
|
|||
|
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
|
|||||
|
|||||
|
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 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 This helps correct unexpected disturbances that only effect the process momentarily. It's formula is: Code:
D = d[ERROR] * GAIN 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
|
|||||
|
|||||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |