• warning: tempnam() [function.tempnam]: open_basedir restriction in effect. File(/var/tmp/) is not within the allowed path(s): (/f2/autarchex/:/nfsn/apps/php5/lib/php/:/nfsn/apps/php/lib/php/:/nfsn/content/content/nfsn/) in /f2/autarchex/public/includes/file.inc on line 528.
  • The file could not be created.

Serial Pic Programmer

Created
12/17/05

Related Items
Update REV 003

Materials
Assorted components

Issues
Malfunctions when used with internal oscillator setting on some PICs. Use updated version.

Note - there is an updated version of this project.

I have long wanted to work with microcontrollers for my own personal, not-for-school projects, but have found both lack of time and lack of a proper programmer to be stumbling blocks. Or maybe excuses. One of my two excuses no longer applies, however, as I have now built a working serial programmer for Microchip's PICmicro microcontroller devices.

My senior design project is (er, will be) an ASIC tester built around a PIC microcontroller. Although PICs are cheap, programmers generally are not, and my group is averse to needless spending (even though we have an as-yet untapped $500 budget.) So, I thought, why not just make a programmer?

The Internet is host to a varied menagerie of PIC programmer designs. We wanted ICSP (in-circuit serial programming) functionality so that we would not have to constantly pull our chip and socket it in the programmer. Also, a widely compatible device was required, because we still have not narrowed down our selection of a particular PIC offering with any great certainty. I chose the ICSP programmer from Olimex Ltd (available here) which is itself based on the JDM programmer. This design can program virtually any PIC, is incredibly simple to build at a mere 13 discrete components, is interoperable with several commonly available open-source transfer programs, and is completely powered by the PC's RS-232 serial port. The transfer program I selected to use with the programmer is WinPic, a popular piece of software that supports a plethora of PICs and all of the common programmer types.

Operation

The programmer twists and perverts the PC's serial port to produce ICSP signals used to program a PIC. This includes clock, bidirectional data, 5 volt power, and ~12.7 volt programming voltage. This last requirement is typical of "high-voltage" programming, where a voltage significantly greater than the typical supply voltage is required to perform writes to the device's Flash/EEPROM memory. Some PICs support a "low-voltage" programming mode, which operates entirely at 5 volts. This programmer does not support low-voltage mode.

Schematic

I made two modifications to the original Olimex design. Both modifications were necessitated only by lack of parts. First, the two transistors in the original design are BC337-40. I didn't have any of those, nor had I ever heard of them. They appeared to be used here simply as switches, so I replaced them with general purpose MPS2222A devices which are particularly plentiful in my parts drawer. Second, I did not have a convenient source for the BZV55C5V1 zener, which I judged by the part number suffix to be a 5.1 volt device. The lowest voltage zener in my diode collection was 5.6. I decided to replace the reverse biased 5.1 volt zener with a forward biased series pair of LEDs with a sum forward voltage drop of about 5 volts (a 3.3v blue and a 1.8v yellow.)

Construction

The entire device consists of a PC serial connector, a circuit board, and an ICSP connector on a ribbon cable. The serial cable is simply a short piece of CAT-5 network cable terminating in a female DB-9 connector. Five of the eight internal wires are used; I used green, orange, brown, blue, and blue-white. Obviously your choice of colors doesn't matter, so long as you remember which colors go to which DB-9 pins.

The circuit is constructed from through-hole components on a small piece of perfboard. No real forethought was put into parts placement; wire connections (which I find rather tedious) could probably be greatly reduced with just a little bit of planning. About half of my interconnections were made with device leads and half with wire jumpers. I used wire-wrap wire for compactness.

My ICSP connection is via a short segment of ribbon cable ending in a six position female header. Some method of indexing pin 1 on the header is recommended; I used the red stripe on one edge of the ribbon cable to denote pin 1. It should be noted that not all six pins are really necessary for programming. My pin 6 is the signal "PGM" which is only used to initiate low-voltage programming mode on the PIC. Because a PIC must be programmed at least once by a high-voltage programmer just to enable the low-voltage ability, supporting low-voltage mode in our application is just silly - besides, this programmer is high-voltage only! So why is the PGM pin included at all? If a standard ICSP header will be used for all of your PIC projects, including this pin and only actually connecting it to those PICs that support low-voltage mode will ensure that when programming these devices, the device cannot accidentally enter low-voltage mode while this programmer is in use (because PGM is connected to GND on this programmer, and is thus forced low, which disables low-voltage mode.)

When plugged into the back of my computer, the blue and yellow LEDs light up. The blue LED is extremely bright. It does not get warm, however, so I guess it isn't getting too much current (I rather expected it to.) The red LED only lights when there is data activity.

For protection from accidental short circuits and to add strength to the cable connections I enveloped the circuit board in hot glue. I love hot glue. It's so much cheaper than epoxy, and easier to use. Too bad it isn't as transparent. However, in this case, the murky translucent character of hot glue was to my advantage, because it really helped cut out the glare from the blue LED. The glue shield spreads the light around as a pleasant blue glow. I also injected hot glue into the DB-9 connector shroud and ran a bead on either side of the ICSP connector for sturdiness.

It works!?

Verification that this programmer functions correctly was given by the slowly blinking light of a little red LED on Friday, 16 December 2005 - a day of rejoicing for our project group. I used the most minimal of setups for programming: a PIC16F687 (which we received as a free sample from Microchip, truly a student-friendly company if there ever was one) and a piece of male header for the ICSP connection. Also, five pieces of wire. That's all you need to program a PIC! To prove that our program, a simple piece of code that slowly toggled the port C bit 0 pin, was actually programmed into the PIC, I added a 7805 voltage regulator, a 100uF filter capacitor, a 330 ohm resistor, and a red LED. The LED blinked. There was much rejoicing.

To program any particular PIC device using this programmer, download and view the datasheet for that device. First, verify that the device supports ICSP programming. Second, determine which external pins correspond to VDD (power), GND (ground), MCRL/VPP (programming voltage), PGD (programming data), and PGC (programming clock). Different PICs have these functions on different pins. After determining the ICSP pin assignments, connect these pins to the corresponding positions on the ICSP header. If you are designing a permanent ICSP circuit, perhaps for future firmware updates, keep in mind that ICSP VDD should probably be isolated from the VDD used for normal operation (remember, the PIC is powered from the PC serial port during programming), and the PGC, PGD, and MCRL/VPP pins may need to be isolated from their normal operation connections as well, depending on your circuit. "Isolation" in the latter cases can often be just a resistor.

 

Reply

CAPTCHA
Verify your humanity, yo.