View Single Post
  #9   Spotlight this post!  
Unread 22-01-2008, 17:06
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: PID without the D

Quote:
Originally Posted by Joohoo View Post
so I looked around a bit for this and I can't seem to find a way to do this on the multiple white papers that are posted. So my question is, how do I use the proportional and Integral parts of the theory with out the derivative part of it.

I know how to do them individually but have no idea on how to combine ay of these aspects to do anything meaningful.

Thanks in advance for any help that can be provided
Actually PI control loops are fairly common. If you have a situation where proportional control alone works well, it's common to add an integral term with a low gain to remove the fixed error inherent with proportional control. Here is example integer PI code from the camera tracking code:

Code:
//
// 
// x-axis/pan tracking code
//
//
 
// save the current pan servo PWM value into a local
// integer variable so that we can detect and correct 
// underflow and overflow conditions before we update 
// the pan servo PWM value with a new value
temp_pan_servo = (int)pan_servo_position;
 
// calculate how many image pixels we're away from the
// vertical center line.
pan_error = (int)T_Packet_Data.mx - (int)Tracking_Config_Data.Pan_Target_Pixel;
 
// Are we too far to the left or right of the vertical 
// center line? If so, calculate how far we should step
// the pan servo to reduce the error.
if(pan_error > (int)Tracking_Config_Data.Pan_Allowable_Error)
{
// calculate how far we need to step the pan servo
servo_step = pan_error / (int)Tracking_Config_Data.Pan_Gain;
 
// Due to rounding error in the division calculation above,
// the step may be calculated as zero, which will make it
// impossible to converge on the target when pan_error is
// smaller than Pan_Gain. To get around this problem, we just 
// test for the zero case and set the step size to one. 
 if(servo_step == 0)
{
    servo_step = 1;
}
}
elseif(pan_error <-1* (int)Tracking_Config_Data.Pan_Allowable_Error)
{
// calculate how far we need to step the pan servo
servo_step = pan_error / (int)Tracking_Config_Data.Pan_Gain;
 
// Due to rounding error in the division calculation above,
// the step may be calculated as zero, which will make it
// impossible to converge on the target when pan_error is
// smaller than Pan_Gain. To get around this problem, we just 
// test for the zero case and set the step size to one. 
 if(servo_step == 0)
{
    servo_step = -1;
}
}
else
{
// if we've fallen through to here, it means that we're
// neither too far to the left or too far to the right
// of the vertical center line of the image and don't 
// need to move the servo
servo_step =0;
 
// signal that the pan servo is on target
Tracking_State += STATE_PAN_ON_TARGET;
}
 
// add the step to the current servo position, taking into
// account the direction set by the user in tracking.h
temp_pan_servo += ((int)Tracking_Config_Data.Pan_Rotation_Sign * servo_step);
 
// check the pan servo PWM value for under/overflow
if(temp_pan_servo < (int)Tracking_Config_Data.Pan_Min_PWM)
{
 temp_pan_servo = (int)Tracking_Config_Data.Pan_Min_PWM;
}
elseif(temp_pan_servo > (int)Tracking_Config_Data.Pan_Max_PWM)
{
 temp_pan_servo = (int)Tracking_Config_Data.Pan_Max_PWM;
}
 
pan_servo_position = (unsigned char)temp_pan_servo;
 
// update pan servo PWM value
Set_Pan_Servo_Position(pan_servo_position);
-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org