Thread: PID crossing 0
View Single Post
  #25   Spotlight this post!  
Unread 27-05-2011, 16:42
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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: PID crossing 0

Quote:
Originally Posted by Strants View Post
Let U be the raw angle given by the encoder, and Q be that same angle put in the range [0, 2pi].

If sin(U) >= 0, then Q = acos(cos(U))
Otherwise, Q = 2pi - acos(cos(U))
Yikes! use this:

U = U - 2pi*floor(U/2pi)



Reply With Quote