What's 1131?

 

First of all, let me say that this is a very cursory glance at this software standard. There are entire books written on this subject, but the basics are easy to understand. You may also want to visit this site for more information.

In the past, if you wanted to write an industrial control program using a PC, you typically wrote it in BASIC, FORTH, C, or Assembly. Then you would compile this code, dump it onto your PC, and see if it ran. Debugging was a problem, as actual machine conditions are difficult to simulate especially when there are hardware or sensor failures. At the same time, there are many versions of each of these languages, and most of them were unsuited for real time control. Upgrades of these languages may not be compatible, and then you get stuck pounding out code in an obsolete language. As the desire to migrate to PC based controls grew, the International Electro-technical Commission (IEC) took on the task of defining a programming standard, not just for PC's but for any type of machine controller. The specification is too large to go into gruesome detail here, and most of it is mainly concerns the way the development software is written. Suffice it to say that if you understand how IEC 1131 programming works, you can directly translate those skills to any package that is 1131 compliant.

1131-3 is a standard for machine logic programming that incorporates four distinct types of programming styles.

Ladder logic is available for the same kind of contact/coil arrangement most guys are used to seeing.

Function Block programming is kind of like Ladder Logic, except it looks more like the electronic AND/OR gates. This is useful because you have a graphic representation of the flow of the program, as the blocks are "wired" together.

Instruction List is the machine code programming that is popular with a lot of Japanese PLC’s. It’s the kind that has instructions like ST, LD, AND, OR, stuff like that. It looks like the way the very first PLC’s were programmed before they had the nice graphical interfaces that showed the ladder. To me, it’s the most confusing and difficult kind of programming to do, but some people like it.

Structured Text looks a lot like Basic, although it’s got a lot of nice features to it. It’s got the IF/THEN/ELSE, WHILE/DO kind of layout. The big advantage here is that you can do real complicated math easily.

You can also write a routine in one type of style and call it from another type of program. For instance, you could write your PID loop in Structured Text and call it in a Function Block program. That way, you can easily see the variable flow as well as be able to change the math in the language that deals with math easily

There is a fifth programming style called Sequential Function Chart, which is basically controls the flow of the above types. You would use SFC to allow processes to execute in a sequence, and change machine modes based on defined conditions. For instance, you may run a homing routine on several parts of the machine before you can go into automatic cycle mode. Sequential Function Charts use one of the other four types to actually do stuff.

What is determinism?

Determinism is the ability to accurately predict the execution time of a process. That means that the programs will execute exactly the same way every time they execute. This is crucial for machine control, because if something doesn’t happen in the expected time, more than likely, something is wrong.

Most operating systems are not deterministic because they do not allow for a runaway process to be suspended if they exceed their execution time. This can be a real problem if you are waiting for the screen to refresh while you bottles go screaming down the line into a box that’s already full.

What’s a task?

Think of tasks like little kids. There’s a bunch of little kids and only one ball to play with. If you tried to let the kids figure out who gets to play with the ball, obviously they’re all going to want to play with the ball at the same time, and they’ll end up doing a lot of damage, and not much playing. So there’s a mommy. Mommy lets each kid play with the ball for a certain amount of time, then takes the ball away and gives it to the next kid. Mommy also knows if one kid has been better than another has, and therefore deserves more time.

All the tasks have to share one processor (ball). And the Task Manager (Mommy) passes the ball around.

Each task can have a different priority and execution interval, meaning that if a task is running and another task with a higher priority has been waiting longer than its execution interval, the Task Manager will stop the current task and give control to the higher priority task. When the higher priority task is done, the first task gets to pick up where it left off.

In practice, all you have to do is assign the programs to tasks and let ’em fly. If you have some low priority stuff, like temperature monitoring, you may put that at a lower priority to the one that is running the PID loop for the mix control.

If you have several programs running in the same task, they basically run sequentially whenever that task is running.

What’s multitasking?

Multitasking means you are performing more than one task at a time. Read the above stuff on what a task is and you'll realize that there's a problem with this definition. You can start multiple tasks at the same time, but they still will execute sequentially on a single processor system. Here's a problem. It is impossible to do multitasking unless you have multiple processors. Keep reading...

What’s multiprocessing?

Multiprocessing systems physically have more than one processor running in parallel. That means that you have to have a hardware platform that supports multiple processors, and then you can assign certain tasks to certain processors. Obviously, this is an advantage, because you can assign your tasks to dedicated processors, and they execute continuously, communicating with the other tasks through shared memory areas.

What's distributed processing?

This is when certain specific tasks are offloaded to specialized processors to reduce the load on the main control system. One example would be in a motion controller, where the main processor gives the motion board a command to move one of the axes to a certain point. After telling the motion board to do that, the main processor goes and does something else until the motion board is done with the move. The main processor doesn't care how the move is executed, just when it's done. This way, you can further lessen the load on the main processor.

Another kind of distributed processing occurs when multiple PLC's or controllers are connected over a network of some kind. Imagine a large assembly line where each individual cell is performing its own function with its own controller and program. Before the line can index, each station must report to the indexing controller that it is done and ready go move. In this way, many tasks are being performed on many processors, but they are not necessarily controlled by the same operating system.