Mindsensors Compass help- First I2C

John Gracey

New Member
Hi,
Im just starting microconrollers and am trying to build a robot. I am having a little trouble with my i2c devices though. I am trying to use a compass that I got at mindsensors.com but cannot get it working. I have read the datasheets, but they have not helped, and there is no sample code to go along withit. The website and datasheet is here:
http://www.mindsensors.com/index.php?module=pagemaster&PAGE_user_op=view_page&PAGE_id=52
Perferably I would like a 8bit reading fro m the 360 degree compass as its an easy start.

Also another side problem is a RTC that I wired on the I2C bus, but the response is in bcd format, skipping 11-16, counting 1,2,3,4,5,6,7,8,9,10,16,17,18... I would simply like the rtc to count regularly one by one by one. The rtc is a phillips pcf8563 and im using a 32.768khz radial crystal with it.
Can anyone help me solve these two i2c problems? :confused:
Thanks a Bunch for any Help
 
Last edited:

hippy

Ex-Staff (retired)
I cannot really help with your I2C issues but I doubt you are going to get the compass to give what you'd like or the RTC chip to count in any way other than it does ( I haven't looked at the datasheets though ).

What you need to do is take the data you have recieved and convert that to the number format or style you need.

Untested, but your should be able to convert an 0-255 angle to 0-360 degrees using ...

- angle = 180 * compassReading / 128

and convert the bcd reading using ...

- decimal = bcd \ 16 * 10 : decimal = bcd & $0F + decimal
 
Top