powermacs plc - gongkong营销传播管理后台 中国...

44
PowerMACS PLC by Dummies

Upload: hoangxuyen

Post on 08-Jul-2018

278 views

Category:

Documents


0 download

TRANSCRIPT

PowerMACS PLC by Dummies

PowerMACS PLC intro...................................................................................................................................3

PLC Configuration – powerMACS System.............................................................................................3Task (cyclic, event, system)....................................................................................................................3POU – Program Organisation Unit...........................................................................................................4Function....................................................................................................................................................4Program (executed under the task)...........................................................................................................4Functional Block (fetched from library or created by application programmer).....................................4

Multiprog wt Environment........................................................................................................................6

The PLC Console......................................................................................................................................22System Globals.......................................................................................................................................23Globals....................................................................................................................................................26

IEC 1363 Literals, data types and variables..........................................................................................26

Examples, Q&A............................................................................................................................................33

PowerMACS PLC introPowerMACS 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

CONFIGURATION

RESOURCE

TASK TASK

PROGRAM PROGRAM

FB FB

RESOURCE

TASK TASK

PROGRAM PROGRAM

FB FB

GLOBAL and DIRECTLY

ACCESS PATHS

Execution control path

Variable access paths

FB Function block

Variable

or

REPRESENTED VARIABLES

Communication function (See IEC 1131-5)

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 DescriptionSET1 BOOL IF TRUE Q1 is set dominantRESET BOOL If TRUE Q1 is resetQ1 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.

INPUT

OUTPUT

PLC

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)

Function BIT_TEST takes as a input parameter IN a bit string and as a input parameter NO a integer that marks which bit in the bit string is to be tested. These functions test the first ( index 0 in the bit string), second, third and the fourth bit. If the bit value on the marked position is 1 then the value TRUE is assigned to the function output, otherwise the value FALSE is assigned.

Start POU

Variable sheet contains following inputs and the outputs:

VAR_INPUTBusy : BOOL;StartIn : BOOL;ModeOk : BOOL;EmergencyStop_N : BOOL;

END_VAR

VAR_OUTPUTStartOut : BOOL;

END_VAR

VAR (*AUTOINSERT*)TOF_1 : TOF;R_TRIG_1 : R_TRIG;

END_VAR

There are four inputs, one output signal and the two local instantiations of the library function blocks TOF (OFF-Delay Timer) and the R_TRIG ( Raisin Edge Detector Trigger). Start POU should generate a 50 ms long start pulse upon getting not busy signal (Busy ==FALSE), (ModeOk == TRUE), EmergencyStop_N == TRUE (Inactive) and StartIn signal has been detected.

R_TRIG_1 is an instance of the function block R_TRIG. Output Q is set to FALSE by default. When R_TRIG_1 detects a rising edge on the CLK input it then set output Q to TRUE. It remains true until the execution of the function block. In order to enable output of the “AND” function block all it’s inputs must be TRUE except the negated inputs. Negation element ( ---o) inverts logical value from TRUE to FALSE and vice versa. Boolean variable Busy must be FALSE in order to get a TRUE value at the input to the AND function block.

Next FB in the evaluation order is Off-delay timer TOF (Instantiated as TOF_1). TOF_1 monitors parameter IN. Q is set TRUE at the same time as IN becomes TRUE but when IN turns FALSE Q is delayed for the time PT (50 ms in our case). Q is TRUE while Elapsed Time ET is less then PT. With this FB we are creating 50 ms long start pulse (StartOut) regardless of how many times we press Start Button (StartIn) during the preset time of 50 ms. It is the first TRUE to FALSE transition that create 50 ms long Pulse.

Program Organisation Unit Main

Is a program assigned to task TASK 10MS : CYCLIC which means that the instance of the program Main is executed in cycles every 10 MS with the highest priority.

Right click on the T10MS : CYCLIC map and select Field properties and settings.

POU Main describes the functionality of the powerMACS default PLC setup. In order to get a more complete overview over Main POU one must look into PLC interfaces. PLC has interfaces

to several units in the powerMACS system. These Interfaces are described in the powerMACS User Manual.

Digital_In_Out Worksheet

contains variables mapped to memory area dedicated to digital inputs and outputs. These variables are global within a resource i.e. PowerMACS station (visible by all tightenning controllers in the station). In POU Main variable sheet the global variables are declared in VAR_EXTERNAL – END_VAR area. Default PLC setup described in this manual is adjusted for the demo powerMACS system. An I/O box depicted in figure below is connected to DeviceNet node 1 via CAN bus. These analog inputs are digitized and stored in the I/O memory area in the TC. There is 1-1 map between hardware memory addresses and the PLC logical addresses.

Digital inputs used in the POU Main:

DI_Start AT %IX 600.0 : BOOL; DI_LampTest AT %IX 602.0 : BOOL; DI_ModeValue_1 AT %IX 604.0 : BOOL; DI_ModeValue_2 AT %IX 605.0 : BOOL; DI_ModeValue_4 AT %IX 606.0 : BOOL; DI_ModeValue_8 AT %IX 607.0 : BOOL; DI_Inhibit_Sp_1 AT %IX 608.0 : BOOL; DI_Inhibit_Sp_2 AT %IX 609.0 : BOOL; Digital outputs used in the POU Main:

DO_Ready_to_Start AT %QX 800.0 : BOOL; DO_Cycle_OK AT %QX 801.0 : BOOL; DO_Cycle_NOK AT %QX 802.0 : BOOL; DO_Cycle_Running AT %QX 803.0 : BOOL; DO_ModeValue_1 AT %QX 804.0 : BOOL; DO_ModeValue_2 AT %QX 805.0 : BOOL; DO_ModeValue_4 AT %QX 806.0 : BOOL; DO_ModeValue_8 AT %QX 807.0 : BOOL; DO_Running_NOK_Sp_1 AT %QX 808.0 : BOOL; DO_Running_NOK_Sp_2 AT %QX 809.0 : BOOL; DO_Cycle_OK DO_Cycle_NOK DO_Cycle_Running

DI_Lamp_Test

DI_Start

EMERGENCYSTOPIN

DI_ModeValue_1DI_ModeValue_4

DI_ModeValue_2

DI_Start AT %IX 600.0 : BOOL;

This declaration of the variable DI_Start means that this is a directly represented variable residing at input memory area %I as a single bit (X) at address 600.0.

System_Globals Worksheet

System Globals are variables that create interface between PLC and the TC firmware. Some of these variables are read by the PLC during input scan period and some are set during output update scan. For detailed information please read the powerMACS user manual.

System Globals variables used in the POU Main:

STATIONSTATUS AT %IB 14 : BYTE;BOLTSTATUS AT %IB 18 : BOLT_STATUS; (* 100 bytes*)EMERGSTOPIN AT %IX 324.0 : BOOL;

These variables are located at input area ( %I ) and are inputs from the TC firmware to the PLC.

START AT %QX 400.0 : BOOL;EMERGSTOP AT %QX 402.0 : BOOL;MODE AT %QW 470 : INT;BOLTCONTROL AT %QB 490 : BOLT_CONTROL; (* 100 bytes *) These variables are outputs ( %Q ) from the PLC to the TC firmware. POU Main contain custom FB described previously. Within Multiprog WT software we can monitor the state of the PLC program and variables in real time by using Online “Debug” function. The Figure below illustrate the state of the input and output variables of the default PLC program after the system power-up.

Figure above illustrates program Main01. All variables on the left side are the inputs to the PLC. For the powerMACS default setup these variables are logical mapping of the digital I/O box buttons and knobs.All variables on the right side are the outputs of the PLC to the TC. For example, when output variable START is scanned by the TC, the tightening cycle starts. PLC programmer is responsible for the design of the control sequence between input and output area.

INPUT to the PLC from TC system and I/O box

PLC output to the Tightening Controller

PLC output to the I/O Box

The PLC Console

To invoke the PLC Console select the item PLC Console from the PLC menu.

The PLC Console interface can be used as a simple operator’s interface. With this you can show some central status information of the PLC. With the input fields you can reset or bypass functions in case of problems.

The output fields are all of string type, i.e. you can output short message. The inputs comprises three boolean inputs (ConsIn1 - ConsIn3) and two string inputs (ConsIn4 and ConsIn5). The latter can be used for any type of information, e.g. integer counter values or to give strings for ID code conversion.

ConsIn_ variables are located in the System_Globals variable sheet.

These variables should be declared inside VAR_EXTERNAL – END_VAR are in POU’s.

System Globals

The System Globals are the interface between the PLC and the tightening controller part of the system. By setting global outputs from the PLC you can order ID devices to be read, start a tightening cycle and so on. By reading inputs you can check the state of the system, for example if a cycle is ready. These variables are all found In the worksheet System_Globals in the project tree of the powerMACS PLC.

Station variables

These variables are basically used to start and control a tightening at station level.

Variable Dir Type Use

MODE Out Int Set to number of mode to use in next cycle. Sampled when START is set True.

START Out Bool Start cycle. Set to True to start the first step in the cycle. This signal is ignored if the station is not idle.

STATIONSTATUS

In Int Status for station:0: Idle OK1: Idle OK after RM (OKR)2: Idle Not OK (NOK)3: Idle Stop and Terminate Not OK (TERMNOK)4: Running5: Evaluating6: Waiting for PLC step

CURRSYNCH In Int Reflects the number of synchronisation points that have been passed. Initialised to 0 at cycle start.

STEPSTOP Out Bool Step stop. Set to True to stop current step with status OK. Next START will continue with next step in the cycle.

EMERGSTOP Out Bool Emergency stop. Set to True to stop the cycle with status Not OK. Next START will start cycle from beginning.

MACHINESTOP

Out Bool Machine stop. Set to True to stop the cycle with status Not OK. Next START will start cycle from beginning.

DATAHOLD Out Bool Data hold. Set to True to hold transmission of cycle data. Set to False to release again.

MONSTART Out Bool Start monitoring. Set to True to start monitoring of the spindles. This signal is ignored if the station is not idle.

MONEND Out Bool End monitoring. Set to True to end monitoring of the spindles.

DATADROP Out Bool Data drop. Set to True to drop cycle data, without

distribution.TRACEDROP Out Bool Trace drop. Set to True to drop trace data, without

distribution.GENEVENT Out Int Set to a code 1-10 to generate an event. The code

used will be displayed together with the event.EVENT In Bool System events. Is True when there are unobserved

events.SPCEVENT In Bool SPC event. Is True when there are unobserved SPC

events.STEPTYPE Out Int Control data for steps of type PLC used in the

tightening program. Step type: 1=Torque, 2=Angle, 3=Time.

STEPVAL Out Real Control data for steps of type PLC used in the tightening program. The target value.

GENOUT_n Out Int General output (n = 1-5). Can be used for selection of double encoders or change of spindle direction. See Error: Reference source not found.

CYCDATA_n In Real Cycle data input (n = 1-10). A Reporter must be set up that loads these values for each cycle.

To use the CYCDATA_n variables you must first activate them by adding a PLC device to your station. This is done using the menu choice Setup-Setup System. Click on the Hardware tag to get the hardware view of the system. Select the station TC and press Add. In the list presented select PLC.

The second step is to create a Reporter for the PLC device. It is used to select which cycle data that is written to the respective CYCDATA_n variables. Note that in this Reporter it is only the Order column that is of interest. It marks the variables to be written to the PLC.

Bolt variables

These variables are used to control and monitor the tightening of single bolts.

Variable Dir Type Use

BOLTCONTROL_n

Out Int To control bolt n. 0: Connect normally 1: Disconnected with OK status2: Disconnected with Not OK status3: Do not run during next cycle

BOLTSTATUS_n

In Int Status for bolt:0: Idle OK1: Idle OK after Reject Management (OKR)2: Idle Not OK (NOK)3: Idle Stop and Terminate Not OK (TERMNOK)4: Running5: Running Reject Management 6: Evaluating7: Waiting for PLC step

BOLTCONTROL_n and DATAHOLD are useful when running several bolts with one spindle.

1. Set DATAHOLD=1 before any bolts are tightened.

2. Set BOLTCONTROL=0 for all bolts to include and 3 for all to exclude in the cycle.

3. Run cycles until all bolts have been run.

4. Set DATAHOLD=0 to release the complete data package for all bolts.

ID Device variables

These variables are used to initiate and supervise the reading of ID string from an ID device.

Variable Dir Type Use

IDREAD Out Bool Set to True to order reading of ID deviceIDSTATUS In Int Status for ID device:

0: Idle OK1: Idle Not Ok2: Busy

IDCODE In Int Code from conversion of read ID string. See Error:Reference source not found for how the conversion is defined.

IDWRITE Out Bool Set to True to overwrite read ID string

IDSTRING Out Str String to replace read ID string

Globals

These variables are used to transfer information from one station PLC to another. All stations can reach these global variables. Only one station should write to a given variable but any number of stations can read it.

Figure: Communication via GLOBAL Variables

Variable Dir Type Use

SYSTEMGLOBAL_n

In/Out

Int For signals between station PLCs. (n = 1-30)

IEC 1363 Literals, data types and variables

Literals

Literals can be used to enter external representation of data. Literals are necessary for the representation of numeric, character strings and time data. Every time you have to enter values you have to use literals.

Numeric literals

Type ExamplesInteger literals -12 0 123_456 +986

Type ExamplesReal literals -12.0 0.0 0.4560 3.14159_26Real literals with exponents -1.34E-12 -1.34e-12 1.0E+6Base 2 literals INT#2#1111_1111Base 8 literals INT#8#377Base 16 literals INT#16#FF SINT#16#ffBoolean FALSE and TRUE FALSE TRUEBoolean 0 and 1 0, 1

Elementary data types

Data type

Description Size Range Default initial value

BOOL Boolean 1 0 up to 1 0SINT Short integer 8 -128 up to 127 0INT Integer 16 -32768 up to 32767 0DINT Double

integer32 -2.147.483.648 up to

+2147.483.6470

USINT Unsigned short integer

8 0 up to 255 0

UINT Unsigned integer

16 0 up to 65535 0

UDINT Unsigned double integer

32 0 up to 4.294.967.295 0

REAL Real numbers

32 3.4E-38 up to 3.40E+38

0.0

TIME Duration 32 about 24 days t#0sBYTE Bit string of

length 88 00 up to FF 0

WORD Bit string of length 16

16 0000 up to FFFF 0

DWORD Bit string of length 32

32 00000000 up to FFFFFFFF

0

Symbolic, located variables and directly represented variables

According to IEC 1131-3 variables are used for programming instead of direct addressing inputs, outputs or flags. Symbolic, located or directly represented variables can be declared.

A declaration of a symbolic variable consists of a variable name and a data type. A declaration of a located variable consists of a variable name, the variable location and a data type. A declaration of a directly represented variable consists of the variable location and a data type. Directly represented variables can only be declared in the declaration of global variables or in programs.

VARname : data type;name AT %location: data type;

AT %location: data type;END_VAR

Figure: Declaration of a symbolic, a located variable and a directly represented variable

The location of the variable consists of a location prefix and a size prefix. Location prefixes are I for inputs, Q for outputs and M for internal memory. Size prefixes are X for single bits, B for byte, W for word and D for double word.

Located and directly represented variables are stored at the declared logical address and it is up to the application programmer to check that no memory address is used twice.

Global and local variables

The scope of each variable which is determined by the use of the variable keyword is limited either to a POU or to the whole project. Therefore two types can be distinguished:

Local variables

Global variables

If a variable can be used only within a POU it is called local variable. In those cases the variable keywords VAR, VAR_INPUT and VAR_OUTPUT must be used.

If a variable can be used within the whole project it is called global variable. It has to be declared as VAR_GLOBAL in the global declaration and as VAR_EXTERNAL in each POU where it is used.

Retentive variables

Retentive variables are variables whose values are stored even if the power is switched off. In case of a warm start the last value of the variable is going to be used.

Retentive variables are declared using the keyword RETAIN as it is shown in the following example:

VAR RETAINvar1 : BOOL := TRUE;

END_VAR

Figure: Example for the declaration of a retentive variable

In this example the variable has got the initial value 'TRUE' which is the initial value for a cold start. In case of a warm start the current value of the variable is used. The keyword RETAIN can be used in combination with the keywords VAR, VAR_OUTPUT and VAR_GLOBAL. It is not possible to declare retentive variables with the keywords VAR_INPUT and VAR_EXTERNAL.

Initializing variables

According to IEC 1131-3 initial values can be assigned to variables. Initial values can be given to all kind of variables except in VAR_EXTERNAL declarations. If the PLC is started the variable is processed using the initial value.

Initial values have to be inserted at the end of the declaration line of the variable using ':=' as it is shown in the following figure:

VARname :data type := initial value;name AT %location :data type := initial value;

AT %location :data type := initial value;END_VAR

Figure: Declaration and initialization of a symbolic, a located variable and a directly represented variable

The initial value has to fit to the data type. It is not possible to use e.g. the data type BOOL and an initial value '5'. In this case the system displays an error message. The initial value is optional. If no initial value is used, the variable is initialized with the default initial value of the data type or with the retained value in case of retentive variables.

Variable declaration keywords

Keyword Variable type / ExplanationVAR for internal variables which can be used only

within a POUfor declaring the instances of function blockscan be used for the declaration of directly represented and located variables in programscan be used for the declaration of symbolic variablescan be used with the keyword 'RETAIN' for declaring retentive variables

Keyword Variable type / Explanation

to be continued....

VAR_INPUT for variables which are inputs to functions, function blocks and programsto give a value to the POU coming e.g. from another POUits value is only read within the POUcan be used only for the declaration of symbolic variables

VAR_OUTPUT for variables which are outputs to function blocks and programssupplies an output value for e.g. other POUsits value is written within the POUit is also allowed to read the valuecan be used only for the declaration of symbolic variablescan be used with the keyword 'RETAIN' for declaring retentive variables

VAR_IN_OUT address of the variable is passed by referencethe variable can be read or writtentypically used for complex data types such as strings, arrays and structures.

VAR_EXTERNAL for global variables in the POUits value is supplied by the declaration of VAR_GLOBALcannot be initializedits value can be modified within the POUcan be used only for the declaration of symbolic variables

VAR_EXTERNAL_PG for global variables in the programits value is supplied by the declaration of VAR_GLOBAL_PGcannot be initializedits value can be modified within the programcan be used only for the declaration of symbolic variables

VAR_EXTERNAL_FB for global variables in the function blockits value is supplied by the declaration of VAR_GLOBAL_FBcannot be initialized

Keyword Variable type / Explanationits value can be modified within the function blockcan be used only for the declaration of symbolic variables

to be continued...

VAR_GLOBAL for global variables which can be used in all programs and function blocks of the projectcan be used for the declaration of directly represented, located and symbolic variablescan be used with the keyword 'RETAIN' for declaring retentive variables

VAR_GLOBAL_PG for global variables which can be used in all programs of the projectcan be used for the declaration of directly represented, located and symbolic variablescan be used with the keyword 'RETAIN' for declaring retentive variables

VAR_GLOBAL_FB for global variables which can be used in all function blocks of the projectcan be used for the declaration of directly represented, located and symbolic variablescan be used with the keyword 'RETAIN' for declaring retentive variables

END_VAR to finish a variable declaration block

Instantiation

IEC 1131-3 provides the possibility of instantiation. Instantiation means that a function block is defined once and can be used several times. As function blocks 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. This is done using instance names. The instance name is declared in the variable declaration of the POU where the function block is going to be used. In the following figure an example of a variable declaration for the function block 'FB_exam' with two instances is shown:

VARdrive1 : FB_exam;drive2 : FB_exam;

END_VAR

Figure: Instantiation of a function block

The function block 'FB_exam', whose code body has been defined somewhere in the project, has got two instances. The instance name of the first instance is 'drive1', of the second 'drive2'. In the corresponding code body worksheet you can use the function block 'FB_exam' twice, entering in

both cases the correct instance name. Function blocks can be instantiated within programs or other function blocks. Functions can be called without instantiation because they do not have an internal memory.

Examples, Q&AQ_1: JOG function signal assign in device card. How to set in Multiprog (PLC) signal and Jog function relation? Q_2: JOG step in system via Anybus card. How to implement this function? Anybus address span the space from 3000 to 3299 for inputs, 3300 to 3599 for outputs. Which address should be used for this function. Are there Anybus cards available to use for JOG step function?

A_1: In the spindle setup you specify the digital signal to use for the JOG step for each spindle. You specify two numbers for this signal with a dot between, e.g. 1.4. The numbers mean <TC no>.<channel>, i.e. 1.4 means signal number 4 on TC 1. The TC number to specify is the TC that has the device net I/O attached to it. See also the example below:

The name of the digital input corresponding to the number in the spindle setup can be found in the PLC program below Digital_In_Out, see below. The input with the address 600.0 is digital input 1, the input with address 601.0 is input 2 etc.. In the example below DI_Start is input 1, DI_Reset is input 2 etc. With 1.4 programmed in the spindle setup the input DI_Spare_603 will be used for JOG steps. (If you press this button when a JOG step is running the spindle is stopped and next step can be started).

A_2: The answer on you question is unfortunately that it is not possible to assign an address from the Anybus Card to the Jog function, you have to use a digital input through the Vipa module for this.

There are however a way to get around this and have almost the same function anyway. Instead of using a Jog step you can use a Run until time step and use the system global STEPSTOP in the PLC to stop the motion. The system global STEPSTOP can when be attached to any input signal that you want digital I/O, field-busses e.t.c... The only problem with this solution is that ALL spindles in the station will be stopped when you use STEPSTOP so this will only work if all spindles are running Jog steps and all spindles have the same signal for stopping the Jog step.

In the PLC the signals should be used in the following way to make this Jog functionality to work:1. Let START = TRUE. This will start the program and all the spindles will start to move.2. Let START = FALSE. The spindles will continue to run.3. When the Jog step shall be ended let STEPSTOP = TRUE. This will stop the ongoing step on all spindles. The status of all spindles will be OK. 4. Let STEPSTOP = FALSE, the spindles will continue to stand still.5. Let START = TRUE. The spindles will start with the next step in the program and run until the program is finished.

The control parameter for the Run until time step should be so long so that you are sure the signal STEPSTOP always come first. It is also good to let the step have a time restriction that is lower than the control value. In this way the status of the step will always be NOK if the signal to stop the step never comes.