This archive/directory contains all information required to build and use a
RS-232 Infrared Remote Control. This device permits you to control various
equipment normally controlled via I/R "remotes" from your computer.

This is a *VERY* simple I/R remote. The component count has been kept to
the bare minimum. The down side is that it will not work will *ALL* remotes,
however it should work with any system that uses a 38 or 50 Khz carrier,
and transmits its codes as a single repeating bit pattern. The design allows
for 115 on/off transitions in a single code pattern. This covers the majority
of I/R remote protocols.

The IR-232 does not store I/R codes. It interfaces to a host computer via
a serial port, and communicates the codes with the host as data frames.
This provides the maximum flexibility at minimum hardware cost. Example
MICRO-C programs are provided to communicate with the IR-232.

IR-232 Kit - Files:

   README.TXT   - This file
   IR232.ASM    - Firmware source code for the IR-232 **
   IR232.MOT    - Firmware download image (Motorola format)
   IR232.INT    - Firmware download image (Intel    format)
   IR232.DWG    - Schematic drawing of RS-232 IR remote control
   IREDIT.C     - MICRO-C Source to IR code editor
   IREDIT.COM   - Executable IR code editor
   IRDEMO.C     - Example MICRO-C program showing how to transmit IR codes
   IRDEMO.COM   - Executable example program

** The firmware source code is not included in the "freely distributable"
   version of this project. It is available on my PROJECT KITS disk.

Dunfield Development Services (DDS) offers software and firmware
development services specializing in systems and embedded applications.
For more information, visit: http://www.dunfield.com


IR-232 parts list:

   Qty Description
   --- -----------
    1  8031 microcontroller IC      *1
    1  2764 8K EPROM IC             *1
    1  74LS373 Octal Latch IC       *1
    1  MAX-232 5V RS-232 driver IC  *2
    1  74LS00 Quad NAND gate IC
    1  11.059 Mhz crystal
    1  10uf 10v capacitor
    4  10uf 16v capacitor           *2
    1  10K ohm 1/4w resistor
    1  20K ohm 1/4w resistor        *3
    1  150 ohm 1/4w resistor        *4
    2  120 ohm 1/4w resistor
    1  0.01 uf capacitor            *3
    2  SPST N.O. pushbutton switches*4
    1  Visible (red) LED            *4
    1  I/R L.E.D.                   *3
    1  I/R photodiode               *3
    3  Jumper pins and plug sets

*1  The IR-232 can also be constructed with an 8051 microcontroller, with
    the firmware placed in internal ROM. In this case, the 2764 and 74LS373
    IC's are not required. The EA pin (39) of the 8051 should be tied to
    +5V in order to execute from the internal ROM.

*2  The MAX-232 IC, and 4 of the 10uf caps can be replaced with any other
    suitable RS-232 driver circuit.

*3  The R/C values should be adjusted to eliminate the 38Khz carrier, and
    provide the 8051 with a clean data bit stream. These values may differ
    depending on the I/R devices used (I scavenged the LED & Detector from
    a dead floppy disk drive).

*4  The indicated parts are not required if the optional manual testing
    feature and busy LED are not required.

Bypass capacitors should be placed across power rails or all IC's.

A complete schematic diagram for the IR-232 is contained in the file
IR232.DWG. You may view/print it with my MICROCAD drawing package:

     MICROCAD IR /D    <- View on VGA monitor
     MCPRINT IR LASER  <- Print on HP laserjet series (LPT1)
     MCPRINT IR EPSON  <- Print on EPSON dot matrix (LPT1)

MICROCAD is available "free" from my WEB PAGE and DEMO disks, as part
of the EMBEDRAW package. For details on editing the drawing, or printing
it to devices attached to different ports, see the MICROCAD documentation.

IR-232 Firmware: **

The 8051 ASM source code to the IR-232 is provided on this disk in
a file called IR232.ASM You can re-compile this using the DDS 8051 Cross
assembler from the 8051 developers kit. I have also provided ready-to-go
download files in both Intel and Motorola format.

IR-232 Jumpers:

The IR-232 has three jumpers, which operate as follows
(0=Jumper closed, 1=Jumper open):

    J1  J2  J3
    0   0   x   - Default 'R'epeat count = 1
    0   1   x   - Default 'R'epeat count = 2
    1   0   x   = Default 'R'epeat count = 3
    1   1   x   = Default 'R'epeat count = 5
    x   x   0   = 50Khz I/R carrier *
    x   x   1   = 38Khz I/R carrier *

* If J3 is closed, all operations are forced to 50Khz. If left open,
  default is 38Khz, and software may select I/R carrier frequency via
  the 'H' and 'N' commands. When J3 is open, P1.3 on the 8051 will
  indicate the currently selected mode (0=50Khz, 1=38Khz).

If you use a 4-bit DIP switch for the jumper settings, use the extra
switch to activate the "AGAIN" function. This provides a convient test
mode where the IR-232 continuously sends an I/R code.

IR-232 Serial Interface/Commands:

The IR-232 operates at 9600 BPS, 8 data bits, 1 stop bit and no parity.
When the box is ready to accept a command, it prompts with '.'. When
you send a command, you should wait for the '.' before attempting to
send another command. If any error should occur in the execution of a
command, the box will send '?' instead of '.'.

'L'earn an I/R code

To learn a remote code, send 'L' to the IR-232, after which it will
hang waiting for an I/R code. The "busy" lamp will be lit indicating
that the IR-232 is executing a command. Butt your existing remote up
to the I/R photodetector and press the key you wish to learn. The
IR-232 will send the following data pattern: *<length><data...><gap>

    '*'         - Indicates successful reception of the I/R code
    <length>    - Length of <data...> in bytes
    <data...>   - Encoded I/R bit pattern (multiple bytes)
    <gap>       - Timing between successsive patterns

Note that <length>, <data...> and <gap> are binary codes, and may
consist of any byte value from 00-FF. Typical I/R codes generate
about 20-30 bytes of <data...>.

Depending on the manufacturers I/R protocol, the positioning of the
remote during learning can be quite "fussy". The IR-232 and remote
should be placed on a table so that once you find a position that
works you can leave them while learning all codes. If you cannot
get the system to work reliably, you may need to experiment with the
R/C values in the photodetector circuit.

'S'end an I/R code

To transmit a previously recorded I/R code, send 'S' to the IR-232,
followed immediately by the <length><data...><gap> values that were
recorded by the 'L'earn command (Do not send the '*'). The IR-232
will regenerate the I/R code, transmitting it the number of times
configured by the 'R'epeat command (see below).

'R'epeat configuration

Many I/R devices require that a command be sent multiple times before
it is recognized. This helps prevent interpreting stray I/R signals as
valid codes. To accomodate these devices, the IR-232 can be configured
to transmit each code from 1 to 256 times. To configure this parameter,
send 'R' to the IR-232 followed immediately by the transmit count (01-
255, or 00 for 256).

'A'gain - retransmit last code

This command takes no operands, and simply causes the IR-232 to
transmit the last I/R code that was 'L'earned or 'S'ent. It provides
an efficent way to transmit one code multiple times without having
to reload it every time.

'H'igh - Set 50Khz mode

This command selects an I/R carrier frequency of 50Khz for all further
operations.

'N'ormal - Set 38Khz mode

This command selects an I/R carrier frequency of 38Khz for all further
operations. An error will be reported if jumper J3 is installed.

Two example MICRO-C programs for the PC which interface with the IR-232 are
included in this archive: IREDIT.C performs both learning and transmitting
functions, while IRDEMO.C contains minimal functions for transmitting only
(the usual application).

IR-232 Manual testing:

The firmware supports two manual buttons and a "busy" LED, which make
it possible to test the device without a computer attached. One button
activates the 'L'earn function, and the other activates the 'A'gain
function. To test the IR-232, press LEARN, the busy LED lights, butt
a remote to the I/R detector and press a key. If the code is received
properly the busy LED should go out. Then press AGAIN to transmit the
code. This should activate the function of a nearby I/R controlled
device.

IREDIT Utility:

The IREDIT program included with this package allows you to record I/R
codes to a file, for later use by applications which transmit those codes.
The syntax of the IREDIT command is:  IREDIT filename [comport]

'filename' is the name of the file you wish to create/edit, and 'comport'
is the PC communications port to which the IR232 device is attached (1-4).
If not specified, IREDIT will assume communications port 1.

If the file you specifiy already exists, IREDIT will load any I/R code
definitions from that file. You can use the UP and DOWN arrow keys to
move back and forth between the codes that are recorded. HOME will move
you to the first code, and END will move you to the last code. As you
select each code, IREDIT displays the code number (0-n) along with the
data length, gap length and data bytes for that code.

The following commands are available, and are activated by pressing the
first character in the command name:

  D)elete - Deletes the code currently being displayed. All subsequent
            codes are moved back.

  I)nsert - Inserts a blank code ahead of the code currently being
            displayed. All subsequent code are moved ahead.

  N)ew    - Records a new code, assigning it the next available code
            number. You will be prompted to press a key on the remote
            control (which must be positioned against the IR232 I/R
            receiver). Afterwards you are positioned to the new code.

  P)lay   - Transmits the code currently being displayed.

  R)ecord - Records new data for the code currently being displyed.

  (esc)   - Pressing the ESCAPE key prompts with the exit menu. Select
            one of R)esume editing, S)ave file (and exit), or Q)uit
            without saving.


All programs, documentation, source code and other information on this
disk is copyright 1994-2005 Dave Dunfield. All rights are reserved.

