Included with this book is a PCB that you can use to build your own PICmicr® microcontroller programmer. The programmer's name is the "El Cheapo" and reflects my efforts to create the least expensive programmer possible that would work on the widest variety of PCs by interfacing to their Parallel (Printer) Ports. This is actually quite a challenge because of the staggering variety of PCs that have been on the market.
The PCB provided here is designed to work with all the different PICmicro® MCU part numbers that come in "DIP" packages and can be programmed using the five line "ICSP" protocol. This means that virtually all the mid-range PICmicro MCUs can be programmed with the El Cheapo as well as a number of the Low-End parts (the PIC12CXXX and PIC16C505). The only mid-range parts that cannot be programmed using this programmer is the PIC14000 and the 20 pin PICmicro MCUs. The El Cheapo cannot be used for the PIC17CXXX and could be used with PIC18CXX2 (but I have not written the software to support the PIC18CXX2). The range of supported PICmicro MCU part numbers includes basically all the devices that are presented in the Experiments, Projects and Tools of this book. The part selection mechanism of the El Cheapo is based on a file table and can be easily updated when new parts become available.
To be as "universal" as possible, the El Cheapo circuit (shown below) uses the "handshaking" lines of the PC's parallel port instead of the data lines. This was done in order to allow the El Cheapo to work on PCs that did not have ECP, EPP or even basic bi-directional parallel ports. For the most part, this effort was successful, but there are a few things that can happen which will make it difficult for you to get your own "El Cheapo" working. At the end of this page, I have included a list of the most common errors made by people building their own versions of the El Cheapo. The circuit provided here is the fourth version of the original and incorporates a number of lessons that I have learned over a year of helping people build their own - chances are you will find that your El Cheapo will work right off the bat.
El Cheapo Parts and Circuit
Part | Description/Comments |
---|---|
U4 | 78L12 +12 Volt, 100 mA Linear Voltage Regulator |
U5 | 18 Pin 0.300" DIP Socket. 18 Pin "ZIF" Socket Recommended |
U6 | 14 Pin 0.300" DIP Socket. 18 Pin "ZIF" Socket Recommended |
P28 | 14 Pin 0.100" Socket Strip. This is one half of a 28 Pin DIP Socket cut down as described in the Text |
P40 | 40 Pin 0.600" DIP Socket. This is a 40 Pin DIP Socket cut down as described in the Text |
Q3 | 2N7000 N-Channel MOSFET Transistor |
Q4 | 2N3906 PNP Bipolar Transistor |
CR6, CR8 - CR10 | 1N914 Small Signal Silicon Diode. Any Small Signal Silicon Diode can be used for this application |
CR7 | 5.1 Volt, 1/2 Watt Zener Diode |
R7, R9 | 1 K, 1/4 Watt Resistors |
R8 | 330W, 1/4 Watt Resistor |
R10, R11 | 10 K, 1/4 Watt Resistors |
R12 | 220W, 1/2 Watt Resistor. Note that this resistor is rated at 1/2 Watt |
C5 | 0.01 uF Capacitor (Any Type) |
C6, C7 | 0.1 uF, 16 Volt Tantalum Capacitors |
C8 | 10 uF, 35 Volt Electrolytic Capacitor |
J1 | 2.5 mm PCB Mount Power Socket. CUI Stack Part Number PH-202B (Digi-Key Part Number CP-202B-ND) |
J2 | 25 Pin Female 90 Degree PCB Mount D-Shell Connector. Note - Male Connector CANNOT be used |
N/A | Four Rubberized "Feet" for PCB. This is Optional, but Recommended to avoid the El Cheapo from scratching table |
Parallel Cable | 6'/10' 25 Pin D-Shell Male to Male "Parallel Transfer Cable". May be labled "Interlink" |
Power Supply | 14+ Volt, 300+ mA AC/DC ("Wall Wart") Power Supply with 2.5 mm Power Plug output |
Miscellaneous | PICmicro® microcontrollers, Controlling PC, EPROM Eraser |
Tools | Digital Multi-Meter, Soldering Iron, Solder, Clippers, Needle Nose Pliers, Flat Bladed Screwdriver, Magnifying Glass |
PC Preparation
- Running Microsoft Windows 95/98/Me/NT/2000. If you are running Windows NT or Windows 2000, you will have to have "Administrator Rights" to install the software
- 100 MBytes of free Hard Drive space
- Display setup as 1024 by 768 pixels with 32 bits "True Color"
- Free Parallel Port (at Address 0x0378, 0x03BC or 0x0378)
With the parallel port set up correctly in the PC, I recommend that you now load in the MPLAB IDE from the CD-ROM and copy the book's application source files as is specified in File Copying/Harddrive Setup.
If you are an MS-DOS user, you can use eldebug.exe to test out your application design while you are building it as I outline below. El Debug and elcheapo.exe (the El Cheapo MS-DOS programming utility) are Version 3.1 tools for the original El Cheapo application. They will program all mid-range PICmicro MCUs that do not require oscillator calibration loading. The two applications can be found at in the "C:\PICmicro\code\elcheapo" directory of your PC.
For this book, I recommend that you use the Microsoft "Windows" version of the El Cheapo interface software. This software can be used for both building and debugging your programmer as well as the primary interface for programming PICmicro devices.
Before attempting to load the El Cheapo Windows application software, you should make sure that you have a "C:\Program Files" directory (folder) on your PC. For most Windows users, this is not an issue, but over the past few months, I have had to help some individuals that have non-standard installations of Windows and do not have the "C:\Program Files" directory. The "C:\Program files" directory is used to store the PICmicro MCU part number data files, the user preference files as well as the PCB layout graphics and if it is not present, the Windows installation program will fail to properly install the files, but you will not be notified of the error.
The first step in the process of installing the El Cheapo Windows interface is to load the "Port95NT" device driver. When Port95NT is clicked on, the PC will be loaded with a set of DLLs that allow the Windows Interface to access the hardware registers of the PC. This package will be required for one of the experiments and should not be removed once it is on your PC.
With the PC setup and Port95NT set up, you can now click Here to load the El Cheapo Windows interface. Loading should just take a few seconds and when it has finished, you can start up the El Cheapo Windows interface by clicking on "Start" -> "Programs" followed by the "El Cheapo Windows Interface".
El Cheapo Assembly
- Click Here to load the Port95NT Device Driver
- Click Here to load the El Cheapo Windows Interface
- Connect the Male to Male 25 Pin D-Shell "Parallel Transfer Cable" to the PC
- Plug the 14+ Volt AC/DC "Wall Wart" Power Supply in
- Click on "Start" -> "Programs" -> "El Cheapo Windows Interface" to start the El Cheapo Control Software. Click on "Build/Test" to expand the display and show the assembly instructions with testing options
The instructions in the "Build/Test" option will be used to guide you with which parts are placed on the board at each step. I have built six different "El Cheapos" and this is the order in which I have found the operations to be most efficient. You may encounter some problems that you can't figure out. If this happens, look down at Common El Cheapo Programmer Problems and their Solutions as your first line of defense.
Warnings:
I do not have a stack of El Cheapo boards waiting to be sent to people who incorrectly build their first ones. If you want a replacement board you will either have to buy another book or have a quick-turn PCB house build what I am calling "PCB1". A little care at the start will keep you from ruining the board or taking a long time to get it running. When you are getting ready to build the programmer, here are some points to keep in mind:
- These instructions are designed to use a Digital Multi-Meter ("DMM") for verifying the circuit. Chances are the board will work if you don't use one for assembly, but if you have a problem you won't be able to find it without a Digital Multi-Meter.
- Use the Digital Multi-Meter for verifying resistor values. You can read the bands on the resistors, but it is much easier to use a DMM.
- Make sure you have a PICmicro MCU chip handy for when the assembly is finished and you can test out the programmer.
- Print out this page before you start assembling the board.
- If you are unsure about anything - ask!
- Much of the information that you will require is on this CD-ROM in the Introduction to Electronics appendix.
- When you are asking questions, make sure you can describe the problems crisply - saying that your El Cheapo board doesn't work won't get you very far. Read Chapter 12, "Debugging your Applications" to help you look at the problems that you are having.
- The clerk at "Radio Shack" is probably not your best source of information or parts. If you have questions, find an electronics technology instructor, send a request to a sci.electronics newsgroup, the PICList, or, as a last resort, me.
- Using a "Straight Through" Male to Female DB-25 and a Male DB-25 Connector is NOT an acceptable replacement to the "Parallel Transfer Cable" and the Female DB-25 Connector on the board. "Straight Through" cables are generally designed for RS-232 applications and often do not have all the pins connected. As well, using a "Straight Through" will reverse the pins between the PC and the El Cheapo and will render the El Cheapo useless.
- Use the right tools for the job. Make sure you are using electronics soldering irons and solder.
- Expect to take an afternoon to build and test this circuit. You won't need anything like this, but it is always nice not to feel rushed.
I hope you understand that most of these instructions are common sense, but as somebody much smarter than me noted, nothing seems to be so uncommon as common sense.
Once you have everything together and you are ready, follow the assembly instructions below. Note that in virtually every step I ask for a voltage measurement and occasionally a test operation from the PC - always disconnect the power and the PC after testing the components for the current assembly step and going on to the next one.
- Get everything together. When I am about to start building a project, I like to place all the parts in front of me. When this is done, click on "Next" on the El Cheapo Windows Interface.
- Solder in the 2.5 mm Power Plug and the silicon diode at "CR8". When this is done, plug the card into the wall wart and measure the voltage at "C8" as shown the El Cheapo Windows Interface. The voltage must be greater than 14 Volts - Up to 18 Volts is not unreasonable. If the voltage is very low (and can be measured very high at the plug), check the polarity of "CR8" - the black band around the part should be pointing away from the Power Plug.
- Solder in the 10 uF (25 Volt Electrolytic) Capacitor at "C8". This capacitor should have a band marked "-" down one side. This is the "negative" side of the capacitor and should not be soldered toward the "+" marked via on the PCB. Next, Solder in "CR9" and "CR10" with the bands pointing toward the Power Plug. Finally, Solder in the 78L12 with the flat side of the component facing the center of the El Cheapo PCB. Plug the Power supply in and measure the power at the points shown on the El Cheapo Windows Interface. If the voltage is less than 13 Volts, then check the polarity of the diodes at "CR9" and "CR10" as well as the orientation of "U4".
- Solder in the 220W (1/2 Watt) Resistor at R12 and the 5.1 Volt (1/2 Watt) Zener diode at "CR7". Note the power rating values for these two parts - this is important to follow because the two components will dissipate quite a bit of power. When the components are soldered in, plug in the power and measure the output voltage as shown in the El Cheapo Windows Interface. If an incorrect voltage is measured, check the component value of "CR7" as well as its orientation.
- Solder in the Female, PCB mount DB-25 Connector at "J2". Next, Solder in the 1K (1/4 Watt) resistors at "R7" and "R9" along with the 0.01 uF capacitor at "C5". Solder in the diode at "CR6" with the band facing away from the Power Plug. Finally, Solder in 0.1 uF Tantalum Capacitors at "C6" and "C7". The two Tantalum capacitors should have a "+" symbol marked on their body to indicate the positive pin - this pin should be connected at the via on the El Cheapo PCB with the "+". To test the assembly of this circuit, connect power and the El Cheapo to the Parallel Port "Parallel Transfer Cable" which is connected to the PC. The test operation (click on "High" and "Low") can run autonomously, but I recommend checking the voltage values between "R9" and "C5" with a DMM to make sure there isn't any kind of voltage drop (caused by a "short" or "open" solder joing) within the circuit.
- Solder in the 10K (1/4 Watt) resistor at "R10". To test the assembly of this circuit, connect power and the "El Cheapo" to the Parallel Port "Parallel Transfer Cable". Again, while the software can test its own operation, I recommend using the DMM to ensure the connections are behaving properly.
- To test the operation of the "clock" circuit, connect power and the "El Cheapo" to the Parallel Port "Parallel Transfer Cable". There is no feedback circuit built into the El Cheapo for this function, so you will have to use the DMM to make sure the Clock connection is correct.
- Solder in the 10K (1/4 Watt) resistor at "R11". Next, solder in the 2N7000 transistor into the circuit with the flat (labelled) side pointing towards the center of the card. Depending on the manufacturer of the 2N7000, the labelled side may not seem to be the "flat" side - for this component, always make sure the writing on the transistor is facing the inside of the card. To test the operation of the "clock" circuit, connect power and the "El Cheapo" to the Parallel Port "Parallel Transfer Cable". There is no feedback circuit built into the El Cheapo for this function, so you will have to use the DMM to make sure the reset inverter circuit connection is correct.
- Solder in the 330W (1/4 Watt) resistor at "R8". Next, solder in the 2N3906 transistor into the circuit with the flat (labelled) side pointing towards the center of the card. The same comments regarding "Flat" and "Labelled" side that were presented in the previous step apply here. To test the operation of the "clock" circuit, connect power and the "El Cheapo" to the Parallel Port "Parallel Transfer Cable". There is no feedback circuit built into the El Cheapo for this function, so you will have to use the DMM to make sure the reset inverter circuit connection is correct.
- Solder in the 18 and 14 pin sockets for "U5" and "U6", respectively. Note that if you are going to use "ZIF" sockets, solder them in with the levers "up" (the socket is "open") to minimize the stress on the pins and it will make them easier to use. If you find that the ZIF sockets are stiff "reflow" the solder at each pin with the soldering iron with the socket "open" (levers "up"). Next, cut one side away from a 28 DIP pin socket and mount it with its "inside" facing the Female DB-25 Connector at "P28". When cutting the side away, make sure you trim off the "supports" to the other side, to avoid interfering with the 40 Pin connector that will soldered in the next step. When soldering in the "p28" connection, make sure the socket is flat against the bottom of the PCB.
- The last assembly step is to cut away the "Pin 1" and center (if present) supports of a 40 pin DIP socket and solder it into the "P40" positions. This is a bit of a tricky step and one that you can easily end up damaging the connector. To be on the safe side, I recommend that you have two (or three) on hand in case you make mistakes (they should be quite inexpensive).
- With the El Cheapo assembled, I recommend that you program in an application (like LEDOn) to test out its "functionality". When testing out the programmer's functionality, remember to "verify" with a loaded and programmed device as well as with a device programmed with a different application. You should be able to see the programmer detecting validly programmed parts and failing invalidly programmed parts.
That's it for the El Cheapo PCB assembly. It is not a terribly hard PCB to build, but if you are new to electronics, you should make sure you plan what you are going to do before hand and don't do anything until you are sure that you're going about it correctly. If you are running under MS-DOS, you will have to follow the same basic instructions, but use the "El Debug" application.
Software Operating Instructions
Both El Cheapo interfaces execute at approximately the same speed. You may find that the Windows version is even faster in some situations. Both interfaces program PICmicro MCUs using the Microchip specified algorithms which are explained in the Datasheets pages.
The MS-DOS "elcheapo.exe" application is invoked with the following command line statement:
elcheapo ProgName[.hex] [/1|/2|/3] [/v] [/e]
Where:
Command | Description/Comments |
---|---|
ProgName[.hex] | Hex File to be programmed into the PICmicro MCU |
[/1|/2|/3] | The parallel port to use with the El Cheapo (specified as "/1", "/2" or "/3"). The MS-DOS version will "pick up" the Parallel Port addresses from BIOS, so the actual port addresses do not have to be specified. If no parallel port is specified, then LPT1 is used by default |
[/v] | When "/v" is specified on the command line, the El Cheapo "verifies" the contents of the PICmicro MCU to the specified Hex File. If "/v" is not specified, then the PICmicro will be programmed with the contents of "ProgName[.hex]" |
[/e] | When "/e" is specified on the command line, the El Cheapo uses the "EPROM" programming algorithm specified in Datasheets. If the "/e" parameter is not present, then the El Cheapo software carries out the programming operation using the "Flash" programming algorithm. |
As well as being much more attractive than the command line interface, the El Cheapo Windows Interface is a lot easier to use without any documentation. As can be seen in the screen shot below, the El Cheapo Windows Interface allows you to simply select the PICmicro MCU part number, the Parallel port as well as the operation to carry out:
The controls on the El Cheapo Windows Interface consist of:
Control | Operation/Comments |
---|---|
File Selection | Select the Hex File to be programmed into the PICmicro MCU. This is stored in the "Preferences" file to avoid having to enter the information repeatedly. |
Parallel Port Select | The El Cheapo Windows Interface relies on actual port addresses rather than LPT numbers. This value is also stored in the "Preferences" file to avoid having to select the Parallel port to use repeatedly. |
PICmicro® MCU Part Number Select | The part to be programmed is selected by the user. When programming operations take place, The El Cheapo Windows Interface will store the program memory size and type as well as whether or not a calibration value is required. The PICmicro MCU part number data is in a table file which can be updated without requiring a rebuild of the application. The selected PICmicro MCU part number is stored in the "Preferences" file to avoid having to be reselected. Note that when a new PICmicro MCU part number is selected, the El Cheapo Windows Interface graphic changes to show where the PICmicro MCU is to be inserted into the card for programming. |
Program | When Clicked, the "Program" Control will initiate programming of the PICmicro MCU. If the device has Flash program memory, it will first be erased. If the device has EPROM program memory, programming will start immediately. Note that a "Blank Check" is not done before EPROM programming. The latest version of the Hex File is programmed into the device and not the version that was available when the application was first selected - this will allow the user to update the application file rather than have to reselect it after an PICmicro MCU application rebuild. If there there is a failure during programming, the operation will stop and the results displayed. Note that the Configuration Registers are programmed according to the contents of the Hex File - to ensure that they are being programmed, use the "__CONFIG" statement in your source code. If the device requires a calibration value, the entered or read in value on the El Cheapo Windows Interface Dialog Box will be programmed into the device. |
Verify | The "Verify" Control will initiate a comparison of the contents of the PICmicro program memory to the contents of the of the PICmicro MCU. If there is a miscompare, then the verify operation stops and the data is immediately displayed. Like the "Program" control, "Verify" operation uses the latest Hex File available on the PC's Hard Drive. Note that PIC12C50X and PIC16C505 devices will fail "Verify" after programming due to changes in how the data is read back after the Configuration Register is written to. |
Blank Check | The "Blank Check" Control will initiate a comparison of the contents of the PICmicro program memory to see if the program memory is fully erased. The configuration registers are checked, but the calibration addresses are ignored. Note that Flash devices are erased by the El Cheapo and do not need to be checked. |
Blank Check | The "Blank Check" Control will initiate a comparison of the contents of the PICmicro program memory to see if the program memory is fully erased. The configuration registers are checked, but the calibration addresses are ignored. Note that Flash devices are erased by the El Cheapo and do not need to be checked. |
Cal Read | Reading the pre-programmed calibration value is invoked by clicking on the "Cal Read" control. Due to the conventions used by Microchip, the calibration values are at the end of program memory and the El Cheapo Windows Interface will have to set the PICmicro MCU's program counter to the last address in order to read the calibration value. Along with the control, there is a text input box that can be used for manually entering the hex calibration value for the PICmicro MCU. When the application is programmed into a blank PICmicro MCU, the calibration address is checked to see if it is blank and if it is, then the least significant two digits of this hex value is used. If any of the digits are incorrect, the calibration value 0x0FF is programmed into the PICmicro MCU. |
Build/Test | The "Build/Test" control will open up the "Build/Test" portion of the El Cheapo Windows Interface and close it when clicked again. When the "Build/Test" mode of the El Cheapo Windows Interface is active, the Programming polling is stopped and the Programming modes of interface are disabled. Clicking on "Debug End" will also terminate the "Build/Test" mode of the El Cheapo Windows Interface. |
About | Clicking on the "About" control will show the El Cheapo Schematic as well as pointers to my email ID and web page. |
The Sun | The yellow circle in the top right hand corner of the El Cheapo Windows Interface Dialog box indicates whether or not the El Cheapo programmer is connected to the PC. If the El Cheapo programmer is not connected to the PC, then what I call "The Sun" will turn black. |
Really, the only thing to watch for with using the El Cheapo Windows Interface is the lack of the a "Blank Check" before programming. I debated on this one, but it does allow people to use "Patch Space" with the programmer.
In the next section, I have listed some common problems and the solutions around them before sending me an angry email saying the El Cheapo doesn't work, please work through the different test options that I have made available to you and make sure you don't have any of the problems listed below. In my first reply back to you I will probably be asking if you have worked through the debug options as well as the common problems listed below - please list your PC, what operating system(s), parallel port type, symptoms and what you've done to try and characterize the problem. This will help me to point you in the right direction much faster than sending back a message at a time.
The El Cheapo was originally presented as a Rentron article. This turned out to be an excellent method of prototyping the application (product) and finding out how to best design it to work with a number of different applications. As I have indicated, this is the fourth version of the design and I believe that it is quite robust. The two things I would do differently if I had to do the project over would be to a) change the 28/40 pin area so a single 40 Pin ZIF socket could be used and b) design it so that an ECP/EPP interface could take advantage of the hardware (and eliminate the need for the RC delay network). I am sure that many other people would approach the problem differently and probably more efficiently.
I am interested in your suggestions about how the El Cheapo works and if you have any ideas for how it could work better for you. Please send me an email (or better yet, publish it on the PICList for other's comments).
Good luck with your El Cheapo and I hope it gives you many hours of service!
Common El Cheapo Programmer Problems and their Solutions
- You may find that the El Cheapo works properly for a Flash based PICmicro MCU but not at all for an EPROM based PICmicro MCU. In this case, your AC/DC power supply is not providing enough voltage/current for the EPROM part's higher Vpp requirement. Increase the voltage output (if possible) in the current AC/DC Power Supply or replace it with a unit capable of higher voltage and current.
- If the El Cheapo Windows Interface is hard to read, I suggest that you change your PC Display to 1024 by 768 Pixels. If possible, 32 Bit "True Color" should also be used.
- You may have problems if you do not have a "true" "Parallel Transfer Cable". Make sure that your cable is DB-25 Male to DB-25 Male and use your DMM to check each pin on a connector to make sure it is wired directly to the corresponding pin in the other connector.
- I have written this several times above, but I must re-iterate that the connector on the El Cheapo PCB MUST be a "Female" connector (holes instead of pins in the connector). A male connector cannot be used as it will "reverse" the pins.
- Do not cut up your cables or make your own. The El Cheapo is designed to use commerical cables to avoid problems with mis-wiring as well as to save time and money. Don't make it hard on yourself - just go out and buy a $5.00 "Parallel Transfer Cable".
- Two people have reported that the El Cheapo only works with six foot or shorter cables. I have never seen this (in fact, on my PC, I use two six foot cables plugged together), but if the debug operations work without any problems and you can't program, you may want to try a shorter cable.
- You will probably find that the "Verify" operation fails for programmed PIC12C50X and PIC16C505 devices. The problem lies in how the data out of the PICmicro MCU after the configuration register fuses are programmed. This is not a problem with the mid-range PICmicro MCUs. I will be looking for a fix for this problem.
- The El Cheapo Windows Interface seems to load properly, but when it is invoked, it fails with a message that a "File is Not Found". Check your "C:\Program Files" directory and it should have a number of files with the extension ".emf". If they aren't there, or if there is a problem with the directory, remove the El Cheapo Windows Interface, fix the problems with the "C:\Program Files" directory and reload the El Cheapo Windows Interface.
- On some PC Motherboards, the built in Parallel port is unable to read back the "STATUS" bits in "SPP" or "Bi-directional" modes. You will see the problem when you are using El Debug or the El Cheapo Windows Interface to test the RC Delay and Data line circuitry. The only solution to this problem is to buy yourself an ISA/PCI "Plug and Play" parallel port (they are usually less than $20 USD) and use this for the El Cheapo interface. The preferable solution is to connect the El Cheapo to an unused parallel port and by buying an additional port, this will allow you to devote the motherboard's Parallel Port for your PC's printer.
- I have not heard any results from people trying the El Cheapo with a USB Parallel Port Interface/Converter. I would suspect that this wouldn't work (although I could be surprised). If you do try this out with a USB Parallel Port Interface/Converter please let me know what your results are and what manufacturer/model hardware you are using. In any case, I recommend that you use the "legacy" ports built into your PC (or get a PC that has them).
- Check my web page for updates to the El Cheapo software. I have arbitrarily labelled the version that is shipped with this book as "0.50" because I expect there to be problems that come up or different ways of approaching the different actions provided by the programmer.
The links to the software are broken
ReplyDelete