
27-05-2011, 16:42
|
 |
systems engineer (retired)
no team
|
|
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
|
|
|
Re: PID crossing 0
Quote:
Originally Posted by Strants
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)
|