Reading the BNO055 9 DOF Absolute Orienation IMU Fusion Breakout board

Gramps

Senior Member
Good results. You may need to increase the PAUSE time in the loop so that you have time to see the rotation, roll, and pitch movements reflected in the readings.
Increased pause to 500,
Only Y is to 4 decimal places,
Edit: Do we need 4 decimal places?
 

Buzby

Senior Member
Gramps,

You've lost the +/- signs for Roll and Pitch.

You need my V2 code, with lbenson's scalling mods added and the sertxd line modified, not just copied.
You will need to change symbol addresses for R_sgn and P_sgn, as lbensons' w4 clashes with b8 b9 . )

( Regarding 4dp, no, I don't think you need any dp )

I'm off to bed now !.

Cheers,

Buzby
 
Last edited:

lbenson

Senior Member
Y is correct but P and R are switched
If the orientation of the module is rotated 90 degrees (headingwise), doesn't that make pitch and roll correct? For instance, if heading is nearly 0 (north) instead of 258 (close enough to west).

You don't need 4 decimal places, but that is the resolution which the module supplies (keeping in mind that resolution to 4dp is not necessarily accuracy to 4dp). You get to decide what resolution is suitable to your task.
 

lbenson

Senior Member
With +/- put back in, what maximums and minimums do you get for pitch and roll. That will determine whether you need to account for decimal places.

If you want only degrees for heading, just don't print w4. No need for the IF statement, you can just say
BNO_YAW=BNO_YAW/16
and then just use Buzby's original:

sertxd("Y=",#BNO_YAW,9,9,"P=",#BNO_PITCH,9,9,"R=",#BNO_ROLL,cr,lf)
 

Gramps

Senior Member
Also off to bed for the evening. Tomorrow is the Lord's Day, so will see y'all Monday.
Thanks again for all your help!
 

lbenson

Senior Member
You don't need 4 decimal places, but that is the resolution which the module supplies
Actually, the resolution for the Euler angles for heading is a sixteenth of a degree, which is .0625, but in decimal you only have a resolution of about a tenth of a degree--that is, rounded or truncated, the number space is only filled at .0 through .9 (I'm not sure that's clear, but I'm not certain of the appropriate mathematical terminology).

What resolution you need depends on the capability of your robot arm (or other device to be controlled). To use the full resolution at a tenth of a degree, you would need for your device to be adjustable to 3600 unique positions. Your next problem, after you are confident of the readings you are getting, will be to map those readings to the control values needed for your arm.

As I understand it, based on the wikipedia article, this device uses a form of the Tait–Bryan angles (a subset of the Euler angles), in which the heading is used as the frame of reference for pitch and roll. This takes the point of view of a boat or airplane (tail to nose). A boat in heavy seas heading into the waves will experience pitch; heading parallel to the waves will give you roll; and quartering the waves will give you pitch and roll (and seasickness if you don't have your sea legs). (This is all speculation on my part--awaiting your further experimentation.)
 

Gramps

Senior Member
Cheers,
Buzby
Did not get a chance to tell you how much we appreciated your patience and help with this project!
If you want only degrees for heading, just don't print w4. No need for the IF statement, you can just say
BNO_YAW=BNO_YAW/16
and then just use Buzby's original:
Lance, thank you also for your ongoing help! Absolutely have not had any time to work on this project this week but hopefully down the road we can. Thanks again to everybody on the Forum, Gramps
 

PieM

Senior Member
According to the data sheet, w6 is ROLL (-90 to + 90) and w7 is PITCH (-180 to + 180). The order in the succession of Euler rotations is important.
 

lbenson

Senior Member
According to the data sheet, w6 is ROLL (-90 to + 90) and w7 is PITCH (-180 to + 180). The order in the succession of Euler rotations is important.
Right. Or redefine
Code:
symbol BNO_YAW   = W5
symbol BNO_PITCH = W6
symbol BNO_ROLL  = W7
to
Code:
symbol BNO_YAW   = W5
symbol BNO_ROLL  = W6
symbol BNO_PITCH = W7
 

Gramps

Senior Member
According to the data sheet, w6 is ROLL (-90 to + 90) and w7 is PITCH (-180 to + 180). The order in the succession of Euler rotations is important
Thank you for that tip! Hoping to experiment some more this afternoon or evening.
Right. Or redefine
Thanks Lance appreciate the clarification!
You guys have been so patient this past year as we have struggled to learn this new language.
Building a stationary jig to hold the sensor and then we will make an attempt to map it. Please don't post the code (yet) I've got to learn how to do this myself.
 

Gramps

Senior Member
Great. Now we want to see those numbers change in a rational way.
Data logged thus far:

Yaw 45* to the left =4865.
Yaw Straight ahead =0
Yaw 45* to the right=961

Pitch 45* down =64696
Pitch Straight ahead =0
Pitch 45* up=685

Roll 45* tipped left =.64859
Roll Straight ahead =0
Roll 45* tipped right=545
 

Buzby

Senior Member
And have a look at generating Calibration data
Read the calib_status register, it should read 255 when fully calibrated.

Anything less than 255 means some angles are not correct.
~
My interpretation of the datasheet is, 'just wiggle the gadget evey direction you can', then it will magically calibrate itself.

I cba finding the dataheet again, but all your answers are in there.

Cheers,
( + a little tipple )
Buzby
 

lbenson

Senior Member
In the video in the link PieM gave, the "wiggle the gadget every direction you can" is shown as a twisty figure 8. The video is good--it shows calibration under two different register settings.

Yaw 45* to the left =4865.
Yaw Straight ahead =0
Yaw 45* to the right=961
4865/16=304.0625 -- if actually at 45 degrees counter-clockwise should be 315.
961/16=60.0625 -- should be 45

Try calibration, as suggested, and re-measure. Got a compass which you can use for correlation? Smart phone compass (may also need calibration)?
 

Gramps

Senior Member
Yes have a smartphone compass. Well we waved the sensor around in a figure eight pattern as suggested in the video and tipped it to the right and left but we are still not getting accurate output. Time for bed . Plan to work on it again Monday.
 

Buzby

Senior Member
Hi gramps.

Try this code, it should show you if the calbration is correct.

Cheers,

Buzby
Code:
#picaxe 28X2
#no_table
#no_data

' BNO055 Test - V3
' -----------------

 symbol BNO_YAW   = w5    ' b10, b11
 symbol BNO_ROLL  = w6    ' b12, b13
 symbol BNO_PITCH = w7    ' b14, b15
 
 symbol CalState  = b4
 
 symbol P_sgn     = b8
 symbol R_sgn    = b9

' Code starts here

 sertxd(cr,lf,ppp_filename," Starting ...",cr,lf)
 pause 1000
   
 ' Setup I2C  
 hi2cSetup i2cmaster, $50, i2cslow, i2cbyte
 
 ' Set BNO active
 hi2cOut $3D, ($0C)

do    
   ' Read chip ID      
   hi2cin $00,(b0)   
   
   ' Quit if chip ID wrong
   if b0 <> $A0 then : sertxd( "Bad comms !",cr,lf): reset : endif
   
   ' Read calibration state
   hi2cin $35,(CalState)   
   
   ' Read Euler angles
   hi2cin $1A,(b10,b11)  ' Yaw,        0 to +360  
   hi2cin $1C,(b12,b13)  ' Roll,     -90 to +90
   hi2cin $1E,(b14,b15)  ' Pitch,   -180 to +180
 
   ' Scale Yaw to 360'
   BNO_YAW = BNO_YAW / 16
 
   
   ' Convert pitch to +/- value
   if BNO_PITCH > $8000 then
      P_sgn = "-"
    BNO_PITCH = 0 - BNO_PITCH
   else
    P_sgn = "+"
   endif    
   ' Scale Pitch to 180'
   BNO_PITCH =  BNO_PITCH / 16 ' ?? might need changing


   ' Convert roll to +/- value
   if BNO_ROLL > $8000 then
      R_sgn = "-"
    BNO_ROLL = 0 - BNO_ROLL
   else
    R_sgn = "+"
   endif    
   ' Scale Roll to 90'
   BNO_ROLL =  BNO_ROLL / 16 ' ?? might need changing


   ' Show results
   sertxd("Y=",#BNO_YAW,9,9,"P=",P_sgn,#BNO_PITCH,9,9,"R=",R_sgn,#BNO_ROLL,9,9)
   
   ' Show calibration state
   if CalState = 255 then : sertxd( "Cal OK") : else : sertxd( "Cal poor") : endif
   
   ' New line
   sertxd(cr,lf)
   
   pause 200
   
loop
[\code]
 

Gramps

Senior Member
As we rotate the BNO055 horizontally on the table Yaw goes from 0 to 359 degrees.
Pitch is from + 52 to -58
Roll is +78 to -76
Cal is ok (mostly) sometimes reverting to poor and after 4 lines again reads ok
24018
 

PieM

Senior Member
Question can we put a battery on the 3 volt pin to keep the calibration?
Yes but BNO must be set in suspend mode (hi2cout $3E ,(%10) (supply current 12 mA → 40 µA.)
hi2cout $3E ,(%00) for normal mode

You can save $6A to $55 registers in Picaxe EEprom and restore in config mode (before NDOF setting)
 

lbenson

Senior Member
Congratulations.

We're getting full pitch and roll now. Just was not tipping it to full range.
If as the datasheet say, "Roll: -90° to +90° (increasing with increasing inclination)", what readings do you get as you do a full 360 degree roll?
 

Gramps

Senior Member
Yes but BNO must be set in suspend mode
Thanks for the code.
Easy-er way is to Velcro it to our control sleeve.
To calibrate, pull it off , wave a figure eight, roll left, then right, and stick it back on.😉

what readings do you get as you do a full 360 degree roll?
Roll: 0 to left +1 to +90 (at 90*) then heads back down to +0 at 180 *)
At 180* it flips over to -negative numbers starting at -179 and returning to 0 at 360*
 

Buzby

Senior Member
... Question can we put a battery on the 3 volt pin to keep the calibration? ...
I would suggest this is not worth the effort.

The calibration will drift unpredictably as magnetic fields change, so a periodic 'wiggle' may be needed.

The BNO seems to be doing some kind of continuous calibration, so even a 'wiggle' might not be needed unless it gets really bad.

Keeping an eye on the calib state register to give a warning if it goes 'poor' for too long would seem a better option.

Cheers,

Buzby
 

lbenson

Senior Member
Roll: 0 to left +1 to +90 (at 90*) then heads back down to +0 at 180 *)
At 180* it flips over to -negative numbers starting at -179 and returning to 0 at 360*
I'm not sure I'm understanding this. What readings do you get for the 8 points (rolling to the right through 360 degress): 0,45,90,135,180,225,270,315?
Just trying to translate to something I understand. Thanks for your patience in reporting measurements.
 

Gramps

Senior Member
8 points (rolling to the right through 360 degress): 0,45,90,135,180,225,270,315?
Start flat: 0* =+0
Roll right to 45* =+45
Roll Right to 90* = +89
roll right to 135* = +45
roll right to 180* = --0
roll right to 225* = --45
roll right to 270* = --89
roll right to 315* = --45
 

lbenson

Senior Member
Thanks. Interesting, but certainly confusing. Don't try to fly upside down, I guess.

It looks like you're ready to start trying to do whatever it was you wished to do with this device.
 

Buzby

Senior Member
Hi Gramps,

This thread has gone very quiet, how are you getting on ?.

We all would like to see how your robot arm is progressing.

Cheers,

Buzby
 

Gramps

Senior Member
how are you getting on ?.
Buzby, thank you again for solving the bno00559 DOF!
Life has been pressing in and demanding all my attention for the last month or so.
Currently the arm model is quietly holding an empty coffee cup to the left of my workspace.
The control sleeve is wired and ready to connect to the arm. The remaining task is to get the code to work!
Often in the evening when I'd like to work on it my mind is too numb🙄
We sketched a flow chart and inserted some commands in the correct places. Hopefully we'll be posting something soon.
 
Top