Reading the BNO055 9 DOF Absolute Orienation IMU Fusion Breakout board

Gramps

Senior Member
Buzby said:
Look up the BNO055. ( https://learn.adafruit.com/adafruit-bno055-absolute-orientation-sensor )

It's a 9-DOF gizmo with all the programming taken care of, so you just get three nice clean signals for roll, pitch, and yaw, with velocities as well.
Our new 9 DOF gizmo arrived today!

data sheet address;
https://www.digikey.com/en/datasheets/bosch-sensortec-bst_bno055_ds000_14

After hours of searching on line and struggling to understand the Manual we are no closer to getting " three nice clean signals" then when we started.
We got this far..............
If this sensor is as far beyond my comprehension as I think it is, please say so and we will send it back!!

Code:
Code:
;Reading the BNO055 9 DOF Absolute Orienation IMU Fusion Breakout board
; SCL connects to C.3
;SDA connects to C.4
; default I²C address of the BNO055 device is 0101001b (0x29).
#Picaxe 28X2

HI2cSetup i2cmaster, $50, i2cslow, i2cbyte
Pause 1000

i2cslave %0101000, i2cslow, i2cbyte ; set BNO055 slave address

main: readi2c; read sensor
debug
pause 2000
goto main
 

inglewoodpete

Senior Member
The sensor's i2c address is $29. For a PICAXE master, this needs to be shifted one bit to the left, so becomes $52 in your hi2csetup command.

Get rid of the i2cslave command.

Look closely at the command description for hi2cread hi2cin command: you need to read the remote device's data into PICAXE variables..

Edit: I was on a bus at the time and got the command wrong.
 
Last edited:

Gramps

Senior Member
Thank you for your help!
Ordinary life is demanding my attention at the moment but we hope to get back to this on the weekend.
 

Gramps

Senior Member
Progress thus far. At least getting some numbers but they do not change when we move the sensor.
23954
 

Buzby

Senior Member
I think you are reading the chip ID bytes at addresses 0,1, and 2. See page 53 in the datasheet.

If this is the case, your values should be $0A, $FB, and $32.

If this is what you see then you know you are talking to the chip correctly.

This is a major step !.

Cheers,

Buzby
 

Gramps

Senior Member
your values should be $0A, $FB, and $32.
Nothing like that appearing.............

Found one error.
Changed the resisters on SCL and SDA from 47,000 ohms to 4700 ohms as specified in "Using i2C with picaxe".
 

Buzby

Senior Member
What values are you seeing ?.

If they are all not $FF ( 255 decimal ), then it is highly likely that you are talking to the chip, but not at the right addresses.

The 47K or 4.7K error is unlikely to affect the data, assuming the BNO055 is the only chip on the I2C buss.

Getting these chip ID bytes reading correctly will prove the comms are OK, then we can move onto reading the axis data.

Have you got the COM_3 pin wired correctly ?. See page 91 in datasheet.

Cheers,

Buzby
 
Last edited:

Gramps

Senior Member
Have you got the COM_3 pin wired correctly
Didn't think we needed to connect it as we were working with the default address. The data sheet is not clear (to me) about how to connect it!
Ground it???
 
Last edited:

Buzby

Senior Member
255 on all readings is most likely wrong I2C address, or wiring error.

The COM_3 pin on the chip itself needs pulling High or Low, which will set either address $29 or $28.
If you are using a Sparkfun or Adafruit type of board, then I should expect that this pin is pulled low by default.

Do you have the weblink for the board datasheet, not the BNO055 chip ?
 

Buzby

Senior Member
Now that you have the chip talking, it's time to get some values.

It looks like the first thing to do is write the OPR_MODE register ($3D) to enable the sensors.

It's a bit unclear as to if this step is necessary. The datasheet says the BNO powers-up in CONFIGMODE, but the register table shows a default of $1C, which is NDOF mode with an extra bit set. Writing $0C will clear this extra bit, so maybe that's what it needs to get running.

Then you should be able to read the EUL_xxxx registers to get the angles.

Cheers,

Buzby
 

inglewoodpete

Senior Member
I haven't gone back to the device's data sheet but building on the information that Buzby provided....

Buzby suggests you write $0C to location $3D. The hi2cOut command does.

You should have already defined the address of the slave ($50) in the hi2cSetup command and you established that your PICAXE can communicate with this (slave) chip. You now need to place $0C in memory/register location $3D within that chip.

hi2cOut $3D, ($0C) will do this.

You could also have $0C in a variable and have the contents of that variable sent:
b12 = $0C: hi2cOut $3D, (b12)

You have already used the hi2cIn command to read a location so, as an exercise, read location $3D back into a different register and display it.
 

inglewoodpete

Senior Member
I'd never heard of this chip until you started this thread, so I'm not going to be able to help much beyond this point.

I've had a look at the data sheet and, brother, it's one sophisticated chip! Hopefully Buzby is a full bottle on this device.

An accelerometer chip usually has 3 axes. This one seems to have 3 x 14-bit values AXIS X, Y and Z. 14 bit values means that you will have to read two bytes into adjacent byte registers for each axis to create word values in the corresponding word registers. Eg w11 is made up of b22 and b23 as shown below
I'd define them this way:
Rich (BB code):
Symbol wAXIS_X    = w11    'b22/23
Symbol bAXIS_X.Lo = b22    'w11
Symbol bAXIS_X.Hi = b23    'w11
 

Buzby

Senior Member
So now we must get the accelerometer to tell us what information it has in $FB. Correct?
Not sure why you are looking for address $FB. The $FB is the contents of location $01, which is the ID number of the accelerometer sub-system.

What you need are the contents of $1A to $1F, which are the 3 sets of angles for roll, pitch, and yaw. See the datasheet, page 53.
 

Gramps

Senior Member
Well what do you know. They appeared like magic!
The descriptions are pitch roll and heading. I was searching for x y z axis and completely overlooked them.
Is the next step to read these locations using hi2cin? It appears they go together in pairs.
 

inglewoodpete

Senior Member
Well what do you know. They appeared like magic!
The descriptions are pitch roll and heading. I was searching for x y z axis and completely overlooked them.
Is the next step to read these locations using hi2cin? It appears they go together in pairs.
Sorry, I thought you were looking at the accelerometer feature of the chip.

and yes, you need use hi2cin to load the values into word registers but using byte registers as I described in post 23.
 

Buzby

Senior Member
So now we must get the accelerometer ... ?
Hi Gramps,

You can, if you wish, read the accel, gyro, and magnet sensors individually, but I'd only do that if I was interested in checking how the chip works.

The roll, pitch, and heading ( yaw ) values are really what you need. The are created by the processor in the chip from the values provided by the 3 sets of sensors. The processor takes all these signals and runs them through a 'Fusion' algorithm, which takes care of the 3D calculations and seperates gravity acceleration from movement acceleration, and a whole lot more.

I'd start by reading just one of the values, probably heading. When you have that reading changing, and understand it's relationship to the orientation of the chip, then you can move on to reading the other two.


Jumping ahead a little, have you decided how the signals from the BNO will map onto the servos of your robot ?.

Cheers,

Buzby
 

Gramps

Senior Member
Jumping ahead a little, have you decided how the signals from the BNO will map onto the servos of your robot ?.
The 4 servos and 3 motor drivers are connected through the picaxe to pots mounted on the "user control sleeve,"
We thought we could mount the BNO sensor to the shoulder area of the sleeve and substitute the BNO outputs for the 3 pots that detect the movements of the shoulder, up and down, left and right, and shoulder rotate.
 
Last edited:

Gramps

Senior Member
I'd start by reading just one of the values, probably heading
OK,
Heading values are 1B and 1A

What is next?:unsure:
hi2cread 1B,1A (W5)?
That does't work.
hi2cin, 1B,1A (W5)?
Nope
Is there an example in the manual how to do this?
 
Last edited:

lbenson

Senior Member
If in post 21, this worked: hi2cin $3D,(b7) ;read location $3D back into a different register

Why wouldn't this work to read from $1A & $1B into b10 & b11 (the components of w5)?

hi2cin $1A,(b10,b11)

(Note: I'm not sure whether the values to be read are big-endian or little-endian, so perhaps what is needed is hi2cin $1A,(b11,b10) )

Try each case followed by a SERTXD(#w5,cr,lf)

(Further note: when you say something doesn't work, please show exactly what you did, and report exactly what didn't work about it--e.g., failed syntax, gave unexpected results, etc.)
 

Gramps

Senior Member
When rotating the sensor 360 * clockwise the B10 values go from 0 to 22.

When B11 is tipped forward and backwards, the values run from 0 to 255.
 

inglewoodpete

Senior Member
As I implied in posts 23 and 29, the i2c protocol transports data in bytes and must be sent from- and received into-byte registers.

When delving deeply into the capability of PICAXEs, it pays to read and understand the commands listed in manual 2. It makes great bedtime reading :).
 

Gramps

Senior Member
Strange, now b10 and b11 stopped responding.
This is the code thus far......
Code:
#Picaxe 28X2
#NO_table
#no_data

    HI2cSetup i2cmaster, $50, i2cslow, i2cbyte; set PICAXE as master and BNO055 slave address
Pause 1000    
main:    hi2cin 0,(b0,b1,b2,b3,b4,b5,b6)    ; read data and debug display    
     
    hi2cin $3D,(b7);read location $3D back into a different register
    debug b1
    
    hi2cin $1B,(b10,b11)  ;heading ( yaw )
    ;hi2cin $1E,(b12,b13) ;pitch 1F
    ;hi2cin $1D,(b14,b15) ;roll 1C
    SERTXD(#w5,cr,lf)
    goto main
 

Buzby

Senior Member
Hi Gramps,

The reason b10/11 stopped changing is probably because you deleted the write $0C to register $3D.

Please don't just say 'it stopped working'. Show us the code !.

Below I've written some code which should read the Euler angles. Please copy to a file and run it exactly as written.

If it works you should see the three values changing as you move the BNO.

If it does not work, please send a screen shot of the terminal output.

Cheers,

Buzby

Code:
#picaxe 28X2
#no_table
#no_data

symbol BNO_YAW   = W5
symbol BNO_PITCH = W6
symbol BNO_ROLL  = W7

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 0,(b0)  
  
   ' Quit if chip ID wrong
   if b0 <> $A0 then : sertxd( "Bad comms !",cr,lf): reset : endif
  
   ' Read Euler angles
   hi2cin $1A,(b10,b11) 
   hi2cin $1C,(b12,b13)  
   hi2cin $1E,(b14,b15)  

   sertxd("Y=",#BNO_YAW,9,9,"P=",#BNO_PITCH,9,9,"R=",#BNO_ROLL,cr,lf)
  
   pause 200
  
loop
 
Last edited:

lbenson

Senior Member
As Buzby's code implies, and other posts have implied/stated, heading, pitch, and roll are WORD values which may be greater than 255, so you can't just look at byte values that you have received (even though you must retrieve multiple byte values to make up the words, because that is how hi2cin works (and it works that way because that is how I2C works)).

If you place the module flat on a table and rotate it a bit clockwise every few seconds until you have gone a full 360 degrees, the following code should give you an idea of what the heading readings mean (include the necessary initialization code):
Code:
do
  hi2cin $1A,(b10,b11)
  if w5 <> w6 then ' if there's a change
    w6=w5
    sertxd(#w5," ")
  endif
loop
You should be able to find the zero point. Is it north? (I don't know the answer to that question.)
 
Top