View Single Post
  #2   Spotlight this post!  
Unread 17-02-2007, 02:47
Ben Englert Ben Englert is offline
Registered User
FRC #1072
 
Join Date: Jan 2006
Location: San Jose CA
Posts: 40
Ben Englert has a spectacular aura aboutBen Englert has a spectacular aura aboutBen Englert has a spectacular aura about
Re: Holding a position in our arm

You can't move the arm at a single hardcoded speed and then suddenly reverse it when you pass your target - you will overshoot, as I'm sure you've noticed. While full-fledged PID (PD, anyway) control would be best here, I understand you're short on time so you can implement a rudimentary version of P control like this:

You will need a PWM-limiting function that takes an integer and bounds it between 0 and 254, because otherwise the unsigned char that representes a PWM setting will roll over and you will find your motors moving backwards.

targetVal = 180;
float pGain = 0.5;
int sensor = Get_Analog_Value(foo);
pwm02 = pwm_Limit((pGain*(targetVal-sensor))+127);

And then, just tweak the pGain up or down in small increments until your arm movement is acceptable.

Again, PID feedback is great, so if you have the time to do it properly I definitely would, but you can get away with this in a pinch.
__________________
Before a match at SVR, 3/17/06
Tatsu: "Yo Englert, what's our autonomous mode?"
Me: "We'll find out, won't we."
Both: *maniacal laughter*
After the match's autonomous period ends:
Me: "Well, the basic control system still responds. That's always good."
Both: *further laughter*