Robotic Stock Car - How to Guide

Using Modulated IR to start the robot

A single chip modulated IR detector, such as the Sharp IS1U60 , will allow your robot to detect a modulated IR signal. The Handy Board comes with one of these automatically, and you can also buy them from Jaycar, Dick Smith, etc. It is a small square device with an oval bubble on the front, made of green plastic, with three pins - 1: control, 2: ground, 3: Vcc.

The diagram below is taken from the Handy Board's schematic list. TIC1 is a pin of the CPU (a M68HC11). The 47k resistor is to pull the normal control voltage up to +5v (read FALSE), as the output of the beacon is active low. When a beacon is detected, the control pin will be 0v (read TRUE). The beacon transmits in pulses - on for 1ms and off for 1ms repeatedly.

The Handy Board will actually decode a valid Sony transmission (read on below). For other circuits you may be content to check for a change in the control signal from FALSE to TRUE and back.

Handy Board instructions

To use the infrared function, the file sony-ir.icb must be loaded into Interactive C. This file may be added to the Handy Board default library file, lib_hb.lis. Please make sure that the file r22_ir.lis is not present in the lib_hb.lis file.

The sony-ir.icb file adds the capability of receiving infrared codes transmitted by a Sony remote, or a universal remote programmed to transmit Sony infrared codes.

int sony_init(1)
Enables the infrared driver.

int sony_init(0)
Disables the infrared driver.

int ir_data(int dummy)
Returns the data byte last received by the driver, or zero if not data has been received since the last call. A value must be provides for the dummy argument, but its value is ignored.

The infrared sensor is the dark green component in the Handy Board's lower right hand corner.


The sony-ir.icb file and its accompanying sony-ir.txt are available for downloading. The file works with my copy of Interactive C (version 2.86) but I haven't tested it with earlier versions.

Basically my "main" from the robot code that used the beacon to start went like this:

void main()
{
  int pid1, pid2;

  sony_init(1);

  while(1) {

    beep();

    /* Wait for start IR signal */
    while(!ir_data(1));

    /* Perform sumo behaviour */
    pid1=start_process(arbitrate()); 
    pid2=start_process(motor_module()); 

    /* Wait for stop button */
    while(!stop_button());
    while(stop_button());

    /* Kill processes */
    kill_process(pid1);
    kill_process(pid2);

    rest();
  }
}

Don't forget to load the sony-ir.icb file - either load it manually each time with "load [path]/sony-ir.icb" at the IC prompt, or add it to the "lib_hb.lis" file that comes with IC, so that it will be loaded each time IC starts.