View Single Post
  #13   Spotlight this post!  
Unread 31-01-2006, 09:32
Mike Shaul's Avatar
Mike Shaul Mike Shaul is offline
Registered User
FRC #0065 (Huskie Brigade)
Team Role: Engineer
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Farmington Hills, MI
Posts: 53
Mike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant futureMike Shaul has a brilliant future
Re: Manual Velocity PID, anyone successful?

Here is some basic P control code, let me know if anyone catches an error!

Code:
#define GAIN       10    //This will need to be tuned

u8 p_control(u16 desired, u16 actual)
{
    s16 error, control;

    error = desired - actual;
    control = error * GAIN;
    if( control > 504 )
		control = 504;
    else if( control < -504 )
   		control = -504;
    
    control /= 4;   /* Convert to 8-bits */

    return (u8)(control +127);   /* PWM Output */
}
__________________
By far the best proof is experience. - Sir Francis Bacon