HexEngine 2 BS2p Tutorial 04
Basic Obstacle Avoidance Using SRF08 Range Finder


Updated: 24-Feb-2010

mms_logo
 
Description

One of the easiest micro controllers to program is the basic stamp range. For this reason I have chosen the BS2p24 stamp to demonstrate how easy it is to communicate with the HexEngine via the serial control port.

This program uses the previous tutorial examples to demonstrate a basic obstacle avoidance programme. If you have successfully completed tutorial 3, then you should be able to download and test this code.

Note: If you are using a p.Brain-µ24, 5 Volts is not available from the board.

 
Equipment Used
  • MSR-H01 Hexapod
  • MSR-H01-PH Pan Only Head
  • p.Brain-SMB + HexEngine or p.Brain-µ24 HexEngine
  • BS2p24 + Carrier Board
  • SFR08 Range Finder
 
HexEngine Configuration

CN18 Jumpers Off Terminal port = RS232 (UART2) , Control port = TTL (UART1).
CBR=4 Control baud rate = 19200
PIP=0 PIP Packet mode = 0
TXD=3 Transmission delay = 3
   
 
Functionality

When running this programme, the hexapod will wake up and begin to walk forward while moving its head from side to side. A range ping is taken at each head position, left, front and right and the if the ping is below a certain distance the hexapod will react by turning or backing up and turning away so as to avoid the obstacle. This is a very simple systems and it doesn't always work! but it does give you an idea of the kind of control applications that can be written for the HexEngine. Why not improve on this code and send me a copy to add to the tutorial :)

 
Connection

Only 3 wires are necessary for communication with the BS2p, which can be found on the p.Brain-SMB connector CN17.

Pin 2 = U1RX
Pin 4 = U1TX
Pin 6 = GROUND

U1RX needs to be connected to the BS2p SER_OUT pin and GROUND to the BS2P ground. IF you are using the 5V regulator ON the p.Brain-SMB, You CAN also take a third wire from PIN 9 ON CN17 TO supply the 5V power to the BS2p

p.brain-SMB
CN17
p.Brain-µ24
CN1
Description BS2p
Pin 2 Pin 2 Data In Pin 4 (Can be user configured in the .BS2 file)
Pin 4 Pin 4 Data Out Pin 5 (Can be user configured in the .BS2 file)
Pin 6 Pin 6 Ground Pin 4
Pin 9 N/A 5 Volts ( Optional ) Pin 21

Four wires are required to connect the SFR08 to the HexEngine.

p.Brain-SMB
CN17
p.Brain-µ24
CN1
Description SFR08 Range Finder
Pin 5 Pin 1 I2C SDA Pin 3
Pin 7 Pin 3 I2C SCL Pin 2
Pin 6 Pin 6 Ground Pin 5
Pin 9 5 Volt is not available on the µ24, use 5 Volt from the BotBoard or other source. Or use the alternate configurateion below. 5 Volts Pin 1

 

 
BS2p Code

HE_BS2_COMS_4_V21.zip Contains HE_BS2_COMS_4_V21.bs2
HE_SRF04_BS2_ATOM.zip Contains BS2 and ATOM version of the code using SRF04, courtesy of Kevin Lincoln.
 
Useful Links & Documents

HexEngine Configuration Guide (PDF)  
HexEngine PIP protocol Guide (PDF)  
p.Brain-SMB user Guide (PDF)  
BotBoard II User Guide (Link)  
BS2p24 Schematic (PDF)  
BS2p24 Information (Link)  
   
 
HE+BS2
Image 01 - Basic Stamp Carrier attached to MSR-H01 Hexapod, HexEngine is mounted on underside of top body plate. ( In the image above I am using my own BS2p carrier board, however, I suggest using a carrier such as the BotBoard II )
 

Video 01 - Video demonstrating hexapod control as described in this tutorial.  
 

BotBoard Configuration 1) (Click image for larger view )
p.Brain-SMB-SRF08

Image 02 - SRF08 + p.Brain-SMB Connection diagram using BotBoard & BS2p. Click for larger image. (Thanks to plingbboot for the image )

 

Alternative BotBoard Configuration 2) (Click image for larger view )
BS2 SMB Config 2

This image shows a sliughtly different configuration, in this case, a 9V battery is used to power both the BotBoard and the SMB logic supply (note the jumper setting). The SRF08 is taking power from the BotBoard, however, there is no reason why it couldnt take power from the SMB CN17 as in the origobal setup abaove.