Five methods of programming automation
Normally when a person creates code, we are always talking about creating pure text. But coding can be much more. In automation we use ladder logic, function blocks, structured text, instruction list and sequential function charts. I’m quite firm believer of ‘learn to code with some automation widget’ as the previous post tells you, so let’s go through five different formats in which you can also "code".
But first you need to know the history of these coding styles. Automation systems didn’t have a computer in them at first as the 70’s computers were huge and really really expensive (not to mention unreliable). So, there was no written code. Code and its functions were made with electricity (or even with pneumatics) and modifying where electricity went or didn’t. Important part was, and still are, relays. They represent simple but powerful functions like IF, OR, XOR, AND. With just these little functions we can create incredible complicated functions and operations. So, the code was physical “if this switch and that sensor are in ON-position, current goes to there and puts light on”.
When we started to use computers, of course people, who created these systems, wanted it to remain similar to what it had been (and it wasn’t so that first we used relays and the not, they are still on the game which means that you need to think those systems in specific way as relays work in specific way). So, we have these five different “coding methods/languages” that are often used in conjunction with each other (these are defined in standard IEC 61131-3):
This is widely used and resembles very much of electronic circuits and relay diagrams.
Function block diagram:
Structured text (which is related to Pascal):
LIGHTS_ON := SENSOR_A AND SWITCH_B;
Instruction list used to look something like this:
LD SENSOR_A LD SWITCH_B ANB ST LIGHTS_ON
But is now changed to xml, which I have never seen, sorry :/
Now we are getting close to “normal” coding which is just text. Who has said that coding always has to be just that? I hardly think it is carved to stone. Okay, text is very very expressive but in some cases I wonder if there would be a better and easier solution for some simpler trivial applications as they don’t need those expressive features.
Automation has very graphic way of expressing itself and I feel that is because it is easier for many people to learn. You don’t need to be a good coder to be able to create good automation code.
PS. Specially instruction list is bit dizzy concept because even IEC 61131-3 defines what it should be, but the manufactures don’t always really follow the standard... maybe it’s because you need to pay to see the standard or because they think it doesn’t work properly or it has had too many changes (newest version is coming 26.2.2013)? Not sure.
PPS. For example Omron have their own serial port that isn’t the ordinary IBM standard. The connector is physically the same but it has different pin out. Just imagine how fun it is to mix these cables :P