loading
Picture of PURPIC, the wearable PICkit2 clone

One of my very first Instructables was a stripped down PIC programmer based on a design by David Tait using through hole transistors and resistors glued to a piece of cardboard. Oh, how times have changed. And as usual, I'm still 7* years behind those changed times. My latest project is a remake of today's hottest 7-year-old PIC programmer, the PICKit2!

*there, fixed!

 
Remove these adsRemove these ads by Signing Up

Step 1: An extremely brief history of the PICkit2

Picture of An extremely brief history of the PICkit2
pics.jpg
Microchip launched the PICkit2 in 2005. It is a hugely popular device that programs and debugs a wide array of PIC microcontrollers and EEPROMs. Even though it has long been superceded by the PICKit3 and the ICD3 programmers, there are still a variety of features which make the PICKit2 quite useful (and cheap) for specific applications.

In addition to working with Microchip's MPLAB IDE as both a programmer and debugger, Microchip also created a nifty standalone software for the device which is very easy to use. There is a Widows GUI version and also a command line version of the programming software. The engineers even added a "programmer-to-go" functionality, which allows the PICKit2 to burn chips with no computer at all. So even though the PICKit2's MPLAB debugger is painfully slow, all those other features are quite useful for low volume batch programming on a budget. So even though I celebrated the PICKit2's 7th* birthday by buying an ICD3, it will never make my PICKit2's obsolete.

Step 2: An extremely brief history of PICKit2 clones

Picture of An extremely brief history of PICKit2 clones
pp7.jpg
Some years ago, Microchip decided to release the firmware and schematics of the PICKit2. Not long after that, the first of countless clones was born.

Many hobbyists stripped down the programmer to the bare essentials. Other commercial variants were made with robust ABS cases and a more secure RJ-12 connector. One version looks more or less exactly like the original from the outside, and it sells today for around 20 dollars!

The schematic is viewable at this link. Scroll down to page 81-82, or click on "Appendix B: Schematic"
http://ww1.microchip.com/downloads/en/DeviceDoc/51553E.pdf

Step 3: Enter PURPIC - Video in Action

Picture of Enter PURPIC - Video in Action
PP4 002.jpg
PURPIC 077.jpg
PP8 001.jpg
PP8 002.jpg
PURPIC 008.jpg

The 4 main features of my PURPIC clone are

1. Integrated li ion battery charger. Whenever the device is plugged into a USB port, it charges the battery with a controlled charge rate of 85mA.
2. DC-boost circuit provides 5V from any lithium battery or a possibly out-of-spec USB port/hub. The boost circuit is good for over 500mA, so it can deliver the goods.
3. The Program button is ported out to the ICSP header, to allow access to Programming-to-Go via your programming interface of choice.
4. Even with the added circuity and the extra large toner transfer-friendly vias, the area of the PCB is still 25% smaller than the PICKit2, making the programmer light enough to stick on the end of a pogo pen interface or to even wear on your wrist, utilizing the Programmer-to-Go function.

I haven't done extensive testing, yet, and I've already found one shortcoming. The real PICKit2 detects a short circuit between Vdd and ground, shuts off power, and displays a Vpp error. When connected to the computer, my clone doesn't detect a short fast enough. It will brownout and lose communication with the computer. Or worse, it may even trip the USB port to shutdown, which (if you have a battery connected) leaves the device locked up in brownout, with output still (trying) to power the short.**

*Edit: I found a simple solution for short-detection is to add a 5 ohm resistor in series with the Vdd line on my pogo pen. Yea! All of the Vpp errors are now detected. A 5 ohm series resistor is obviously not an ideal solution, because it will result in significant voltage drop if your programmer is ever called upon to drive a significant load, so some careful selection and experimentation with different FETs might be warranted. I checked the specs on the P-FETs I'm using, and they have much faster rise/fall times and a significantly lower RDSon resistance than the one in the dual FET that the schematic calls for. Of course you still have some extra power draw from the DC boost, which is unavoidable. But I'd think a slower Vdd P-FET could alleviate or solve the problem. I updated the PDF images. The new revision has a space for a 0805 series resistor on the output of the Vdd P-FET. If you were to end up having short-detection issues, you could put a small resistance here. If not, you could just bridge it with a 0R resistor. I also updated the PURPIC layout to include a pad big enough for a 10uF ceramic cap (probably couldn't fit the better-at-this-frequency tantalum variety, but I'm using all ceramic, and everything looks good even without this cap, at all) on the source of this P-FET as per the original schematic. So now the PURPIC layout is quite faithful to the original schematic other than a missing decoupling cap on the opamp, an extra optional cap footprint or two on the +5V rail, the smaller Vpp pump cap substitution, and the space for the series resistor on the Vdd output. (I did not update the PICZYL pcb with the Vdd P-FET 10uF cap pad; I never changed this version's Vpp pump cap from the 47uF tantalum to the 22uF ceramic, so there's no space for this.)

**Update 3.11.15 - First off, yes. I am still using these programmers. Secondly, I was mistaken about the brownout/lockup. The BATTERIES I am using have their own short circuit detection, and that was what was kicking in. So yeah, the short circuit detection is too slow, but no, this probably won't cause a brown-out/lock-up.

Here are some links of the action:
Here I'm wearing the programmer on my wrist
http://s18.photobucket.com/albums/b103/klee27x/?action=view¤t=Moviepp.mp4

But in reality, it's light enough to just stick on the end of a pogo pen.
http://s18.photobucket.com/albums/b103/klee27x/?action=view¤t=PP2006.mp4

Step 4: Schematic and board layout

Picture of Schematic and board layout

Now I'm not going to be super smug about this clone. Anyone with some CAD PCB software could make a PICKit2 clone. The DC boost circuit is also a basic cut-n-paste, straight from the Linear Technologies LT1308 datasheet. The lithium charging is performed by Microchip's MCP73811. All I added was the extra Program button header pin, the Schottky diodes that make the charger and USB port work together. and a microcontroller to control power and perform low battery shutdown.

The 12F508 I put in there is wired to a push button switch, an LED, and a P-FET. The push button switch toggles battery output on/off via the P-FET, and the LED indicates the status. It also receives input from the LT1308's low battery detector output, and when the voltage drops to 2.9 volts a fancy-pants shut-down sequence is started. The LED blinks increasingly fast for 1 minutes until unity is reached. Then the LED slowly fades out over the next 3 seconds before everything shuts down. If the voltage goes back up to 3V in the interim, the sequence is aborted. Or you can switch it off, of course. The key thing here is that this chip protects the battery from over-discharging and becoming damaged, but it still gives you the last say. Instead of cutting out, unexpectedly, it gives you a full minute to finish what you were doing, and you can flip it off/on to reset the 1 minute timer as many times as you dare.

The PICKit2 schematic is viewable an Microchip's website. Scroll down to page 81-82, or click on "Appendix B: Schematic"
http://ww1.microchip.com/downloads/en/DeviceDoc/51553E.pdf

Linear technologies LT1308 boosts the li ion battery output to 5V. Datasheet is viewable here.
http://cds.linear.com/docs/Datasheet/1308i.pdf

The lithium ion battery charging is handled by the MCP73811. This nifty SOT-23 5 pin IC requires just 2 1uF capacitors to work.
http://ww1.microchip.com/downloads/en/DeviceDoc/51553E.pdf

The firmware and pinout for the 12F508 will be posted shortly. But basically, put these three schematics together with a few diodes, and there's the schematic. USB +5 is in continuity with the li ion charging IC input. Then 2 diodes go from that main +5V rail. 1 diode goes from there to the the PICKit2. And another diode goes to the input of the DC boost circuit, to bring the voltage of the PICKit2 back up to 5V. A third diode goes between the battery and the DC boost input.

Sorry to disappoint, but there' no silkscreen, and I have no plans to add one. There's not enough room, and I've already spent too much time on this. A BOM in the form of a Mouser project/cart might be forthcoming, but I can't guarantee the accuracy, since I am using so many parts I already had on hand.

Step 5: PIC 12F508 annotated source code; if anyone has a problem assembling as posted, please comment

list p=12F508 ; list directive to define processor
#include ; processor specific variable definitions

__CONFIG _MCLRE_OFF & _CP_ON & _WDT_OFF & _IntRC_OSC

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.

;***** VARIABLE DEFINITIONS
cblock 07h
qw1
qw2
temp
test
counter
counter2
on_counter
off_counter
endc

;PINOUT
;pin 1 is power
;pin 8 is ground
;pin 5 is not connected
button equ 3 ;pin 4, to the button. internal pullup is set
output equ 4 ;pin 3, to the P-FET; there's no internal pullup on this pin.
;I should have put a physical pullup on the P-FET gate,
;in case the PIC were to brownout or otherwise malfunction.
LED equ 1 ;pin 6, ;Hi = on, Lo = off
LBI equ 5 ;pin 2, Low battery indicator output of the LT1308 goes here.
;If you set the biasing resistors to 825K and 67K
;the setpoint is 2.9V. See LT1308 datasheet for the details.
;this pin also does not have an internal pullup. I did remember to put this on the pcb. :)

;**********************************************************************
ORG 0x3FF ; processor reset vector

; Internal RC calibration value is placed at location 0x3FF by Microchip
; as a movlw k, where the k is a literal value.

ORG 0x000 ; coding begins here
movwf OSCCAL ; update register with factory cal value

initialize
movlw b'00000000'
;7:lo_enable wake-up;6:lo_enable weak pullups;5:lo_timer clock source is internal
;4:hi_timer clock source enabled on falling edge;3:lo_prescaler select timer (vs WDT)
;2-0:prescaler (p22)
option

start
call clear ;set tristate and output of I/O pins to default/OFF state
btfss GPIO,button ;check state of button
goto On ;if pressed, goto On
sleep ;if not, goto sleep
nop
On
bsf GPIO,LED ;turn on LED
bcf GPIO,output ;turn on P-FET
call DD ;Debounce Delay
btfss GPIO,button ;check button state
goto $-1 ;wait till it's released before continuing to main loop
call DD
loop
btfss GPIO,LBI ;this checks the Low Battery Indicator
goto LB_shutdown ;if pulled low, then goto Low Battery shutdown

btfsc GPIO,button ;as long as the button isn't pressed, the PIC stays in "loop."
goto loop
shutdown ;if the button is pressed, everything turns off and the PIC goes to sleep.
;This device starts at the beginning of the code when it wakes up, FYI
call clear ;
call DD
btfss GPIO,button
goto $-1
call DD
sleep
nop
;Subroutines;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
clear
movlw b'101000'
tris GPIO
movlw b'010000'
movwf GPIO
return ;this device doesn't actually have a "return" command.
;This is a pseudo-command, which is actually assembled as the "retlw 0" command.
;Which just means it places literal 0 into the W accumulator when it pops.
DD
movlw .100
movwf qw2
goto dsub.2
dsub.2
decfsz qw1
goto $-1
decfsz qw2
goto $-3
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LB_shutdown ; this is the fancy-pants shutdown sequence
LB.1
clrf counter
LB.2
btfss GPIO,LBI
goto LB.3
bsf GPIO,LED
goto loop
LB.3
goto $+1 ; just some extra delay
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
decfsz counter,f
goto $+2
goto shutdown_kewl
movf counter,w
movwf qw2
movlw b'000010'
xorwf GPIO,f
call DLB
movwf temp
decfsz temp,f
goto LB.2
goto shutdown

DLB ;Delay Low Battery Routine
btfss GPIO,button ;constantly check the status of the button
retlw .1 ;if it's pressed, then immediately pop with literal .1 in the accumulator,
;so we know that the button
;was pressed and the delay was exited early... so we can turn off
;the power instead of continuing the fancy pants blinky light shut down routine.
goto $+1
decfsz qw1
goto DLB
decfsz qw2
goto DLB
retlw .0

shutdown_kewl ; fade out the LED, instead of just turning it off
clrf on_counter
movlw .1
movwf off_counter
shutdown_kewl.1
bsf GPIO,LED
call on_delay
bcf GPIO,LED
call off_delay
incf off_counter,f
decfsz on_counter,f
goto shutdown_kewl.1
goto shutdown
on_delay
movf on_counter,w
movwf qw2
goto fade
off_delay
movf off_counter,w
movwf qw2
goto fade
fade
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
decfsz qw2,f
goto fade
return

END ; directive 'end of program'

Step 6: Programming interfaces for a 1-man PIC factory.

Picture of Programming interfaces for a 1-man PIC factory.
Here's my collection of programming devices. All are homemade.

Step 7: No Case? No problem. Meet the Holy Trinity of the Lazy Modder.

Picture of No Case? No problem. Meet the Holy Trinity of the Lazy Modder.
PP9.jpg
Mr Packing Tape. Mistress Stretch Plastic. And Lord Hotmelt Glue. If you don't got e'm, get 'em!

Step 8: Simple tips for working with SMD stuff

Picture of Simple tips for working with SMD stuff
PP3 001.jpg
PP3 003.jpg
PP3 006.jpg
Check the pics

Step 9: The End

Picture of The End
thats some good work. im remaking my pickit2 clone (first one was made on perf board and still works) my original was 100% through hole, but didnt have the fets or opamp to power the target board. i just made a new one thats 2" square (much smaller than my original) and everything fits on 1 side of the board (no vias at all). just wanted to thank you for confirming that a 22uf cap works for the vpp pump, because that is what i had on hand.
klee27x (author)  bowlofpudding1 year ago
Nice to see people still using this great device. I stopped after building 3 of them for my own use. I have to admit, I made this thing too darn small. It was no fun at all to solder with no mask! I have one for general use, plugged into my computer. I have a full battery powered version on an arbor press, for batch flashing individual boards. And I have one installed on a CNC mill. The mill is run with a totally custom control board and an old computer power supply. A PIC is the brains, and it runs the steppers in unipolar mode via 12 FETs. It flashes panels of pcb's, using the indicator LED signals of the PICKIT2 to verify programming before continuing to the next pcb. I flash the control board with the number of rows per panel, columns per panel, the number of steps for X and Y directions (4 steps per mil), and the distance of Z axis movement in hexadecimal into the EEPROM to switch between different boards!
so are you saying you have a setup to just place the boards down, and it goes and selects the board and programs it autonomously? thats pretty advanced. i dont even bother putting the icsp header on my boards anymore, i just flash a usb bootloader on the pic before installation. and i agree the compact placement makes fitting the components complicated, ive been using a solder resist because some chips ive been using are the qfn versions. i did have trouble with the circuit from the pickit2 manual though, something must not have been soldered right cas it kept saying there was a problem with VDD but i added some flux and reheated all the joints and now its fine. by the way, vdd should go up and down when changed in the pickit2 application correct? because my board the VDD always stays around 4V, im thinking my circuit has an error. end of long winded post
klee27x (author)  bowlofpudding1 year ago
No. The mill is for batch programming of large amounts of small panelized pcbs. I can put down, say, an 8x4 panel of 32 pcbs on the mill. Setup the PICKIT2 for P-2-Go. Flash the control board with the panel dimensions. Then press a button and the mill flashes the pcbs, one at a time. If there's a programming error, it will pause indefinitely until I fix or override the error. I have flashed over 500 pcbs in about an hour or two, and I didn't have to sit there and watch it. Just swap out the panels at my own convenience.

Yes, the Vdd should be adjustable. I think it goes from 1.8V -5.5V, or thereabouts. The clock and data lines will automatically mimic this voltage because the transistors on those lines act as voltage followers. There's a lot of "stuff" in the schematic that people frequently omit, but everything in there is quite useful and well thought out. If your programmer Vdd doesn't follow the voltage setting in the software, then it sounds like you have a bug somewhere.
klee27x (author)  klee27x1 year ago
I think the Vdd voltage control circuitry should be easy to identify. The schem is pretty well documented and labeled. Sorry I can't be more specific. t's been a long time since I looked at the schematic.
cody3053 years ago
I have no idea what these little programmable chips and stuff are used for, do you build robots with them? Build your own cell phone? What kinds of things can you make that would be worth all this trouble? Or do you just do it for fun like a hobby? Thanks!
TDWay cody3053 years ago
AC freezing up is an easy fix , go to the automotive parts store buy a refrigerant refill kit, around $34.00 USD with the engine turned off just add refrigerant (134A)
Connect it to the large AC Line, 1/2 a bottle by weight maybe a little more.
for best results take your car to a garage and have them charge the AC unit.
klee27x (author)  cody3053 years ago
That's a good question. Microcontrollers are a computer on a chip, complete with integrated memory, digital and analog I/O's, timers, PWM modules, and all sorts of neat things.

Microcontrollers control the stuff you have all around you. It's not just cell phones and robots. They also control the mundane things that don't take an EE degree to make or modify. I'm talking about elevators. Microwave ovens. Carpet cleaning machines. Coffee makers. They're even appearing on such things as heat guns and other power tools, to provide information such as temperature and battery life.

So... you could make you own microwave oven, carpet cleaning thingy, coffee maker, etc. Or you could modify the above to work more like you envision, rather than how someone else decided you might like it.

You could use them for such mundane things as making a simple on/off toggle switch! I have used dozens of microcontrollers to do exactly that. Why? Cuz combined with a tiny MOSFET, you can control a lot of power at the touch of a tiny microamp button that will fit anywhere, and the micro will draw practically no power when it's asleep.

Some of the things I've done with microcontrollers are viewable in my other Instructables. I've used them to make an LCD display temp-controlled soldering station. And a heat sealer that uses just one push button for both operation and for programming the impulse delay. (That firmware also makes for a great programmable delay fireworks igniter!) And of course, you may also see where I used one to make a simple toggle switch on a small LED flashlight.

One of the things I'm currently envisioning is a lab power supply and soldering station combo, using a single encoder knob to adjust PWM-controlled voltage, current, and soldering iron temperature, with 4 programmable saved settings on the power supply, and all the info displayed on an LCD display.

Lots of today's IC's are even designed with features that require a microcontroller to take full advantage of. The LT1308 I used for the DC boost on this programmer is one example. It has pins on it that are designed with the purpose of providing a low battery warning to a microcontroller.

If you've ever heard of the Arduino, then there you go. Anything you can do with an Arduino, you can do with a single chip. The Arduino just has extra stuff on it that makes it easier to use for a beginner, quicker to develop stuff for the veterans, and easier to share with other hobbyists. It's wonderful. But sometimes, all you want is a 50 cent power switch circuit that fits on a dime.

A microcontroller can also replace logic chips (albeit not quite as fast in many cases). The computer that landed men on the moon was built using something like 50 logic chips. That could be done on a single high speed microcontroller, today.
cody305 klee27x3 years ago
You just gave me an idea for an application for these. When I have my car A/C on with the blower on low speed, eventually the evaporator coil freezes up and I get no air coming through. Then I have to turn of the A/C compressor switch until the blower melts away the ice and I can get cold air again. If i had an automatic switch that turns the compressor on and off, say five minutes on, and one minute off, but variable time for both on and off, that would allow me to fine-tune it so it would never or rarely freeze up. Is that something a microcontroller could do? Are there existing designs for a circuit like that? What would it cost for all the parts? Thanks!
klee27x (author)  cody3053 years ago
Yeah, that's something a microcontroller can do. I think that might be overkill, though, for someone that doens't know how to program one. A 555 timer chip could do much easier for the uninitiated. Google "555 timer chip" and you'll see what I mean.

Hmm. Try this. Use a comparator to turn the coil on/off based on temp. Put a thermistor as one half of a voltage ladder onto the coil. That goes to one input of the comparator. Then put a potentiometer on the other input of the comparator. Now the coil automatically cuts off when it gets too cold, and you can adjust the cutoff with the potentiometer.

Course, you need to use the output of the comparator to drive a transistor that drives a relay, which disconnects power to the coil.

The hardest part about working on a car is identifying and getting to the right wires!
I call that last picture (it occurs with relative frequency among my cats as well) "Syncroni-kitty".
That picture really scares me at the thought of kitties scratching the couch with their nails = (

A nice pic indeed.
klee27x (author)  ildegiron3 years ago
I have long given up on worrying about that kind of thing. Cats will be cats. They are incredibly resistant to learning what I wish they would or wouldn't do. And I have decided they make me happier than nice furniture or security deposits. :)
wbond13 years ago
I have a question, can this device extract a program from an eeprom? I have a collection of about 11 eeproms from the mid 80s that we have lost the program to and we need to extract it, but don't know how or where to go to have it done, can you help me with this please.
klee27x (author)  wbond13 years ago
According to my PICKit2 software device list, it can read the following EEPROM families:
11LC
24LC
25LC
93LCAx,C
93LCBx,C

I have no clue as to the amount of standardization between different EEPROM manufacturers or between different decades. I hope you have the datasheet for your parts? And that the parts aren't read-protected?

I wish I could be more help, but I don't have much experience using EEPROMS from this decade, let alone from the 1980's. :(
ciroman3 years ago
" My latest project is a remake of today's hottest 15-year-old PIC programmer, the PICKit2!"
"Microchip launched the PICkit2 in 1997."

Umm...

Launched in 2005?
Davak72 ciroman3 years ago
Yeah, I don't know where the 1997 came from. Here is wikipedia on the subject:
http://en.wikipedia.org/wiki/PICKit#PICkit_2
klee27x (author)  Davak723 years ago
Hmm. Yeah, I dunno either. Thanks for the heads up, guys. I have amended the Instructable.

This is good news! I'm only 7 years behind. At this pace, I should have my first smart phone before the end of the decade. :)
Davak72 klee27x3 years ago
Haha awesome.

Also, great instructable! The tip about denatured alcohol for hot melt glue will certainly come in handy! (I find it very easy to mess glue up)

Also I read your breadboard ible. When I got my breadboard, the first thing I did was take the back off and connect all the power bars to the screw connectors built into the top of it. It was nice to see I wasn't the only one not wanting to repeat connections that are used all the time. But now I'm going to have to make some of those leds with the smd resistors on the small board!

Thanks for the tips,
David