Relay Trainer

Relay Trainer

Design Relays
Circuit Design
Conditional Logic
Instruction Set
Usage Keypad/Display
Serial Console
Example Programs
Software Tools
Build/Dev Log

Project page

Relay computer "trainer"

Click for high resolution

The idea behind this project is to make a low relay count, single board computer similar to the single-board trainers of the early microcomputer era which can be mass produced for a reasonable price.

Relays are expensive and large, so primary importance is given to keeping the relay count low. The basic strategy is implement just the CPU and some basic I/O using relays, but implement the memory and front panel user interface with semiconductors. The CPU is designed using low cost DPDT DIP relays. The front panel and memory are implemented using Microchip PIC microcontrollers.

Architectural and circuit design tricks keep the relay count for the CPU low. The Relay Trainer uses edge-triggered D flip-flops implemented with just 1.5 DPDT relays / bit. Multi-port memory reduces the number of required register bits. Self-modified code (borrowed from very early computers) keep the number of registers and logic gates needed to an absolute minimum while still maintaining an interesting instruction set.

Here are some of the basic characteristics of the Relay Trainer:

  • Relay count: 83
  • Datapath width: 8 bits
  • Instruction width: 32 bits
  • Instruction type: two-address (each instruction specifies two memory locations and the result is written back to one of them)
  • Memory size: 256 32-bit words (1 KB)
  • Registers: 13 bits total including 8-bit Program Counter, 1-bit carry flag, 4-bit output register
  • Performance: one cycle per instruction, up to ~12 Hz for ~12 instructions per second
  • I/O: 4 switch closure inputs and 4 relay contact outputs brought to screw terminals. Programs can also read from keypad and serial console and write to serial console.
  • Supported concepts:
    • Subroutines (supported with self-modified code: the return address is inserted into a jump instruction)
    • Indexing (supported with self-modified code: the index is inserted into a memory reference instruction)
    • Multi-precision arithmetic
    • Multiply and Divide implemented as subroutines
    • Complete set of conditional jumps (altough there are no Zero or Negative flags, a memory word can be tested for zero and negative)
    • Single-instruction loops with "incjne" (increment and jump if not equal to zero) instruction

Other basic features:

  • Keypad and LED display allows you to:
    • Display and modify memory
    • Halt / run and single step
    • Vary clock speed (15 pre-programmed speeds or use knob)
  • Discrete LEDs
    • Show current 32-bit instruction given to CPU
    • Show two 8-bit operands fetched from memory
    • Show current program counter value
    • Show 8-bit data being written back to memory
    • Show carry flag and condition logic result
    • Show input and output port bits
    • Show the clock
  • Uses hard drive molex connector for 12V and 5V power. Small switching power supplies for hard drives for IDE/SATA to USB converter kits are widely available at low cost.
  • 512 bytes of Non-volatile memory is provided to save and restore the RAM
  • Serial port provided for 9600 serial console
    • Built-in assembler, disassembler and instruction trace display
    • Load or save programs by cutting and pasting into terminal emulator window
    • Provides 6-pin Arduino logic-level RS-232 header for use of widely available USB to TTL RS-232 converter cables
  • The relay clock is stopped when the CPU halts: this saves the life of the relays. The clock resumes if you press the step or run buttons.

Yes, there are videos! Check out the example programs page.

I'm selling some of my prototypes on eBay: search for "Relay Computer Trainer"

Homebuilt CPUs WebRing

JavaScript by Qirien Dhaela

Join the ring?

To join the Homebuilt CPUs ring, drop me a line, mentioning your page's URL. I'll then add it to the list.
You will need to copy this code fragment into your page.
Note: The ring is chartered for projects that include a home-built CPU. It can emulate a commercial part, that′s OK. But actually using that commercial CPU doesn′t rate. Likewise, the project must have been at least partially built: pure paper designs don′t rate either. It can be built using any technology you like, from relays to FPGAs.