HM55B compass output to LCD
benty
Posts: 20
Hey all, I've been trying to figure out how to get the output from the HM55 compass to just dump out an angle to an lcd but I'm not really sure how.
The HM55B_DEMO_object_V1.1 code works fine and I get the output to the tv no problem, but the question is how do I take theta(from the demo code below) and
get a useful output from it?
theta := HM55B.theta
gr.arc(0, 0, 50, 50, -theta+2048, 0, 1, 0) 'Draw needle
gr.arc(0, 0, 50, 50, -theta+6144, 0, 1, 1)
gr.arc(0, 0, 5, 5, -theta, 0, 1, 0) ' Draw needle cross
gr.arc(0, 0, 5, 5, -theta+4096, 0, 1, 1)
gr.arc(0, 0, 40, 40, -theta+2048-150, 0, 1, 0) ' Draw needle arrow
gr.arc(0, 0, 50, 50, -theta+2048, 0, 1, 1)
gr.arc(0, 0, 40, 40, -theta+2048+150, 0, 1, 1)
gr.copy(display_base) 'copy bitmap to display
Looking at the BS2 code they perform the following, but I have yet to find an arctan function for the propeller(if it exists?) or am I way off track?
angle = x ATN - y ' Convert x and y to brads
Thanks for any info!
benty
The HM55B_DEMO_object_V1.1 code works fine and I get the output to the tv no problem, but the question is how do I take theta(from the demo code below) and
get a useful output from it?
theta := HM55B.theta
gr.arc(0, 0, 50, 50, -theta+2048, 0, 1, 0) 'Draw needle
gr.arc(0, 0, 50, 50, -theta+6144, 0, 1, 1)
gr.arc(0, 0, 5, 5, -theta, 0, 1, 0) ' Draw needle cross
gr.arc(0, 0, 5, 5, -theta+4096, 0, 1, 1)
gr.arc(0, 0, 40, 40, -theta+2048-150, 0, 1, 0) ' Draw needle arrow
gr.arc(0, 0, 50, 50, -theta+2048, 0, 1, 1)
gr.arc(0, 0, 40, 40, -theta+2048+150, 0, 1, 1)
gr.copy(display_base) 'copy bitmap to display
Looking at the BS2 code they perform the following, but I have yet to find an arctan function for the propeller(if it exists?) or am I way off track?
angle = x ATN - y ' Convert x and y to brads
Thanks for any info!
benty
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Digital Technology Group
I'm a little confused as to how much more useful information you want from 'theta'.
The code-snip that you posted simply draws the compass needle for the DEMO·application.
The returned value for 'theta' from the HM55B is a 13-bit·integer that represents the angle. (0..$1FFF = 0°..359.956°)
To convert this number into a more "human readable" value ranging from 0 to 360 (<-- perhaps what you mean by more useful), you can do something like this...
Deg = (theta * 360) / 8192
...OR you can simplify it into something like this...
Deg = (theta * 45) / 1024
If you want the RAW x and y values, then you can use something like this in your code...
RAWx := HM55B.HM55B_x
RAWy := HM55B.HM55B_y
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
And now I know where the trig functions are too so killed two birds with one stone, thanks guys!
Good, I'm glad that I was able to help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.