Myke Predko's PIC Burner, and Software for Linux
PIC Microcontrollers (supplier) are cheap, versatile single-chip microcontrollers. They require very few external components (some require none, some need as few as a resistor and a capacitor for clock) and have many I/O lines which can be used as ADC, PWM, UARTs, or binary I/O. Each chip is a computer with built-in RAM and some ROM (EEPROM or FLASH) for holding your program. These chips can be used to replace hundreds of ICs in your design.
But, like any other computer, you must program it before you use it, and as these things don't have a nice disk drive or ethernet jack, you have to perform a special procedure to burn your program onto it's internal ROM.
In particular, I am using the PIC16 family of microcontrollers, which all use a variations of a strobed serial burning protocol. See the bottom of the page for specific processors I've tried this on.
I found the designs for the ElCheapo programmer on Myke Predko's page. It's a relatively simple design. However, his page lacks discussion of how the circuit works, software for linux to control it, and every email address listed on his site is invalid.
The circuit can be conceptually understood in two halves: the power supply and the buffer between the parallel port and the PIC.
The power supply is pretty simple. The zener diode below the 78L08 voltage regulator performs two roles. It first gives us a 5V supply used to power the hex inverter chip. The output voltage of the 78L08 is 8V above it's middle pin, and thus it outputs 13V. The light emitting diode and R9 form a pull up resistor for "turn-nMCLR-on" signal, and the 2N3906 acts simply as a switch. All capacitors in the circuit act to reduce the effects of transients from digital circuitry on the supply.
The buffer between the parallel port and the PIC--a bunch of open-drain inverters with pull-up resistors--seems pretty straightforward. The only trick is the node at pin 13 of the PIC. That pin acts in a bi-directional manner during programming. When we write to it, we do so via the parallel port's 17th pin. When we want to read from it however, we have to hold the parallel port's 17th pin high, this way the inverter feeding into pin 13 doesn't drive any voltage (remember, it's an open-drain inverter), and we can read the ouput on the parallel port's 13th pin. If we leave the parallel port's 17th pin low, then the inverter will drive a low voltage and short with the PIC.
And, in a few ways, the ElCheapo really sucks:
- The 180 Ohm resistor drops about 10 volts, and so it gets really hot. This makes some people (namely me) nervous.
- For my next design, I intend on using a 78L05 and a 78L12 for the two supplies.
- The ElCheapo does not support turning the Vdd signal on or off, which I have found out is actually specified for some types of PICs.
- For my next design, I intend on having independant control of this signal.
- Operates over a parallel port, and thus requires root. (Not as annoying if you have sudo, but...)
There is a pretty technical specification for the programming sequence, but it can be kind of confusing. I've written software to control it, which works. This software:
- Is known to work on PIC16F716, PIC16F627A, PIC16F628A, PIC16F648A. It's expandable by modifying the file /etc/pic-type-database.
- There are reports that you cannot get low-voltage programming to work unless you can control the Vpp signal independantly. My software can be expanded to do this with a one line modification (if your programmer supports it).
- Will burn program, configuration area, and data EEPROM.
- Verifies everything it burns.
- Automatically checks for jump tables that cross PCL boundaries.
- This feature is a heuristic, and has false positives and false negatives, but works pretty well.
- I intend on adding more static checks, as I think of them.
- Has a sister utility ElDump which reads a PIC to a hexfile.
- Has a sister utility hexcat which offers a semantic view of a hexfile.
- Can be downloaded: elcheapo.tar.bz2