Programming PIC18F Chips
The pin-out for Microchip standard 6-pin connector for In-Circuit Serial Programming (ICSP) is listed in table below:
||_MCLR/Vpp (programming voltage)
||LVP (low-voltage programming mode control)
There are many PIC programmer available, commercial and DIY devices. As Microchip introduces the new microprocessors the programming software got to be updated accordingly playing catch-up with the PIC manufacturer. That is the root of the problem with third-party PIC programmers. Microchip's PICkit 2 is the low cost ICSP programmer for Flash PICs with USB interface introduced by Microchip. Only subset of PIC microcontrollers is supported, but the list is including all the recent devices from PIC16, PIC18 and PIC24 families and certainly covers all the PICs you are most likely want to use. It is fully integrated with Microchip’s MPLAB IDE and allow not only program but debug applications as well. As alternative you can use the standalone programmer applet, see picture below.
The PICkit 2 has USB bootloader and capable of updating the programmer firmware directly from Microchip web site. Every time the PICkit 2 programmer application is launched, it will check the firmware version of the PICkit 2 to see if it is the latest version. If not, it will attempt to automatically download the latest version. The software upgrades are free and Microchip updates them in timely fashion. Even more, the firmware and schematic are freely available. Apparently Microchip has made the open design intentionally, see it as the way to boost using the popularity PIC microprocessors. With such simplicity of design it is easy to build a clone version. The Sure Electronics is making a good clone and it comes with ICSP cables, see the Products page. My first PIC programmer was Melabs EPIC device with parallel port interface. After upgrading my PC I have realized that parallel port became legacy these days, as the most of new PC motherboards do not have it all. The another annoying part about Melabs programmers in general is that even if you buy the full package (hardware + software) upgrades are not free and only beta stuff available for download. I have successfully burned all my PIC18 and PIC24 chips using PICkit 2 and would definitely recommend it.
PICkit 3 was introduced recently and supersedes the PICkit 2.It is build around PIC24FJ256GB106 16-bit PC device.
The Microchip states that the PICkit 3 differs from the PICkit 2 by providing:
- Extended EE program image space (512 Kbytes)
- True voltage reference
- Increased voltage range (1.8-5V VDD; 1.8-14V VPP)
- Doesn't have standalone programming application and can be used only with Microchip IDE
Some of the latest PICs being supported by PICkit 3 but not PICkit 2, it looks like eventually PICkit 2 will be phased out.
DIY PICkit 2
PICkit 2 was originally built by Microchip as open design programmer with the schematic, source code and firmware available to boost the popularity of the PIC devices. Because of that it is easy to build a clone version of the original device. Most of the clones will produce unregulated 5 volt VPP where the original Microchip PICkit 2 provides adjustable VPP output to allow 3.3 and 2.5 volt parts programming. The schematic I have used is based on the original PICkit 2 without programmer-to-go functionality. That functionality allowing a hex file to be downloaded to the PICkit 2 to later program PIC microcontrollers without a PC with a simple pressing programmer's push button. I do not think that functionality is required for a hobbyist but allows simplify the schematic by omitting two 24C512 EEPROM chips. The Eagle Files designed using only thru-hole mounting parts.
Building PICKit 2 clone is facing a chicken-egg problem as another programmer is required to program the firmware into the PIC18F2550. Once the PIC18F2550 chip for PICKit 2 is programmed, you can the upgrade the firmware as it includes USB bootloader. The latest PICkit 2 firmware version is available from Microchip and the current version is also is available on the site - click here to download!
The DIY PICkit 2 part list for the two the most popular electronic components vendors, Mouser and DigiKey is shown below.
|USB type B connector
||Green 5mm LED
||Yellow 5mm LED
||Red 5mm LED
Setting Unit ID
The programmer can be assigned a Unit ID to identify it uniquely. After the fresh firmware programming the device applet is always showing the funny ID
"ID= OIHoss". It could be reset to not-assigned or set to any value by selecting “Tools>Calibrate VDD & Set Unit ID” menu, see picture below.
Calibration allows greater the VDD voltage accuracy. Note that as the calibration is dependent on the USB voltage and moving the PICkit 2 unit to a different USB port, to or from a USB hub or to another computer port may invalidate the calibration. To calibrate the PICkit 2 unit, a digital multi-meter is required. Disconnect the PICkit 2 unit from the target and select "Tools>Calibrate VDD & Set Unit ID". to bring up the calibration wizard. Follow the steps in the wizard to complete the calibration process.
Troubleshooting DIY PICkit2 assembly
You can use "Tools->Troubleshoot" menu to help with resolving connectivity from the PICkit 2 to the target device. This is also useful where there are the device assembling errors, as providing step-by-step output validation process.