The Record-Replay-Bot SensorBot allows the user to record a sequence of movement "steps" or "beeps" then play them back multiple times. It includes bump and light sensors.
So it's like a simple record-and-replay bot but it also has sensors. It has only one button other than the bump-sensor switches.There is no "Go" button. Switching the robot on starts running the program - it is in "Run" mode.
Switching the robot on with the middle button held down puts the robot into "Record" mode.
Various chirps, beeps and warbles tell the user what mode they're in.
There are four bump sensors and one button. In Record mode, they are used to insert command instructions and to start a new event handler. In Record mode, the LEDs show the current instruction. The user can insert and delete instructions and step through the program.
In Run mode, the bump sensors trigger Event handlers.
Program Sections
The program is divided into sections and episodes, for instance:
<main program> | Episode 1 | |
Front-Left-bump | ||
<front-left-bump instructions> | ||
Front-Right-bump | ||
<front-right-bump instructions> | ||
Dark | ||
<dark instructions> | ||
Episode | ||
<main program> | Episode 2 | |
Back-Right-bump | ||
<Back-right-bump instructions> | ||
Front-Right-Left-bump | ||
<Right-left-bump instructions> | ||
Light | ||
<light instructions> |
The <main program> instructions of Episode 1 are executed repeatedly. If the front-left bump sensor is touched then the <front-left-bump instructions> are executed once and control returns to the <main program>. While the <front-left-bump instructions> are being executed, if the front-right bump sensor is touched then the <front-right-bumpinstructions> are executed once. But while the <front-right-bumpinstructions> are being executed, front-left bump sensor touches will be ignored.
The Back-Right-bump, Front-Right-Left-bump and Light events cannot be triggered as they belong to a different Episode.
If the Dark Event is triggered then the <dark instructions> are executed followed by the <main program> of Episode 2. The <main program> instructions of Episode 2 are executed repeatedly. The Back-Right-bump, Front-Right-Left-bump and Light events can now be triggered; when they have been executed, execution returns to the start of Episode 2.
There can be any number of Episodes. In an Episode, there can be any number of sections in any order.
When execution reaches the end of any section then execution returns to the start of the first, Main, section. However, if a Episode instruction has been executed then when execution reaches the end of any section it returns to just after the Episode instruction. This allows for a "sequence" of events. For instance, the main section and the first few event handlers are for following a canyon - the interesting events are left and right antennae touching the walls. When you reach the end of the canyon (event = change in light level) then you turn right 90deg and follow a left-hand wall (event = left antenna touching) until you see a black line. Then you ...
Forward | <main program> |
Front-Left-bump | <left-bump instructions> |
Forward-right | |
Front-Right-bump | <right-bump instructions> |
Forward-left | |
Light | <light floor found instructions> |
Spin-right | |
Spin-right | |
Episode | <subsequent execution returns to here> |
Forward | |
Forward-left | |
Front-Left-bump | <left-bump instructions> |
Spin-right | |
Dark | <dark line found instructions> |
Episode | <subsequent execution returns to here> |
Forward | |
Dark | <follow line> |
Light | <follow line> |
... etc. |
Assume that the following Event handlers have been defined:
... | <main program> |
Front-Right-bump | |
... | |
Front-Left+Right-bump | |
... | |
Dark | |
... |
and the Left and Right front bump sensors are touched then the "Front-Left+Right-bump" Event handler will be triggered (of course). The "Front-Left+Right-bump" Event handler was defined after the "Front-Right-bump" Event handler; if they had been defined in the opposite order and the Right bump sensor was triggered just before the Left bump sensor then the "Front-Left+Right-bump" Event handler would not be triggered
If there is no Event handler for front-left+right:
... | <main program> |
Front-Right-bump | |
... | |
Dark | |
... |
and both the Left and Right front bump sensors are touched then the "Front-Right-bump" Event handler will be triggered.
Record Mode User Interface
Clicking a bump-sensor inserts an instruction to drive in a particular direction:
The coding is that the bumper near a wheel says which way the wheel is to turn - so spinning-on-the-spot means one motor goes forward and the other backward.
Holding a bump-sensor down (until the sounder beeps) means start a new Event handler. You can hold two or more sensors down to mean both must be down to trigger the event (there's no way to specify "either left or right touch" - just duplicate the event handler).
Holding the central button down (until the sounder beeps) means start a new On-bright-light Event handler. Double-Clicking the central button means start a new On-dark-light Event handler. The "Light" and "Dark" light thresholds are adjusted with potentiometers.
So, consider the following button press sequence:
Bump FL | === | . | . | . | . | . |
Bump FR | . | . | === | . | . | . |
Bump BL | . | . | . | . | === | . |
Bump BR | . | . | . | . | === | . |
Button | . | . | . | . | . | . |
Beeper | . | A | . | A | . | A |
Means enter the folowing instructions:
To begin an Event handler, hold down the sensor until it beeps; you can also hold down pairs of sensors. Hold down the button to begin an On-Light Event handler; double-click the button to begin an On-Dark Event handler. A total of ten kinds of Event handler are allowed:
Bump FL | === | . | . | . | . | . | . | ======== | . | . |
Bump FR | === | . | . | . | . | . | . | ======== | === | . |
Bump BL | . | . | . | === | . | . | . | . | === | . |
Bump BR | . | . | . | === | . | === | . | . | . | . |
Button | . | . | ======== | . | . | . | . | . | . | . |
Beeper | . | A | ..........B | . | A | . | A | ..........B | . | A |
Means that the three sub-programs are:
Main program: |
|
both motors forward (executed repeatedly) |
|
On seeing light area |
|
both motors reverse |
|
right motor reverse |
|
On both front bumpers touched: |
|
spin right |
FL and BL together sound a chirp. FR and BR together sound a different chirp.
FL, FR, FL and BL together insert a "Episode" instruction.
Editing the program
Clicking both the button and one of the bump sensors together means "edit the program":
Button+FR | Next |
display the next instruction |
Button+BR | Prev |
display the previous instruction |
Button+FL | Start |
go to start of program |
Button+BL | BkSp |
delete previous instruction |
Button+FL+BL | CM |
"Clear Memory" - delete whole program |
Button+FR+BR | Calib |
Calibrate the light sensor |
The "Current Instruction" is the instruction currently being displayed. The instruction is displayed by the LEDs:
FL steady | left motor forward |
FR steady | right motor forward |
BL steady | left motor backward |
BR steady | right motor backward |
FL+BL steady | Chirp 1 |
FR+BR steady | Chirp 2 |
FL+FR+BL+BR steady | Episode |
FL flashing | start of On-FL-touch Event |
FR flashing | start of On-FR-touch Event |
BL flashing | start of On-BL-touch Event |
BR flashing | start of On-BR-touch Event |
button flashing | start of On-Light Event |
button dbl-flashing | start of On-Dark Event |
all flashing | start of main program |
The Current Instruction is the one that has just been entered. Entering another instruction, inserts it after the Current Instruction.
The "backspace" command delete previous instruction: i.e. the one that has just been entered.
For instance
Bump FL | === | . | . | . | . | . | . | . | . | . |
Bump FR | . | . | === | . | === | . | === | . | . | . |
Bump BL | . | . | . | . | . | . | . | . | === | . |
Bump BR | . | . | . | . | . | . | . | . | . | . |
Button | === | . | === | . | === | . | === | . | . | . |
Beeper | . | C | . | D | . | D | . | D | . | A |
Moves to the start of the program, advances three instructions and inserts a Motors-Back-Left instruction (which becomes the fourth instruction).
Calibration
Holding down the two right bump sensors and the button puts the robot into light sensor calibration mode. One of the forward LEDs or the button LED flashes quickly:
Pressing the bump sensors turns on the motor for the Motor-On time. Pressing the button and the Right Forward or Back bump sensors increases or decreases the Motor-On time. The Motor-On time is a multiple of 0.26 seconds:
To exit calibration mode, switch off the robot.
Summary
Clicking a bump-sensor inserts an instruction to turn the motor on. The bump-sensor near a wheel says which way the wheel is to turn.
Clicking several bump-sensors inserts an instruction to chirp or to start a new Episode.
To begin an Event handler, hold down the sensor until it beeps; you can also hold down pairs of sensors.
Hold down the button to begin an On-Light Event handler.
Double-click the button to begin an On-Dark Event handler.
Clicking both the button and one of the bump sensors together means "edit the program":
Questions or
comments ? E-mail me at peterbalch@btinternet.com
No part of this web page may be reproduced in any form or by any means,
including photocopying and recording, for any purpose without the express
written permission of Analogue Information Systems Ltd.
This web page is copyright © 2008 Analogue Information Systems Ltd.,
1 Warrender Park Crescent, Edinburgh EH9 1DX, Scotland, UK, Tel: +44 (0)
131 228 6008. All Rights Reserved