SRF08 Ultrasonic sensor and SX/B
Hi,
I wonder if anybody out there has used the Devantech SRF08 Ultrasonic Sensor with SX/B?
It is quite straight forward·to use the sensor with PBASIC but I fail to get it working with SX/B.
I assume I'm abusing the I2C-commands as the code compiles.
Any working code snippets or·suggestions would be welcome.
A simple testprogram for the SRF08 follows, (cut from the Devantech website - http://www.robot-electronics.co.uk/htm/srfxxbs2p.htm·).
'{$STAMP BS2p}
'***********************************************************
'**······················································ **
'**······ I2C Routines for the Basic Stamp BS2p·········· **
'**· with the SRF08, SRF10 and SRF235 Ultrasonic Rangers· **
'**······················································ **
'**············ Copyright 2005 - Devantech Ltd··········· **
'**···· Commercial use of this software is prohibited···· **
'**···· Private and educational use only is permitted···· **
'**······················································ **
'**······· Written by Gerald Coe - February 2005········· **
'**······················································ **
'***********************************************************
' Connect P8 (pin13) of the BS2p to the SRFxx SDA' Connect P9 (pin14) of the BS2p to the SRFxx SCL' Use 4k7 pull-up resistors from SCL and SDA to 5v supplySDA CON 8 ' SDA on pin13, SCL on pin14Ver VAR ByteLight VAR ByteRange VAR Word ' rangeLoop: I2COUT SDA, $e0, 0, [noparse][[/noparse]81] ' Rangeing command - 80 for inches, 81 for cm, 82 for uS PAUSE 100 I2CIN SDA, $e1, 0, [noparse][[/noparse]Ver, Light, Range.HIGHBYTE, Range.LOWBYTE] DEBUG 2,0,1, "BS2p to SRF08, SRF10 or SRF235 " DEBUG 2,0,3, "Firmware Version ", DEC Ver, " " DEBUG 2,0,4, "Light Sensor ", DEC Light, " (SRF08 only, Reads 128 on the others) " DEBUG 2,0,5, "Range ", DEC Range," cm " GOTO Loop
I wonder if anybody out there has used the Devantech SRF08 Ultrasonic Sensor with SX/B?
It is quite straight forward·to use the sensor with PBASIC but I fail to get it working with SX/B.
I assume I'm abusing the I2C-commands as the code compiles.
Any working code snippets or·suggestions would be welcome.
A simple testprogram for the SRF08 follows, (cut from the Devantech website - http://www.robot-electronics.co.uk/htm/srfxxbs2p.htm·).
'{$STAMP BS2p}
'***********************************************************
'**······················································ **
'**······ I2C Routines for the Basic Stamp BS2p·········· **
'**· with the SRF08, SRF10 and SRF235 Ultrasonic Rangers· **
'**······················································ **
'**············ Copyright 2005 - Devantech Ltd··········· **
'**···· Commercial use of this software is prohibited···· **
'**···· Private and educational use only is permitted···· **
'**······················································ **
'**······· Written by Gerald Coe - February 2005········· **
'**······················································ **
'***********************************************************
' Connect P8 (pin13) of the BS2p to the SRFxx SDA' Connect P9 (pin14) of the BS2p to the SRFxx SCL' Use 4k7 pull-up resistors from SCL and SDA to 5v supplySDA CON 8 ' SDA on pin13, SCL on pin14Ver VAR ByteLight VAR ByteRange VAR Word ' rangeLoop: I2COUT SDA, $e0, 0, [noparse][[/noparse]81] ' Rangeing command - 80 for inches, 81 for cm, 82 for uS PAUSE 100 I2CIN SDA, $e1, 0, [noparse][[/noparse]Ver, Light, Range.HIGHBYTE, Range.LOWBYTE] DEBUG 2,0,1, "BS2p to SRF08, SRF10 or SRF235 " DEBUG 2,0,3, "Firmware Version ", DEC Ver, " " DEBUG 2,0,4, "Light Sensor ", DEC Light, " (SRF08 only, Reads 128 on the others) " DEBUG 2,0,5, "Range ", DEC Range," cm " GOTO Loop
Comments
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I know what I know, don't confuse me with the facts...
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
The program·will read version number, light value and·range in cm's and send the·range values out an attached RS-232 port at 9600B as 5 ASCII characters followed by CRLF.
The program can also be used to show the values using WATCH during debug mode.
Comments for this are included in the program listing.
You can find the program source attached to this reply.