HMR3300 compass module
eco
Posts: 4
hi there,
I am trying to hook-up a BS2sx with a Honeywell HMR3300 compass module: http://www.ssec.honeywell.com/magnetic/datasheets/HMR32003300_manual.pdf
the module supports UART interface with 19200 baudrate, so I tried:
' {$STAMP BS2sx}
INPUT 8 'TX HMR -> BS2sx
deg VAR Byte
compass:
PAUSE 1
SERIN 8, 110, [noparse][[/noparse]deg] 'serin with 19200 baudrate
DEBUG ? deg
GOTO compass
no luck,
the HMR3300 also supports SPI, so I tried:
' {$STAMP BS2sx}
deg VAR Byte 'the degrees
CS CON 8 'BS2SX pin 8 -> HMR CS
DataShift CON 9 'BS2SX pin 9 -> HMR TX / SPI Data Output
CLK CON 10 'BS2SX pin 10 -> HMR SCK
compass:
LOW CS 'Activate the HMR
SHIFTIN DataShift, CLK, 0, [noparse][[/noparse]deg] 'Shiftin the data.
HIGH CS 'Deactivate HMR
DEBUG DEC deg, CR 'degree
PAUSE 100 'Wait a second.
GOTO compass
also no luck,
any ideas?
cheers,
seiko
Comments
The way I'm reading the data sheet, all commands to the module in UART mode must begin with either an "*" or a "#" and must terminate with the following sequence: <cr><lf> (carriage return, linefeed). I don't see that being done in your program.
Above and beyond that, if I were testing this sytem out, I'd drop my baudrate back to the minimim (2400 baud) and raise it later once I got everything working to my satisfaction. The way to do that, in UART mode, is to send the following command at 19,200 baud, since that's the default baud rate for the module:
"#XBAU=2400<cr><lf>" (without the quotes).
Once that is done, you can be pretty well assured that the communications link between the compass and the PBASIC Stamp SHOULD be at a baud rate that's acceptable to both. I'm sure you can boost up it later, but for testing, I'd leave it there.
Let us know how you make out after making those changes.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
thanks for help
>Above and beyond that, if I were testing this sytem out, I'd drop my baudrate back to the minimim (2400 baud) and raise it later >once I got everything working to my satisfaction. The way to do that, in UART mode, is to send the following command at 19,200 >baud, since that's the default baud rate for the module:
>"#XBAU=2400<cr><lf>" (without the quotes).
doesn't work:
serout pin, 110, [noparse][[/noparse]#BAU=2400<cr><lf>]
because Basic Stamp struggles with the "#"
seiko
My fault, I should have been more exacting in what I said. Some quotation makes ARE necessary, since you're sending a constant (a string) in the SEROUT command:
serout pin, 110, [noparse][[/noparse]"#BAU=2400", cr, lf] 'CR and LF are predefined, internal to the IDE
That should do it - sorry.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
SEROUT 9, 110, [noparse][[/noparse]"#BAU=2400", CR, lf]
LF remains undetectable to the BS2SX
thanks,
s
Also, at some point in this thread, the command changed from "#XBAU" to "#BAU". You might want to double-check that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
Place the following in the beginning of your program, and the error should disapper:
' {$STAMP BS2sx}
' {$PBASIC 2.5}
Note: Those are curly braces, not parenthesis.
I wasn't aware that LF was a PBASIC 2.5 extension. I thought it has been in there all the while, although I never used it for anything.
If you defined LF as LF CON 10 as Steve suggested, you will have to remove it before adding the lines above. Otherwise another error will appear - something like: LF is already defined, meaning that it's defined internal to the IDE, as I originally suggested.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
' {$STAMP BS2sx}
' {$PBASIC 2.5}
kills the error!
'LF CON 10
this as well!
'changed from "#XBAU" to "#BAU"
yes, because in the datasheet it only specifies "#Bau", not "#XBAU", no?
in any case I still only get gibberish out of my compass, with my code looking now like this:
INPUT 8
OUTPUT 9
RX CON 8 'HMR -> BS2sx
TX CON 9 'BS2sx -> HMR
heading VAR Byte
setbaudrate:
SEROUT TX, 110, [noparse][[/noparse]"#BAU=2400", CR, LF] 'set baudrate
PAUSE 5
SEROUT 9, 1021, [noparse][[/noparse]"*H", CR, LF] 'set HMR to Heading output mode
compass:
SERIN RX, 1021, [noparse][[/noparse]heading] 'red the heading
DEBUG ? heading
GOTO compass