Bugdozer is an autonomous mini-Sumo robot.
Her main board consists of a MC68HC908GP32 microcontroller along with input/output support chips, a voltage regulator, a crystal oscillator, and the usual assortment of resistors, capacitors, and switches.
All chips are socket mounted. I’m not experienced at soldering, so soldering the sockets avoided damage that could have resulted from soldering the chips directly. Also, if a chip becomes damaged in battle, it can be replaced easily.
PDIP MC68HC908GP32CP microcontroller
The 8-bit MC68HC908GP32 microcontroller (MCU) was chosen for its:
This gave Bugdozer all she needed without any external memory.
The chip was programmed with hand-coded assembly language, taking about 5K for program and data. Only about 140 bytes of RAM is used (not counting the stack). I’m very happy with the speed, capability, and ease of development.
All of the code running in the chip is mine. There isn’t an OS or third-party library. This gives me complete control, albeit with all the work.
Although not officially multitasking, each task completes some work and then returns to the main loop to allow time for other tasks. Using the built-in timer, an interrupt occurs every thousandth of a second which scans a table to set alarms or immediately call registered routines.
It’s got the clocks, it rocks!
A low-cost, low-noise 32.768 kHz watch crystal is ramped up to an 8 MHz bus clock by the 68HC08’s built-in phase-locked loop (PLL) circuitry. The microcontroller is running at 32 MHz internally, so many instructions complete in a single clock cycle.
See PLL for schematics and source code.
Onboard voltage regulator, power switch, and current tap
Bugdozer uses two 9-volt batteries, for a maximum of 18 volts. Actually, two 7.2-volt nickel-metal hydride (Ni-MH) secondary batteries are often used instead of true nine volts. Rechargeable batteries are cheaper per use and landfill friendlier.
The batteries are center tapped for the motherboard. So, only half the voltage is passed to the regulator, wasting less power. Full voltage is provided to the LEDs and DC motors.
Although not required, a pre-regulated 330-microfarad capacitor and a post-regulated 100-microfarad capacitor were added to provided stability during power transitions associated with motors and LEDs. All chips have 0.15-microfarad decoupling capacitors. A few larger capacitors (1 microfarad to 33 microfarad) are strategically placed near major users, like the microcontroller, LED transistor drivers, and DC motor drivers.
As always, there’s a power switch. And, like Twofold, a current tap jumper allows a multimeter or ammeter to be connected in series with the board to determine current usage.
38-kHz oscillator circuit
The 38-kHz square wave emitted by the infrared LEDs provides object detection without false signaling from ambient lighting.
The 74HC00 NAND-chip circuit generates the oscillations. A potentiometer can be adjusted to fine-tune the frequency. An input pin on one of the NAND gates leads to the microcontroller, allowing the oscillator and emitters to be turned off by software.
74HC14 integrated-circuit chip, plastic dual-inline package
A gate on the 74HC14 inverter buffers the signal to prevent the load from affecting the oscillator. The 7414 is a Schmitt-trigger IC. A standard 7404 could be used, but I thought I might need the extra gates for some other signal processing. Turns out I didn’t.
Four 2N2222 transistors arranged in pairs
A pair of 2N2222 transistors first bring the voltage up to full (14 to 18 volts) and then amplifies the current to meet the full needs (up to 50 mA) of the infrared LEDs. By raising the voltage first, the current wasted connecting the transistor to ground (for “off” states) is equivalent to only a 10-kilohm pullup resistor.
This transistor arrangement inverts the signal, so only one gate of the inverter chip is needed, with the reinversion occurring at the transistors. If the LEDs weren’t running on unregulated power (if they were running at 5 volts), only one transistor would be necessary.
To aid debugging, a 4-line 20-character LCD panel can be attached to the main board. The LCD is too heavy, too wide, and possibly too fragile to be used during combat. The connector allows easy removal. A single standoff screw hole at the bottom of the motherboard holds the LCD in place, well, most of the time.
A pair of TelCom MOSFETs
A pair of TC4427A 1.5-amp dual high-speed MOSFET drivers form a classic H-bridge for driving the DC motors. They work perfectly with few external components. No noise appears to be introduced into the motherboard.
Each motor is sent pulse-width modulated signals from the microcontroller via the MOSFET drivers. This allows each motor to be controlled independently, forward or reverse, at any speed from off to maximum (or in-between) from software. Because of this control, Bugdozer consistently centers her scoop attack on the target.
The inputs are pulled high via 10-kilohm resistors. So, the motors default to off during times when the microcontroller isn’t ready (such as cold-start power-up).
A pair of 74HC251s
The 74HC251 is a 3-state data selector / multiplexer. By addressing two chips with the same four pins that are connected to the LCD, the microcontroller can read the logic state of 16 additional input lines. Additionally, these inexpensive chips may act as fuses to protect the microcontroller in the event of a damaged input.
All inputs are read and debounced in software and stored globally. This eliminates the complexity of reading bits in various locations of the source code. The different routines can choose to read the current bit(s) or the debounced bit(s) by accessing the appropriate global variables. Routines can register to be called whenever a debounced bit changes state.
The dipswitch, pushbuttons, and infrared logic detectors all are connected to these inputs. And remember, they’re already debounced by the read routine!
10-kilohm resistor arrays are connected to the inputs to pull them high when they aren’t in use or for when they are connected directly to switches. The arrays save space and have fewer solder points (there’s a common pin) than do standard resistors.
Low-profile blue dipswitch
A low-profile dipswitch provides 8 settings (or more combinations). Currently the settings are:
Two low-profile miniature pushbuttons.
The first button steps through each page of information on the LCD.
The second button either starts the combat countdown or causes some other action depending on which page is displayed (or would be displayed) on the LCD. A common action would be to reset the minimum / maximum values recorded for a set of sensors.
Left: Point-to-point wiring. Right: Wires take up too much space when installed
The board has soldered, point-to-point wiring. Almost all of my robots since Bugdozer have printed circuit boards.
Point-to-point wiring of an entire motherboard has enormous disadvantages!
And that’s why my newer robots use printed circuit boards!
To make sure that everything is wired and processing correctly, it helps to display data on an LCD screen. Let’s look at that next.