Log in

View Full Version : PI Like Control with Pots


Tom Bottiglieri
21-02-2005, 22:39
I have run into a problem. Our main arm is powered by 2 fisher price motors, and is subject to backdrive when the arm is extended too much. I have a pot connected to it to drive to pre set positions, and I was wondering if anyone has had experience with coding a control loop that is driven by a potentiometer. Normally, I would research this topic, but with one night left to get this working, I need help.

Right now i am using a basic "check and correct" function. I have the code so when the joystick is neutral, it grabs the pots value. Then in the following program loops if that value deviates from the original, it will drive the motor accordingly. This is not working very well. Our only other alternative is a mechanical brake, but we do not have enough time to do this.

Please help me with this...

Thanks,
Tom

Max Lobovsky
21-02-2005, 22:43
A PID feedback loop is what you want. There are many, many threads on this including many with code posted. IM me if you want and I can give you my own code.

Bharat Nain
22-02-2005, 02:07
All I can suggest from my past years experience of working with pots is give it some slack. If you over power it, it will go nuts trying to correct itself.

FotoPlasma
22-02-2005, 02:18
If the point of this feedback loop is to prevent backdriving, have you considered switching the jumper on your speed controllers to active breaking?

The double jointed arm (http://firstrobotics.net/04Gallery/pages/0258-1_jpg.htm) I had the pleasure of working on, last year, had some trouble with inertia until we turned this option on. It worked like a charm.

sanddrag
22-02-2005, 02:26
have you considered switching the jumper on your speed controllers to active breaking?LOL! A setting to break it! Anyhow, setting the braking jumper might not stop it, but it should noticably slow it's fall.

FotoPlasma
22-02-2005, 02:31
*snap*
*crash*

*FotoPlasma walks away, whistling inconspicuously*

jzampier
26-02-2005, 17:38
for an arm I'd avoid PID control. Usually you can get away with just P control and
you will avoid oscillatory problems that like to creep up with PI control.

The way P control works is very simple.
Take the actual postition of the arm (call it y) (from the pot) and subtract it from
the desired position of the arm. (call it r) (from your joystick/whatever).
This is your error signal value. e = r - y

Assuming your pots are calibrated so zero on the arm is in the appropriate location...
(if not add/subtract a fudge factor to y or r as needed)...

Multiple that error value by a constant... (called P
probably between 1 and 2) which is
determined experimentally...
and output that value + 127 to the motor.

output = 127 + ( P * e )

note that depending on directions of movement, e may be negative
and as such P may need to be negative if you are going the wrong direction.

Should work like a charm.
Matt Leese and I had a P controller working with 340's arm last sunday.
(Although I wanted a PD cause i thought it would be faster and more damped)

Man was it cool to push on the arm and watch it go back to where it was before. :D