Sure compass module

John O

Senior Member
Hi All,

I've been following this old thread but it seemed to end without coming to any conclusion.

I've managed to communicate with one of these modules but I can't get much sense out of the returned values. Although the low byte of each axis varies between 0 and 255 (twice in a revolution), the high byte only seems to be either 7 or 8.

It's supposed to be 12 bit resolution but it seems the low 4 bits of the high byte are always either 0111 or 1000, which is really only a 9-bit resolution (ie 2 * 255) or am I missing something?



http://www.sure-electronics.net/download/DC-SS503_Ver1.0_EN.pdf


John.
 

John O

Senior Member
I'll be interested if you can get the uart working. I don't think it mentions any signal polarities but it shows it connected to a PC. I tied the "option pin" to 5v to set it to uart operation but couldn't get a peep out of it with a termianl program.

John.
 

Andrew Cowan

Senior Member
My module arrived today.

The board has the compass module fitted, then a space where another chip can go. This other chip is a PIC - it is fitted on the serial version of the board.

The pins 'Option, RXD and TXD' are only used if the PIC is fitted - the modules we have are I2C only. Now I just need to work out how to convert an absolute X reading and a Y reading into a bearing - it's going to be pretty hard, I think! I'd imagine you start by working out the relative value (the range), then getting out the triganometry... Fun!

The 7 or 8 you are getting for b1 is fine - these modules give a certain output per gauss (rather than 0-255 as rotated) - you need to make a PICAXE program to calibrate and scale your output.

Andrew
 
Last edited:

sghioto

Senior Member
John,

If it's 12bit don't you need to set I2c address to:

i2c slave %01100000, i2cslow, i2cword

Steve G.
 

John O

Senior Member
Erm...
(image of 1-chip module)
:confused::confused:
I've oredered so much stuff recently that I'm not even sure what the postman's going to bring... but, if I remember, this module didn't have a "Buy Now" option so I visited the online shop. It may well be that I ordered the 2-chip module. I looked through their stock last night and both kinds are available.

In the light of what you've siad, I'll have another play with the uart - that seems much easier to interrogate and is supposed to reply with a direct 0 - 360 degree reading.

Edit: Thinking about it, it might well be that some boards have a non-functional second chip so they're still sold as an I2C only board.

John.
 
Last edited:

John O

Senior Member
John,

If it's 12bit don't you need to set I2c address to:

i2c slave %01100000, i2cslow, i2cword

Steve G.
IF I'm reading the datasheet correctly, writing a '1' to address 0 will result in 5 x 8-bit bytes being returned as follows:

contents of the internal register
x-axis MSB
x-axis LSB
y-axis MSB
y-axis LSB

As I don't think I need to know what's in the internal register, I've started reading from address 1.

I've just tried 'i2cslave %01100000, i2cslow, i2cword' and changing the read to w0 and w1 but nothing gets returned.

With regard to the axes' MSB, the datasheet says: Even though each axis consists of two bytes, which are 16-bits of data, the actual resolution is limited to 12 bits. Unused MSB should be simply filled by "0"s

What I had expected was for bits 0, 1, 2 and 3 of the MSB to actively count up from 0 to 8 but bits 0, 1 and 2 all change together as bit 4 toggles betwen 1 and 0 (ie 8 and 7).

As Andrew says, there's going to be some sort of mathematical relationship between the x and y axis readings (probably involving sines or something!) but I doubt my maths is up to the task even if the 18M2 is! :)

using the uart would have been a much simpler option -- if I could get it to work - even with two chips on my board!

http://www.sure-electronics.net/download/DC-SS503_Ver1.0_EN.pdf

John.
 

Andrew Cowan

Senior Member
OK - it tuns out I have the DC-SS503 (I2C only), while John has the DC-SS504 with the UART. I've ordered myself a PIC16F690 as the hex code for the DC-SS504 is on sure's website - I'll solder it up, program it, and let you know how I get on!

Andrew
 

John O

Senior Member
You're a lot more adventurous than me :)

Mine does say SS503 on it so it may be that the part number is printed on after they've tested them?

John.
 
Last edited:

John O

Senior Member
The I2CWORD relates to the addressing size, not the data size, so would likely be I2CBYTE.
Ah thanks, that would explain why it didn't work :). I'm also trying to remember to use the 'hi2csetup i2cmaster' and 'hi2cin' format so as not to get into the habit of using deprecated commands.

John.
 

Andrew Cowan

Senior Member
I guess they only have one type of PCB made (cheaper that way), then either solder on the PIC and sell it as a DC-SS504, or miss out the PIC and sell it as a DC-SS503.

Andrew
 
Last edited:

Andrew Cowan

Senior Member
Right!

My PIC16F690 (microchip sample) has arrived - I've soldered on the PIC, the two missing resisitors and the two missing capacitors. I connected it to my PIC programmer, and downloaded the hex file from sure's website. Now hopefully, I've converted my $5 DC-SS503 into a $15 DC-SS504. Lets see if it works!

A
 

John O

Senior Member
Ah, good luck. I'll be interested in how you get on.

Mine's back on the 'pending' shelf at the moment while I work out the best way to use the magentic rotary encoder.

John.
 

Andrew Cowan

Senior Member
It works!

For some reason, my Axe027 (reprogrammed to not invert tx and rx) wouldn't work. Sending '$sure su' should return 'unknown command' - instead it was returning 'bad command' for everything. In other words, it wasn't successfully receiving and decoding the $sure part. Any idea why, hippy?

Switching to a different USB-serial adaptor (a CP2102 based model) solved the problem - it now outputs a 0-359 degree serial signal. Fantastic, for £5!

And I soldered the SSOP 208mil package without any problems - very satisfying!
 

Attachments

Last edited:

BillyGreen1973

Senior Member
Andrew, am I right in thinking the compas module is linked direct to your PC and not via a Picaxe?

If so, what strings have you sent to the module from your terminal program?

Thanks
 

Andrew Cowan

Senior Member
You can see the terminal window in the top corner of my attachement (post 17).

$sure ga
returns the angle of the sensor, $sure cl to calibrate, and $sure sv=-2 to set my magnetic declination.

Note the module uses true polarity TTL data (unlike the axe027 which uses inverted TTL, and a standard serial port, which uses true RS232 data).

Andrew
 

BillyGreen1973

Senior Member
Note the module uses true polarity TTL data (unlike the axe027 which uses inverted TTL, and a standard serial port, which uses true RS232 data).
So you are using a CP2102 (or similar) to do convert from TTL serial to USB, and not connected via a picaxe?
I see now, thought you were using a picaxe to do the conversion and using the programming cable as the link to your terminal.
 

Andrew Cowan

Senior Member
You're right, although it would be a very simple task now to connect a PICAXE to it - using serout, then serin, then sertxd. The code is very simple - something like:

Code:
do
serout T9600 ("$sure ga",13,10)
serin T9600 ("="),#b0
sertxd (#b0,13,10)
pause 500
loop
 
Top