If you visit my blog on a regular basis, you see me blogging a lot about Azure IoT Edge. This means that logic is deployed from the cloud onto Industrial PCs (or a more moderate, non-industrial, Raspberry Pi).
But this is just the ‘third’ generation of automatically controlling machines.
The first generation are magnetic contactors or relay like this one:
The logic is ‘hardcoded’. If some inputs are set, some outputs are set; or not. With each kind of relay comes some internal schematics:
It’s easy to see the limitations of these kind of relays. Wouldn’t it be great to program a similar relay a bit more dynamicaly using a little bit of software?
Enters the second generation: PLCs or Programmable Logic Controllers:
I got my hands on a Siemens LOGO! 230R. Although this model is not sold anymore, its programming model is still valid. Newer models have more capabilities but still rely on the same basic functionality.
Let’s check out on how to program this PLC.
This PLC is running on 220V which is standard in Europe. Please check your wiring twice before touching anything 🙂
The PLC comes with a manual which tells you with icons how to program it by hand using that little display and the cursor buttons.
But you can also program it using software running on your PC with a serial connection. Yes, this module is still programmed using a serial cable.
Note: Newer models are programmed over the local IP network.
I’m not afraid of serial cables but this is a special Siemens cable which costs as much as a new PLC! This is what you get:
Impressive, isn’t it?
Now it’s time to put your PLC in programming mode. The trick is to shutdown the PLC, plug in the cable into both the PLC and the PC and then powering up the PLC. This will bring up the programming mode:
Note: Later on I found some magic key combinations on the PLC to change the behaviour of my PLC (switching between programming and running or even clearing the PLC).
I use Siemens LOGO!Soft Comfort 8 for this PLC. This is an older version but still sufficient for programming this device.
Once the application starts, checkout the layout:
Automatically, an empty circuit diagram is shown to the right. On this, you can add instructions taken from the left. After placing the instructions of your interest, you can connect them by drawing lines between instruction output points and input points.
But first, you have to tell the LOGO!Soft application which kind of device you have, because this will probably limit the supported instructions. I had to double click on the ‘0BA7.Standard’ at the status bar. In this new dialog, I was able to select the right Hardware type:
It was not intuitive which to choose. Luckily, I had the original package of the PLC with some kind of serial number on it. The last part was 0BA0 which was also in the list. I noticed the number of instructions was drastically reduced; this is an older type of a Siemens LOGO PLC.
So I wrote this simple diagram:
The steps are simple:
- I take the value from input 1 (false)
- I invert it (true)
- I send this to a Symmetrical Pulse Generator running at 1 Hz (1 second). It starts due to the incoming ‘true’
- If the pulse is ‘true’, output 1 and 3 are ‘true’ too.
- If the pulse is ‘false’, output 1 and 3 are ‘false’ too.
- The signal coming from the pulse generator are splitted towards output 2 and 4. But that splitted signal is inverted first. Therefor, if the pulse is ‘true’, output 2 and 4 are ‘false’, etc.
Note: Both the NOT and the splitting indicator of a signal are represented by a black sphere.
After that, I only have to program the PLC with this application by transferring it.
Press CTRL-D to start the transfer from PC to PLC:
First, check if the right type of connection is select: the LOGO serial cable.
Then, check if the right serial port (here it’s COM1) is selected.
You can try the TEST button.
Finally, select OK to start the actual transfer.
Once ready, detach the cable and take the power from the PLC.
After you reattach the power to the PLC, it will start executing the application.
Or you can press ESC on the Logo, select Start and press OK:
As you can see, output 2 and 4 are activated. Can you trace this back to which step of the logic shown above?
Note: Do not forget to re-attach the protective cap back on the PLC where the serial cable was attached.
To go back into programming mode, press the LEFT and the RIGHT arrows together with OK on the LOGO. Select PC/Card (OK) and then select PC<->LOGO (OK).
The Logo!Soft Comfort also has a nice simulation option. Press F3 to get into the simulation mode:
As an example, I can activate input 1 and the rest of the instruction will stop executing. Once I deactivate input 1, the execution (the switching outputs) will continue again.
While checking out the software, I was shown the ability to transfer the application running on a PLC back into the software application. While this seems a nice feature (if your project gets lost, you can still retrieve it back from a PLC) this is also a potential security risk. A hacker can retrieve the PLC app, alter it and upload it without any security questions as long as he has a time window and physical access to the PLC. Nobody will notice this probably until it’s too late!
Luckely, Siemens has taken some counter measures in the form of this warning text:
Programming a Siemens Logo PLC is pretty easy once you have figured out how to set the LOGO application to the right hardware device.
Of course, this is a very simple PLC. Still, the actual capabilities of this PLC are quite impressive. I leave this in the hands of skilled engineers.
But the limitations are also clear: you need physical access to program it. And the complexity can be as extravagant as the amount of available programming instructions (a couple of hundred).
Adv: Interested in running your own WordPress blog? Click this link