The Versabot Manual: July 2009
The Versabot Manual: July 2009
July 2009
Index
1. Getting Started
1.1 How this manual works
1.2 Breaking out your pieces
2. The Components
2.1 The Motherboard
2.2 The Modules
2.3 The Microbric ‘Brics’
2.4 Connecting the Batteries
2.5 Joining Modules to your Motherboard using the Brics
2.6 The Download Adapter
6. What Now?
6.1 Cleaning up the edges
6.2 Variations
6.3 Go online
1. Getting Started
Finally! An electronics set that is really easy to build without sacrificing functionality! Welcome to
Versabot, the first solderless construction set made for electronics enthusiasts.
If you follow the manual through from start to finish, you will learn everything you need to know to
create the robots we have given you, as well as the knowledge and skills needed to build and program
unique robots of your own. Additional information about programming the PICAXE microcontroller
which acts as the 'brains' of your Versabot is included in the PICAXE Manuals accessible through the
Programming Editor and AXEpad Help menus.
LED module This module contains an LED (light emitting diode) and the
circuitry to drive it. A LED is a tiny light, used, amongst other
things, to show that an electronic device is turned on.
Slide Switch This module contains a small switch and the circuitry to drive
module it. A switch allows us to turn an electronic device on, or
‘switch’ between two electronic functions.
Buzzer This module contains a Buzzer and the circuitry to drive it.
module The buzzer is able to make sounds and even play simple
tunes.
Button This module contains a small push Button and the circuitry to
module drive it. It can be used to start or stop an electronic function.
Motor module This module contains a small Motor and the circuitry to drive
it. The motor can be used to drive wheels forwards and
backwards.
Bump Sensor This module contains a Bump Sensor and the circuitry to
module drive it. A bump sensor can detect when it touches
something, such as bumping into an object.
You can then use the Brics to attach the various modules (and other pieces) to the motherboard.
When connecting modules to the motherboard you need to make sure of a few things:
1. Make sure that the little red dot on the
edge of the module lines up exactly with
the little red dots on the edge of the
Motherboard (at the pins).
2. Make sure that you use all 3 screws and
do them up firmly (but not too tight).
3. Make sure that the Bric is the right way
around. It will only fit one way – you do
not need to force pieces together!
However, if you turn it up the other way it will sit straight. i.e.
If you’ve done it correctly, your Module and Motherboard should look like this:
If using a CAB010 9 way M-F serial download cable this can be connected directly to the motherboard
download connector.
3. Programming the Microcontroller on your Motherboard
Your motherboard is fitted with a PICAXE-28X2 microcontroller that can hold a range of instructions to
drive various electronic components. The sets of instructions are called programs and writing the
instructions is called programming.
To write programs, write programs, and to download them into the PICAXE microcontroller,
you need to install either the PICAXE Programming Editor or the cross-platform AXEpad
program.
This situation is very common in computer engineering where a general purpose programmable chip
is used with specific hardware and is very easy to deal with. All that is required is a table which maps
'hardware terminology' to 'software terminology' and you can go on using the hardware descriptions,
for example pin 1 (P1), which makes sense to you and the controlling software will understand what
you mean.
This table is implemented by using symbol commands and the complete set of pin mappings is as
follows:
There is another set of mappings for when the pins are used as inputs:
The details of the table and the mappings is not really important unless you want to get more deeply
involved in PICAXE programming generally. All you need to do is include the revelevent Symbol for
each pin your program uses at the top of the program. You can of course include the complete table of
Symbol definitions if you wish.
START
Turn on LED
Keep on for
200
milliseconds
3. Again, let’s draw a flow diagram before we write the program. Here is one for the program we
will write.
START
No
Is switch
on?
Yes
Turn on LED
Keep on for
200
milliseconds
Turn on LED
Keep on for
2000
milliseconds
Is the No
switch
1?
Yes
If the switch is
changed to 0
3. To program the buzzer, we will use the sound command. Let’s have a look at how the sound
command works. The sound command takes the general form:
You can put together a series of notes to make a tune by specifying note length and note
frequency.
4. Start the Programming Editor or AXEpad, or start a new program by using the
File/New/Basic Program menu option.
5. Now, type the following into the text window:
symbol IN1 = pinB.1 ' Define Input P1
symbol P2 = B.2 ' Define Output P2
No
Is switch
on?
Yes
Turn on LED
Keep on for
200
milliseconds
Play buzzer
tune
2. Start the Programming Editor or AXEpad, or start a new program by using the
File/New/Basic Program menu option.
3. Now, type the following into the text window:
symbol P0 = B.0 ' Define Output P0
symbol IN3 = pinB.3 ' Define Input P3
LightLED:
high P0 ' Turn P0 LED on
pause 1000 ' Leave on for 1000ms (1s)
return ' And return from subroutine
1. Attach the Motor module to P4 on the edge of the motherboard. Connect one of your wheels
to the motor axle.
2. Before writing the program below, let’s have a look at the serout and pulsout commands in
BASIC. The serout command allows you to specify such things as the direction and speed of
the motor. The pulsout sends a tiny pulse to brake the motor.
They are written in the following general formats:
3. Start the Programming Editor or AXEpad, or start a new program by using the
File/New/Basic Program menu option and then type in the following program:
2. Keep the assembled Versabot wheels off the ground or it may ‘run away’ with the download
cable attached when you download your program to it.
3. Start the Programming Editor or AXEpad, or start a new program by using the
File/New/Basic Program menu option.
4. Now, type the following into the text window:
symbol P0 = B.0 ' Define Output P0
symbol P4 = B.4 ' Define Output P4
symbol IN5 = pinB.5 ' Define Input P5
2. In order to use the remote control with the microcontroller, you will need to follow a sequence
of steps to preset the remote to work with the microcontroller.
a. Put two AAA batteries into the remote control unit.
b. Simultaneously hold down the S button (in the middle of the arrows) and the B button
on the remote (a red light will go on in the top left hand corner of the remote.)
c. Press the number sequence 0 1 3 on the remote buttons.
d. Press the red power button on the remote.
e. The remote is now configured to work with your microcontroller.
Note that buttons A, C, D, E, F and G are for setting the remote control into different modes which
are not required for this project. Avoid pressing these buttons as this will inadvertently set your
remote into another mode. You can always return to the ‘B’ mode by pressing the B button.
3. Start the Programming Editor or AXEpad, or start a new program by using the
File/New/Basic Program menu option.
4. In this program you will be using the infrain command. This is a command that tells the
microcontroller to wait for a remote control signal.
'**Variables**
symbol keyPressed = w0
symbol timeout = w1
ObeyIrCommand:
select case keyPressed
case KEY_UP : gosub GoForward ' When up arrow, clockwise
case KEY_DOWN : gosub GoBackwards ' When down arrow, anticlockwise
case KEY_RIGHT : gosub LightLED ' When right arrow then light LED
case KEY_LEFT : gosub PlayTones ' When left arrow then play tones
end select
return
GoForward:
serout P4,T2400,("C",255) ' Run motor forward
gosub WaitWhileKeyHeld ' Wait for key release
pulsout P4,6 ' Stop Motor
return
GoBackwards:
serout P4,T2400,("A",255) ' Run motor backwards
gosub WaitWhileKeyHeld ' Wait for key release
pulsout P4,6 ' Stop Motor
return
LightLED:
high P0 ' Turn LED on
pause 1000 ' Keep on for 1000ms (1s)
low P0 ' Turn LED off
return
PlayTones:
sound P2,(50,50,60,50) ' Play two tones
return
Button Value
On/Off Power 21
1 0
2 1
3 2
4 3
5 4
6 5
7 6
8 7
9 8
0 9
/\ Up 16
\/ Down 17
< Left 19
> Right 18
| Vertical Bar 96
/\ Tent 54
+ Vertical Cross 37
X Diagonal Cross 20
- Minus 98
+ Plus 11
A list of remote control key codes definitions is included as program IrKeys.bas on the CD-ROM
which may be cut and pasted into your programs as required.
symbol KEY_POWER = 21
symbol KEY_1 =0
symbol KEY_2 =1
symbol KEY_3 =2
symbol KEY_4 =3
symbol KEY_5 =4
symbol KEY_6 =5
symbol KEY_7 =6
symbol KEY_8 =7
symbol KEY_9 =8
symbol KEY_0 =9
symbol KEY_UP = 16
symbol KEY_DOWN = 17
symbol KEY_LEFT = 19
symbol KEY_RIGHT = 18
symbol KEY_BAR = 96
symbol KEY_TENT = 54
symbol KEY_VERT_CROSS = 37
symbol KEY_DIAG_CROSS = 20
symbol KEY_MINUS = 98
symbol KEY_PLUS = 11
4. Building your Bump Robot
4.1 What will it do?
The Bump robot will drive in a straight line until it hits an
obstacle. If the ‘bump sensors’ meet an obstacle, such as a
wall, the robot will stop, reverse and try a new direction. You
will press the button to start it moving.
Step 01
Step 02
Step 03
Step 04
Step 05
Step 06
Step 07
Step 08
Step 09
Step 10
Step 11
Step 12
Step 13
4.3 Downloading the program to drive your bump robot
Once your bump robot is built:
1. Start the Programming Editor or AXEpad and open the file BumpRobot.bas from your
CD-ROM ( File/Open).
2. Save the program (File/Save As…) to a location on you hard drive.
3. Connect the download cable to your motherboard.
4. Press the F5 key to download your program into the PICAXE on your Versabot
motherboard.
5. Disconnect the download cable and place your Versabot on the ground.
6. Press the button on the Button Module to start your Bump Robot.
'**Variables**
symbol temp = w0
'**Outputs**
symbol LeftLED = P0
symbol RightLED = P12
symbol RightMotor = P11
symbol LeftMotor = P1
'**Inputs**
symbol PushButton = IN6
symbol LeftBumper = IN15
symbol RightBumper = IN13
StartOfProgram:
high RightMotor
high LeftMotor
pause 50
StopRobot:
BackwardTurnRight:
gosub StopMotors ' Call StopMotors
gosub GoBackwards ' Call GoBackwards
gosub TurnRight ' Call TurnRight
goto Main ' Loop around to Main
BackwardTurnLeft:
gosub StopMotors ' Call StopMotors
gosub GoBackwards ' Call GoBackwards
gosub TurnLeft ' Call TurnLeft
goto Main ' Loop around to Main
GoForward:
serout LeftMotor,T2400,("A",150) ' Drive motor Anticlockwise
serout RightMotor,T2400,("C",150) ' Drive motor Clockwise
return
GoBackwards:
pause 50
serout LeftMotor,T2400,("C",150) ' Drive motor Clockwise
serout RightMotor,T2400,("A",150) ' Drive motor Anticlockwise
for temp = 1 to 25
pause 7
if PushButton = 1 then StopRobot ' If Push Button is pressed
' StopRobot
next
gosub StopMotors
pause 50
return
TurnRight:
serout LeftMotor,T2400,("A",150) ' Drive motor Anticlockwise
serout RightMotor,T2400,("A",150) ' Drive motor Anticlockwise
for temp = 1 to 25
pause 15
if PushButton = 1 then StopRobot ' If Push Button is pressed
' StopRobot
next
gosub StopMotors
pause 50
return
TurnLeft:
serout LeftMotor,T2400,("C",150) ' Drive motor Clockwise
serout RightMotor,T2400,("C",150) ' Drive motor Clockwise
for temp = 1 to 25
pause 15
if PushButton = 1 then StopRobot ' If Push Button is pressed
' StopRobot
next
gosub StopMotors
pause 50
return
StopMotors:
pulsout LeftMotor,6 ' Brake Left Motor
pulsout RightMotor,6 ' Brake Right Motor
return
5. Building your Infrared Versabot Robot
5.1 What will it do?
Your infrared Versabot can be driven using your remote control.
Note that buttons A, C, D, E, F and G are for setting the remote control into different modes which are
not required for this project. Avoid pressing these buttons as this will inadvertently set your remote into
another mode. You can always return to the ‘B’ mode by pressing the B button.
'**Variables**
symbol keyPressed = w0
symbol motorSpeed = w1
symbol timeout = w2
'**Pins**
symbol LED_PIN = P6
symbol LeftMotor = P13
symbol RightMotor = P15
symbol IR_PIN = P14
'**Inputs**
symbol IR_SIGNAL = IN14
ReadIrCommand:
IrIn IR_PIN, keyPressed ' Read an IR command
return
ObeyIrCommand:
select case keyPressed
case KEY_UP : gosub GoForward
case KEY_DOWN : gosub GoBackwards
case KEY_LEFT : gosub TurnLeft
case KEY_RIGHT : gosub TurnRight
case KEY_POWER : gosub StopMotors
case KEY_0 : motorSpeed = 70
case KEY_1 : motorSpeed = 90
case KEY_2 : motorSpeed = 110
case KEY_3 : motorSpeed = 130
case KEY_4 : motorSpeed = 150
case KEY_5 : motorSpeed = 170
case KEY_6 : motorSpeed = 190
case KEY_7 : motorSpeed = 210
case KEY_8 : motorSpeed = 230
case KEY_9 : motorSpeed = 255
else : return
end select
gosub WaitWhileKeyHeld
return
GoForward:
serout LeftMotor,T2400,("A",motorSpeed)
serout RightMotor,T2400,("C",motorSpeed)
return
GoBackwards:
serout LeftMotor,T2400,("C",motorSpeed)
serout RightMotor,T2400,("A",motorSpeed)
return
TurnLeft:
serout LeftMotor,T2400,("C",motorSpeed)
serout RightMotor,T2400,("C",motorSpeed)
return
TurnRight:
serout LeftMotor,T2400,("A",motorSpeed)
serout RightMotor,T2400,("A",motorSpeed)
return
StopMotors:
pulsout LeftMotor,6 ' Brake Left Motor
pulsout RightMotor,6 ' Brake Right Motor
return
6.3 Variations
You now know enough about programming to make your own variations of the models provided.
Experiment with a range of robot designs and write or adapt the programs to drive your new robots.
6.4 Go Online
Want more? Go online to www.picaxe.com to find out the latest news in PICAXE
Robotics! Join an online forum. Find out the newest models and designs. Buy
additional pieces or replace missing ones. Check out the FAQs to troubleshoot
problems, or Contact the PICAXE team.