View Single Post
  #9   Spotlight this post!  
Unread 09-04-2006, 18:04
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Camera without servos

Quote:
Originally Posted by kiettyyyy
Okay, I have something mocked up now.. How does this look??

if (swt_camera)
{
// If the image is not center, check with the allowable error range
if (pan_error > PAN_ALLOWABLE_ERROR_DEFAULT)
{
// Attempt to turn left
pwm_rightDrive_cim = pwm_rightDrive_cim = 200;
pwm_leftDrive_cim = pwm_leftDrive_fp = 120;
}
else if(pan_error < -1 * PAN_ALLOWABLE_ERROR_DEFAULT)
{
// Attempt to turn right
pwm_rightDrive_cim = pwm_rightDrive_cim = 120;
pwm_leftDrive_cim = pwm_leftDrive_fp = 200;
}
else
{
// Set drive motors to neutral
pwm_rightDrive_cim = pwm_rightDrive_cim = 127;
pwm_leftDrive_cim = pwm_leftDrive_fp = 127;

// Tell the controller that it is now on target
Tracking_State += STATE_PAN_ON_TARGET;
}
}


Should this work?
It's going to be a bumpy ride. Chances are your robot isn't going to stop dead right on target, it will glide, spin back quickly, glide...overshooting back and forth. A basic P loop would help, but that would always introduce a steady state error.

P = error * gain;

Error is the pan_error, gain is the factor at which the motor responds, the higher, the more the motor responds. The problem is as you get close, the error decreases, meaning motor output decreases. Eventually the power level will get low enough that you stop moving. This is called "Steady state error" you can only get so close before the power output is insufficient to move. You can turn up the gain, but that will very likely make it oscillate again. You should look in to PID control, or even PI, if you search around here and on google I'll bet you can find some nice references. Also, if by experimenting you determine you need a minimum PWM value of Z to keep moving, you can do a check that if the error is past the deadband and the PWM is below Z, set it to Z, that's a crude PI, with a fixed I output. That should work but it won't be as precise as PI. Does this reply make any sense?
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)