PLCopen has released their coding guidelines for 61131-3 structured text (ST) some time ago. If you haven’t read that yet, I highly recommend you to do so! Even if I don’t agree with everything, it’s still a good read and a really good initiative to consolidate all the different coding guidelines that every vendor has for their 61131-3 ST environment.

Included in this is Rule L16 “Define the use of tabs”. Let me quote:

Use of tab character (ASCII code 9) should be avoided, and Programming Support Environment set to replace tabs with spaces

This is a common rule in many projects, as this simplifies copying of code into other contexts and makes the code less dependent on the user settings for display. Simply put, the visual interpretation of a tab character varies wildly. As the TwinCAT development environment integrates into visual studio, this is the place we need to do our change. I’m going to use visual studio 2015 community edition for this particular demonstration, but it should be more or less the same in the other versions of visual studio.

Read more

When integrating various forms of devices, generally speaking there are usually requirements that a certain degree of fault isolation of those devices needs to be done. EtherCAT slaves specifically can transmit emergency objects (EMCY) – a protocol inherited from CANopen. An emergency message is a high priority message sent once, and is triggered by an error event in the EtherCAT slave device.

Normally the emergency objects are showing up in the visual studio development environment, but that might not be enough. At one occasion I wanted to be able to handle the emergency objects in PLC code. Handling and reception of the emergency objects via the diagnosis history object will be explained in two parts – first we’re going to start with the theory of the diagnosis history object. In the second part we’ll create function blocks to implement handling of the diagnosis history object. The first part is out and can be located here!

Warning Icon by Martz90 / CC BY

Read more