Fun in real time

Greg Bollella, the real-time lead at Sun has convinced a few of us to help him out with his Slot Car Programming Challenge for JavaOne this year. This is a picture of him assembling a slot car track on an 8'x16' table. The cars that run on track are absolutely standard 1/24 scale cars. No mods. The track has 80 sensors spread along its length. Instead of a manual control, the power supply is controlled by an A/D converter driven from a workstation. The challenge is to write software to control the car and get around the track as fast as possible. This is a pretty tricky problem since entries will have to get the timing of the power changes exactly right. It's doubly tricky because the sensors are fairly primitive (which is very common in actual realtime systems). These sensors are simple photocell gates (the kind used to detect paper moving through a printer) placed along the slot. They give a simple 0/1 indication of whether or not the car is passing by the sensor. To make life harder, all of the sensors are ored together. There's only 1 bit of input - two, actually - one sensor gets's a seperate bit: it's the start/finish line. So you have to count. Accuratly. No missing sensor pulses. A map of the course will be provided. One of the bonus features is that the power supply can swing it's voltage pretty quickly - even going into reverse. So there are lots of tricks to be done involving rapid braking, or pulsing. It's remarkably easy to send the car flying off the corners.
April 18, 2006