Introduction:

  PC-REMOTE is a simple learning infrared remote control application which
  runs under DOS. While not particularly useful as a general remote control
  (Even laptops are a touch big to hand-hold), it provides a convienient
  way to record, archive and share remote control codes.

  PC-REMOTE was designed to work with IR devices which operate with an IR
  carrier of 36-40 khz which covers the vast majority of consumer equipment.
  It works by recording and playing back the raw on/off transitions of the
  remote which means it *should* work with "most anything" regardless of
  the actual IR protocol employed.

There are however a few caveats:

- The carrier generated by PC-REMOTE via the PC serial port is at a
  frequency of 38.4 khz - this should be be close enough to work with
  most devices, however if your equipment is particularly "fussy" about
  the IR frequency, it may not be compatible.

- Due to the tight timing requirements, especially during IR code recording,
  it is best run run PC-REMOTE under a clean (no TSRs) copy of pure DOS.
  Although pure-DOS systems are increasingly uncommon these days, PC-REMOTE
  can be easily placed on a bootable pure-DOS floppy disk.

- The RS-232 spec. allows voltages in the range of +/- 3-25v as a valid
  signal. Most PCs use a voltage in the range of 10-12v. Some equipment
  (noteably laptops) provide a low voltage on the COM connector and you
  may need to adjust the IR emitter/detector accordingly.


Hardware requirements:

  PC-REMOTE requires a 486 or better PC with at least one 82x50 based
  serial (COM) port. Serial ports build into mainboards and ISA expansion
  cards are almost always the right type. USB serial adapters and other
  non-standard serial hardware will NOT work.

  PC-REMOTE uses an easy-to-build IR adapter connected to the serial
  port. Details of this adapter are provided in the next section.


Building the IR adapter:

  The IR adapter consists of an IR emitter (LED), IR detector (photodiode),
  visible LED, three diodes and two resistors:

                                      //
    IR Emitter:     TXD   ---->|-----[>|]-----/\/\/\/--- GND     
                             Diode  IR LED      1K


    IR Detector:    DTR   ---->|-----------[>|]--------- DCD     
                             Diode    IR photodiode

                                      //
    Busy LED:       GND   ---->|-----[>|]-----/\/\/\/--- RTS
                             Diode    LED       1K

  The separate sections shown above are optional - if you do not care
  about a busy indicator on the IR interface, you can leave it out. If
  you only want to play IR codes that have been recorded elsewhere, you
  do not need to build the detector circuit.

  None of the components are critical. The IR emitter and photodiode can
  be salvaged from an old diskette drive with optical index sensor, or the
  optical decoder from a mouse. The diodes can be any general purpose small
  signal diode (such as IN4004).

  For reference - here are the PC serial connector pinouts (viewed from
  rear of PC):

                    PC (25 pin)                              AT (9 pin)
  1   2   3   4   5   6   7   8   9  10  11  12  13      1   2   3   4   5
   14  15  16  17  18  19  20  21  22  23  24  25          6   7   8   9

      Signal name               Origin   25-Pin(PC)  9-Pin(AT)
      --------------------------------------------------------
      Protective Ground   (GND)   ---         1          -
      Transmit Data       (TXD)   DTE         2          3
      Receive Data        (RXD)   DCE         3          2
      Request To Send     (RTS)   DTE         4          7
      Clear To Send       (CTS)   DCE         5          8
      Data Set Ready      (DSR)   DCE         6          6
      Signal Ground       (GND)   ---         7          5
      Data Carrier Detect (DCD)   DCE         8          1
      Data Terminal Ready (DTR)   DTE        20          4
      Ring Indicator      (RI )   DCE        22          9


IR Emitter - Description of operation:

  The PC holds TXD at -10v when idle. The diode prevents reverse BIAS
  of the IR LED during this off condition. When transmitting IR pulses,
  TXD swings to +10v, forward biasing the diode and providing current
  to the IR LED. The 1K resistor limits the current, protecting the IR
  LED and the COM port output driver.

  - With the 1K resistor, the IR output is fairly low - you will have
    to place the emitter fairly close to the equipment IR detector.
    Lowering this resistor value will increase output and range - to an
    extent, however low resistor values will load the COM port excessively.
    For a "full range" IR remote, you could use a switching transistor and
    external power supply driving an array of IR LEDs, each with it's own
    current limiting resistor.


IR Detector - Description of operation:

  The PC holds the DTR output high (+10v). When the IR photodiode is
  exposed to an infrared source, it conducts raising the voltage of
  the DCD line indicating the presense of IR to the PC. The diode serves
  to block reverse bias to photodiode in the event that DTR is deasserted.

  - This circuit assumes that the DCD input assumes "false" when not
    driven, and that the idle current of the photodetector is not enough
    to trigger it. If this is NOT the case, you may need to add a 10k
    resistor between DCD and RTS (PC-REMOTE holds RTS low during IR
    operations).

    When idle, PC-REMOTE scans the IR detector, and displays "IR" at
    the lower right-hand corner of the screen when in infrared signal
    is detected - this can be used to check for proper operation of
    the detector.

  - The detector should filter the 40 khz carrier, and present only
    the On/Off transitions of carrier at the DCD input. With DCD
    unloaded, I find the capacitance of the PC serial hardware and
    cable sufficient, however for some PC ports, especially if you
    add the 10k resistor described above, you may need to place a
    small capacitor between DCD and GND.

    After capturing a remote code, use the S)how command to look at
    the transition list. Many small values (<5) may indicate that
    more filtering is required at the DCD input. Also, if codes are
    recorded, but not recognized by the equipment, you may need to
    add filtering to this input.

  - Some IR detectors are sensitive to visible light:
    - You may need to shield the IR detector in a small dark tube to
      limit the field of view.
    - If you add the optional busy LED, make sure the output of the
      LED does not fall on the IR detector.


The PCRMT program:

  Use:    PCRMT [file[.RMT] [code# | Ddelay | Rrepeat]...] [options]

  Opts:   /I[*]           = disable Interrupts when active
          B=#             - set Burst                             [4]
          C=1-4           - set Com port                          [1]
          D=#             - set inter-code Delay                  [500]
          H=ACLR          - set Hotkey (Alt/Ctrl/Lshift/Rshift)   [LR]
          O=#             - set Offset                            [20]


Command line options:

  When capturing or playing an IR code, PC-REMOTE has to service the
  serial port every 12 microseconds - on very slow machines, the timer
  and other interrupts can interfere with this servicing. The /I option
  causes PC-REMOTE to disable interrupts when performing an IR operation.
  Following the operation, PC-REMOTE will reset the PC clock to the
  value of the CMOS clock if they differ by more than one second. If
  your system has a non-standard CMOS clock, you can use the /I* form
  to disable interrupts without resetting the clock.
  NOTE this option can cause your computer clock to lose a small amount
  of time which will be corrected the next time you reboot.

  B= Burst indicates how many "bursts" of IR transitions will be recorded.
  Most remotes send data in bursts with longer gaps in between, and often
  the complete IR code is made up of more than one burst.
  - If Burst is too low,  IR codes will be incomplete and not work.
  - If Burst is too high, IR codes will be larger than necessary.
  The default value of 4 works with most systems. Try increasing it if you
  cannot get codes to work. If you wish to minimize the size of the .RMT
  data file, try reducing Burst until you find the point where codes stop
  working reliably. The Burst setting affects recording only.

  C= selects the PC COM port (1-4) which will be used for the IR device.
  NOTE: Only "real" 82x50 COM ports can be used.

  The filtering of the DCD input, and the transmit buffering of the 8250
  serial port tend to lengthen the IR-ON times, shorten the IR-OFF times,
  resulting in a distorted signal on playback. The O= Offset parameter
  compensates for this by reducing the IR-ON time and lengthening the IR-
  OFF times by this amount (intervals of 12 microseconds). If you are
  having difficulty playing codes reliably, try adjusting the Offset value.
  NOTE: Offset can be specified as a negative value in which case it will
  lengthen the IR-ON time and shorten the IR-OFF time (you shouldn't have
  to do this). The Offset setting affects playback only.

  PC-REMOTE uses a HOTKEY sequence to activate certain functions. This
  consists of a combination of Alt, Control and Shift keys. The default
  hotkey is both shift keys together, however this may conflict with the
  hotkey sequence used by some TSR's. You may change the hotkey sequence
  used by PC-REMOTE with the H= option using any combination of:
       A=Alt   C=Ctrl   L=Left-shift   R=Right-shift
  NOTE: Some PC BIOS have difficulty with combinations including CTRL and
  both shift keys. I can activate this on my machine only by pressing
  CTRL (and ALT if it is included), then Lshift, then Rshift, then
  releasing Lshift (before any other key).

  If a filename is specified on the command line, PC-REMOTE will load
  IR remote code definitions from it. Following the filename, you may
  specify one or more IR code indexes (1-75) - in this case, PC-REMOTE
  will play the corresponding IR codes from the file and then exit.
  The D= option specifies how long (milliseconds) to wait between each
  code when multiple codes are specified.

  When playing codes from the command line, the following special
  function sequences can be inserted into the code index list:
     Dn    - Delay 'n' mullisconds
     Rn    - Repeat the next code 'n' times


Interactive Operation:

  PC-REMOTE has two interactive modes, PLAY mode and EDIT mode.

  If executed with the name of an existing IR remote code .RMT
  file, PC-REMOTE will startup in PLAY mode. If no filename is
  given, or the file does not already exist, EDIT mode will be
  entered.


PLAY mode:

  In PLAY mode, PC-REMOTE operates much like a normal remote control,
  with the PC keyboard representing buttons on the remote. The remote
  code names and keyboard-keys assigned are shown on the screen.
  Pressing a key on the keyboard transmits the corresponding IR code.

  Key indicators are as follows:
    (ascii)             = Any ASCII character key
    ^A-Z ^[ ^\ ^] ^^ ^_ = Ctrl + ASCII key  ^[ = ESC, ^J = Enter
    &A-Z                = Alt  + ASCII key
    F1-F10              = Function keys F1 through F10
    SP                  = Space bar
    UA DA LA RA         = Up/Down/Left/Right Arrow key
    HO EN               = HOme ENd
    PU PD               = Page Up/Down
    IN DL BS            = INsert DeLete BackSpace
    K+ K-               = Keypad +/-
    ^LA ^RA             = Ctrl + Left/Right Arrow
    ^HO ^EN             = Ctrl + HOme/ENd
    ^PU ^PD             = Ctrl + PgUp/PgDn

  To switch from PLAY mode to EDIT mode, press the HOTKEY sequence (default
  is both shift keys at the same time). NOTE: To exit the program from PLAY
  mode, you must switch to EDIT mode first.

EDIT mode:

  In EDIT mode, you can record IR codes, assign activation keys and
  edit names.

  The following commands are available:

  Up/Down/Left/Right - Move cursor
    Positions the hilighted cursor over any one of the 75 possible IR
    code positions.

  E - Erase
    Erases the hilighted IR code entry - prompts for confirmation.

  G - Graphical display
    Displays the IR code streams graphically.
      Up/Down = Move selected entry by 1
    PgUp/PgDn = Move selected entry by 23 (1/2 screen)
   ^PgUp/PgDn = Move to first/last entry
    Left/Right= Move horizontal view by 5 pixles
   ^Left/Right= Move horizontal view by 62 pixles (1/10) area
        H     = Reset horizontal position
    Home/End  = Move transition indicators right/left by 1
   ^Home/End  = Move transition indicators right/left by 10
        T     = Reset transition indicators
      F1/F2   = Adjust display scaling factor by 1
      F3/F4   = Adjust display scaling factor by 20
       0-9    = Set display scaling factor to n*10
        P     = Play selected IR code
        S     = Slow/Skip repeated screen updates
          During "key down" repeated movements, some PCs cannot update the
          screen fast enough to keep up with the key repeat rate. In this
          case:
            Slow: slow down key repeat (you will see all screen updates)
            Skip: full speed repeat (some intermediate updates may be skipped)
        E     = Edit transitions in selected code entry
           Left/Right = Move transition indicator by 1
          ^Left/Right = Move transition indicator by 10
               T      = Reset transition indicator
             F1/F2    = Adjust value by +/-1
             F3/F4    = Adjust value by +/-10
             F5/F6    = Adjust value by +/-100
              INS     = Insert code pair
              DEL     = Insert code pair
               P      = Play IR code
              ESC     = Exit transition editor
       ESC    = Exit graphical display


  I - edit remote control Id
    The remote control Id is displayed at the top of the right hand portion
    of the screen and serves to identify the remote from which the codes
    have been recorded. See 'N'ame for edit keys.

  K - assign Key
    Assigns a keycode to the hilighted IR code entry. Prompts for
    you to press any key. The following keys can be used:
    - Any ASCII character key, including SPACE and ESC
    - Control: A-Z [ \ ] ^ _
    - Alt: A-Z
    - F1-F10
    - Up Left Down Right (arrows)
    - Backspace Insert Delete Home End PgUp PgDn Keypad+ Keypad-
    - Control: Home End PgUp PgDn Left Right
    To cancel without assigning a key, press the HOTKEY sequence
    (default is both SHIFT keys together).

  L - Load code definitions from file
    Prompts for file to load.

  M - Merge code definitions from file
   Similar to 'L'oad, except that:
   - Existing code definitions are not deleted
   - Codes numbers are ignored, and codes are assigned to first empty slot
   - 'T'itle is set only if not already assigned.
   Useful to combine two RMT files.
   Also useful to re-organize order of file items after manual rearrange.

  N - edit code Name
    Positions the cursor at the IR code name, allowing you to enter or
    modify the name. Available keys are:
      Delete     = Delete character under cursor
      Backspace  = Backup and delete (correction)
      Left/Right = Move cursor
      Home/End   = Move to begining/end
      PgUp/PgDn  = Clear entire/to-end
      Insert     = Toggle insert On/Off
      Enter      = Exit name editor

  P - Play code
    Plays the hilighted IR code entry through the IR emitter.

  Q - Quit PC-REMOTE
    Prompts for confirmation. If editing has been performed,
    confirmation screen will include filename which can be
    edited before pressing:
      ENTER = Save file and exit
      F1    = Exit without saving
      ESC   = Continue without exit

  R - Record IR code
    After pressing this key, hold the IR remote control close to the
    IR detector, and press the key to be recorded and assigned to the
    hilighted code. To cancel without recording a code, press the
    HOTKEY sequence (default is both SHIFT keys together).

  T - display Transition list
    Displays the transition list for the hilighted IR code. The transition
    list contains the IR-ON and IR-OFF times for the recorded code. Odd
    numbered codes (1, 3, 5 etc) represent IR-ON times, while even numbered
    codes (2, 4, 8 etc) represent IR-OFF times. Times are in intervals of
    approx 12 microseconds, and values are in hexidecimal.
      Up/Down/Left/Right/PgUp/PgDn/Home/End = Move cursor
      F1/F2 = Adjust value +/-1
      F3/F4 = Adjust value +/-10
      F5/F6 = Adjust value +/-100
       F10  = Toggle Hex/Decimal
       INS  = Insert code pair
       DEL  = Delete code pair
        P   = Play IR code
       ESC  = Exit

  Home/End  - adjust Offset value +/-
  PgUp/PgDn - adjust Burst  value +/-
    These keys provide a convienent means to tweat the Offset and Burst
    values "on the fly" - see command line options for meanings.

  HOTKEY - switch to Play mode
   Pressing the HOTKEY sequence (default is both SHIFT keys together)
   will switch to PLAY mode.


.RMT file format:

Remote codes are stored in a ASCII text (editable) ASCII file with the
extension .RMT, and having the following format:

index activation-key name
 transition-list
 ... as many lines as needed

'index' is the IR code index representing the screen position where the
code occurs, it ranges from 1 to 75. A value of 0 is a special case and
means that the remainder of this line contains the Title string.

'activation-key' is the key indicator for the key which must be pressed
in PLAY mode to activate the code.

'name' is the ASCII name for the code.

'transition-list' is the recorded IR transition list for the code. See
'T'ransition command for details.


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