Menu
The IRDAR Processing display: a green radar screen with concentric range rings, a rotating sweep bar and white dots marking detected obstacles all around

IRDAR — a Scanning Infrared Rangefinder

IRDAR ("IR radar") is a scanning infrared rangefinder built on a Freescale MC9S08QE128 (HCS08 8-bit). A servo pans a pair of Sharp infrared distance sensors through a full circle while the microcontroller streams angle and range to a Processing sketch that draws a radar-style sweep.

The assembled IRDAR turret: a servo at the base, a hand-wired signal board on its front, and an aluminium bracket on top holding an infrared sensor, mounted on a slip-ring bearing

The assembled scanning head — servo, slip-ring joint, sensor bracket and signal board.

How It Works

  1. A servo continuously pans a bracket carrying two Sharp IR distance sensors mounted back-to-back, so between them they see all the way around.
  2. An encoder on the servo shaft tracks the angle; a slip ring carries the sensor wires through the rotating joint.
  3. The microcontroller samples both sensors, pairs each reading with the current angle and direction, and sends a short frame over serial.
  4. The Processing sketch converts each reading to centimetres, places it at the right angle, and paints it on a green radar display with range rings.

Hardware

MicrocontrollerFreescale MC9S08QE128 (HCS08, 8-bit) on a DEMOQE128 board; ~4.2 MHz internal bus clock
Scan driveContinuous-rotation servo on a 50 Hz PWM (TPM1), swept by ramping the pulse width 500–2500 µs
Angle feedbackShaft encoder into a keyboard-interrupt (KBI) pin, counted in firmware
Sensors2 × Sharp analog IR distance sensors, back-to-back, read on ADC channels 0 and 1
LinkAsynchronous serial (SCI) to the PC at 9600 baud
ExtrasSlip ring for continuous rotation; a hand-wired board for sensor and encoder signal conditioning

Close-up of the sensor bracket: two black Sharp infrared distance sensors bolted to an aluminium bar on top of the servo

The hand-wired perfboard with two DIP ICs and many resistors that conditions the sensor and encoder signals

Firmware

Written in CodeWarrior for HCS08 with Processor Expert generating the peripheral drivers. The work splits between three interrupts and a small state machine:

  • Servo sweep — a timer interrupt ramps the servo pulse width by a fixed step each tick and flips direction at the 500 / 2500 µs limits, so the head oscillates across the scan arc.
  • Encoder count — the KBI interrupt increments an angle counter on every encoder edge. It is kept as two bytes (rolling the low byte at 124) so it survives the byte-oriented serial link.
  • Measurement tick — a timer interrupt nudges the main loop from WAIT into MEASURE.

The main loop then runs MEASURE → SEND → WAIT: read both ADC channels, then transmit one framed packet —

'C'  count_hi  count_lo     encoder counts
'D'  direction               sweep direction
'A'  sharp1  sharp2          the two ADC readings
'E'                          end of frame

The Radar Display

The Processing sketch (in GUI/) opens the serial port, parses each frame and:

  • rebuilds the sweep angle from the encoder count and direction (about 230 counts across the ~180° arc);
  • converts each raw ADC value to centimetres with a per-sensor exponential fit of the Sharp response — e.g. distance = 89.41 · e^(-0.04 · adc) + 6.41 — the curves fitted in Ecuaciones sharps.xlsx;
  • plots the two sensors 180° apart, so one sweep of the servo fills the whole circle;
  • draws it all on a green scope-style display with range rings at 10, 30, 60 and 120 cm and a rotating sweep bar.
The IRDAR radar display running on a monitor, showing the sweep bar and two short arcs of detected points from the two sensors

The display running live, with obstacle points picked up on both sides of the sweep.

Notes

  • Built on the HCS08 / CodeWarrior / Processor Expert toolchain, all now legacy — the design ideas carry over to any small MCU with a timer, an ADC and a UART.
  • The serial frame is parsed by fixed byte position, so a sensor or count byte that happens to equal a delimiter letter can misalign it; a length-prefixed or escaped framing would be more robust.
  • The two-Sharp / 180°-offset trick trades a full second sensor for full-circle coverage from a half-circle sweep — neat, but the two sensors need matched calibration.
Posted In:
Embedded Software