BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Sat Oct 20, 2018 7:53 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: HM55B compass for Atom Pro and FATAN2 function
PostPosted: Fri Feb 16, 2007 7:00 am 
Hello,

This is my sample for HM55B compass, but I dont understand why
"fatan2 tofloat x ofloat y, fangle" fangle = 0 when y = 0
I need workaround with "fatan2 tofloat x ofloat y + 0.1, fangle" to get correct compass bearing.

--------------------------------------------------------------------

pdata con p0
pclock con p1
penable con p2

reset con %0000
measure con %1000
report con %1100

status var nib
ready con %1100

x var sword
y var sword
fangle var float
angle var word

debut

high penable
low penable

shiftout pdata, pclock, msbfirst, [reset4]

high penable
low penable

shiftout pdata, pclock, msbfirst, [measure4]

status = 0
repeat
high penable
low penable
shiftout pdata, pclock, msbfirst, [report4]
shiftin pdata, pclock, msbpost, [status4]
until status = ready

shiftin pdata, pclock, msbpost, [x11, y11]

high penable

if(x.bit10 = 1) then
x = x - %11111111111
endif
if(y.bit10 = 1) then
y = y - %11111111111
endif

fatan2 tofloat x ofloat y + 0.1, fangle
angle = toint((fangle / 3.1416) * 180.0) + 179

serout s_out, i38400, ["X = ", sdec x, " Y = ", sdec y, " Angle = ", dec angle, 13]
pause 200

goto debut

--------------------------------------------------------------------


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO