News:

Let's find out together what makes a PIC Tick!

Main Menu

BNO055 9 axis orientation sensor Bosch

Started by chris_cb_uk, Dec 22, 2021, 10:00 AM

Previous topic - Next topic

top204

#20
Remember, the value often given for a slave address is not actually what the device uses. Demo or sample programs often have a habit of giving a slave value before it is shifted left by one, and that is not what the actual device uses, because it uses the top most 7-bits only, and bit-0 is for Read or Write. A lot of library functions for C and C++ shift the address left when sent as a parameter value, but the compiler's commands do not, and what is passed is what the device sees.

Try the address: %10100000

Which is given in the datasheet on page 54 as "Chip-ID" for some strange reason!

chris_cb_uk

#21
Thanks Les, I've tried your suggestion with the below code.  And also included a screen shot of the signals.
 Picture of scope (cannot seem to link it to a image) https://photos.app.goo.gl/XoUDRJdq7eQ38zLR6
Device = 18F4550
Declare Xtal = 16   
Declare LCD_DTPin = PORTB.4
Declare LCD_RSPin = PORTB.2
Declare LCD_ENPin = PORTB.3
Declare LCD_Type 0
Declare LCD_Interface 4
Declare LCD_Lines 2
All_Digital = true
Declare SDA_Pin PORTB.0
Declare SCL_Pin PORTB.1
Declare Slow_Bus On

Dim value1          As      Byte
Dim regi            As      Byte

Main:
Clear : DelayMS 200                                     
regi=0
start:

DelayMS 300
Cls
bs1:
BStart
    BusOut %10100000
    BusOut %00000001
    DelayUS 50
BReStart
    BusOut %10100001
    BusIn value1
BStop

Print At 1,1,"V ", Hex2 value1

GoTo start


trastikata

Chris, can you post some of the values you get for the known IDs with the different code. Preferably post several values in the order you receive them, often helps to see the pattern in it and helps analyzing the source of the error.

chris_cb_uk

Well that's the thing, working on the bit bashing method I'm not getting anything now! I fear that using the i2c commands was causing some communication mid way which was being interpreted by the pic as sequential but random nonsense. I've ordered a different kind of board from roboelectronics which appears to have a bit of a pre processor built in which seems to standardise the i2c commands. Will see if it plays happier.
I contacted the service department of where I purchased the adafruit board which seems pretty u responsive, and they assure me the unit works perfect (without testing it) and I should use it with an alduino and use the library..
Obviously a pic is too challenging for them to understand!

JonW

Chris look in the include folder

Les Quote""
The compiler installs quite a few libraries that I have created over the years, and are held in the "Includes" directory: "C:\Users\Computer Name\PDS\Includes\"

There are bitbash I2C routines that can be easily manipulated

Jon

JonW

Chris did you look at the Arduino code?  Even though its in C its quite easy to follow and may have show something you are missing.  I know in the past I have seen this issue with Spi where an extra clk pulse was needed on some IC.  I found it by examining the Arduino libraries

J

top204

What is termed as I2C is not always true I2C.

I came across this last year when I created a library for a water flow sensor for someone. The datasheet stated it was I2C, but its protocols did not follow the protocols of true I2C and it had twists.

Take a look at the datasheet and see where and when the address' are sent and the data read and the Acks, and Nacks etc... Then use the individual Bus commands to re-create what it is looking for. It will still use, Start, Stop, ReStart, Ack, Nack etc, but, probably, in a slightly different sequence.

chris_cb_uk

Quote from: top204 on Dec 27, 2021, 07:40 PMWhat is termed as I2C is not always true I2C.

This is very frustrating since according to the datasheet it meets the requirements of I2C protocol!
On page 1 of this thread I started stripping back and using the busack and restart function to try replicate the signal per datasheet. I'll have another look next week when I'm back in front of the computer properly!

Stephen Moss

Quote from: chris_cb_uk on Dec 23, 2021, 03:42 PMBStart
    BusOut %10100000
    BusOut %00000001
    DelayUS 50
BReStart
    BusOut %10100001
    BusIn value1
BStop

What is the purpopuse of the DelayUs 50?
If it is to allow for somehting like an ACK instead of sending/checking reciept of an ACK that may be causing problems. I was using timing with a DualShock controller (SPI) instead of checking for a pulse (PIC not fast enough to time it) and while the A varient was fine with it the H varient did not want to know. I think the problam was that the H varient was a little stricter with the timing and my delay was causing a timing issue, so maybe that delay is having a similar effect.

Damn, it just occured to me the delay instruction is probalby longer than the time specified by the command as there is bound to be a few set up instructions used before the delay loop begins that perhapse I should have accounted for. So, if you really need the delay then perhapse try reducing it 1 or 2 microseconds to see if that makes a differnce or if the device supports DelayCs try specifying the delays in instruction cycles for a finer adjustment between 48uS and 50uS, then @ 16MHz I think you will get about a 0.25uS adjustment when using DelayCs.

chris_cb_uk

Oh this was for test purposes to see the commands on a scope only and to easily see the break between the sets of commands to Cound the bits.

chris_cb_uk

Quote from: JONW on Dec 27, 2021, 02:21 PMChris did you look at the Arduino code?  Even though its in C its quite easy to follow and may have show something you are missing
It appears Arduino and Raspberry Pi favours serial to communicate with the board.   

tumbleweed

The BNO055 requires the I2C master to support clock stretching, and I don't think the various Busin/Busout, etc commands used in post #21 do this

top204

The software Bus commands do have a rudimentary clock stretching mechanism, but it is not designed for longer time stretches, so that they do not slow down a program's flow, so it will be better to use the included I2C library procedures in the "Software_I2C.inc" file. They are written in Positron BASIC so they can be altered to suit, and their code comments and header texts show exactly what they are and how to use them.

The library file is in the folder: "C:\Users\User ID\PDS\Includes\"