PURPIC, the wearable PICkit2 clone using PIC12F508 programmer
PURPIC, the wearable PICkit2 clone
An extremely brief history of the PICkit2
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.
An extremely brief history of PICKit2 clones
Enter PURPIC – Video in Action
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.
*Edit: 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.)
Here are some links of the action:
Here I’m wearing the programmer on my wrist
But in reality, it’s light enough to just stick on the end of a pogo pen.
Schematic and board layout
The PICKit2 schematic is viewable an Microchip’s website. Scroll down to page 81-82, or click on “Appendix B: Schematic”
Linear technologies LT1308 boosts the li ion battery output to 5V. Datasheet is viewable here.
The lithium ion battery charging is handled by the MCP73811. This nifty SOT-23 5 pin IC requires just 2 1uF capacitors to work.
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.
PIC 12F508 annotated source code; if anyone has a problem assembling as posted, please comment
#include <p12F508.inc> ; 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
;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
;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)
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
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
btfss GPIO,LBI ;this checks the Low Battery Indicator
goto LB_shutdown ;if pulled low, then goto Low Battery shutdownbtfsc GPIO,button ;as long as the button isn’t pressed, the PIC stays in “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 ;
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.
LB_shutdown ; this is the fancy-pants shutdown sequence
goto $+1 ; just some extra delay
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.
We recommend EasyEDA for electronic circuit design.
EasyEDA: A Powerful Free Circuit, Simulation & PCB Design Tool
Register now for free. No Need to download. Lots of resources and Step by step tutorials