Programmers should use the inherent languages built into IEC61131-3 to achieve acceptable best practice programming for PLC applications. Discussed further is how AIE split up the application for a machine automation task into the different language subsets.
The Beckhoff Twin Cat2 PLC fully supports IEC61131-3, however programmers need to be aware that many PLCs still only support parts of the standard.
ST (structured text) was used to develop function blocks for – encoder based position control, alarm queuing across tasks, and overall order of code execution for each task. SFCs (sequential function charts) were used for conveyor table and machine sequence control, whilst FBD's (function block diagrams) were used for general control and logic functions.
This demonstrates the usage of the defined function block Alarm and its instance fwAlarm1.
The rising edge trigger (R_TRIG) and the register (SR) are responsible for holding the alarm active until acknowledged by the Alarm.Ack output. The Alarm function block (FB) will queue the Message on the message queue pointed to by the Alarm.Qaddress input, and when successfully queued the Alarm.Ack output will reset the holding register.
The Alarm FB is written to work in a multitasking system where multiple tasks accessing the alarm queue
asynchronously will not cause alarms to be lost, and the de-queuing task can run significantly slower.
The de-queuing task is normally running the HMI so scan time only need to be in the order of 250 to 500 msec, whilst the task generating the alarm could be typically running at 10 to 50 msec.
Using data structures (shown above) makes your programs more readable, and easier to commission and maintain. They are especially powerful when used with pointers. New alarms are added to the Alarms array using the Next pointer, whilst alarms to be read out are removed by using the First pointer.
The instance of the Alarm_read FB shown above is executed by the HMI task and removes an alarm from the queue to be displayed on the HMI panel. Activation of "Alarm Clear" will cause the next pending alarm to be displayed.
State or Sequential control using SFC
The self documenting nature of SFC programs makes them essential for use for all process control functions which are by nature sequential or state based. Programmers are able to execute specific programs on entry, exit and continually within each step. Defined conditions between steps determine when step changes occur.