goto Home

 

PIC Programmer Hardware

If you're going to use PICs' whether it's with code written by someone else, or with your own code you'll need a programmer.  There are numerous free hardware designs available and the software to control them.  Alternatively you can buy programmers as kits or ready built. 

I now have three different programmers and they are described below.  If you are new to PICs and looking to buy or build your first programmer I would recommend the PICkit2 from Microchip, or build a clone version of it.  You can find more information on the PICkit2 at the bottom of this section.

K149  The original one I started with which is still an easy to use and consistently reliable programmer is sold in the UK by Quasar Electronics.  It is part number 3149 - USB & Serial PIC programmer with ICSP  and is available as a kit or ready assembled.  It comes with its own software and can program a good range of PICs.  The software is good, easy to use and reliable. It has an ICSP header as well as 40 pin socket for standalone programming (the kit doesn't come with a ZIF socket, you have to buy that as an extra).  One feature it does have is the ability to automatically program a device when it detects it in the programmer socket; useful if you need to duplicate code into a number of devices quickly. 

My only issue with this programmer is that they haven't updated the software for sometime now.  It can still program all the PICs I'm interested in using but it's a point worth noting.  This programmer is produced by Kitsrus.com and is available from a number of resellers around the World. For details and distributors see  http://kitsrus.com/pic.html

Inchworm+
The second programmer I now use is an ICD2 clone called the Inchworm+ from Blueroom Electronics. 

The Inchworm+ is a clone of the Microchip ICD2 programmer / debugger.  It is fully supported in the Microchip MPLAB IDE software development application and therefore as new versions of MPLAB are released to support new devices, the Inchworm+ will be able to program them.

The basic Inchworm+ has an RS232 serial interface and an ICSP plug for connection to the target PIC device.  This is all you need to start using and programming PICs.

Firefly
In addition to the basic Inchworm+ there is the Firefly Programmer adapter / 16F88 tutor board.  This is a dual function board that can be used with the Inchworm+ as a PIC ZIF socket adapter or as a PIC software development tutor platform using the 16F88 PIC.  If assembled with all the parts, it can be swapped between the two roles at any time.

Unicorn
The second board available for use with the Inchworm+ is the Unicorn USB upgrade / experimenter board.  Like the Firefly this board is dual function.  It can either be attached directly beneath the Inchworm+ board to provide USB connectivity for Inchworm+ ICD2 function, or as a USB experimenter board with a PIC18F4550, Character and Graphic LCD interfaces as well as RS485, USB  and keypad interfaces.

The great thing about the Firefly and Unicorn is that once assembled you can swap between the two functions, or if you only want to use it for one of the functions omit the parts not needed to save a bit of cash.

I've now got three Inchworm+ programmers;

  • An original Inchworm that lives in the workshop.
  • Inchworm+ with Unicorn attached as a USB interface in the office
  • Inchworm+ with Firefly that doubles as both a programmer for PICs using the ZIF socket and a code test platform to save me hooking up on a breadboard.

Not that you actually need three Inchworm+'s, one will do. Add the Unicorn for full USB connectivity with MPLAB and then add the Firefly, stack them together and you've got yourself a first rate setup for PIC programming and development work.

Another nice thing about these boards is that they use standard parts that are readily available which means if you blow a part through ambitious experimenting, it's simple and cheap to fix.

I know it's a bit of a cliché but I don't know how a managed before. With MPLAB loaded and the Inchworm+ connected to a PIC through the ICSP connector, you hit 'quickbuild' in the MPLAB IDE and your code is assembled and (assuming no errors) written straight to the PIC.   It really makes development work so much easier and faster. 

Assembly Photos
All three boards are sold as bare PCBs / kits.  Assembly is very straightforward as these photo's show.


Inchworm+ ICD2 & Unicorn USB upgrade connected to a one of my projects

Although the 12F6xx series PIC's can't use the In-Circuit Debugger you can still use the ICD connector for In-Circuit Programming.  A lot easier than constantly swapping PIC's between the programmer and circuit.

Inchworm+ ICD2 with Firefly board mounted on top.

I've swapped the supplied 10 pin straight box header used on the Inchworm+ for the ICSP connector for a right angle connector. If you use the straight header, when the Firefly daughter board is located above the Inchworm you can't unplug the cable if you want to use it for in circuit debugging / programming.

The Inchworm+ is a clone of the official Microchip ICD2 programmer/debugger so it supports all PIC's that operate on a 5V supply and as new PICs come out it should be able to support them.  I've started to use the Inchworm+ for all my code development as it integrates fully with MPLAB.  With some thought to circuit and pin functions the development host circuit can be connected using the ICSP connector so there's no need to keep swapping PICs between the programmer and the host circuit which makes life so much easier.

You can buy the Inchworm+ kit which includes the pre-programmed 16F877 and Firefly PCB from DipMicro.  They're located in Canada and they ship Worldwide.  It took about 7 days to arrive in the UK when I ordered it.  With the current (March 2007) USD/GBP exchange rate it's a real good deal price wise. 

If you don't want to buy the kit you can buy the PCB's for the Inchworm and Firefly as well as the pre-programmed 16F877 PIC.  Schematics and construction details can be found on the Blueroom Electronics website.


PICkit2

Microchip have now brought out the PICkit2 programmer.  It programs most of the PICs you are likely to want to use in a hobby environment and possibly professionally too.  It works with Microchips MPLAB IDE software as well as it's own standalone programmer application.  As well as programming a good range of PICs, it can also program and read EEPROM.  Microchip continue to develop the software for the PICkit and as new PICs are introduced support is likely to be added for them.

Blueroom Electronics make a PICkit2 clone and PIC tutor all in one.  The kit is called the Junebug and you can assemble it without the components for the Tutor and just use it as a PICkit2 clone programmer, or with the Tutor section as well you have a PIC 18F1320 or PIC16F88 and various switches, LEDs, IR sensors which provides you with a complete programmer and training environment on a single PCB.  I've starting using mine with a 16F88 to develop and test code as it's completely self-contained.  The PICkit2 software also allows the programmer to act as a Serial UART and includes a terminal emulator. The Junebug uses a DIP switch to allow the serial RX/TX connections on the Tutor PIC to be connected back to the programmer which means even if your PC doesn't have a serial port, you can develop and test serial interface applications.

I've been really impressed with my PICkit2 clone and I'd recommend it, or the genuine thing from Microchip as the way to go if you are looking for your first PIC programmer, or want to upgrade from one of the free programmers.  What I really like about the Blueroom Electronics Junebug clone is that it can be used as a self contained development system.  For a lot of code development work I just connect up to a USB port and I'm ready to go, no need for breadboards and cables, power-supplies etc all over the desk.

Blueroom Electronics Junebug PICkit2 clone and PIC tutor

The photo above shows my Junebug PICkit2 clone.  This is assembled as the programmer only.  The photo below shows the board with the Tutor section assembled as well.

For construction photo's of the Junebug click here

Screen dump from Microchips PICkit 2 Programmer software connected to the Junebug pictured left.

Free programmers and software from the Internet

I did build a popular free programmer to help troubleshoot a problem. Someone had built it and was having problems getting it to program my code into a PIC; I built the programmer to find out whether it was my code, the person or the programmer - turned out it was the free programmer/software. My experience with that left me feeling that the old adage "you get what you pay for" still stands.  But don't let me put you off, if you're short of cash have a go at building a programmer yourself and see how you get on. 


Writing Code

You can get C compliers, Basic compilers and Assemblers for the PIC.  Some are free, some you pay for and yet others you pay even more for, there is even a compiler language called JAL written just for the PIC and it's free.   Of course, you can just program in straight assembler and Microchip provide free IDE software for code development and simulation/debugging.  Three links for starters are here, there's a lot, lot more out there, Google for it.

PIC Simulator

Although the Microchip MPLAB IDE has a software simulator it's not easy or in some case possible to emulate interrupts and some of the hardware devices such as the USART.

I've found a really great PIC simulator that you can get here http://www.oshonsoft.com/.  Download a time-limited version for free and try for yourself.  The cost of the personal edition is only about £12 and I've found it a really useful application.  

Tutorials

Hundreds of PIC tutorial web sites out there, many of them are rubbish, out-of-date or written by people who know less than you do already so be careful which one you PIC (pun intended).

However, it's not all bad and two that I think are worth a spending some time looking at are:

And don't forget the Help files in MPLAB already contain many answers to questions you may have so it's worth having a look through them.

Buying PIC's

Occasionally you can pick up some good deals on PICs on E-bay, just browse to Business, Office & Industrial > Electronic Components then search for the key word PIC. 

There's  a lot of information and reference to the 16F84 PIC chip. This chip is an old PIC dating from the 90's. You are much better off going for one of the newer PIC's like the 16F627A/628A or 12F675. The 16F627A is pin compatible with the 16F84 but has a lot more functionality, including internal 4Mhz oscillator so you don't need an external crystal or resonator.  The other reason for going with these newer PICs is that the arrangement of their special function registers is standardised so it's easier to port code from one chip to another. In addition the program FLASH memory is now rated for much higher write/erase cycling than the 16F84. 

Two even newer PICs that are worth considering for any new projects are the 12F683, which is backward compatible with the 12F675 but has additional features including 2K program memory and 8Mhz internal oscillator.  Then there's the 16F88 which has 4K program memory, 8Mhz internal oscillator and the ability to self-program along with lot's of other features. I also like the 16F690, 20 pin device, all the features of the 16F88 except self-program and cheaper. It's worth looking over the datasheet for these devices if you're planning a new project.

Finally, the newer parts are generally cheaper to buy which is as good a reason as any to use them.

PIC Instruction Set

The Microchip PIC microcontrollers use a Harvard architecture where code and data memory are separate, unlike the von Neumann architecture used on processors such as the Intel Pentium.   The device uses a RISC instruction set with just 35 instructions. All instructions execute in one instruction cycle except for those that modify the program counter such as conditional branches, and goto's which always need two cycles.  Despite this alternative architecture, it is very easy to work with. I've had quite a lot of experience with the 6502 processor from the early 1980's (used in the Apple II and BBC Micro among many).  Although the 6502 had some better test and branch functions, it had only two internal registers so I've found the limited instruction set on the PIC quite easy to adapt to. In addition, the instructions the PIC has, particularly for bit testing and manipulation, are well suited to its intended applications.  PIC Instruction Set

Datasheets

Before you start using a PIC microcontroller you'll need to know all about it.  You should download the datasheet and while you don't need to read it cover to cover, it's the first place your should turn to when you're not sure about something, or things aren't working as you expected.  You can download datasheets from the Microchip website and while your there, take a look through the Application Notes, there's lots of interesting and useful information to be found in them.

Feature Creature

A feature I really like in the PIC is its low power consumption. It's quite practical to build battery operated devices with a PIC running at 4Mhz.  When you consider that the 6502 processor from 25 years ago, ran at the same instruction clock speed, had a single-stage pipeline and an instruction set that is similar and today would be considered RISC-like, it's just a great little device.  Going from 6502 to PIC having done little or no work with hardware and assembler programming in between is a bit like dreaming of all the things you wanted from a microcontroller and waking up to find it actually exists.

The PIC comes in a range of devices from 8 to 40 pin and different devices have different peripheral features built in.  A lot of thought has gone into the design to reduce the need to rely on external hardware.  The latest PIC's feature 8 different instruction clock sources, including an entirely internal 4Mhz oscillator that requires no external parts.

Inputs feature programmable pull-up resistors, the I/O pins are all multifunction and can be programmed to do whatever is required of them. The 12F675 for example has a 10-bit A/D converter, but this can be used on up to 4 inputs through a software selectable switch.  The reference voltage for the A/D converter is also software selectable.  As you look through the Mid Range MCU data sheet, you'll find that every peripheral on every PIC variant is like this and with a little thought you can achieve a great deal with the PIC interfacing directly to the I/O device with no 'glue' hardware between.

For full details of the Microchip Mid-Range MCU family check out this data sheet (it's big, 3Mb PDF) from Microchips website.