PowerMACS PLC by Dummies


PowerMACS PLC intro 3

PLC Configuration – powerMACS System 3

Task (cyclic, event, system) 3

POU – Program Organisation Unit 4

Function 4

Program (executed under the task) 4

Functional Block (fetched from library or created by application programmer) 4

Multiprog wt Environment 6

The PLC Console 22

System Globals 23

Globals 26

IEC 1363 Literals, data types and variables 26

Examples, Q&A 33

PowerMACS PLC intro

PowerMACS tightening system uses IEC 1131-3 compatible application Multiprog wt as a PLC programming environment using LD (Ladder logic) and FBD (Functional Block Diagram) programming styles. It is a powerful programming tool that enables almost countless configuration possibilities. This manual should be used s a complement to the powerMACS Users Manual as it describes programming environment and explains how it interacts with TC hardware, I/O devices, FieldBus devices and other peripheral devices.

Default PowerMACS PLC setup is a example platform used in this manual. Default setup is created by the WinTC Wizard according to PLC template. Default setup comprises 1 TC, 1 spindle and an I/O box. You should read powerMACS Users Manual prior to reading this text.

PLC Configuration – powerMACS System

A configuration is specific to a particular type of control system, including the arrangement of the hardware, processing resources, memory addresses for I/O channels and system capabilities according to IEC 1131-1 standard. A “system” within powerMACS is represented as a “configuration” in the Multiprog wt PLC environment. A configuration contains one or more resources, each of which contains one or more programs executed under the control of zero or more tasks. A program may contain zero or more function blocks. The starting of a configuration shall cause the initialization of its global variables, followed by the starting of all the resources in the configuration. The starting of a resource shall cause the initialization of all the variables in the resource, followed by the enabling of all the tasks in the resource. The stopping of a resource shall cause the disabling of all its tasks, while the stopping of a configuration shall cause the stopping of all its resources.

One can look at a resource as a processing facility that is able to execute IEC programs. In PowerMACS system the resource is a Station.

Task (cyclic, event, system)

A task is defined as an execution control element which is capable of invoking, either on a periodic basis or upon the occurrence of the rising edge of a specified Boolean variable, the execution of a set of program organization units, which can include programs and function blocks .

PowerMACS default setup includes one task per station that executes cyclically every 100 ms.

A program with no task association shall have the lowest system priority. Any such program shall be scheduled for execution upon "starting" of its resource and shall be re-scheduled for execution as soon as its execution terminates.

When a function block instance is associated with a task, its execution shall be under the exclusive control of the task, independent of the rules of evaluation of the program organization unit in which the task-associated function block instance is declared.

POU – Program Organisation Unit

The program organization units are the function, function block and program. Program organization units are not recursive; that is, the invocation of a program organization unit shall not cause the invocation of another program organization unit of the same type.

Function

A function is defined as a program organization unit (POU) which, when executed, yields exactly one data element. Functions shall contain no internal state information, i.e., invocation of a function with the same arguments (input parameters) shall always yield the same value (output). Any function type which has already been declared can be used in the declaration of another program organization unit.

Program (executed under the task)

A program is a network of Functions and Function Blocks. A program can be written in any of the defined programming languages (LD and FBD). Programs can only be instantiated within resources. PowerMACS default setup executes program MAIN under control of a task for every resource (STATION).

Functional Block (fetched from library or created by application programmer)

A function block is a program organization unit (POU),which, when executed, yields one or more values. Multiple, named instances (copies) of a function block can be created. All the values of the output variables and the necessary internal variables of this data structure shall persist from one execution of the function block to the next. Invocation of a function block with the same arguments (input parameters) need not always yield the same output values.

Any function block type which has already been declared can be used in the declaration of another function block type or program type.

The scope of an instance of a function block shall be local to the program organization unit in which it is instantiated, unless it is declared to be global in a VAR_GLOBAL block.

Figure: PLC automation model according to IEC 1131

Multiprog wt Environment

Upon starting Multiprog wt a project tree is displayed in the project manager area. A project contains libraries, data types, Programming Organization Units (POUs) and the set of configuration elements (such as resources, tasks and programs) which are represented in the subtree 'Physical Hardware'. A project is represented in the project tree as shown in the figure below:

Figure: Project tree in unfolded view

Figure: project tree in compact view

The subtree 'Libraries' contains all libraries which are announced in your project.

Libraries are either user defined libraries or firmware libraries. These library types are distinguished as follows:

Firmware libraries are libraries containing POUs prepared by the PLC manufacturer. The file extension for firmware libraries is *.fwl. powerMACS template PLC setup uses Bit_UTIL and PROCONOS libraries. Bit_UTIL library contains Bit manipulation functions provided by KW-software and PROCONOS library contains functions that executes cold-, warm- , hot-restart and manages data area.

User libraries are projects which you have created before and from which you want to reuse POUs. The file extension for user libraries is *.mwt.

The subtree 'Data Types' contains data type declaration worksheets.

The subtree 'Logical POUs' contains all POUs which are used in your project.

Figure: Logical POU subtree in compact and unfolded view

ReadyToStart POU comprises two worksheets:

ReadyToStartV* – Input, output and internal variables are declared in this worksheet.

Input variables are declared between VAR_INPUT and END_VAR keywords. Output variables are declared in the declaration block between VAR_OUTPUT and END_VAR keywords. A comment (* AUTOINSERT *) means that the input and output variables are automatically inserted into the variable declaration worksheet during application development. Here we can see all input and output variables declared as Boolean i.e. logical TRUE or FALSE (1 or 0 respectively).

ReadyToStart*

In this worksheet resides program done in FBD style. (Function Block Diagram)

Programming is done with logical function blocks (AND and OR). Output signal READY will turn TRUE (ON, 1) when signals ModeOK, StationRun_N and EmergencyStop_N are TRUE. ReadyLT is signal that is send to the I/O box to be displayed by the on-board LED when system starts.

Inhibition

Input variables to the Inhibition POU are OKResult and NOKResult declared in the input area of the variable sheet. (Between keywords VAR_INPUT and END_VAR. Output variable Boltcontrol is declared as a BYTE. Variables local to the POU Inhibition are DISCONNECTED_OK and DISCONNECTED_NOK. These variables are initiated with integer values 1 and 2 respectively. Initiation of the variables is explained later.

Inhibition POU is programmed with Multiprog Library functions SEL, ADD and INT_TO_BYTE. Select one of the SEL Function blocks, right click and select object properties.

Left click on the ? button. You will see functional description of the SEL function.

In the help window a detailed description of the SEL function is given followed by an example and different representations.

Let us now se how the SEL Function block work.

If OKResult (BOOL) variable is FALSE (0) then the integer value 0 (residing on the input IN0) is selected and assigned to the ADD FB.

If OKResult (BOOL) variable is TRUE (1) then the integer value DISCONNECTED_OK (Initialized to Integer value 1 and residing on the input IN1) is selected and forwarded to the ADD FB.

Function ADD is selfexplanatory. It takes values provided on respective inputs, adds them and forwards computed value to the output. In our case inputs to the ADD FB are integer pairs (0,0), (0,2), (1,0), (1,2) and respective outputs are integers 0,1,2,3 as stated in the comment under.

Function INT_TO_BYTE takes an integer (INT) as input value and converts it to a BYTE type (Bit array of length 8). Function ADD outputs 0,1,2,3 are converted to BYTEs 00000000, 00000001, 00000010 and 00000011. Execution flow is from left to right. Execution time of the Inhibition POU and timing considerations are out of the scope of this text.

ConvertBoltStatus

VAR_INPUT (*AUTOINSERT*)

Lamptest : BOOL;

StationRun : BOOL;

Status : BYTE;

END_VAR

VAR_OUTPUT (*AUTOINSERT*)

Run : BOOL;

RunLT : BOOL;

OK : BOOL;

OKLT : BOOL;

NOK : BOOL;

NOKLT : BOOL;

RunNok :BOOL;

RunNokLT : BOOL;

END_VAR

VAR (*AUTOINSERT*)

SR_1 : SR;

IDLE_OKR : BYTE := 1;

IDLE_NOK : BYTE := 2;

IDLE_TERMNOK : BYTE := 3;

RUNNING : BYTE := 4;

END_VAR

Figure: variable sheet for the ConvertBoltStatus function.

Note that Variables declared between VAR and END_VAR keywords are local to the functions and cannot be accessed or seen outside of ConvertBoltStatus function. Here, we can see an “Instantiation” of the function block SR (SET-RESET Latch). An Instantiation means that a function block defined once is used several times. As function block always have an internal memory it is necessary to store their values for each time the function block is used to a different memory region.

SR_1 : SR;

With this declaration we are creating an instance (“dedicated memory area”) of the SR function block. Upon using FB SR_1 a SR is not altered in any way.

SR (as explained in Multiprog wt Help file)

This bistable function block realizes a prior set of the output Q1. If the input SET1 = TRUE, the output Q1 is set. Q1 remains set even if SET becomes FALSE. Q1 is reset, if RESET = TRUE. If both inputs = TRUE, the output Q1 is set by SET1 to TRUE.

If the function block is called for the first time, Q1 is FALSE.

Parameter Data types Description

SET1 BOOL IF TRUE Q1 is set dominant

RESET BOOL If TRUE Q1 is reset

Q1 BOOL output

Note: All parameters can be negated.

This function convert Status of the bolt (BYTE) to discrete equivalents (Run, OK, NOK, RunNOK). Function blocks used are GE (Greater or Equal), LE (Less or Equal), SR (SET-RESET Latch) and FB for logical operations (AND, OR). Input variables are Status (BYTE), StationRun (BOOL) and Lamptest (BOOL). As an example we can assume that the Bolt status has a value 6 represented as a BYTE (00000110). In the uppermost GE FB a Status value is compared to the variable RUNNING (BYTE, initialized to the value 00000100 (4)). GE function block outputs a TRUE (1) if Status value is greater or equal then RUNNING value or FALSE (0) otherwise. In our case output is TRUE (1) and the Run variable (BOOL) is set to TRUE. Evaluation of the other function blocks and respective outputs are shown in figure below.

What does the SR_1 function block do? Output Q1 is initiated to FALSE by default and RESET input is set to FALSE. This means that we have locked the Q1 to FALSE state until the input SET1 (StationRun) turns TRUE. After StationRun turns true the output Q1 is then locked into TRUE state because the only way to turn Q1 to FALSE is to assign RESET input to TRUE value. That is impossible because a value FALSE is hardwired to the input RESET. (Cannot be changed)

SelectStationStatus

A variable sheet for the SelectStationStatus resembles a lot

VAR_INPUT (*AUTOINSERT*)

Status : BYTE;

Lamptest : BOOL;

END_VAR

VAR_OUTPUT (*AUTOINSERT*)

Run : BOOL;

OK : BOOL;

NOK : BOOL;

RunLT : BOOL;

OKLT : BOOL;

NOKLT : BOOL;

END_VAR

VAR (*AUTOINSERT*)

SR_1 : SR;

IDLE_OKR : BYTE := 1;

IDLE_NOK : BYTE := 2;

IDLE_TERMNOK : BYTE := 3;

RUNNING : BYTE := 4;

END_VAR

A reader should be accommodated with the syntax used to declare input, output and local variables. A program code sheet and the evaluation flow for input Status := 3 (BYTE 00000011) and Lamptest set to TRUE.

In this example we assume that the station has done several cycles. Q1 output from the SR_1

function block is then locked to TRUE value regardless of the SET1 value.

ModeSelection POU

Nothing new in the variable sheet. Everything is done according to IEC 1311 specification.

VAR_INPUT (*AUTOINSERT*)

StationRun : BOOL;

Mode_Value_1 : BOOL;

Mode_Value_2 : BOOL;

Mode_Value_4 : BOOL;

Mode_Value_8 : BOOL;

END_VAR

VAR_OUTPUT (*AUTOINSERT*)

Mode : INT;

ModeOk : BOOL;

ModeConfirm_1 : BOOL;

ModeConfirm_2 : BOOL;

ModeConfirm_4 : BOOL;

ModeConfirm_8 : BOOL;

END_VAR

VAR (*AUTOINSERT*)

L_ModenNo : INT;

END_VAR

We will follow execution flow in the Program code sheet for actual input parameters:

StationRun TRUE;

Mode_Value_1 FALSE;

Mode_Value_2 FALSE;

Mode_Value_4 TRUE;

Mode_Value_8 FALSE;

Function BOOL_TO_INT takes a Boolean variable (TRUE or FALSE) and converts it to an Integer value (1 or 0). Mode_Value_1,2,8 are converted to 0 and Mode_Value_4 is converted to 1. Function MUL takes two integers as input values and output their product. Function ADD sums its input values and assign computed sum to the output variable. L_ModeNo is assigned integer value 4. Next step is to check L_ModeNo.

Here we check that the L_ModeNo 4 > 1 AND L_ModeNo 4 < 15 “and” if they are both evaluated as TRUE then output Boolean variable ModeOK assigns TRUE.

Next step is to freeze the output variable Mode to a specific Integer value while the station is running a tightening cycle.

SEL function block output IN0 value if the G value is FALSE, otherwise it outputs IN1 value. StationRun is TRUE and the value L_ModeNo (INT 4) is assigned to Mode. Variable Mode is feed to the input IN1 ensuring that the Mode keeps the value during the cycle run.

Next step is to convert Mode to the discrete confirmation signals. First we convert Integer variable Mode (4) into its binary counterpart with function INT_TO_BYTE. By testing different bit positions (bit value 0 or 1)