Shop OBEX P1 Docs P2 Docs Learn Events
Head SPINning trying to SPIN heading ! — Parallax Forums

Head SPINning trying to SPIN heading !

NR1XNR1X Posts: 111
edited 2012-02-27 09:39 in General Discussion
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

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-27 09:08
    NR1X wrote: »
    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).
  • NR1XNR1X Posts: 111
    edited 2012-02-27 09:39
    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.
Sign In or Register to comment.