How To Make A PIC Programmer From Scratch, The Newbie Way

So I had a flu… Wouldn’t go out.. Couldn’t anyway… And decided to learn CadSoft Eagle.

I opened a thread about Microcontrollers recently on the great , and I wanted to build a PIC Programmer … I’ll eventually buy  a “real” one (PICKit 2 or something), I just wanted to lose my PCB virginity with this project.

Anyway, I wanted something simple, so I exluded de facto clones with microcontrollers which have to be programmed in the first place inside them  (The ones I found had a PIC18 inside, like PICKit2 clones).

Anyway… Eagle thingy..

The project I chose is a JDM Serial PIC Programmer… (JDM stands for Jens Dyekjaer Madsen) which I found here :

And which the author found here :

He substituted the 25 pin connector with a 9 pin connector ( DB25 – DB9 … RS-232) .. I like the DB9 more.

I worked with the schematic from the original page. Have in mind though that pins like TxD (2) or GND (7) refer to the DB25 Pinout, while I’m going to do a DB9 version.

To get the corresponding pins in a DB9, you can search for something like « RS232 pinout » or « DB9 pinout » or something like that..

Or you can find it directly here :

Anyway … Here are schematics I did…

Notice how angles are « rounded », it’s called « Mitering », there’s a button for it on the left panel.

Here’s ultimately the « Board », revision 4…

I drew a rectangle on the whole surface on vRestrict layer, I didn’t want any Vias in there. I’m a beginner, so I didn’t want to  bother with that just  yet.

I drew two small rectangles under the PIC microcontroller, on two layers tRestrict and bRestrict, they coincide, so you only see one.

I didn’t want any routing under the PIC, because I thought it would be better (Less heat influencing its functionning, and I wanted to diminish the influence of a field that would be created by the the current in a hypothetical route. I know, I know.. Actually, I don’t. I asked questions about this on the forum, if I’m overthinking or not.)

I had a problem as shown in the image, where these rectangles crossed over the pads, and it showed errors when I hit DRC (Design Rules Check), here’s a zoom in:

Note how tiny it is, the pads crossed over the restricted surface, and this provoked an error. Amazing software.

I couldn’t draw accurate enough rectangles to include the whole chip, or “just” the chip. i.e : It was either too small, or a little bit too big.. So I increased the Grid resolution by chosing 5 mils in « Size ». I could draw  my rectangles with more precision.

I managed to have a single sided board before (drawing a rectangle in the tRestrict Layer over the whole board), but NOT with that disposition, and it was a LOT of gymnastic. This one is very symmetrical as you can see here :

Here it is with Dimension, Top, Pads, tNames, tPlaces…

It’s a relatively small board  1.8’’ by 2.135’’.

Here’s an image with all layers..

I asked some questions about design faults on the forum mentionned, if you don’t know it, well you should check it out.


What is a PLC ?

So what is a PLC ?

PLC stands for Programmable Logic Controller, and I’m not going to force-feed you all the techy definitions that made me more confused than I already was when I just wanted to know what a PLC does.

A PLC in a nutshell is an electronic device, which got inputs and outputs. You can change the state of the outputs depending on the inputs to accomplish a certain desired task.

Imagine that you are a  chemist (I know, you’re too cool to wear glasses and be a nerd and all), and that to make something, you’ll need to mix a fluid with another one for a certain period of time, then put the result in a balloon and heat it until it reaches a certain temperature, then you’d have to evacuate the emanations with a ventilation system as long as the fluid is there and then pump the fluid to a reservoir, and control the flow of the magic liquid that is the favorite beverage of your dog not to provoke a torrent.

Now, how would you do that ?

Well, long ago, engineers had to build complex circuitry specifically to control each thing (ventilation system, the motor of the mixer to run for a certain time, the temperature sensors, etc) , and interconnect all this to produce the expected task. That was a lot of work, and if they ever wanted to change something, they had to rewire things, replace components and always tweak things.

A PLC makes it possible that you don’t have to do that. A PLC is an electronic device,  kind of a computer but without the screen and the keyboard, for it is NOT a general purpose device . It’s not made to write the draft of the next Le Comte de Monte Cristo and then browse the web looking for awesome blogs like this one.

So, you do have to program it to do specific tasks, but do not have to make electronic boards your own to accomplish  these specific tasks- which would’ve required integrated circuits, transistors, amplifiers and lots of other things and then wire all that in a unique way-. That’s good, isn’t it ? What’s even better is that you can re-use the PLC to do OTHER tasks, simply by writing another program and uploading it to the PLC. That’s something that would’ve been very difficult to achieve before PLCs, as you would have had to change the whole circuitry and even then, make other boards for the tasks are no longer the same.

So the same PLCs that are used in plants/factories, can be used to simply turn a light on. Of course if you use a PLC to just turn a light on, you’d be throwing money out of windows, not so smart of you. So PLCs are interesting when things get more complex than something you could deal with using a less expensive solution.

Now, there are lots of vendors, like Siemens, Schneider, Omron, Allen Bradley, ABB, Yokogawa, General Electric… And each vendor offers different choices, depending your needs.

For example, Siemens offers a range named SIMATIC S7 which has got S7-200, S7-1200, S7-300,S7-400 and then again, in teh S7-200 family, there are different types, like the S7-221, S7-222, S7-224, S7-226 and S7-226 XM ..

Each differs from the other, be it speed, memory, autonomy.. So you have to chose something that suits your needs.

For example, the S7-200 series is for small applications.

All right, how to program a PLC ?

To program a PLC, you would need either a dedicated device from the vendor, OR a Personnal Computer with the propper software and the connection cable. (For example, to program Siemens SIMATIC S7 Controllers, you would need a program named STEP7 Micro/WIN32 in a PC, and the propper cable called PC/PPI cable (PPI for Point-to-Point Interface, the cable is a sort of RS-232/RS-485 adapter)… And then, when you’re done programming it and you put the PLC to work, you would use another program, called WinCC to supervise the process. It took me a while to figure out what exactly does each of these fancy names do.)

Which programming language do we use to program PLCs ? You have the choice :

-Ladder Logic

-Statement List

-Function Block Diagram.

Are the most used.

In Ladder Logic , you will use  symbols  called Coils and Contacts.

In Statement List, well, you use statements to get the job done.

In Function Block Diagram , you arrange blocks that have inputs and outputs (graphically) to achieve whatever you want.

What you need to know is that PLCs have input ports which you connect your inputs to (like a button, or a switch or even the output of a device) and output ports to which you connect whatever you’d like to control (be it a light, an electric door, a motor, a device, etc).

Something to keep in mind, which is fundamental is the signal flow the direction in which the signal flows.

A signal ENTERS a PLC from the Input Ports, and GETS OUT of the PLC from the Output Ports.

Some PLCs can do lots of other things too, like Pulse Width Modulation , and if they can’t do what you want, vendors provide extensions that you connect to your PLC to enable it to do something (Like sending a text message (SMS) to a certain number, or to be controlled at a distance via modem , imagine that, huh !)

That’s it for this little introduction to PLCs. In posts to come, I’ll talk about  Siemens SIMATIC S7 PLCS and start with the S7-200… The smallest one.