HexEngine 2 BS2p Tutorial 02
Two Way Serial Comms

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 BS2p stamp to demonstrate how easy it is to communicate with the HexEngine via the serial control port.

This programs demonstrates two way serial communications between the HexEgnine and a basic stamp BS2p device using the SERIN and SEROUT commands. When using SERIN, the maximum baud rate is 19200, and a delay is needed from when the HexEngine receives a packet request to when it returns it. This is because we are not using hardware uarts on the BS2p. There is a setting on the HexEngine that will transmit a number of 0xff bytes to form a transmission delay before the actual reply packet. This setting also sets the UART STOP bits to two, which also helps slow down the comms data rate. Also, it is much easier to receive PIP packets in mode 0, with no Escape code checking.

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

 
Equipment Used
  • MSR-H01 Hexapod ( Used, but not necessary )
  • p.Brain-SMB + HexEngine or p.Brain-µ24 HexEngine
  • BS2p24 + Carrier Board
 
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 debug BS2 debug window will display the digital, analogue and I2C return data if applicable.

You may also wish to configure the HexEninge I/O port for a mix of analogue & digital using the ADC command, e.g. ADC=AAAADDDD, and DIO=IIIIIIII. Even with nothing connected to the four analogue inputs you should see a small floating voltage. Don't forget to exit config mode when your are done!

 
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 Description BS2p
Pin 2 Pin 2 Data In Pin 5 (Can be user configured )
Pin 4 Pin 4 Data Out Pin 6 (Can be user configured )
Pin 6 Pin 6 Ground Pin 4
Pin 9 N/A 5 Volts ( Optional ) Pin 21
 
BS2p Code

HE_BS2_COMS_2.zip Contains HE_BS2_COMS_2.bs2
 
Useful Links & Documents

HexEngine Configuration Guide (PDF)  
HexEngine PIP protocol Guide (PDF)  
p.Brain-SMB user Guide (PDF)  
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.