Compass Interface

John Todd

New member
I am an oldie just trying to resurrect my knowledge
I have CMP14 Compass module with serial function @9600bps
I will be using 08M2 Chip @ 3.3V
Compass requires the command of 0x13 to be sent to the Compass @9600bps
I would need to put this in a timed loop to get compass bearing data regularly
Could you please give me an insight into the syntax I would need
Any help appreciated
Thanks,
John
 

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

I suspect the actual module you have is the CMPS14 which uses a BNO080 chip as that fits your description. I found a datasheet here -

https://robot-electronics.co.uk/files/cmps14.pdf

From that I would guess the approach for using serial on an 08M2 would be -
Code:
#Picaxe 08M2
#Terminal 4800

Symbol TX_PIN    = C.?
Symbol RX_PIN    = C.?

Symbol direction = w1 ; b3:b2
Symbol dir.lsb   = b2
Symbol dir.msb   = b3 

Do
  High TX_PIN
  SetFreq M32
  Pause 100
  SerOut TX_PIN, T9600_32, ( $13 )
  SerIn RX_PIN, T9600_32, dir.msb, dir.lsb
  SetFreq MDEFAULT
  Pause 100
  SerTxd( "Direction=", #direction, CR, LF )
  Pause 1000
Loop
How well that works would depend on how quickly the CMPS14 responds to a command and what sort of gaps are between the bytes returned which it sends back.

If the above does not work reliably it may be better to use HSERIN for receiving data, and may be easier all round if one simply configured the CMPS14 to use I2C.
 
Top