Starting and Stopping

The Operator Pushbutton

The vehicle sits on an "off" state until an operator presses a button, whereupon it sets off along the track. It continues until the button is pressed again, or it senses a trackside marker, or it senses a collision

Starting on the press of a button is a simple enough behaviour, but not quite as trivial as it may at first appear. Once in motion, the system is likely to be checking all of its sensors every few milliseconds. Unless the programmer determines otherwise, it will check the pushbutton many times during a single press, alternatively starting and stopping; whether it is on or off when the finger is removed from the button is a matter of chance. To prevent this it must wait for the button to be released before checking again, so that it responds to successive button presses and not repeatedly to the same button press. A minority of learners have some difficulty getting their heads round this.

Trackside Markers

When it finds a trackside marker the vehicle halts and goes back into its stable "off" state, where it will remain until someone presses the button start it up again. (This represents a laundry pick-up point, where the vehicle would wait while it is loaded/unloaded before being sent on its way.)

Stopping is simple enough, but learners often find that the vehicle refuses to start again when the button is pressed. This is because the sensor is still over the trackside marker, so the vehicle does, notionally, start but it stops again instantly because it has found "another" marker. There is more than one way round this, but the neatest is probably not to stop the vehicle until it reaches the far side of the marker.

Positioning of the sensor on the chassis needs care. Clearly it must be on the left-hand side, in line with the markers, but it must also be well behind the line following sensors to ensure that it does not foul the track on a left-hand bend thus causing a spurious halt. There are limited opportunities for siting the sensor beneath the chassis, and the problem is exacerbated by sharp right angled bends, which is why our current track has only curved bends.

Collisions

Collisions are sensed by a microswitch on the front of the chassis (but see the Improvements section for more sophisticated alternatives). Originally the switch was operated by a full-width bumper, but these were removed most of the time for fitting and adjusting sensors, so in the end we just left them off. There is a picture of the original buggy, with the bumper, in the History section.

In collision, the vehicle must stop immediately and sound an alarm, usually a two tone siren. It does this until the obstacle is removed, when the alarm stops and the vehicle sets off again, without operator intervention, after a few seconds delay. While it is in this collision state, of course, it must be possible for someone to switch the vehicle off with the pushbutton - a requirement often overlooked by learners!

Piezo-electric sounders would probably be suitable for the sound. We used tiny loudspeakers, with series resistors, because we had a box of them that we had salvaged from scrap PCs.