Microcontroller and PLD projects

PIC (Microchip)
68HC11 (Motorola)
GAL20V8, ISP1016 (Lattice)


From time to time people ask for schematics. Sorry, I don't have any. Read the source file for information about connections and additional components. This should be enough to build a project, if you have some experience in electronic assembly. Anyway I don't publish my projects to copy them, but to give you some ideas and code examples for your own projects.

PIC (Microchip)

USB Bootloader

A serial pic18f2550 bootloader that directly accepts Intel hex data. The interface is based on Microchip's CDC example and available for the application through some simple calls at fixed addresses. Leaves plenty of room for the user's application. No need for a C-Compiler. No external USB chip. Saves the USART. For details please have a look at usbolo.asm.
Two little examples show how to use USB by polling or interrupt. Windows requires an inf file for installation. An incomplete USB suspend and stolen Vend/Prod-IDs make the hole thing suitable only for lab use. Meanwhile Microchip has released new PICs with USB; I've adapted the bootloader for the 20 pin device 18F14K50 and for a cristalless 18F25K50.

Bit rate converter

The eight pin device PIC12F683 has no built-in UART but is used here to convert the bit speed of an asynchronous serial port. baud.asm implements bit banging receive and transmit in the range of 9600bps to 38400bps. For down conversion up to 64 bytes can be buffered. Conversion in two directions (RX and TX) is possible when two such chips are used. The picture shows an application where an USB serial port is turned into a MIDI interface (the FTDI FT232R can communicate with 31250bps directly, but usually that speed is not supported by serial drivers).

CNC controller

A PIC16F88 based three axes controller for Trinamic TMC246 stepper motor drivers: cnc.asm. The RS232 interface supports commands for initializing, positioning, drill motor switching and status reading. Communication uses readable characters and coordinates are signed decimal numbers. Simultaneous movement of X and Y axes for drawing of free angled lines. I used the controller to build a little drilling/engraving machine with drawer slides and 1mm-pitch screws. Here are some views from the front, the back and the bootom. For working with HPGL plot and Excellon drill files I've written a small program for linux. This program can also act as a controlling terminal, drill 5x7 matrix text and generate previews in PostScript format.

Simple 16F88 programmer

Yet another PIC programmer: pp88.asm. A PIC12F629/675 receives hex records from an asynchronous serial port and converts them to program the PIC16F87/88. Host software is not required! (the PIC16F88 is a worthy successor to the famous PIC16x84 with larger program memory, more RAM, more EEPROM, more timers, wide supply range, USART/SCI, analog comparators and a 10bit ADC, with internal reset and oscillator circuits to save money and get extra pins for I/O). picture

Serial to i2c converter

The outstanding advantage of i2c devices is the low pincount needed for communication. Here is a serial interface for the i2c bus which comes in handy when attaching measurement and control circuitry to a laptop or PDA. Two pins are used to select the bit rate from 1200bps to 9600bps. Please read the source file s2i.asm for a description of connections and the simple serial protocol. There is a picture of a test setup with an MCP2150 IR interface and a PCF8591.

To reduce part count in simple applications there is a modified version s2i_b.asm with inverted txd/rxd signals: No RS232 driver is needed and only a resistor at rxd. Pin layout has changed and bit rates are higher. Another picture shows this version under test with a 24C16.

Graphics display driver

Adds a serial interface to a MGLS12864T 128x64 dots LCD module with the T6963 controller. display.asm implements the Bresenham line algorithm and font drawing in two different sizes. The negative LCD voltage is produced by a MAX232 line driver that is needed anyway. The PIC16F88 has an internal oscillator, enough program memory to store the font, and RAM for a 256 bytes receive buffer.

Silent flute

A flute with an air pressure sensor and momentary switches controlled by a PIC16F876. It is not suited to become an expert in flute playing: fingering can be learned but blowing technique is very different. When used with earphones you can practice without annoying anybody. flute.asm implements a MIDI output and a square wave tone generator. The picture shows the flute together with a plastic prototype and a closer look to some switches.

Piano trainer

The device receives midi data and can record note-on messages to an external eeprom. In play mode the keys that have to be played next are indicated on a 2x40 character LCD. When all required keys have been played the next accord is shown. This is useful to learn playing a song and to check whether a song is played without missing notes. There is also a midi monitor mode to analyze midi data (useful in some of my other midi projects). The modes play/record/monitor are entered with key hits normally not used when music is played. piano.asm picture

Electronic barrel organ

A song is played according to the rotation speed of a cranc.

First version barorg.asm was realized with a pic 16C71 and a 2kByte eeprom in a small box with an AC motor to take the crank speed, midi in/out connectors for record/play, a dc supply connector and a momentary switch to enter record mode or change voice.

The first quick and dirty version was quite funny so I decided to create an enhanced version barrel.asm with a pic 16C73. The new device was built into a hifi speaker box. A sound module and an audio amplifier were included and everything is powered from the crank driving a bike dynamo. More song storage was provided, the box can merge midi data and may be used as a midi expander (to connect a midi keyboard or my drum trigger to midi interface).

Autoranging frequency meter

Measures 0.900Hz to 30.00MHz with a PIC16F84. Unlike in a simple frequency counter frequency is calculated from cycles and time to get a high resolution also for low frequencies. The display is rounded to four decimal digits so oscillator adjustement is not required. Because the PIC timer prescaler can handle frequencies above the processors clock a 4MHz rated PIC is sufficient. Two display types are supported: Hitachi LM054 8-digit LCD (low power consumption) or Siemens DL1414T 4-digit LED display (small size). fmeter.asm

Power switch controller

The main purpose of this device is to turn off my PC (AT power supply) after some delay giving linux time to shut down. It is also used to control the power of other devices from the PC. Four outputs are controllable over a serial input (RS232) and with buttons. The buttons may be locked from the serial interface. Switching commands may be delayed up to 255 seconds. switch.asm

Remotely controlled switches

A 12C509 controller for 418/433MHz RF transmitters/receivers. FM coding for tolerant clock regeneration allows using the internal oscillator. A mode pin determines whether the device is used as a transmitter or a receiver. remote.asm

A second version does only control a single output but includes zero crossing detection to drive a triac or a random switching solid state relais. When configured for full brightness at power up, lamps may be still switched by a mechanical switch or a timer. Brightness may be set absolutely, incremented, decremented or toggled between off and the last setting. dimm.asm

Alarm clock

An alarm clock using the DCF77 time base (Germany). There is no backup battery needed since timer settings are stored in the PIC16C84 eeprom and the time is radio controlled. For a flickerfree display all idle time of the controller is used for updating the Hewlett Packard HDSP-2000 4 digit 5x7 led matrix. clock.asm

Color-Checker with RS232 interface

Three leds of different wavelengths are directed to the measured surface and the reflected light is measured with a photo diode. Leds are pulsed for low power consumption. A PIC16C71 is used and communicates over a PC serial port without RS232 drivers. The supply current is taken from the PC's RTS signal. Measurement of color is a difficult problem and this simple device is far from perfect: light spectrum of leds is not photometric and not stable with temperature, a photodiode is not very sensitive to blue light, the result has a low resolution etc. rgb.asm

Children night display

A flat box showing 11 illuminated stars and a moon (LEDs). When children go to bed all 12 lights turn on; then every hour a star is turned off and finally also the moon. This was built because my children used to get up in dark night just to ask how long it will take until breakfast. The clock is radio controlled so it does not need an interface to set the time. The leds are multiplexed: receiving the time without disturbation is only possible when leds are idle. night.asm

Chromatic tuning fork

A small device with a push-button, 12 leds, a speaker and a microphone. Some circuit details are included in the source. The single button can turn on the device, check the battery state, sound the selected tone and select the next note! The leds show the selected note and if a signal comes from the microphone show the interference pattern with the built-in generator. Automatic shut off when idle for five minutes. The code tune.asm for the PIC16C71 was initially written for the old MPALC assembler but this is a revised edition for MPASM or GPASM. picture

RS232 LC-Display

Display data from an asynchronous serial port on a 2x40 character LCD. Carriage return, newline and formfeed are treated specially. Since pins A0 to A3 are not used I took a saw, shortened (!) the PIC and got a DIL-14 device. The 3mA to supply the PIC and the LCD are taken from the RS232 data input with a bridge rectifier (the device ground must be left floating). The source code lcd.asm is for the old MPALC assembler.

68HC11 (Motorola)

The 68HC11A1 or 68HC11E1 have 256 Bytes eeprom that may also be used for program code. Simple devices may be created without attaching external memory. The HC11 has a special bootstrap mode to load code to ram and execute from there. The program eeprom.a can then be used to receive code and store it permanently in eeprom. When the asynchronous serial port tx and rx are tied together a reset will execute code from eeprom. External logic is necessary when the serial port is still needed. See the HC11 reference manual for details.

Drum trigger to MIDI interface

Using seven analog to digital inputs of the HC11 as drum trigger inputs allows for keeping external part count low. A potentiometer is attached to the eighth adc input to vary metronome speed and to select different sounds for two trigger inputs. Foot switches are used for kick drums and high-hat. I use a roland v-drum trigger pad for the snare drum and some yamaha rubber pads. drum.a

LED time display

A small 4 character time display. The HDSP-2000 LED matrix allows using a readable font and the red dots do not illuminate the bedroom like green displays. The clock receives the DCF77 time base. A later version using a PIC controller added some timer functions (see the PIC alarm clock). I use this to keep orientation in time space when sleeping was interrupted at an inconvenient time. clock.a

DCF77 radio clock tester

Generation of a DCF77 time telegram (time adjustable, date fixed). The output modulates an 77.5kHz oscillator driving a ferrite arial. Do not attach a transmitter with high power output: Public time in middle Europe is often based on DCF77 receivers. funky.a

GAL20V8, LSI1016 (Lattice)

Stepper motor controller

Expand the PC parallel port to control up to four stepper motors: step.gal I used this to build a drilling machine for PCBs. The machine is also good enough to engrave name plates. Three stepper motors are used for X/Y/Z axis. A free output switches the drilling motor. Each axis has a switch at one end for position sensing. X/Y axis use an M6 screw with a gradient of 1mm. Unfortunately the motors I got had 96 steps per rotation. The controlling program has been developped with DOS GCC (DJGPP) to interpret excellon drill data and a subset of HPGL. picture

Video test generator

An ispLSI1016 is externally clocked by an 8MHz oszillator. Four data outputs and a synch output produce a gray scale 50Hz interlaced test image with 16 shades of gray and the word TEST in the center. Outputs are coupled with resistors to a npn emitter follower. Voltage is attenuated with two 150ohm resistors to get an output impedance of 75ohms. bas.ldf

(updated: 2013-May-28)