PDA

View Full Version : Head SPINning trying to SPIN heading !



NR1X
02-27-2012, 03:51 PM
HI All, Longtime lurker here but still an infant in the world of propellers.
What Im attemting to do seems fairly simple, but it involes math, and thats where I hit the wall...Here's the scene... I have 8bit adc value (read from antenna rotor indicator signal) from 0-255, and I need to see that data as 0-360( as in degrees). That part doesnt seem to be too complicated, but here is where it gets a little more complex. 0 deg is actually center on the incoming signal, so adc-0 := 181deg. and adc-255 := 179deg with adc-127 := 0 (or 360) deg.
I know this is silly simple to do, I just dont know where to start.
NR1X, Al, CT

Duane Degn
02-27-2012, 04:08 PM
HI All, Longtime lurker here but still an infant in the world of propellers.
What Im attemting to do seems fairly simple, but it involes math, and thats where I hit the wall...Here's the scene... I have 8bit adc value (read from antenna rotor indicator signal) from 0-255, and I need to see that data as 0-360( as in degrees). That part doesnt seem to be too complicated, but here is where it gets a little more complex. 0 deg is actually center on the incoming signal, so adc-0 := 181deg. and adc-255 := 179deg with adc-127 := 0 (or 360) deg.
I know this is silly simple to do, I just dont know where to start.
NR1X, Al, CT

Make "heading" a long sized variable to be safe from overflowing the byte size limit.

Here's my guess at the equation.


heading := (((adc * 360) / 256) + 180) // 360


I haven't tested it (but I'm pretty sure it should work).

NR1X
02-27-2012, 04:39 PM
Yep.. I figured it was something simple to do. Thanks for your help... Now I have a number to work with. Plugged in a new VAR and it took right off. What a great rescource this forum is.