I mentioned in one of my previous posts that I decided to give PIC family MCUs a spin after having been working with AVR chips for sometime. From a pure technological stand point PIC programming and AVR programming are not all that different, especially if you are using a high level language like C. But the AVR world definitely seems to have a few advantages in the open-source arsenal such as avr-gcc and Arduino.

The lack of a comprehensive open source platform makes it more the difficult to develop products — or simply to just experiment — outside the development suite offered by Microchip. The product suite from Microchip includes Windows based MPLAB development studio and PicKit2/PicKit3 programmers which only work under MS Windows. This situation may soon change though, as a Windows/Linux version of MPLAB — MPLAB X based on NetBeans is currently in beta and presumably will enhance the cross-platform development experience.

But even with this cross-platform compatibility, the licensing for the compilers are still somewhat confusing. For instance, while MPLAB C Compiler for PIC24 has free and unrestricted evaluation version, the compiler for PIC18 does not and only offers reduced feature set for evaluation purposes. There are open-source compilers that support the PIC product line, such as SDCC, but the support level varies depending on the MCU used.

Anyway, as I do not have a PIC programmer and do not want to buy one for just a few projects I decided to build one myself. And after some research, I decided to build a USBPICProg USB PIC programmer. It is particularly attractive since it is open source in both hardware and software, and it uses an MCU (PIC18F2550) I already have.

The main circuit for the USBPICProg programmer is actually quite simple. In fact, it contains nothing more than a charge pump DC/DC converter for generating the 13V programming voltage for the target MCU and everything else is accomplished in the firmware code. The reference design used a BC847 NPN transistor, two BS170 N channel MOSFETs and a more exotic P channel MOSFET TSM2301CX. These components however, can be replaced with pretty much any kind of small signal transistors or MOSFETs of the same type. I changed the components in the charge pump circuit to 2N3904 (replacing BC847), 2N3906 (replacing TSM2301CX) and 2N7000 (replacing BS170), which are more commonly available in the United States.

In theory, 2N7000 MOSFET can be replaced by an NPN BJT such as 2N3904 as well. But in this particular application, the use of N channel MOSFET 2N7000 does have its advantages since the switching voltage drop Vds(on) is almost negligible. If an NPN transistor is used instead, the Vces will be much higher.

The following schematic is the revised charge pump portion of the circuit:

Charge Pump Circuit
Charge Pump Circuit

And the picture below shows the completed USBPICProg board with the firmware loaded.

USBPICProg Board
USBPICProg Board

To load the firmware, I used the parallel programmer I used in one of my previous posts. The one resistor parallel programmer worked quite well and I had no problem flashing the firmware onto my PIC18F2550 for the first time.

Note that you only need to flash the firmware.hex file onto the MCU and not the boot.hex. This might not be quite clear on the official USBPICProg website.


After the firmware is in place, you should be able to use the programmer to program any other PIC MCUs via the ICSP header. Note that in normal use mode (i.e. programmer mode), VPP_SELF should be tied to Vdd (+5V) and PGC_SELF should be tied to the ground using jumpers (please refer to the USBPICProg schematics).

But if you run into any issues, I would suggest the following troubleshooting steps.

The first thing you need to make sure is that the switching capacitor stages work correctly. The easiest way to do this is using an oscilloscope to view the waveform supplied at Pump_1 and Pump_2. The firmware generates a pair of complementary square wave at roughly 2 kHz:

Charge Pump Driving Wave Form
Charge Pump Driving Wave Form

When VPP_CTRL_RST is driven low, the test point at the emitter of 2N3904 should have a reading of 3xVdd which is typically between 11 to 14 volts, depending on Vusb and the load.

One of the potential issues of the reference design is that if the pin controlling VPP_CTRL_RST is left float, the 2N7000 may be partially switched on due to none-zero Vgs resulted from charges being accumulated on the gate from either environmental interference or accidental touching of the gate. This will result in fluctuation of the 13 volts programming voltage as the maximum output current the charge pump circuit can supply is very low. To make this circuit more robust, you can simply connect a large resistor (e.g. 1M) between the gate and the drain of the discharging MOS FET.

USBPICProg provides a few input/output tests that you can use in conjunction with your hardware to make sure that the programmer is working as designed. For instnace, when first plugged into the USB port, the states of VPP pin, VDD pin, PGD pin and PGC pin should be as follows:

Control Pin States (Default)
Control Pin States (Default)

And by clicking each radio button, you should see the HW states change. Particularly, the VPP pin should change to the voltage selected as seen below:

Verifying Programming Voltage
Verifying Programming Voltage

The following pictures were taken when I used the USBPICProg to program a PIC18F4553. The red LED would flash when there is write activity and the orange LED would flash when there is read activity.

USBPICProg in Action (Programming a PIC18F4553)
USBPICProg in Action (Programming a PIC18F4553)
PIC18F4553 being Programmed
PIC18F4553 being Programmed

Here are a few screenshots showing a successful flash:

usbpicprog 1
usbpicprog 1
usbpicprog 2
usbpicprog 2

After a successful flash, you should always verify that the content has been written correctly:

usbpicprog 3
usbpicprog 3
Be Sociable, Share!

29 Thoughts on “Building a USBPICProg PIC Programmer”

  • If you’re going to the extent of using a USB-enabled PIC for a programmer, like the 18F2550, you might as well make a PICKit 2 clone.

    The huge benefit is the clones run the existing PICKit 2 software, which supports far more devices than the USBPICProg software, ans is updated regularly to support newer MUCs. A very good example is here: http://simon.derr.free.fr/site/spip/spip.php?article11

    • Hi bubba

      I made that pickit2 clone thta mensioed in this link http://simon.derr.free.fr/site/spip/spip.php?article11

      software dettect this programer succesfully ,but when i connect device it can’t able to dettect the divice PIC , some times it could able to dettect but it always showing PIC16F886 dettected actualy i was put PIC16F676 and 30F2010.
      some times error is coming [” Vpp is ready …like that ]. i had check the Vpp but its only 5v pulses .how much it should be? and MCLR feed back volt is 1.8v.

  • Hai Kerry,
    I have used the BC557 instead of 2N3906 and BC547 instead of 2N7000. With this change also my circuit worked fine. Also in your circuit meant for charge pump, the resistor 100K should be connected between collector and base of 2n3904. In my circuit i have short circuited the 1K resistor before 2N3904 for getting good level of Vpp. I dont know the purpose of 1K there. In my testing occasionally the host program fail to communicate with the harware. I tried to used all new versions of firmware and host programs. Can you make a comment on this.

    • The 1K resistor was only appropriate when you are using a MOSFET instead of a BTJ, it was meant to limit the inrush current due to the gate capacitance and also to prevent MCU port damage should the gate become shorted.

  • I hope the 1K resistor for discharging the potential in the charge pump with the help of Vpp control transistor. If so then why can’t we move this resistor to the collector/drain of this transistor, as i got poor Vpp by including this resistor. This is my suggestion. whether my suggestion ?#@**!!?

  • Help me plzzz

    i cant write the firmware to the pic18f2550. i checked everything, changed lot of parts, still same problem.
    dont know what to do. i connect the device. bootloader connected . the red and yellow ON .. open the software .. green LED ON. open hex file to write and …

    7/12/2012 12:56:20 AM: Erasing before programming…
    7/12/2012 12:56:22 AM: Erase OK
    7/12/2012 12:56:22 AM: Programming the code area of the PIC…
    7/12/2012 12:56:25 AM: Write Code memory OK
    7/12/2012 12:56:25 AM: Programming the data area of the PIC…
    7/12/2012 12:56:25 AM: Write Data memory OK
    7/12/2012 12:56:25 AM: Verifying all areas of the PIC…
    7/12/2012 12:56:26 AM: Verify code failed at 0x800. Read: 0xFF, Expected: 0xD2 <<<<<<<<<<<<<<<<<<<<<< !!!!!!!!!
    7/12/2012 12:56:26 AM: Programming configuration area of the PIC…
    7/12/2012 12:56:26 AM: Error programming config memory

        • lsn . when i finished the hardware . i took the PIC18f2550 to my friend, he has a parallel programmer. and i write the boot1.hex to the PIC.

          should i do the same thing for the firmware or what ?
          coz in official site said that u only need the boot then u short some pins and write the firmware and then u short another 2 pins. and it will be ready to use

          • You need to flash the firmware.hex onto the PIC18f2550 not the boot.hex. The boot-strapping process requires a parallel programmer (or any other functional programmers) but once you have a functional USBPICProg, you can use it to load updated firmware using the method mentioned. Hope it helps.

    • Hmm.. you will first need to flash it on to your PIC using another programmer? (e.g. a parallel programmer). It’s the bootstrapping process…

  • hai,
    Can anyone tell me how usppicprog find the hex file and burn only the data into that particular locations of the given addresses.
    i mean the code how it finds the hex file in usbpicprog.
    Thanks in advance.

  • ok, i did like what u said. i used JDM programmer and i programmed firmware.hex to PIC18f2550, opened the software and said Unable to read firmware version?!

    any ideas ?

  • Hi, i have build this programmer and i have following problem, when i plug it into USB it turns on, but in 5s it goes off and then again on in 10s On … When i give between drain and gate (discharging tranzistor BSS98) a 1M resistor i have very low VPP voltage … when i give between the Gate and ground a 3,3M rezistor i have max VPP 12,6V but i can only programm 16F84 … i tried to programm a 18f2550 but it dont work … the SW finds the pic but the memory is clear :( …

    PS: Sorry for my VERY BAD english i havent use it in years :( …

    • Could you try using a external power supply for the programming voltage? I suspect that the programming voltage might be a bit low (should be around 13V).

      • Am gonna cry over here :(

        you know i did that JDM programmer in the USBPICPROG.ORG and i cant program the 18f2550.
        srsly am started to hate this project.

        i use PICPgm it detects the JDM programmer (Auto detect) but cant detect the PIC.
        winpic says hardware not responding.

        i have my own voltage 12V and stable at 12.23V and i bought all new components i did everything but same problem. i will try to buy new PIC18f2550.

        • Sorry to hear that Muhammad.

          I built a parallel programmer to program the 18F2550, if you still have a computer that has parallel port, you may want to give that a try, it’s simple and better yet it works.

    • Problem solved, i changed the resistors from pic to the gates from the BSS98 Mosfets and i groundet them with a 100K resistor, i tried to program 16f84, 18f2550 and some 16cXX and everithing goes without a problem … only one last question, my USBpicprog dont find 16F84A i can read her, i can burn her but autodetect doesn´t work … by the 18F2550 and 18f4550 autodetect works fine … any idea ?

  • Good day, i realy do like your site, I came across it while making a research on how to build a progrmmer, I am a student and love to program(simulating only) but getting it here is like hell except u have someone who stays abroad and willing to help you, but I need help on building one so I can help my self through my school project and other stuffs. I need a circuit diagram to build a programer, for now Atmel 8051 can be gooten from few stores for now.. Thanks will be waiting for ur reply

  • This article isn’t quite correct. Even back in 2011 when it was written, the PicKit2 programmer from Microchip did have Linux support. It’s not first-class support unfortunately, but the “pk2cmd” program is available from Microchip in both source and binary forms; it’s a command-line program that works with the PicKit2 USB programmer on Linux. Just Google for more info on it. I’ve been using the PicKit2 programmer with pk2cmd for 3-4 years now with great success. This programmer is also inexpensive, at less than $50, and there’s 3rd-party clones available for much less (though I can’t vouch for their quality). Microchip publishes the schematics for this programmer so it’s easy to build your own if you want. Just be careful to get the PicKit2, and not the PicKit3 which does not work with pk2cmd. The PK3 supposedly does work with the new MPLAB X IDE from Microchip, which works in Linux, but I tried it once and it’s an extremely slow and heavyweight application.

  • Thank you very much for the article, it has been very useful.
    You’re saying that in order to get the programmer working, I just need to flash the firmware.hex to the 18F2550, and not the boot.hex, but in usbpicprog’s website it says that you need to burn the boot and the firmware.
    What’s the difference between the boot and the firmware? If i’m correct, the firmware transforms the USB signals to ICSP signals, but what is the boot.hex file needed for?
    I’ve been looking around the web for articles about this USB programmer, some sites say you need to burn both the boot and the firmware, some say only the firmware, so i’m a little confused about this. Could you please explain me about the firmware and the boot?

    • Hi Emilio,

      It has been a while… at the time of my writing, the firmware contains the bootloader and that was why you needed to flash the firmware (just the bootloader would not work).

  • is there any circuit for the parallel programmer. because i don’t have another programmer to flash the firmware in pic18f2550. and i am comfortable with a usb programmer than a serial port.

Leave a Reply

Your email address will not be published. Required fields are marked *