What I did
I recently got into Arduino and after doing the usual newbie "blink a LED" and "show something on the LCD shield" stuff, I turned my hand to something a little more challenging - a programmer for PIC microcontrollers!
The old RS-232 based programmer I built years ago is now a museum piece because there are no computers left in the house with an RS-232 port and USB serial converters just don't work. Then I thought: all I need to do is twiddle the data and clock lines in the correct pattern, right? Can I build a shield for that? Thus began my obsession of the last 3 weeks. All of the details and source code are up on github:
Documentation: http://rweather.github.com/ardpicprog/index.htmlSource code: https://github.com/rweather/ardpicprog
There were some interesting challenges. The first being that the Protoshield wasn't big enough for the whole circuit! The solution was to build it onto two shields: the 13 volt power supply on one shield, and the PIC programming circuit on the other. Then simply stack them up.
The 13 volt VPP programming voltage was the next challenge. There are circuits out there for 5v-to-13v boost converters, but the current draw can be a bit high and the circuits used zener diodes and inductors and other funky components I don't normally have on hand. To simplify things, I used a standard 7812 voltage regulator with a resistor ladder in the output stage to generate 13 volts using a 12 volt regulator. Thanks to the Jaycar catalogue for that trick! The supply is powered by an external 16-20 VDC source, either a bench power supply or two 9 volt batteries wired in series. A connecting cable passes the 13 volts up to the top shield.
Next was the circuit for the programmer itself. An article from Silicon Chip Magazine Sep 2003 gave me most of the details. The top board features a ZIF socket, ICSP header, 18 pin vs 8 pin selector, status LED's, and a transistor for switching the 13 volt supply on and off under Arduino control (transistor on = reset PIC, transistor off = apply VPP).
All of the circuit details are on the web site: http://rweather.github.com/ardpicprog/p ... rcuit.html
The next challenge was making it possible to download a HEX file into the PIC. I divided the problem into two parts: a sketch running on the Arduino and a host program running under GNU/Linux. The host program has the same command-line syntax is the venerable picprog. The host and the sketch communicate using a simple serial protocol over USB. The protocol is fully documented on the site, so other people can make compatible sketches for other shields and PIC types.
Right now the range of PIC's supported is fairly basic, mostly common members of the 14-bit series: PIC16F84A, PIC16F628A, PIC12F675, and so on (full list on the site). New PIC types can be added by modifying the sketch and circuit. Or throwing the sketch away and writing a new one that implements the same serial protocol. Patches welcome to support other people's favourite PIC's.
It works great on the PIC's I've tested it with. It even managed to resurrect a PIC that I had considered "bricked" years ago - I had flipped the wrong bit in the config word and made it unprogramable by my old RS-232 programmer. But since my circuit includes VDD control, it was able to force the PIC into programming mode and bring it back from brick heaven.
Feedback, patches, better circuits, all welcome!
Comments
Please log in or sign up to comment.