HexEngine 2 BS2p Tutorial 04 Basic Obstacle Avoidance Using SRF08 Range Finder
Updated: 28-Oct-2008
Description
One of the easiest micro controllers to program is the basic stamp range. For this reason I have chosen the BS2p 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.
Equipment Used
MSR-H01 Hexapod
MSR-H01-PH Pan Only Head
p.Brain-SMB + 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
Description
BS2p
Pin 2
Data In
Pin 5 (Can be user configured )
Pin 4
Data Out
Pin 6 (Can be user configured )
Pin 6
Ground
Pin 4
Pin 9
5 Volts ( Optional )
Pin 21
Four wires are required to connect the SFR08 to the HexEngine.