Bugdozer’s Autonomous Motherboard

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.

Back in 2000, this was a very big picture to download.

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.

Microcontroller

PDIP MC68HC908GP32CP microcontroller

PDIP MC68HC908GP32CP microcontroller

The 8-bit MC68HC908GP32 microcontroller (MCU) was chosen for its:

This gave Bugdozer all she needed without any external memory.

  1. An MR32 or surface-mount GP32 would have provided additional pulse-width generators so that the 38-kHz oscillator circuit and chips could have been eliminated.
  2. An AB32 or external EEPROM would have been nice to allow in-field ambient calibration.
  3. I should have added a MON08 debugger connection to the motherboard to allow in-field reprogramming of the FLASH.

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.

Crystal Clock

It’s got the clocks, it rocks!

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.

Power

Onboard voltage regulator, power switch, and current tap

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.

The Maxim MAX603 is at the heart of the onboard power supply. This voltage regulator has:

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 Infrared Emitter Oscillator

38-kHz oscillator circuit

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.

See the Infrared Transmitter page for a schematic, sample layout, and debugging hints. Although not used in this robot, I’ve since improved the oscillator.

74HC14 integrated-circuit chip, plastic dual-inline package

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

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.

LCD Connection

LCD connector

LCD connector

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.

Click here for screen shots of Bugdozer’s LCD...

H-Bridge DC Motor Driver

A pair of TelCom MOSFETs

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).

Additional Input

A pair of 74HC251s

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.

Caveats:

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!

Resistor array

Resistor array

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.

Dipswitch Settings

Low-profile blue dipswitch

Low-profile blue dipswitch

A low-profile dipswitch provides 8 settings (or more combinations). Currently the settings are:

  1. The first two switches indicate opening attack patterns so that the operator can adjust for different opponents. Four battle strategies are currently available:
    • Hunt normally (Move forward a bit, if the opponent is unseen then scan in a circle.)
    • Hunt far (Opponent is at the very back of the ring. Move forward until the opponent is seen or an edge is detected.)
    • Hunt left (Bugdozer placed on ring first, opponent was placed to her left. Start moving toward left, looking for opponent.)
    • Hunt right (Bugdozer placed on ring first, opponent was placed to her right. Start moving toward right, looking for opponent.)
  2. Opening attack pattern bit 2
  3. Unused
  4. Unused
  5. ON reduces timer for preprogrammed patterns. Bugdozer doesn’t have wheel encoders, so timers are used to determine how long a particular movement should last. For higher voltage batteries (18 V vs. 14.4 V rechargeables), the motors will spin faster, thus the movement should take less time.
  6. ON forces all LEDs on. This is useful for testing the line and object sensors, which are normally off (to save power) except in combat.
  7. ON initiates immediate attack mode from reset or cold-start. Normally Bugdozer waits for the start button. But if something should short or crash during combat, this causes Bugdozer to continue attacking.
  8. ON disables the LCD, thereby speeding the processor by returning immediately from all drawing routines.

Pushbuttons

Two pushbuttons

Two pushbuttons

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.

Rat’s Nest

Point-to-point wiring Wires take up too much space when installed

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.