Only kidding. Well, half. But it's irrelevant, as I won't lend you my wife.
We need to have a way to write short programs on our computer (we all have one of them, right?) and then download them onto our MCU.
No! Stop! Take that chip out of your floppy drive... that's not going to work!
We need a programmer. One that is designed to program PIC chips.
They come in all shapes and sizes and price points. If you rush off now and do a search for PIC programmers, you'll likely be aghast that the only ones you can find are quite expensive. But not to worry -- they can be had cheaply. I won't recommend a particular model, but briefly list the things to consider:
- - Does the programmer support our chip? Most will, but some of the very old ones might not.
- Does the programmer plug in via USB or an old serial port? Not all new computers have serial ports, and for ease of use, I recommend USB... but serial port programmers are more established and possibly cheaper.
- Does the programmer require an external power supply? Most USB ones don't, but you should check. The power supply requirements can be quite odd (like, say, a 16V supply).
- Does it come in kit form or assembled. Kits are cool – easy to assemble with the instructions provided (and a soldering iron), and can be cheaper.
- Do they come with a ZIF socket? These sockets make it easy to insert and remove your chip into the programmer. Some kits don't come with a ZIF socket, to reduce cost. Make sure you order one separately.
- What is the programming software they use? Is it easy to use? (snazzy professional units use the official "MPLAB" software from Microchip... but I find this quite cumbersome to use) [Note: the programming software varies depending on the programmer, but it is usually given away or downloadable for free]
What do I use? I use the "DIY Kit 128" from
http://www.kitsrus.com . You will see these
sold around the web as kits or fully assembled, at various price points and with different names, but they are all easy to spot. They are USB, and don't need a separate power supply. Their price ranges from $40 - $60.
If I was buying again, would I buy the same? Yes, possibly.... but I would look on eBay. There are many
new PIC programmers on eBay. It'd be foolhardy for me to recommend any particular sellers to you, but the following promising looking programmers came up in a "Buy it now" search for "PIC programmer":
This one looks like it'll do the job at only $12.95!!!
This one is really fancy – will program everything, even your dog. Can’t vouch for ease of use though. $23.
Here's one similar to mine. Serial and USB. Easy to use. $39
Same again. $38
Same. $35
And many, many, many more. Of course, the usual caveats apply for eBay – check the seller's rating, the delivery fees, and feedback... and ask questions if you feel uncomfortable. But, in my experience, it is absolutely the best place to pick up stuff like this.
OK, OK.... I can afford that.... but what about the programming? It sounds far to complicated for me or my odourful Aunt??
I'd better explain a bit. You see, the MCU takes its instructions in machine code. Machine code is like looking at those green symbols in The Matrix. Trippy, but not good if you want to get stuff done.
So, our friends at Microchip created a low-level "language" called Assembly language, or "Assembler", that allows you to write in vaguely meaningful codes, and translate it into machine code when you're finished. Now, there are loads of geeks in the world who love Assembler. Not least, beacue it is free.
I, for one, can't bear it.
You see, in Assembler, you can't give a chip an instruction like:
Nooooo... no way. In Assembler, it would look something like this:
Code: Select all
I'm going to give you some instructions.
Are you ready?
Are you sure you're ready?
OK, you've got two legs, right?
One of them is left and one is right.
Think about lifting the right one.
Good, now lift it.
Now move forward a little.
....etc......
AAARRRRGGGGHHHHHH. If you hate your life, then take my advice: Program in assembler. It is very powerful, but only if you have the time.
But WAIT.... Don't worry.. there are other options. You see, there are more "high level languages", which take in instructions like "Walk from A to B", and translate (or "compile") it into instructions that our MCU can understand.
That's what we're going to use. Phew.
The kicker? This software can be expensive. My tool of choice would be PICBASIC PRO. Based on the popular BASIC language. It can be yours for $250.
YIKES!!! NOT **** LIKELY... NOT FOR SOME STINKING MOONLIGHTS!!!
OK, OK, calm down... don't worry. There is another option. There is a lesser known competing product called
MikroBasic. Straight from Belgrade. Really. This software is
ABSOLUTELY FREE, provided your final programs (after conversion into MCU language) take up less than 2,000 program words. This should be fine for us. And if we do run over (unlikely), it doesn't matter, as I can attach the compiled code for loading onto people's chips.
THIS STILL SOUNDS FAR TOO COMPLICATED
Trust me -- it's not. I post the code. You copy and paste into MikroBasic. Get MikroBasic to compile it into machine code and download it to your chip. I'll try to include comments in the code so it's easy to understand what's going on... but if you're not interested in any of that, it really is just a copy - paste job. I learned how to code by starting out copying other people's code.
Still not up for it? A friend with a programmer could program the chips for you with the code I post... or, I could even send you a pre-programmed chip (if you cover my costs).
A few dollars and a bit of time is a small investment to make for this though. These tools open up a world of possibilities. From flashing Christmas lights to full-on aquarium water changes.... you'll be able to do it, and quite simply.
***** IN THE NEXT POST I REALLY, REALLY, REALLY WILL BUILD IT. HONESTLY. IT'S ALL DOWNHILL NOW. ********