Ultra Low Cost PIC Programmer With Arduino Uno
by nrbittencourt in Circuits > Electronics
229 Views, 1 Favorites, 0 Comments
Ultra Low Cost PIC Programmer With Arduino Uno
As my projects became increasingly complex (and required more discrete components), I decided to migrate several of them from "discrete" electronics to microcontrollers.
During this transition, I evaluated various microcontroller families available and I selected PICs because they are easy to find, cost-effective and meet my requirements.
To keep my projects as low-cost as possible (and also as a personal challenge), I made two decisions: a) to purchase some PIC12F675s (the cheapest here in Brazil) and some PIC16F819s and b) to build my own PIC programmer!
Thus, the PicArd (PIC + Arduino) Project was born!
PicArd IS:
- a full USB programmer for PIC microcontrollers;
- composed by PC software, Arduino software and extremely simple and cheap hardware;
- able to run in Windows and Linux;
- able to use High Voltage Programming (HVP) and Low Voltage Programming (LVP);
- script oriented (and based on PICkit 2 Interface Guide from Microchip);
- capable of select between three voltages (5.0V, 3.3V and 2.7V) and
- PicKit independent (you don't need to have one of them to extract firmware).
PicArd ISN'T:
- a debugger for PIC microcontrollers;
- able of performing all PicKit's functions;
- capable of handle PIC32, EEPROM and KEELOQ families and
- able to program device via ENHANCED ICSP (programming executive).
Important note: PicArd has only been tested with the PIC12F675 and PIC16F819 microcontrollers.
For more details about this project, please visit the GitHub repository
Supplies
1 x 47uF Polarized capacitor (C1);
1 x 330pF Unpolarized capacitor (C2);
1 x 470uF Polarized capacitor (C3);
1 x 100nF Unpolarized capacitor (C4);
1 x 1N5231 5V Zener diode (D1);
1 x 1N5817 20V 1A Schottky Barrier Rectifier Diode (D2);
1 x 1N4148 100V 0.15A standard switching diode (D3);
1 x 2.2mH Inductor (L1);
2 x BC547 0.1A Ic, 45V Vce, NPN Small Signal Transistor, TO-92 2 (Q1 and Q4);
5 x BC557 0.1A Ic, 45V Vce, PNP Small Signal Transistor, TO-92 (Q2,Q3,Q5,Q6 and Q7);
1 x 1k2 Resistor 1 (R1);
3 x 4k7 Resistor (R2, R4 and R8);
1 x 2k8 Resistor (R3);
2 x 100k Resistor (R5 and R14);
3 x 10k Resistor (R6, R7 and R9);
1 x 56 ohms Resistor (R10);
3 x 2k2 Resistor (R11, R12 and R13);
1 x Arduino Uno R3 (Original or Clone with same PINOUT;
Breadboard wires;
Arduino Uno USB cable (Arduino to PC connection);
PicArd Arduino Firmware (see Step 2) and
PicArd PC Software (see Step 3).
Build the Hardware
I assembled the circuit on a breadboard, but I plan to design a custom PCB Shield for the Arduino Uno in the future. Feel free to build yours however you prefer, following the schematic shown above or in the PDF below.
The file below points to version 0.41. However, I recommend visiting the PicArd GitHub Project Releases Page to verify the most recent version.
Downloads
Install Arduino Uno Firmware
Arduino UNO firmware main functions:
- Control and monitor PicArd's hardware voltages (voltages on/off, PWM, etc);
- Send/receive serial data to/from the connected PIC and
- Send/receive information to/from PC via USB port.
Upload the (firware) to your Arduino Uno using the Arduino IDE or your favorite application.
Downloads
Download PC Application
PC software is a console application for Windows/Linux, its main functions are:
- Parse device database;
- Parse '.hex' files provided by user;
- Backup OSCCAL, bandgap and configuration words to avoid data loss and
- Send/receive information to/from Arduino via USB port.
Download the appropriate version for your operating system and extract the files to an easily accessible folder (e.g. 'C:\picard' or '/home/user/picard').
Make sure the executable ('picard.exe' or 'picard') and the device data file ('pic_devices.dat') are placed in the same folder.
PC software is available in PicArd GitHub Project Releases Page.
Connectios
The connection between the computer and the Arduino is self-explanatory (I hope...).
When wiring up a PIC microcontroller, it is necessary to follow the "Memory Programming Specifications" for that device.
The diagram above shows an example of the connection between the Arduino Uno and a PIC16F675 (This example follows PIC16F818/819 Memory Programming Specification)
Downloads
Using
Command line sintaxe:
Where:
serial port - [Mandatory] USB connected to Arduino Uno with PicArd firmware;
device name - [Mandadory] Device name. Example: PIC12F675;
-r - [Optional] Reads device parameters (use picard -r 0 to see read options);
-w - [Optional] Writes device parameters (use picard -w 0 to see write options);
-h - [Optional] Used with -w program and -w all. Specifies hex file to be send to device;
-o - [Optional] Output file for read options. If omitted, outputs to screen.
Common operations:
1) Verify a hex file:
This will create the file hex_verification.txt, which allows you to verify if file was correctly parsed by PicArd.
Attention: check_hex option does not consider device's actual OSCCAL and Bandgap parameters!
2) Verify if PIC12F675 exist in database (pic_device.dat):
3) Read all parameters from a PIC12F675 (Arduino on COM4, Windows OS), results to screen:
4) Read all parameters from a PIC12F675 (Arduino on COM4, Windows OS), results to file:
Short text results (configuration words, device ID and user words) will be displayed on screen. EEPROM and Program data will be save to 'test.epr' and 'test.prg', respectively.
5) Send hex data (program.hex) from PC to PIC12F675:
Will send all necessary data (program data, EEPROM data, configuration words, etc) to device.
The -w all option executes a chip erase before writing data. For some devices, using this option is mandatory to write all the data correctly.
6) Send EEPROM data only (program.hex) from PC to PIC12F675:
Conclusion & Next Steps
Possible next steps:
1) Improve the comments in the source code and make them available on Github;
2) Create a graphical interface for the project;
3) Create a shield and
4) Test new PIC microcontrollers (if possible).
If you test this project, please leave your comments about your experience, and it is very important that you indicate which PIC model you used in your tests!
For more details about this project, please visit the GitHub repository
Thank you for reading!