Few days ago a friend of mine, while tidying up our workroom, found remnants of a robot – Aya – which we built about 5 years ago for the Eurobot challenge. Ah, the memories. Back then we used Microchip’s PIC processors, specifically we were fond of PIC16F627A. It was very cheap and the aforementioned friend had had some experience with them.
We spent weeks fiddling with the PIC assembly, trying to get the robot to work. (There were no free C compilers available for the platform. There were free AVR compilers though. We definitely should have gone with AVRs.) Unfortunately, we didn’t get the robot working in time for the national competition.
The next year we started from scratch. To simplify debugging (and secondarily to make the robot easily reconfigurable), we didn’t build everything into a single processor. Instead we built several modules, each with a single well-defined purpose. This way, we could develop and test each functionality separately.
Although it was a great idea, the modules would need to communicate, but the basic PIC processors lacked the support for the I2C bus. They only featured the plain old USART peripheral – great for communication with a PC, but unsuitable for multi-point communication. Eventually, we ended up connecting the USART’s TX pin through a diode to a common wire, which was pulled up by a resistor. (This is basically how I2C is implemented, but of course I didn’t know that back then. I thought I was so smart, until I found out that this ingenious technique is actually used all the time.)
Skip a few months of programming (in assembly, of course) and you get to the point where we already had what I passionately named Aya-bus: a fully featured implementation of a communication bus based on a USART peripheral. And when I say fully featured, I mean it. I could enumerate the devices connected to the bus, I could even hot-plug new devices into a running system.
(To be perfectly honest, the implementation was quite buggy. It was no easy task to debug an embedded concurrent system written in assembly. I eventually maneuvered around the problems by making the bus self-repairing – the bus-master would monitor the bus and clear it in case of an error. It also generated a token if it got lost. The hot-plugging ability was a mere consequence of these “fixes”, as the bus would simply regenerate after the module was plugged in.)
The picture above is the robot’s main board. You can see the two optical switches with which we used to measure the speeds of the motors. Each motor had its own processor that would measure the speed and transmit that information to the master. There are two chips missing on the board, I’m guessing the left one was a Schmitt trigger and the other was a processor that generated the control signal for servos (and motors, which were controlled by a BLDC regulator). To keep it precise, the signal was generated by a PWM peripheral and demultiplexed by the 74HCT238 chip visible at the top.
The chip to the right named “Rickie” was the bus-master and communicated with the computer through the barely visible MAX232-like chip at the bottom.
There were two peripherals remotely connected to the Aya-bus: several switches – a start button and an array of switches that formed a bumper – and the device photographed above: a color sensor. (You should know that the table on which the robots competed had a chessboard pattern of yellow and brown colors with special areas painted differently. We used the color of the ground beneath for localization.)
The device has a photo-diode in the center. The diode was quite expensive, it is very precise and has color characteristics matching those of a human eye. Around the diode there are four pairs of LEDs, red, green, blue and ultraviolet. To determine the color of the ground, each pair of LEDs was lit and the intensity of the reflected light was measured. The ambient light was measured as well and subtracted from the color channels.
We ended up twelfth out of some fifty teams at the international championship in Switzerland. We had a lot of fun and I’ve learned things about programming and design I will never forget. Thank you, Aya, rest in peace.