View Single Post
  #6   Spotlight this post!  
Unread 31-01-2013, 18:12
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,062
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Gyro PID Programming

Quote:
Originally Posted by Ether View Post
You don't want the (corrected) gyro angle in the range -360 to +360 ... you want the corrected gyro angle in the range -180 to +180, with zero being your starting position.
This should do the trick:

Code:
double corrected_angle(double Angle){
return Angle + 360*floor(0.5-Angle/360);
}
Then use setpoint=0 and process_variable = corrected_angle as inputs to a PID controller.


Reply With Quote