Arduino-based PIC programmer

Showcase your projects! We love to see what people come up with, so please share your creations here.
rweather
Posts: 7
Joined: Sat Apr 28, 2012 9:49 am

Arduino-based PIC programmer

Post by rweather » Sat Apr 28, 2012 10:37 am

Hi all,

I recently got into Arduino - all Freetronics boards and shields of course - and after doing the usual newbie "blink a LED" and "show something on the LCD shield" stuff, I turned my hand to something a little more challenging - a programmer for PIC microcontrollers!

The old RS-232 based programmer I built years ago is now a museum piece because there are no computers left in the house with an RS-232 port and USB serial converters just don't work. Then I thought: all I need to do is twiddle the data and clock lines in the correct pattern, right? Can I build a shield for that? Thus began my obsession of the last 3 weeks. All of the details and source code are up on github:

Documentation: http://rweather.github.com/ardpicprog/index.html
Source code: https://github.com/rweather/ardpicprog

There were some interesting challenges. The first being that the Protoshield wasn't big enough for the whole circuit! The solution was to build it onto two shields: the 13 volt power supply on one shield, and the PIC programming circuit on the other. Then simply stack them up (hopefully the images will work in this post - see the web site otherwise):

Image

The 13 volt VPP programming voltage was the next challenge. There are circuits out there for 5v-to-13v boost converters, but the current draw can be a bit high and the circuits used zener diodes and inductors and other funky components I don't normally have on hand. To simplify things, I used a standard 7812 voltage regulator with a resistor ladder in the output stage to generate 13 volts using a 12 volt regulator. Thanks to the Jaycar catalogue for that trick! The supply is powered by an external 16-20 VDC source, either a bench power supply or two 9 volt batteries wired in series. A connecting cable passes the 13 volts up to the top shield.

Image

Next was the circuit for the programmer itself. An article from Silicon Chip Magazine Sep 2003 gave me most of the details. The top board features a ZIF socket, ICSP header, 18 pin vs 8 pin selector, status LED's, and a transistor for switching the 13 volt supply on and off under Arduino control (transistor on = reset PIC, transistor off = apply VPP).

Image

All of the circuit details are on the web site: http://rweather.github.com/ardpicprog/p ... rcuit.html

The next challenge was making it possible to download a HEX file into the PIC. I divided the problem into two parts: a sketch running on the Arduino and a host program running under GNU/Linux. The host program has the same command-line syntax is the venerable picprog. The host and the sketch communicate using a simple serial protocol over USB. The protocol is fully documented on the site, so other people can make compatible sketches for other shields and PIC types.

Right now the range of PIC's supported is fairly basic, mostly common members of the 14-bit series: PIC16F84A, PIC16F628A, PIC12F675, and so on (full list on the site). New PIC types can be added by modifying the sketch and circuit. Or throwing the sketch away and writing a new one that implements the same serial protocol. Patches welcome to support other people's favourite PIC's.

It works great on the PIC's I've tested it with. It even managed to resurrect a PIC that I had considered "bricked" years ago - I had flipped the wrong bit in the config word and made it unprogramable by my old RS-232 programmer. But since my circuit includes VDD control, it was able to force the PIC into programming mode and bring it back from brick heaven.

Feedback, patches, better circuits, all welcome!

Cheers,

Rhys.

User avatar
jonoxer
Freetronics Staff
Freetronics Staff
Posts: 297
Joined: Sat Oct 15, 2011 11:31 am

Re: Arduino-based PIC programmer

Post by jonoxer » Sun May 20, 2012 7:30 am

That's a very impressive project, Rhys, good work!

It's been a few years since I've used a PIC but I still have a few around here somewhere. They can be really handy because of the built-in peripherals in some models.
--
Jon

User avatar
ecips
Posts: 3
Joined: Thu Aug 09, 2012 2:00 pm

Re: Arduino-based PIC programmer

Post by ecips » Thu Aug 09, 2012 2:55 pm

Hi All,

Firstly, thanks to Rhys for sharing his work on this programmer with us. His documentation and write up are awesome.

I decided to have a go and build one for myself to add to my collection of tinkering toys.

Image

I am pleased to say, it works exactly as advertised!

As you can see, I built the entire device on a single shield.

I have uploaded some additional photos here:

http://www.spice.net.au/ArdPicProg/

Thanks again to Ryhs for his hard work.



Cheers,

Gary

blesbok
Posts: 3
Joined: Fri May 17, 2013 7:37 pm

Arduino-based PIC programmer: code missing?

Post by blesbok » Fri May 17, 2013 8:49 pm

ecips wrote:
It works exactly as advertised
Well, I look forward to saying the same. So far, I've got the circuit built and the sketch uploaded to the Arduino Uno. The only obstacle to burning the PIC is the lack of a Host Program.

There's no download to be found at http://rweather.github.com/ardpicprog/host_program.html Where did you get it? Is there an alternative link?

blesbok
Posts: 3
Joined: Fri May 17, 2013 7:37 pm

Re: Arduino-based PIC programmer

Post by blesbok » Mon May 20, 2013 12:42 pm


Alex1138
Posts: 3
Joined: Thu May 30, 2013 5:05 pm
Location: Provincias Unidas del Rio de la Plata - Córdoba de la Nueva Andalucia
Contact:

Re: Arduino-based PIC programmer

Post by Alex1138 » Thu May 30, 2013 5:21 pm

Hi! Is there any .exe file from Host Program for windows xp ready to run?
where I can download it?
I'm having some trouble compiling with devgcc. :evil:

blesbok
Posts: 3
Joined: Fri May 17, 2013 7:37 pm

Re: Arduino-based PIC programmer

Post by blesbok » Fri May 31, 2013 6:00 pm


Alex1138
Posts: 3
Joined: Thu May 30, 2013 5:05 pm
Location: Provincias Unidas del Rio de la Plata - Córdoba de la Nueva Andalucia
Contact:

Re: Arduino-based PIC programmer

Post by Alex1138 » Sat Jun 01, 2013 5:47 am

I download it,
Ardpicprog.exe is working.
now I be figthing with my hardware, seem to be have an error.
Thank, Blesbok.

PD: Alex1138 = Miranda
Attachments
ArduinoPICprogrammer.jpg

Alex1138
Posts: 3
Joined: Thu May 30, 2013 5:05 pm
Location: Provincias Unidas del Rio de la Plata - Córdoba de la Nueva Andalucia
Contact:

Re: Arduino-based PIC programmer

Post by Alex1138 » Sat Jun 01, 2013 6:52 pm

I can not believe it, my Arduino Nano V.3 recorded the PIC16F628!
I had an error in the connections, so it threw an error, I fixed it .
Question, can change the 'sketch' of Arduino and burn pic16f877 PIC16F876 PIC16F819.
It's enough to retouch and add the data in the section:

Code: Select all


// Device names, forced out into PROGMEM.
const char s_pic12f629[]  PROGMEM = "pic12f629";
const char s_pic12f630[]  PROGMEM = "pic12f630";
const char s_pic12f675[]  PROGMEM = "pic12f675";
const char s_pic12f676[]  PROGMEM = "pic12f676";
const char s_pic16f84[]   PROGMEM = "pic16f84";
const char s_pic16f84a[]  PROGMEM = "pic16f84a";
const char s_pic16f87[]   PROGMEM = "pic16f87";
const char s_pic16f88[]   PROGMEM = "pic16f88";
const char s_pic16f627[]  PROGMEM = "pic16f627";
const char s_pic16f627a[] PROGMEM = "pic16f627a";
const char s_pic16f628[]  PROGMEM = "pic16f628";
const char s_pic16f628a[] PROGMEM = "pic16f628a";
const char s_pic16f648a[] PROGMEM = "pic16f648a";


struct deviceInfo const devices[] PROGMEM = {
    // http://ww1.microchip.com/downloads/en/DeviceDoc/41191D.pdf
    {s_pic12f629,  0x0F80, 1024, 0x2000, 0x2100, 8, 128, 1, 0x3000, FLASH4, EEPROM},
    {s_pic12f630,  0x10C0, 1024, 0x2000, 0x2100, 8, 128, 1, 0x3000, FLASH4, EEPROM},
    {s_pic12f675,  0x0FC0, 1024, 0x2000, 0x2100, 8, 128, 1, 0x3000, FLASH4, EEPROM},
    {s_pic12f676,  0x10E0, 1024, 0x2000, 0x2100, 8, 128, 1, 0x3000, FLASH4, EEPROM},

    // http://ww1.microchip.com/downloads/en/DeviceDoc/30262e.pdf
    {s_pic16f84,   -1,     1024, 0x2000, 0x2100, 8,  64, 0, 0, FLASH,  EEPROM},
    {s_pic16f84a,  0x0560, 1024, 0x2000, 0x2100, 8,  64, 0, 0, FLASH,  EEPROM},

    // http://ww1.microchip.com/downloads/en/DeviceDoc/39607c.pdf
    {s_pic16f87,   0x0720, 4096, 0x2000, 0x2100, 9, 256, 0, 0, FLASH5, EEPROM},
    {s_pic16f88,   0x0760, 4096, 0x2000, 0x2100, 9, 256, 0, 0, FLASH5, EEPROM},

    // 627/628:  http://ww1.microchip.com/downloads/en/DeviceDoc/30034d.pdf
    // A series: http://ww1.microchip.com/downloads/en/DeviceDoc/41196g.pdf
    {s_pic16f627,  0x07A0, 1024, 0x2000, 0x2100, 8, 128, 0, 0, FLASH,  EEPROM},
    {s_pic16f627a, 0x1040, 1024, 0x2000, 0x2100, 8, 128, 0, 0, FLASH4, EEPROM},
    {s_pic16f628,  0x07C0, 2048, 0x2000, 0x2100, 8, 128, 0, 0, FLASH,  EEPROM},
    {s_pic16f628a, 0x1060, 2048, 0x2000, 0x2100, 8, 128, 0, 0, FLASH4, EEPROM},
    {s_pic16f648a, 0x1100, 4096, 0x2000, 0x2100, 8, 256, 0, 0, FLASH4, EEPROM},

    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
looking for information on:
PIC16F818/819 Flash Memory Programming Specification
http://ww1.microchip.com/downloads/en/D ... 39603c.pdf

PIC16F87x EEPROM Memory Programming Specification
http://ww1.microchip.com/downloads/en/d ... 39025f.pdf


it's possible?

User avatar
AlchemyCS
Posts: 6
Joined: Thu Nov 29, 2012 11:06 pm
Location: Sydney, Australia

Re: Arduino-based PIC programmer

Post by AlchemyCS » Sat Jun 22, 2013 6:48 am

I've been eyeing this projects for months now, finally got around to doing it - works great!

A note for Mac users:

DON'T use: /dev/tty.xxxx

DO use: /dev/cu.xxx

Take care!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests