Home
Manual de Utilização
Contents
1. Figura 6 83 Breakpoint Deactivated As soon as a breakpoint position is reached during stepping or program processing a yellow arrow will be displayed in the breakpoint symbol and the red shaded area will change to yellow The currently reached halt position is indicated by a yellow shadow and the subsequent not yet reached one by a red shadow i iubi ivarl Outvar erg fubinst ivarl TO ivarl 875 el ivarl 673 1 Figure 6 84 Halt Positions Shown in FBD 184 6 Programming Languages Editors fubinstt LD fubinst outvar sr cts EET gt Figure 6 85 Halt Positions Shown in IL NOTE Notice for breakpoints in methods A breakpoint will be set automatically in all methods which might be called If a method is called via a pointer on a function block breakpoints will be set in the method of the function block and in all derivative function blocks which are subscribing the method 185 7 Libraries 7 Libraries The library standard library is installed by default It contains all functions and function blocks which are required according to the IEC61131 3 standard as default POUs for an IEC programming system Several further libraries are needed for the various functionalities of the programming system like for example visualization profiling etc Those are implicitly used libraries by default will be included automatically in a project and the user has not to deal with them
2. FURTHER OUTPUT ASSIGNMENTS This effects that the output of the method is written to the locally declared output variables as given within the call Example Assume that function blocks fubl and fub2 EXTEND function block fubbase Method method 1 is contained Possible use of the method calls VAR INPUT B BOOL END_VAR VAR PINST POINTER TO FUBBASE INSTBASE FUBBASE INSTI PUBIS INST2 FUB2 END_VAR IF B THEN PINST ADR INSTBASE ELSE PINST ADR INST1 END IF PINST METHOD1 If B is true FUBBASE METHOD1 is called else FUB1 METHOD1 is called Now assume that fubbase of the upper example contains two methods method and method2 fubl overrides method2 but not method1 method is called like shown in the upper example PINST METHOD1 If B is true FUBBASE METHOD1 is called else FUB1 METHOD1 is called Call via pointers method implementation METHOD METHOD1 BOOL 26 3 Concepts and Basic Components VAR_INPUT END VAR METHOD1 METHOD2 For calling fubbase method1 via pointers the following 1s true e If THIS is of type fubbase fubbase method2 will be called e If THIS is of type fub1 fubl method2 will be called Data Type Unit Method Along with the standard data types the user can define own data types Structures enumeration types and references can be created as Data Type Units DUTs in a DUT editor A DUT h object can be added to the
3. Actions Step active Stepl_active Step entry StepO_entry Step exit StepO_ exit Sa Prql SPl gt 22 5 Init Figure 6 26 IEC Extending Step Actions The Step active Step Entry and Step Exit actions are defined in the step properties 140 6 Programming Languages Editors Action 451 Figure 6 27 Step Active Action Branches A sequential function chart can diverge that is the processing line can be branched into two or several further lines branches Parallel branches will be processed parallel both at a time in case of alternative branches only one will be processed depending on the preceding transition condition Each branching within a chart is preceded by a horizontal double parallel or simple alternative line and also terminated by such a line or by a jump Parallel Branch Symbol ga A parallel branch must begin and end with a step Parallel branches can contain alternative branches or other parallel branches The horizontal lines before and after the branched area are double lines Processing in online mode If the preceding transition t2 in Figure 6 28 is TRUE the first steps of all parallel branches will become active The particular branches will be processed parallel to one another before the subsequent transition t3 in Figure 6 28 will be noticed A parallel branch is inserted via command Insert branch right when a step is currently selected Notice that parallel and alternative bran
4. 74 5 Programming Reference REAL LREAL REAL and LREAL are so called floating point types They are required to represent rational numbers 32 bits of memory space is reserved for REAL and 64 bits for LREAL Value range for REAL 1 175494351e 38 to 3 402823466e 38 Value range for LREAL 2 2250738585072014e 308 to 1 797693 1348623 158e 308 NOTES The support of data type LREAL depends on the target device Please see in the corresponding documentation whether the 64 bit type LREAL gets converted to REAL during compilation possibly with a loss of information or persists If a REAL or LREAL is converted to SINT USINT INT UINT DINT UDINT LINT or ULINT and the value of the real number is out of the value range of that integer the result will be undefined and will depend on the target system Even an exception 1s possible in this case In order to get target independent code handle any range exceedance by the application If the real lreal number is within the integer value range the conversion will work on all systems in the same way See also REAL LREAL Constants STRING A STRING type variable can contain any string of characters The size entry in the declaration determines how much memory space should be reserved for the variable It refers to the number of characters in the string and can be placed in parentheses or square brackets If no size specification is given the default size of 80 characters will be used
5. In the other hand the MV and PV parameters of the PID are REAL type The units and the operating range can be set in the most appropriate The following examples for PID parameters conversion can be used Consider the following examples e MV with the same operating range of AO and is not prepared value eg 0 30000 e MV percentage eg 0 control valve fully closed 100 control valve fully open In each example the need to observe conversion to implement e AO REAL_TO_INT MV AO REAL_TO_INT MV 30000 100 NOTE there some PID parameters described below which impose maximum and minimum values for MV They are called MaxMV and MinMV respectively Substituting MV in expressions on the previous examples by MaxMV and MinMV must generate values in the AO operation range eg O 30000 It is necessary to check this to avoid overflow problems 218 7 Libraries Example of PID block em FBD ErrorCode IntegralAction Input parameters Setpoint REAL Unit and range must be the same as the PV because the two variables can be compared Process variable PV REAL Unit and range must be the same as the SP because the two variables can be compared Proportional gain used to calculate the proportional action of the PID REAL block Td REAL Derivative Time in seconds used to calculate the derivative action of the PID block Ti REAL Integral Time in seconds used to calculate the integral action of
6. The string length basically is not limited in MasterTool IEC XE but string functions only can process strings of 255 characters If a variable is initialized with a string too long for the variables datatype the string will be correspondingly cut from right to left Example of a String Declaration with 35 characters Str TRING 35 A This 1S a string y See also WSTRING and STRING Constants Time Data Types The data types TIME TIME_OF_DAY abb TOD DATE and DATE_AND_TIME abb DT are handled internally ike DWORD Time is given in milliseconds in TIME and TOD time in TOD begins at 12 00 A M Time is given in seconds in DATE and DT beginning with January 1 1970 at 12 00 A M Notice in this context also LTIME available as a 32 Bit time TIME Constants DATE Constants DATE_AND_TIME Constants TIME OF DAY Constants Extensions to the IEC 1131 3 Standard Norm Extended Data Types In addition to the data types according to IEC1131 3 there are also some norm extending data types available implicitly in MasterTool IEC XE e UNION e TIME 75 5 Programming Reference e WSTRING e Pointers e References UNION As an extension to the IEC 61131 3 standard it is possible to declare unions in user defined types In a union all components have the same offset they all occupy the same storage location Thus assuming a union definition as shown in the following example an assignment to name a also would mani
7. 7 Libraries pd inst PD LIMITS ACTIVE Inputs of the Function Block KP REAL Proportionality coefficient unity gain of the P part TV REAL Derivative action time unity gain of the D part in seconds for example 0 5 for 500 msec Y MANUAL REAL Defines output value Y in case of MANUAL TRUE Y_OFFSET REAL Offset for the manipulated variable Y Y_MIN REAL Lower upper limit for the manipulated variable Y If Y exceeds these Y_MAX limits output LIMITS ACTIVE will be set to TRUE and Y will be kept within the prescribed range This control will only work if Y_MIN lt Y_MAX MANUAL BOOL If TRUE manual operation will be active that is the manipulated value will be defined by Y_MANUAL RESET BOOL TRUE resets the controller During reinitialization Y Y_OFFSET Table 7 3 Input Variables PD Outputs of the Function Block Datatype REAL Manipulated value calculated by the function block LIMITS ACTIVE BOOL TRUE indicates that Y has exceeded the given limits Y_MIN Y_MAX Table 7 4 Output Variables PD Y_OFFSET Y_MIN und Y_MAX are used for the transformation of the manipulated variable within a prescribed range MANUAL can be used to switch on and off manual operation RESET serves to reset the controller In normal operation MANUAL RESET and LIMITS_ACTIVE FALSE the controller calculates the controller error e as difference SET_POINT ACTUAL generates the derivation with respect to ti
8. IEC 61131 Programming Manual Rev B 10 2014 Cod Doc MP399609 General Supply Conditions No part of this document may be copied or reproduced in any form without the prior written consent of Altus Sistemas de Automac o S A who reserves the right to carry out alterations without prior advice According to current legislation in Brazil the Consumer Defense Code we are giving the following information to clients who use our products regarding personal safety and premises The industrial automation equipment manufactured by Altus is strong and reliable due to the stringent quality control it is subjected to However any electronic industrial control equipment programmable controllers numerical commands etc can damage machines or processes controlled by them when there are defective components and or when a programming or installation error occurs This can even put human lives at risk The user should consider the possible consequences of the defects and should provide additional external installations for safety reasons This concern is higher when in initial commissioning and testing The equipment manufactured by Altus does not directly expose the environment to hazards since they do not issue any kind of pollutant during their use However concerning the disposal of equipment it is important to point out that built in electronics may contain materials which are harmful to nature when improperly discarded Therefore it i
9. na Figure 6 6 CFC Toolbox Default The desired element can be selected in the Toolbox and inserted in the editor window via drag amp drop Besides the programming elements there is an entry k Pointer by default at the top of the toolbox list As long as this entry 1s selected the cursor has the shape of an arrow and you can select elements in the editor window for positioning and editing them The elements MI O Eh 12 The text offered by can be selected and replaced by a variable or constant The input assistance serves to select a valid identifier The text offered by can be selected and replaced by a variable or constant The input assistance serves to select a valid identifier A box can be used to represent operators functions function blocks and programs The text offered can be selected and replaced by an operator function function block or program name The input assistance serves to select one of the available objects In case a function block is inserted another will be displayed above the box and have to be replaced by the name of the function block instance If an existing box is 125 6 Programming Languages Editors replaced by another one by modifying the entered name and the new one has a different minimum or maximum number of input or output pins the pins will be adapted correspondingly If pins are to be removed the lowest one will be removed first Jump
10. 5 0 Real number PBB BOO Table 5 3 Shortcut Examples AT Declaration In order to link a project variable directly with a definite address you can enter this address in the declaration of the variable Regard that the assignment of a variable to an address also can be done in the mapping dialog of a device in the PLC configuration device tree Syntax lt Identifier gt AT lt Address gt lt Data type gt Keyword AT must be followed by a valid address See the Address help page for further information and consider possible overlaps in case of byte addressing mode This declaration allows to assign a meaningful name to an address Any changes concerning an incoming or outgoing signal may only be done in a single place for example in the declaration Notice the following when choosing a variable to be assigned to an address e Variables requiring an input cannot be accessed by writing The compiler intercepts this with error e AT declarations only can be used with local or global variables not however with input and output variables of POUS e AT declarations must not be used in combination with VAR RETAIN or VAR PERSISTENT e If AT declarations are used with structure or function block members all instances will access the same memory location which corresponds to static variables in classic programming languages like e g C e The memory layout of structures is determined by the target too Examples count
11. Bitstring Operators Bit Shift Operators Selection Operators Comparison Operators Address Operators Calling Operators Type Conversion Functions Numeric Functions IEC extending Operators IEC extending Scope Operators The following operators prescribed by the IEC1131 3 standard are available ADD MUL SUB DIV MOD MOVE There are also two norm extending operators e SIZEOF e INDEXOF IEC Operator Addition of variables Allowed types BYTE WORD DWORD LWORD SINT USINT INT UINT DINT UDINT LINT ULINT REAL and LREAL Two TIME variables can also be added together resulting in another time for example t 45s t 50s t 1m35s Example in IL LD T ADD E ADD 4 ADD T oT ivar Example in ST varl lt I 2 4 75 Example in FBD 86 MUL SUB DIV 5 Programming Reference T Yarl IEC Operator Multiplication of variables Allowed types BYTE WORD DWORD LWORD SINT USINT INT UINT DINT UDINT LINT ULINT REAL and LREAL Example in IL LD T HUL E r 4 r T ST varl Example in ST varl 1 2 4 7 Example in FBD 7 varl s 4 T IEC Operator Subtraction of one variable from another one Allowed types s BYTE WORD DWORD LWORD SINT USINT INT UINT DINT UDINT LINT ULINT REAL and LREAL A TIME variable may also be subtracted from another TIME variable resulting in third TIME type variable Note that negative TIME values are undefined Example in IL LD T SU
12. END VAR An instance of the function block is called in the program MainPrg PROGRAM MAINPRG VAR nmyPouU POU MmyString STRING END VAR myPOU MVotrang myPOU Str The instance myPOU having been initialized the string variable STR will be assigned the path of the instance myPOU of POU e g Device Application MAINPRG myPOU This path will be assigned to variable myString within the main program 62 5 Programming Reference Linkalways Attribute The pragma attribute linkalways allows to mark POUs for the compiler in a way so that they are always included into the compile information As a result objects with this option will be always compiled and downloaded to the PLC This option only affects POUs and GVLs that are located below an application or in libraries which are inserted below an application The compiler option Link always does the same Syntax attribute linkalways When using the symbol configuration editor the marked POUs are used as basis for the selectable variables for the symbol configuration Example The global variable list GVLMoreSymbols is implemented making use of the attribute attribute linkalways VAR GLOBAL g 1Va l z INT g 1Ver2 INT END VAR Monitoring Attribute A property may be monitored in online mode either with help of Monitoring window The monitoring can be activated by adding the monitoring attribute pragma in the line above the property definit
13. If a reset is performed on the associated application the integer variable A will be again initialized implicitly with O whereas variable B maintains the value it is currently assigned to Obsolete Attribute An pragma attribute obsolete can be added to a data type definition in order to cause a user defined warning during a build run 1f the respective data type structure function block etc is used within the project Thus for example you might announce that the data type should not be used any longer Unlike a locally used Message Pragma this warning is defined within the definition and thus globally for all instances of the data type This pragma instruction always is valid for the current line or if placed in a separate line for the subsequent line Syntax attribute obsolete User defined text Example The obsolete pragma is inserted in the definition of function block fb1 attribute obsolete Data type fbl not valid FUNCTION BLOCK Tol VAR INPUT LINT END VAR If fb1 is used as a data type in a declaration e g fbinst fb1 the following warning will be dumped when the project is built Data type fb1 not valid Pack _ mode Attribute The pragma attribute pack_mode defines the mode a data structure is packed while being allocated The attribute has to be set on top of a data structure and will influence the packing of the whole structure Syntax attribute pack mode
14. Index access with pointers and strings User Management and Access Rights Concept User accounts user groups specific rights to groups for access and actions in specific objects Characteristics in Editors ST Editor editing resources break line autocomplete monitoring and SET RESET assignment in line FBD LD IL Editors reversible and programmable in one combined editor IL Editor as Table editor FBD LD IL Editors possibility of changing the main output in boxes with multiple outputs FBD LD IL Editors without automatic update of the box parameters FBD LD IL Editors branches and networks inside the networks SFC Editor only one type of step macros multiple selections of independent elements without syntactic checkup during editing and automatic declaration of signal variables Library Versions Several library versions can be used in the same project using namespaces Installation in repositories automatic update and debugging Additional Functionalities Menus toolbar and keyboard usage Inclusion of specific user components PC Configuration and task configuration integrated in the device tree UNICODE Support Comments in line Watchdog Multiple selection in the project object device Online help on the user interface Conditional building Conditional breakpoints Debugging step to the cursor and return to previous call Field bus driver according to IEC 61131 3 PC and symbol configuration available
15. Insert Network Insert Network below Insert label Ctrl Ctrl T Toggle network comment state Ctl 0 Insert Box Insert Empty Box Insert Box with EN ENO Insert Input Insert Assignment Insert Jump Insert Return Negation Edge Detection Set Reset Set output connection Insert Branch Update parameters Ctrl Cctrl Shift 8 ctrl Shift E ctl H0 Ctrlt a Ctrl Ctrl HN Ctrl E Ctrl M1 Ctrl 44 Ctrl Shitt V Ctrl u Remove unused FB call parameters View Figure 6 63 FBD LD IL Menu in FBD Editor View For a description of the commands see Editor FBD LD IL Commands in the MasterTool IEC XE User Manual MU299609 Elements 6 Programming Languages Editors FBD LD IL Toolbox Network The FBD LD IL editor provides a toolbox which offers the programming elements for being inserted in the editor window by drag amp drop The toolbox by default can be opened via command Toolbox in the View menu It depends on the currently active editor view which elements are available for inserting see the respective description of the Insert commands The elements are sorted in categories General general elements like Network Assignment etc Boolean operators Math operators Other operators SEL MUX LIMIT and MOVE Function blocks R_TRIG F_TRIG RS SR TON TOF CTD CTU Ladder elements and POUs user defined The POUs category lists all POUs which have been defined by the user
16. PT TIME Upper limit for counting up ET delay time Outputs Q BOOL Gets a rising edge as soon as ET has reached the upper limit PV delay time is over ET current state of delay time TON N PT Q ET If IN 1s FALSE Q will be FALSE and ET will be 0 As soon as IN becomes TRUE the time will begin to be counted in milliseconds in ET until 1ts value 1s equal to PT It will then remain constant Q is TRUE when IN is TRUE and ET is equal to PT Otherwise it is FALSE Thus Q has a rising edge when the time indicated in PT in milliseconds has run out 197 TOF 7 Libraries tO AT tl t4 AT t5 PT aS A S D tO t tz td t t5 Figure 7 2 Graphic Display of TON Behavior Over Time Declaration example TONInst TON Example in IL CAL TONinst IN VYarBD0Ll PT T 5s f ET gt VYarTimeCur LD TONinst D ST YarBO00LZ Example in FBD TOWinst YarBooLl YarBoou Le T 5s ETP VarTimeCur Example in ST TONInst IN VarBOOL1 PT T 5s Provided by standard library Timer function block implements a turn off delay When the input changes from TRUE to FALSE falling edge first a certain time will run through until also the output gets FALSE Inputs IN BOOL Falling edge starts counting up ET PT TIME Upper limit for counting up ET delay time Outputs Q BOOL Gets a falling edge as soon as ET has reached the upper limit PV delay time is over ET current state of delay time
17. VR OP E N 49 Inputand Output ariables VAR TN OUT poietic tanita iS 50 Global Variables VAR GL OBA i a e O e eid ete 50 Temporary Variables MAR MiP toc os is O e eal a ae 50 Static Variables MARS TA E ai 51 External Variables VAK EXTERNAL da 51 Attribute Keywords tor Variable IPS aa 51 Remanent V anaples a cias 51 E A A O A a fone 53 Vanables Configuration VAR CONFIG auna 54 Declaration and Initialization of User Defined Data Types ooooonnnnnnnononononcnononononnnnonnnncnnnnnnnnnnnnnnononononnnnos 55 FBM FB Remit MAS oe 55 PEAP a ac 56 Praisma astucia 57 Hist Components Funcional My cenere nnen od 71 ap O 72 Summary Sl A A 72 A O ies 73 Data Desi 74 Standard Data PES di eteniallbedrcnep ences nacre ente int 74 Extensions tothe ECT Standards a ii oiii a 75 User Demed Dita POS ai dis 79 A O N R 85 IEC Operators and Norm Extending Functions cccccccccncnnnnnnnnnononncnnnnnnnnnnnnnnnonononnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnos 85 AT NMCUS OPTIO Sea ii di 86 Bits ime Operators aia 90 BUSES te a OO 92 SO A AN 95 COMPARISON O DELAlOES A A as 98 IN A R ORTH ner RRS NES A eer ony ornare Sean er eneen re rena 100 Calle Operator ES 101 Type Conversi n Fanchon cst a has ede hte ate ae 101 Ne O See Aer erent en neen 109 EC Ext ndine OM CralOrs aancsteehcencs dei cacteai a sl etiadadcteehcennededuagiaiGel aa 114 OPUS 115 SA O EEA einer EEE sen O E eee A 115 o A O A A A 118 ISS A O A O A O O A A A 120 A A 12
18. attribute monitoring call the attribute can only be used for properties returning simple data types or pointers not for structured types The value to be monitored is retrieved directly by calling the property 1 e the monitoring service of the runtime system calls the Get method Regard that if any operations on the variables are implemented within the property the value might still change No check Attribute The pragma attribute no_check is added to a POU in purpose to suppress the call of any POUs for Implicit Checks As check functions may influence the performance it is reasonable to apply this attribute to POUs that are frequently called or already approved Syntax attribute no Check Example Using the POU for implicit checks CheckRangeSigned for example added to the project run the code below with the pragma attribute no_check the function won t be checked in this case allowing the variable x to accept any value attribute Tno check PROGRAM MainPrg VAR xi DINT 100 200 y DINT END VAR x lt y No_ init Attribute Variables provided with the pragma attribute no_init won t be initialized implicitly The pragma belongs to the variable declared subsequently Syntax attribute no init or attribute no init 64 5 Programming Reference attribute noinit Example PROGRAM MainPrg VAR A 75 INI lateribute no Antes B INT END VAR
19. ivartl fbinst in 11 erg fbinst Hm Ga Ri P Figure 5 6 List Components Function Block e Ifyou enter any string and press lt CTRL gt lt SPACE gt a selection box will appear listing all POUs and global variables available in the project The first list entry which is starting with the given string will be selected and can be entered to the program by pressing the lt ENTER gt key I O Mapping General This sub dialog of the devices is called Bus I O Mapping it used to setup a I O mapping of the PLC This means that the project variables used by applications are assigned to inputs and outputs of the device All I O mapping can be set for the current device An address can also be assigned to a variable using AT declaration In this case consider the following points e AT declarations can be used with only the local or global variables however not with inputs and outputs variable of the POUs e For AT declarations is not possible to create forces for variables e If AT declarations are used to structure or function block all instances will access the same memory location corresponding to static variables in programming languages such as C For further information see AT Declaration The Bus I O Mapping dialog contains on its bottom part the following commands e Reset mapping This button resets the settings for the mapping default defined by the device description file e Always update variables I
20. Bitstring operators compare the corresponding bits of two or several operands IEC Bitstring Operator Bitwise AND of bit operands If the input bits each are 1 then the resulting bit will be 1 otherwise O Allowed types BOOL BYTE WORD DWORD LWORD Example in IL LD 2 1001 0011 AHD 2 1000 1010 ST varl Result in Varl is 2 1000_0010 Example in ST VAR Varl sBYTE gt 90 OR XOR NOT 5 Programming Reference END VAR varli 271001 0011 AND 271000 1010 Example in FBD 2 1001 0011 varl 2 1000_1010 IEC Bitstring Operator Bitwise OR of bit operands If at least one of the input bits is 1 the resulting bit will be 1 otherwise 0 Allowed types BOOL BYTE WORD or DWORD LWORD Example in IL LD 281001 0011 OR 281000_1010 ST varl Result in var1 is 2 1001_1011 BYTE type Example in ST Varl lt 21001 0011 OR 241000 1010 Example in FBD 281001 0011 Yarl 2 1000_1010 IEC Bitstring Operator Bitwise XOR operation of bit operands If only one of the input bits is 1 then the resulting bit will be 1 if both or none are 1 the resulting bit will be 0 Allowed types BOOL BYTE WORD DWORD LWORD NOTE Notice the behavior of the XOR function in extended form that means 1f there are more than 2 inputs The inputs will be checked in pairs and the particular results will then be compared again in pairs this complies with the standard but may not b
21. C SP 30000 gt 130 C Or to restrict the range between 50 C and 80 C SP 6000 gt 50 C SP 15000 gt 80 C General Block Diagram and Limit Values The Figure 7 26 shows a overall of the system block diagram controller process where into the controller is shown the PID function block Note that SP PV and MV are variables of the controller 228 7 Libraries analog output PROCESS analog input CONTROLLER Figure 7 26 Block Diagram of the PID Function Block SP minimum 6000 50 C maximum 15000 80 C PV minimum 0 30 C maximum 30000 130 C MV minimum 0 0 m3 h maximum 7500 gt 6 m3 h It is observed that in the case of MV although the valve is able to inject 8 m h it is desirable to limit this flow in 6 m h Process Parameters The Figure 7 27 shows the result of a test on the opened loop process To perform this test it was used the variables MV and PV directly with its internal units 229 7 Libraries MV 4 mh 5000 2 mh 2500 FOC 12000 a79 90 26 o0 60 90 Figure 7 27 Open Loop Test From Figure 7 27 can determine the three basic parameters as explained above in the section Application Notes Tm 10 seconds dead time as the step was applied at t 50 s and started responsing at t 60 s T 30 seconds time constant as the response started at t 60 s and reached 63 21 of excursion at t 90s 9
22. External File Any external file can be added to the POUs view of a project via the Add Object command In the Add object dialog choose object type External File E Press button L for getting the dialog for browsing for a file the path of which will be entered to the field below File path In the field below Name automatically the name of the chosen file will be entered without extension You can edit this field to define another name for the file under which it should be handled within the project Select one of the following options e Remember the link The file will be available in the project only if it is available in the defined link path e Remember the link and embed into project A copy of the file will be stored internally in the project but also the link to the external file will be remembered If the external file is linked to the project you can additionally select one of the options o Reload the file automatically The file will be updated within the project as soon as it has been changed externally o Prompt whether to reload the file A dialog will pop up as soon as the file has been changed externally You can decide whether the file should be updated also within the project o Do nothing The file will remain unchanged within the project even when it is changed externally e Embed into project Just a copy of the file will be stored in the project There will be no further connection to the external file On thi
23. FOR Loop With the FOR loop one can program repeated processes Syntax FOR lt INT Var gt lt INIT VALUE gt TO lt END VALUE gt BY lt STEP SIZE gt DO Lois ceuecr1 One END FOR The part in braces is optional The lt INSTRUCTIONS gt are executed as long as the counter lt INT_Var gt is not greater than the lt END_VALUE gt This is checked before executing the lt INSTRUCTIONS gt so that the lt instructions gt are never executed if lt INIT_VALUE gt is greater than lt END_VALUE gt When lt INSTRUCTIONS gt are executed lt INT_Var gt is increased by lt STEP SIZE gt The step size can have any integer value If it is missing then it is set to 1 The loop must also end since lt INT_Var gt only becomes greater Example FOR Counter l TO 5 BY 1 DO Varl Varl 2 END_FOR Erg Varl Let us assume that the default setting for Varl is 1 Then it will have the value 32 after the FOR loop NOTE If lt VALOR_FINAL gt is equal to the limit value of counter lt INT_VAR gt for example if Counter used in the example shown above is of type SINT and if lt VALOR_FINAL gt is 127 then you will get an endless loop So lt VALOR_FINAL gt must not be equal to the limit value of the counter The CONTINUE instruction can be used within a FOR loop WHILE Loop The WHILE loop can be used like the FOR loop with the difference that the break off condition can be any Boolean expression
24. In case of assigning multiple actions to a step action list the actions will be executed from up to down Different qualifiers can be used for IEC step actions in contrast to a normal step action A further difference to the normal step actions is that each IEC step action is provided with a control flag which allows to make sure that even if the action is called also by another step the action will get executed always only once at a time This is not guaranteed with the normal step actions An EC step action is represented by a bipartite box connected to the right of a step via a connection line In the left part it shows the action qualifier in the right part the action name Both can be edited inline IEC step actions get associated to a step via the Insert action association after command One or multiple actions can be associated to a step The position of the new action depends on the current cursor position and the command The actions must be available in the project and be inserted with a unique action name for example MainPrg al Figure 6 25 IEC Conforming Step Action List Associated to a Step Each action box in the first column shows the qualifier and in the second the action name IEC Extending Step Actions These are actions extending the IEC standard The actions must be available as objects below the SFC object The action names must be unique 139 6 Programming Languages Editors Step Entry Action
25. Pointers ARRAYS One two and three dimensional fields ARRAYS are supported as elementary data types Arrays can be defined both in the declaration part of a POU and in the global variable lists Notice the possibility of using implicit boundary checks Syntax lt Name gt ARRAY lt I L gt vull SliZ2 gt asl OF lt Type gt L11 112 113 identify the lower limit of the field range ull ul2 and ul3 identify the upper limit The range values must be integers 79 5 Programming Reference Example Card games ARRAY Llwwlo y Lect OF INT ARRAYS Initialization arr ARRAY Pisso OE INET te Llop Ayo arr ARRAY lei2 3 04 OF INT lt 11 37 arros z ARRAY ewe 7 ee Sy Oke SDE ANT AShore tor 0 0 4 A A lapa Example of the initialization of an array of a structure as US Rore Tor adsl E 2 0 4 4 2 3 Structure definition TYPE STRUCT 1 STRUCT OLALDE oe ul aha poydword END STRUCT END TYPE ARRAY initialization ARRA CDs SOS ERUCT I A ole 2 10 pos ada y Olt 2 02 f 07 0S 2 9 ols E pza oy po Lisa Example of the partial initialization of an ARRAY arri ARRAY 1 10 OF INT 2S 1 2 3 Elements to which no value is pre assigned are initialized with the default initial value of the basic type In the example above the elements anarray 6 to anarray 10 are therefore initialized with 0 Accessing ARRAY Components ARRAY components are accessed in a two dime
26. Program Program Calls A program can be called by another POU But A program call in a function is not allowed There are also no instances of programs If a POU has called a program and 1f thereby the values of the program have been changed these changes will be retained until the program gets called again even if it will be called from within another POU Regard that this is different from calling a function block where only the values in the 20 Function 3 Concepts and Basic Components given instance of the function block are changed and so the changes only are of effect when the same instance will be called again If you want to set input and or output parameters in the course of a program call you can do this in text language editors e g ST by assigning values to the parameters after the program name in parentheses For input parameters this assignment takes place using just as with the initialization of variables at the declaration position for output parameters gt is to be used See for an example below If the program is inserted via Input Assistant with option Insert With Arguments in the implementation window of a text language editor it will be displayed automatically according to this syntax with all parameters However you not necessarily must assign these parameters Examples for program calls in IL CAL PRGexanple in Vari 33 LD PRGexample out var ST erg Assigning the parameters Input
27. So variables can be declared with the same name in different global variable lists and can be accessed specifically by preceding the variable name with the list name Example GLOBLIST1 IVAR GLOBLIST2 IVAR IVAR from GLOBLIST2 is copied to IVAR in GLOBLIST1 e Variables defined in a Global Variables List of an included library can be accessed according to syntax lt Library Namespace gt lt Name of Global Variables List gt lt Variable gt See below for namespaces of libraries Example GLOBLIST1 IVAR LIB1 GLOBLIST1 IVAR IVAR from GLOBLIST1 in library LIBI is copied to IVAR in GLOBLISTI For a library also a namespace is defined when it gets included via the Library Manager So you can access a library module or variable by lt Library Namespace gt lt Modulename Variablename gt Notice that in case of nested libraries the namespaces of all libraries concerned have to been stated successively Example If Lib1 was referenced by LibO the module fun being part of Lib is accessed by LibO Lib1 fun IVAR LIBO LIB1 FUN 4 5 return value of FUN is copied to variable IVAR in project As far as the checkbox Publish all IEC Symbols to that project as if this reference would have been included there directly has been activated within the properties of the referenced library Lib the module fun may also be accessed directly via Lib0 fun AT lt Address gt Type The variable can directly be linked to a definite add
28. This address is valid as long as the function exists on the target See also INDEXOF Index Access to Pointers As extension to the IEC 61131 3 standard index access to variables of type POINTER STRING and WSTRING is allowed e Pint i will return the base data type e Index access on pointers is arithmetic If the index access is used on a variable of type pointer the offset will be calculated by pint 1 pint 1 SIZEOF base type The index access also performs an implicit dereferencation on the pointer The result type 1s the base type of the pointer Note that pint 7 pint 7 e If the index access is used on a variable of type STRING the result is the character at offset index expr The result is of type BYTE str 1 will return the i th character of the string as a SINT ASCII e Ifthe index access is used on a variable of type WSTRING the result is the character at offset index expr The result is of type WORD wstr 1 will return the 1 th character of the string as INT Unicode CheckPointer Function For checking pointer access during runtime you might use the implicitly available check function CheckPointer being called before each access on the address of a pointer Therefore add the object POU s for implicit checks to the application using the Add Object dialog Mark the checkbox related to the type CheckPointer choose an implementation language and confirm your settings with Open whereon the
29. Z POINTER TO INI t ADR Gy Not described by the IEC61131 3 Init value defined by an address function Be careful in this case the pointer will not be initialized during online change END VAR See ARRAYS Structures Subrange Types and Arbitrary Expressions For Variable Initialization Arbitrary Expressions For Variable Initialization A variable can be initialized with any valid ST expression It is possible to access other variables out of the same scope and it is possible to call functions However the programmer has to assure that a variable used for initialization of another variable is already initialized Examples for valid variable initializations VAR LEIN SS ee Ge Y e ENT Se a EUA Z POINTER TO INT ADR y Be careful the pointer will not be initialized during online change END_VAR Declaration Editor The declaration editor is a text or tabular editor used for the declaration of variables Usually it is provided in combination with the language editors For detailed information see the Declaration Editor chapter in the MasterTool IEC XE User Manual MU2996009 Autodeclaration Dialog It can be defined in the Options dialog category Text Editor that an Auto Declare dialog should open as soon as a not yet declared string 1s entered in the implementation part of an editor and the lt ENTER gt key is pressed This dialog will support the declaration of the variable The dialog also c
30. oniyi VAR GLOBAL LVars ENT s END VAR Within a POU MainPrg for example this global variable has to be called with the prefix GVL GVL iVar 5 The following incomplete call of the variable will cause instead an error Ivar 5 gt Reflection Attribute The pragma attribute reflection is attached to signatures Due to performance reasons itis an obligatory attribute for POUs carrying the instance path attribute Syntax attribute reflection Example See the example of the instance path attribute Symbol Attribute The pragma attribute symbol defines which variables are to be handled in the Symbol configuration which means that they will be exported as symbols into a symbol list exported to a XML file lt Project Name gt Device Application xml in the project directory as well as to a file not visible for the user and available on the target system for external access e g by an OPC Server Variables provided with that attribute will be downloaded to the PLC even if they have not been configured or are not visible within the symbol configuration editor 66 5 Programming Reference Regard that the Symbol configuration must be available as an object below the respective application in the Devices tree Syntax attribute symbol none read write readwrite Regard that access is only allowed on symbols coming from programs or global variable lists For accessing a symbol the symbol name
31. 6 Programming Languages Editors In a FBD or LD network it can be placed in parallel or at the end of the previous elements If the input of a RETURN is TRUE the processing of the POU immediately will be aborted For inserting use command Insert Return Alternatively drag the element from the Toolbox or copy or move it from another position within the editor In FBD In LD RETURN RETURN T Figure 6 67 RETURN Element In IL the RET instruction is used Branch Hanging Coil in FBD LD IL FBD LD In a FBD LD network a branch and a hanging coil splits up the processing line as from the current cursor position The processing line will continue in two sub networks which will be executed one after each other from up to down Each sub network can get a further branch such allowing multiple branching within a network Each sub network gets an own marker an upstanding rectangle symbol which can be selected cursor position 11 in order to perform actions on this arm of the branch Figure 6 68 Branch and Markers In FBD a branch gets inserted via command Insert Branch Alternatively drag the element from the Toolbox To verify the possible insert positions see Insert Branch in the MasterTool IEC XE User Manual MU299609 NOTE Cut and Paste is not possible for sub networks See the example shown in the Figure 6 69 A branch has been inserted at the SUB box output This created two sub networks each selectable by its
32. ATTENTION In order to maintain the check functionality do not change the declaration part of an implicit check function Example The assignment of a variable belonging to a signed subrange type entail an implicit call to CheckRangeSigned The default implementation of that function trimming a value to the permissible range is provided as follows Declaration part Implicitly generated code DO NOT EDIT FUNCTION CheckRangeSigned DINT VA ENDE value lower upper DINT END VAR 84 5 Programming Reference Implementation part Implicitly generated code Only an Implementation suggestion IF value lt lower THEN CheckRangeSigned lower ELSIF value gt upper THEN CheckRangeSigned upper ELSE CheckRangeSigned value END_IF When called the function gets the following input parameters e Value The value to be assigned to the range type e Lower The lower boundary of the range e Upper The upper boundary of the range As long as the assigned value is within the range the output of the function is the value itself Otherwise in correspondence to the range violation either the upper or the lower boundary of the range will be returned The assignment 1 10 y will now be replaced implicitly by 1 CheckRangeSigned 10 y 4095 4095 If y has the value 1000 for example the variable 1 will not be assigned to 10 1000 10000 as provided by the original implementation but to the upper bound
33. Assistant With Arguments see above CAL PRGexanple in VWari 33 E out War gt erg Example in ST PRGEXAMPLE ERG PRGEXAMPLE OUT VAR Assigning parameters Input Assistant With Arguments PRGEXAMPLE in Vars 33 out var gt eLg NOTE Brackets are obligatory Example in FBD TFesvar A function is a POU which yields exactly one data element which can consist of several elements such as fields or structures when it is processed and whose call in textual languages can occur as an operator in expressions A function POU can be added to the project via command Add Object and Add POU To assign the function to an existing application select the application entry in the Devices view and use the command from the context menu Otherwise it will be added to the POUs view In the Add POU dialog choose type Function enter a name lt function name gt and a return data type lt data type gt for the new function and choose the desired implementation language After confirming the settings with button Open the editor window for the new function will open and you can start editing Declaration A function declaration begins with the keyword FUNCTION A name and a data type must be defined Syntax FUNCTION lt FUNCTION NAME gt lt DATA TYPE gt This is followed by the variable declarations of input and function variables 21 3 Concepts and Basic Components A result must be assigned to a func
34. E i Qualifier of action Branch name i atepl Action name Jump Figure 6 16 Possible Cursor Positions Element Bodies When you click on a shadowed area the element will get selected It gets a dotted frame and is displayed red shaded for multiple selection see Working in SFC Editor Figure 6 17 Selected Step Element 133 6 Programming Languages Editors Working in SFC Editor By default a new SFC POU contains an init step and a subsequent transition For how to add further elements how to arrange and edit the elements see the following information For possible cursor positions see the above item Navigating Jumping to the next previous element in the chart is possible by using the arrow keys Insert Elements The particular SFC elements can be inserted via the respective commands which by default are available in the SFC menu See Cursor Positions in SFC for details A double click on an already inserted step transition or action element which does not yet reference a project object will open a dialog for assigning one Select Elements An element and a text field might be selected by a mouse click on a possible cursor position The selection might also always be given to an adjacent element by using the arrow keys The element will change color to red For examples see Cursor Positions in SFC Steps and transitions can be selected and thus also moved cut copy paste or deleted separately Mult
35. LEFT hast STR YarATRINGLl 4 SIZE Example in ST VarSTRING1I LEFT SUSI 3 Provided by standard library Function of type STRING Returns the right initial string for a given string Inputs STR STRING string to be analyzed SIZE INT number of characters to be counted from the right in string STR Return value STRING initial right string RIGHT STR SIZE means Return the first SIZE character from the right in the string STR Example in IL LD USE RIGHT 3 ST YaraTRINGl The result is USP Example in FBD RIGHT has a TR Yar TRING 4 SIZE Example in ST VarSTRINGL RIGHT SUSI 3 Provided by standard library Function of type STRING returns a partial string from within a string Inputs STR STRING string to be analyzed LEN INT length of the partial string number of characters 187 CONCAT INSERT 7 Libraries POS INT start position for the partial string number of characters counted from the left of STR Return value STRING partial string MID STR LEN POS means Retrieve LEN characters from the STR string beginning with the character at position POS Example in IL LD SUST HID E E ST YaraTRINGl The result is US Example in FBD HID haut a TR WarsSTRING1 A LEN E POS Example in ST VarSTRING1 MID SUSI 2 2 Provided by standard library Function of type STRING doing a concatenation combination of two strings Inputs STR1
36. STR2 STRING strings to be concatenated Return value STRING concatenated string CONCAT STRI STR2 means to connect STR1 and STR2 to a single string STRISTR2 Example in IL LD Es COHCAT WILLI ST WarsTRING1 The result is SUSIWILLP Example in FBD CONCAT Aua STRI Yar STRINGI WILLI STR Example in ST VarSTRINGl CONCAT SUSI WILLI Provided by standard library Function of type STRING inserts a string into another string at a defined point Inputs STR1 STRING string into which STR2 has to be inserted STR2 STRING string which has to be inserted into STR1 188 DELETE 7 Libraries POS INT Position in STR1 where STR2 has to be inserted number of characters counted from left Return value STRING resulting string INSERT STR 1 STR2 POS means Insert STR2 into STR1 after position POS Example in IL LD SUST INSERT oe s ST Yara TRINGl The result is SUXYST Example in FBD haul Yar STRINGI l xY I 2 Example in ST VarSTRINGI z INSERT SUSI A Provided by standard library Function of type STRING removes a partial string from a larger string at a defined position Inputs STR STRING string from which a part should be deleted LEN INT length of the partial string to be deleted number of characters POS INT position in STR where the deletion of LEN characters should start counted from left Return value STRING string remaining after deletion DELETE S
37. TO BOOL TRUE h Result is TRUE STRING TO WORD labcid Ww Result is O STRING TO TIME t gl17m t Result is T 127ms STRING TO BYTE 500 hw Result is 244 IEC Operator Converting from REAL to DINT The whole number portion of the value will be used When you perform a type conversion from a larger to a smaller type you risk losing some information Example in IL LD 1 9 TRUH C ST divar 108 5 Programming Reference Examples in ST diVar TRUNC 1 9 Result is 1 daiVar TRUNC 1L 4 Result as 1 TRUNC_INT IEC Operator Converting from REAL to DINT The whole number portion of the value will be used When you perform a type conversion from a larger to a smaller type you risk losing some information Example in IL LD m9 TRUHC IHT oT LV ar Examples in ST iVarzs I RUNC INT 1 9 Result is 1 Var UNC ENE l 4 7 e Pocult Le L ANY TO Conversions An IEC Operator from any data type and more specifically from any numeric data type to another data type A reasonable choice of data types is assumed Syntax ANY NUM TO lt Numeric data type gt ANY TO lt Any data type gt Example Conversion from a variable of data type REAL to INT re REAL 1 234 i INT gt ANY TO INT re Numeric Functions ABS The following numeric IEC operators are available ABS SQRT LN LOG EXP SIN COS TAN ASIN ACOS ATAN and EXPT IEC Operator Returns the abs
38. TOF N PT Q ET If IN is TRUE the outputs will be TRU respectively 0 As soon as IN becomes FALSE in ET the time will begin to be counted in milliseconds in ET until its value is equal to PT It will then remain constant Q is FALSE when IN is FALSE und ET equal PT Otherwise it is TRUE Thus Q has a falling edge when the time indicated in PT in milliseconds has run out 198 RTC 7 Libraries to tl PT te 15 PT E i po yl ET FA i ri f y O Figure 7 3 Graphic Display of TOF Behavior Over Time Declaration example TOFInst TOF Example in IL CAL TUFinst IN VYarBuouLl PT T 53 f ET gt VYarTimelur LD TOFinst Q ST YarbBooLe Example in FBD TOFinst YarBooLlL YarBoo Le T 53 ETP YarTimeCur Example in ST TOFInst IN VarBOOL1 PT T 5s VarBOOLZ s TOFInst lt 0 Provided by standard library Timer function block RunTime Clock returns starting at a given time the current date and time Inputs EN BOOL At a rising edge starts counting up the time in CDT PDT DATE_AND_TIME Date and time from which the counting up should be started Outputs Q BOOL Is TRUE as long as CDT is counting up CDT DATE_AND_ TIME Current state of counted date and time VarBOOL2 RTC EN PDT Q CDT When EN is FALSE the output variables Q und CDT are FALSE respectively DT 1970 01 01 00 00 00 As soon as EN becomes TRUE rising edge the time given by PDT is set is counted up in seconds and retu
39. The jump element is used to indicate at which position the execution of the program should continue This position is defined by a label see below So replace the text offered by by the label name Label A label marks the position to which the program can jump see above Jump In Online mode a RETURN element is automatically inserted in the first column and after the last element in the editor In stepping it is automatically jumped to before execution leaves the POU A composer is used to handle an input of a box which is of type of a structure The composer will display the structure components and thus make them accessible in the CFC for the programmer For this purpose name the composer like the concerned structure by replacing by the name and connect it to the box instead of using an input element Selector or A selector in contrast to the composer is used to handle an output of a box which is of type of a structure The selector will display the structure components and thus make them accessible in the CFC for the programmer For this purpose name the selector like the concerned structure by replacing by the name and connect it to the box instead of using an output element Comment lt EnferpourcommenfiAere gt Use this element to add any comments to the chart Select the placeholder text and replace it with any desired text You obtain a new line within the comment with lt Ctrl gt l
40. This means you indicate a condition which when it 1s fulfilled the loop will be executed Syntax WHILE lt Boolean expression gt DO lt s lt Instroctions gt END WHILE The lt INSTRUCTIONS gt are repeatedly executed as long as the lt BOOLEAN EXPRESSION gt returns TRUE If the lt BOOLEAN EXPRESSION gt is already FALSE at the first evaluation then the lt INSTRUCTIONS gt are never executed If lt BOOLEAN EXPRESSION gt never assumes the value FALSE then the lt INSTRUCTIONS gt are repeated endlessly which causes a relative time delay Example WHILE Counter lt gt 0 DO Varli Varl 2 Counter Counter 1 END WHILE The WHILE and REPEAT loops are in a certain sense more powerful than the FOR loop since one doesn t need to know the number of cycles before executing the loop In some cases one will 156 6 Programming Languages Editors therefore only be able to work with these two loop types If however the number of the loop cycles is clear then a FOR loop is preferable since it allows no endless loops The CONTINUE instruction can be used within a WHILE loop REPEAT Loop The REPEAT loop is different from the WHILE loop because the break off condition is checked only after the loop has been executed This means that the loop will run through at least once regardless of the wording of the break off condition Syntax REPEAT lt Instructions gt UNTIL lt Boolean expression gt END REPEAT
41. VAR Oo Ww 0 3 Mn Ww N Ae 1 LD bar variable ST instl IN starts timer with risin JHFC ml CAL instli PT tl ET gt tout li LD instl Q is TRUE PT seconds aft ST inst2 IN starts timer with risin E ml LD dar ADD 230 ST dwhes Figure 6 47 IL Program Example in IL Table editor The IL Editor is a table editor integrated in the FBD LD IL Modifiers and Operators in IL The following modifiers can be used in Instruction List Moder consa mp C With JMP CAL RET The instruction only will be executed if the result of the preceding expression is TRUE With JMPC CALC RETC The instruction will only be executed if the result of the preceding expression is FALSE O N In any other case Negation of the operand not of the accumulator Table 6 11 Modifiers 163 6 Programming Languages Editors The following Table 6 12 shows which operators can be used in combination with the specified modifiers The accumulator always stores the current value resulting from the preceding operation operator Modifiers LD N Loads the negated value of the operand into LD iVar the accumulator ST N Stores the negated content of the accumulator ST iErg into the operand variable S bVar1 Sets the operand type BOOL to TRUE when the content of the accumulator is TRUE Sets the operand type BOOL to FALSE when R bVar1 the content of the accumulator is TRUE Bitwise AND of the accumula
42. You must use the type conversion REAL LREAL Constants REAL and LREAL constants can be given as decimal fractions and represented exponentially Use the standard American format with the decimal point to do this Example 7 4 instead of 7 4 1 64e 009 instead of 1 64e 009 STRING Constants A string is a sequence of characters STRING constants are preceded and followed by single quotation marks You may also enter blank spaces and special characters UMLAUTS for instance They will be treated just like all other characters Notice the following possibilities of using the dollar sign in string constants lt two hex numbers gt Hexadecimal representation of the eight bit character code Dollar sign PS Single quotation mark L or I 117 5 Programming Reference P or p Page feed Tab Table 5 12 Possibilities of Use for Signal Examples 1 Abby and Craig 7 1 1 COSTS 99 Typed Literals Basically in using IEC constants the smallest possible data type will be used If another data type must be used this can be achieved with the help of typed literals without the necessity of explicitly declaring the constants For this purpose the constant will be provided with a prefix which determines the type Syntax lt TYPH gt lt Literal gt lt TYPE gt specifies the desired data type possible entries are BOOL SINT USINT BYTE INT UINT WORD DINT UDINT DWORD REAL L
43. a function block instance lt IDENTIFIER gt lt FUNCTION BLOCK NAME gt Example Declaration e g in the declaration part of a program of instance INSTANCE of function block FUB INSTANCE FUB The declaration parts of function blocks and programs can contain instance declarations But Instance declarations are not permitted in functions Calling a Function Block Function blocks are always called through a function block instance Thus a function block instance must be declared locally or globally The desired function block variable can be accessed using the following syntax Syntax lt INSTANCE NAME gt lt VARIABLE NAME gt Regard the following e Only the input and output variables of a function block can be accessed from outside of a function block instance not its internal variables e Access to a function block instance is limited to the POU in which it was declared unless it was declared globally e At calling the instance the desired values can be assigned to the function block parameters See below e The InOutVariables VAR_IN_OUT of a function block are passed as pointers e In SFC function block calls can only take place in steps e The instance name of a function block instance can be used as an input parameter for a function or another function block e All values of a function block are retained until the next processing of the function block Therefore function block calls do not always return the s
44. activated as described above Control of SFC execution Syntax for accessing e From an action or transition within the SFC POU lt step name gt lt flag gt and _ lt action name gt lt flag gt Examples status step1 _x checkerror SFCerror e From another POU lt SFC POU gt lt step name gt lt flag gt and lt SFC POU gt _ lt action name gt lt flag gt Examples status SFC_prog step1 _x checkerror SFC_prog SFCerror In case of write access from another POU the implicit variable additionally must be declared explicitly as a VAR_INPUT variable of the SFC POU or globally e g ina GVL Example Local declaration PROGRAM SEC prog VAR INPUT Serna BOOL END VAR Or global declaration in a GVL VAR GLOBAL SECTNEESBOOL END_VAR Accessing the flag in MAINPRG PROGRAM MAINPRG VAR setinit BOOL END VAR SEC prog lt SPCinits secinit 7 7 Write access 11 the SFCinit on SPC prog Sequence of Processing in SFC In online mode the particular action types will be processed according a defined sequence Table 6 6 First note the following use of terms e Active step A step whose step action is being executed is called active In online mode active steps are filled with blue color e Initial step In the first cycle after a SFC POU has been called the initial step automatically gets active and the associated step action is executed e ITEC actions are executed at least twice the first time when they
45. arbitrary user or application defined attribute pragmas to POUs type declarations or variables This attribute can be queried before compilation by means of conditional pragmas Syntax attribute attribute This pragma instruction is valid for the current or if placed in a separate line for the subsequent line See for the use of Conditional Pragmas An user defined attribute can be assigned to the following objects e POUs and Actions e Variables e Types Example for POUs and Actions Attribute displaymode to the variable dwVarl VAR attribute displaymode hex dwVarl DWORD END VAR Example for variables Attribute DoCount defined in Conditional Compilation Operators for the variable ivar is added PROGRAM MAINPRG VAR tattribute DoCount Ivara INTs var BOOL END VAR Displaymode Attribute With the help of the pragma attribute displaymode the display mode of a single variable can be defined This setting will overwrite the global setting for the display mode of all monitoring variables done via the commands of the submenu Display Mode available in the Online menu The pragma must be positioned in the line above the line containing the variables declaration Syntax attribute display mode lt display mode gt For display in binary format attribute display mode bin attribute display mode binary For display in decimal format attribute display
46. below the same application as the FBD LD IL object which is currently opened in the editor If a POU has got assigned a bitmap in its properties then this will be displayed before the POU name otherwise the standard icon for indicating the POU type The list will be updated automatically when POUs are added or removed from the application The category folders can be unfolded by a mouse click on the button showing the respective category name See in the Figure 6 64 Category General currently is unfolded the others are folded The picture shows an example for inserting an Assignment element by drag amp drop from the toolbox Currently only section General in the toolbox is unfolded 2 ToolBox 0 X PRG2 General 5 f Network SF Box JE Box with EN ENO PRG3 k Assignment Jump ARET Return e Input PRG1 SP1 232 Branch a0 Figure 6 64 Inserting from Toolbox To insert an element in the editor select it in the toolbox by a mouse click and by drag zdrop bring it to the editor window The possible insert positions will be indicated by position markers which appear as long as the element is drawn keeping the mouse button pressed across the editor window Always the nearest possible position will light up green When leaving the mouse button the element will be inserted at the currently green position If you draw a box element on an existing box element the new one will replace the old one if inputs and outputs alre
47. block of type fbA is expected 25 3 Concepts and Basic Components e FbB is allowed to override the methods defined in fbA That means fbB can declare a method with the same name and the same inputs and output as declared by A e FbB is not allowed to use function block variables with the same name as used in fbA In this case the compiler will prompt an error e FbA variables and methods can be accessed directly within an fbB Scope by using the keyword SUPER SUPER lt method gt NOTE Multiple inheritances are not allowed Method Invocation Object oriented programming with function blocks is besides of the possibility of extension via EXTENDS This requires dynamically resolved method invocations also called virtual function calls See Method for further information on Method Virtual function calls need some more time than normal function calls and are used when e A call is performed via a pointer to a function block pfub method e A method calls another method of the same function block Virtual function calls make possible that the same call in a program source code will invoke different methods during runtime According to the IEC 61131 3 standard methods like normal functions can have additional outputs Those must be assigned in the method call according to syntax lt METHOD gt IN1 lt VALUE gt FURTHER INPUT ASSIGNMENTS OUT1 gt lt OUTPUT VARIABLE 1 gt OUT2 gt lt OUTPUT VARIABLE 2 gt
48. can change statements at which the program flow branches out or at which another POU is called That is the following positions e On the network at a whole which effects that the breakpoint will be applied to the first possible position within the network e Ona box if this contains a statement so not possible on operator boxes like for example ADD DIV Regard however the note inserted below e Onan assignment e At the end of a POU at the point of return to the caller in online mode automatically an empty network will be displayed for this purpose which instead of a network number is identified by RET NOTE Currently you cannot set a breakpoint directly on the first box of a network If however a breakpoint is set on the complete network the halt position will automatically be applied to the first box You might have a look at the selection list within the breakpoint dialog for all currently possible positions A network containing any active breakpoint position is marked with the breakpoint symbol red filled circle right to the network number and a red shaded rectangle background for the first possible 183 6 Programming Languages Editors breakpoint position within the network Deactivated breakpoint positions are indicated by a non filled red circle resp a surrounding non filled red rectangle Figura 6 83 110 Breakpoint set Figure 6 82 Breakpoint Set and Reached zle ___ Breakpoint Deactivated
49. cycle after a step has been deactivated Table 6 3 Specific Properties Description NOTE Notice the possibility of getting information on step action status and timeouts via the appropriate implicit variables and SFC flags SFC Elements Toolbox The graphic elements usable for programming in the SFC editor window currently can be inserted by using the insert commands SFC menu See also Working in SFC Editor The following elements are available and described in the following Step Transition Action Branch Alternative Branch Parallel Jump Macro Step Transition Symbol T A step is represented by a box containing the step name and being connected to the preceding and subsequent transitions by a line The step name can be edited inline The box frame of the init step is double lined Notice that each step by command Tnit step or by activating the respective step property can be transformed to an init step that is to that step which will be executed first when the IL POU is called Each step is defined by the step properties The actions to be performed when the step is active processed are to be associated see below Action Steps and transitions are basically inserted in combination via command Insert step transition after NOTES There is only one type of steps the IEC conforming steps Step names must be unique in the scope of the parent POU Notice this especially when us
50. declaration gt The time declaration can include the time units as used with the TIME constant see above and additionally 6 e us microseconds e ns nanoseconds Examples of correct LTIME constants in a ST assignment LTIME1 LTIME 1000d15h23m12s34ms2us44ns ETTMEL lt ETTMEFS245343m gt 4247328 1482318 See also Time Data Types DATE Constants These constants can be used to enter dates Syntax d lt Date declaration gt Instead of d also the following can be used DE date DATES The date declaration is to be entered in format lt year month day gt DATE values are internally handled as DWORD values containing the time span in seconds since 01 01 1970 00 00 clock Examples DATE 1996 05 06 AL LS SL See also Time Data Types TIME_OF_DAY Constants Use this type of constant to store times of the day Syntax tod lt Time declaration gt Instead of tod also the following can be used TOD time_of_day TIME_OF_DAY The time declaration is to be entered in format lt hour minute second gt Seconds can be entered as real numbers that is also fractions of a second can be specified TIME_OF_DAY values are internally handled as DWORD values containing the time span in milliseconds since 00 00 clock Examples TIME OF DAY 15 36 30 123 tod 00 00 lt 00 See also Time Data Types DATE AND_ TIME Constants DATE constants and TIME _OF_DAY consta
51. declaration part The field cannot be edited and can be switched on or off via option Show symbol comment Operand comment This field contains the comment for the current line It is editable and can be switched on or off via option Show operand comment Table 6 13 Structure of the do IL Tabular Editor 167 6 Programming Languages Editors PROGRAM myFuncCall VAR tonInstl TON tonInst2 TON tl TIME tOutl TIME t2 TIME tOutz TIME bYar BOOL bReady AT 0B1 BOOL END VAR Standard Library function call Two timers CAL tonInstl IN bYar PT tl ET gt t0utl LD tonInstl Q is TRUE PT seconds after IN had a r ST tonInst2 IN starts timer with rising edge reset CAL tonInst2 PT t2 Q gt bReady 3051 for tonInst2 ET gt t0ut2 Figure 6 51 IL Tabular Editor Navigating e lt f gt and lt gt keys Moving to the field above below e lt TAB gt Moving within a line to the field to the right e lt SHIFT gt lt TAB gt Moving within in a line to the field to the left e lt SPACE gt Open the currently selected field for editing Alternatively perform a further mouse click on the field If applicable the input assistant will be available via the button hd A currently opened edit field can be closed by lt ENTER gt confirming the current entries or by lt ESC gt cancelling the made entries lt CTRL gt lt ENTER gt Enter a new line below the current one lt DELETE
52. erorri a 186 SS FUNCION PP O 186 Bistable PUN CUO iTS LOCKS tare cs cteicn ihe tases tain A anish ate taicn bad 19 TOE aeaecss ates 192 COUN asou a a oi ae 193 A A O N 196 The UTE Wp rary LIDLAFY aida 200 BED CON Erotica dia Golam ied ias 200 a A A a a 201 Mathematical Auxiliary PACO ica 202 CONTO UE aa coll 205 Sinal GESTOS code 209 Function MA AS o elo 212 A alo sue Valle PrOCESSIMO estacionario ora poa lic 214 Nexto PID brary LID sas cveseessseenstasduasbesesessesscocsecssucensasssiersseseesvancoceeeeoece 216 A RR 216 RA A ses vunauccveaven a caceessusssusuesessssusccusasie ten cossuncs saves A 231 1 Introduction 1 Introduction Nexto Series is a powerful and complete Programmable Logic Controller PLC with unique and innovative features Due to its flexibility smart design enhanced diagnostics capabilities and modular architecture Nexto can be used for control systems from medium or high end applications Due to its compact size and superior performance Nexto can also be used for small automation systems with time critical requirements MasterTool IEC XE is a complete tool for programming debugging and performing configuration and simulation of user applications Based on a concept of being integrated flexible and easy to use this software provides six programming languages defined by IEC 61131 3 standard Structured Text ST Sequential Function Chart SFC Function Block Diagram FBD Ladder Diagram LD Inst
53. ever seen before The user does not need any special software to configure fieldbuses anymore because MasterTool IEC XE covers this requirement providing a unique tool reducing engineering time and making applications more simple In order to increase user s productivity some important features are also available Module Printing which is a report generation of every module specific parameters and application general settings Logic Printing which is a report generation of all application code Enhanced Project Verification which helps user to check several different conditions during programming like programming syntax power supply module current consumption placement rules for Nexto modules modules parameters and settings Real Time Debugging which provides useful way to check the application step by step verify variables values or add and remove breakpoints during Nexto CPU programming Documents Related to this Manual For additional information about MasterTool IEC XE you can examine other specific documents in addition to this one These documents are available in its last review on www altus com br General Regards on ALTUS Documentation Each product has a document called Technical Characteristics CT where there are the characteristics for the product in question Additionally the product may have User Manuals manual s codes if applicable are always mentioned at CTs from the respective modules 1 Introduction MasterT
54. explicitly See also in the MasterTool IEC XE User Manual MU299609 Library Installation and Library Manager Editor The Standard library Library The library standard library is by default provided with the MasterTool IEC XE programming system It contains all functions and function blocks which are required matching IEC 61131 3 as standard POUs for an IEC programming system The difference between a standard function and an operator is that the operator is implicitly recognized by the programming system while the standard POUs must be tied to the project standard library String Functions LEN LEFT Provided by standard library Function of type STRING returns the length of a string Input STR STRING string to be analyzed Return value INT length of string number of characters Example in IL LD SUST LEH ST WarlNTl The result is 4 Example in FBD LEH haul A TR varINTl Example in ST Var INtL s LEN oUSL Provided by standard library Function of type STRING Returns the left initial string for a given string Inputs STR STRING string to be analyzed SIZE INT length of left initial string number of characters 186 RIGHT MID 7 Libraries Return value STRING initial string LEFT STR SIZE means Return the first SIZE characters from the right in the string STR Example in IL LD JUSTE LEFT 3 ST Yara TRINGl The result is SUS Example in FBD
55. have got active the second time in the following cycle when they have been deactivated e Alternative Branches If the step preceding the horizontal start line of alternative branches is active then the first transition of each particular branch will be evaluated from left to right The first transition from the left whose transition condition has value TRUE will be searched and the respective branch will be executed that is the subsequent step within this branch will get active e Parallel Branches If the double line at the beginning line of parallel branches is active and the preceding transition condition has the value TRUE then in all parallel branches each the first step will get active The branches now will be processed parallel to one another The step subsequent to the double line at the end of the branching will become active when all previous steps are active and the transition condition after the double line has the value TRUE Processing order of elements in a sequence ltem Description OOOO All action control flags of the IEC actions get re set not however the flags of IEC actions that are called within actions 149 6 Programming Languages Editors Step exit actions All steps are checked in the order which they assume in the sequence chart top to bottom and left to right to determine whether the requirement for execution of the step exit action is provided and if that is the case this will be executed
56. history of the controller error I part influence the manipulated variable The PID controller can be easily converted to a PI controller by setting TV 0 Because of the additional integral part an overflow can come about by incorrect parameterization of the controller if the integral of the error D becomes too great Therefore for the sake of safety a Boolean output called OVERFLOW is present which in this case would have the value TRUE This only will happen if the control system is instable due to incorrect parameterization At the same time the controller will be suspended and will only be activated again by re initialization NOTE As long as the limitation for the manipulated variable Y_MIN and Y_MAX is active the integral part will be adapted like if the history of the input values had automatically effected the limited output value If this behavior is not wanted the following workaround is possible Switch off the limitation at the PID controller Y_MIN gt Y_MAX and instead apply the LIMIT operator IEC standard on output value Y NOTE Altus recommends using the PID function block available in the library NextoPID and described herein The PID function block of the library NextoPID has advanced parameters that allow a better fit of the control The two libraries cannot be used simultaneously PID_FIXCYCLE Provided by util library This function block corresponds to a PID controller with the exception that the cycle time
57. in its application or its secondary applications Application An application is a set of objects which are needed for running a particular instance of the PLC program on a certain hardware device PLC controller For this purpose independent objects managed in the POUs view are instantiated and assigned to a device in the Devices view This meets the mind of object orientated programming However also purely application specific POUs can be used An application is represented by an Application UE object in the Devices tree insertable below a programmable device node PLC Logic Below an application entry the objects defining the applications resource set are to be inserted The standard application Application is created along with new projects created from the template MasterTool Standard Project It is added to the device tree below the item Device and PLC Logic An essential part of each application 1s the Task Configuration that controls the execution of a program POUs instances or specific POU of the application Additionally resources objects can be assigned such as global variables lists libraries which unlike those managed in the window of POUs can only be used for specific application and its sub items When going to log in with an application on a target device PLC or simulation target it will be checked which applications currently are on the PLC and whether the application parameters on
58. in online mode see User Interface in Online Mode in the MasterTool IEC XE User Manual MU299609 Notice that the editor window of an CFC object also includes the Declaration Editor in the upper part For information on the declaration editor in online mode see Declaration Editor in Online Mode in the MasterTool IEC XE User Manual MU299609 Monitoring The actual values are displayed in small monitoring windows behind each variable inline monitoring Device Application PRG2 Expression Type Value Prepared value Comment RESULT REAL 60 425 eson H app H mars A _ H Figure 6 10 Online view of a Program Object MAINPRG Notice that for the online view of a function block POU In the implementation part no values will be viewed in the monitoring windows but lt Value of the expression gt and the inline monitoring fields in the implementation part will show three question marks each Breakpoint Positions in CFC Editor Basically the breakpoint positions are those positions in a POU at which values of variables can change or at which the program flow branches out resp another POU is called Figure 6 11 130 6 Programming Languages Editors Figure 6 11 Breakpoint Positions in CFC Editor NOTE Notice for breakpoints in methods A breakpoint will be set automatically in all methods which might be called If a method is called via a pointer on a function block breakpoints will be set in the m
59. is measured automatically by an internal function but is defined by input cycle in seconds 208 7 Libraries Example of PID_FIXCYCLE in FBD PID_FIXCYCLE LIMITS_ACTIVE OVERFLOW _MANUAL _OFFSET Y_MIN MAX MANUAL RESET CYCLE Signal Generators BLINK Provided by util library The function block BLINK generates a pulsating signal The input consists of ENABLE of the type BOOL as well as TIMELOW and TIMEHIGH of the type TIME The output OUT is of the type BOOL If ENABLE is set to TRUE BLINK begins to set the output for the time period TIMEHIGH to TRUE and afterwards to set 1t for the time period TIMELOW to FALSE When ENABLE is reset to FALSE output OUT will not be changed that is no further pulse will be generated If you explicitly also want to get OUT FALSE when ENABLE is reset to FALSE you might use OUT AND ENABLE that is adding an AND box with parameter ENABLE at the output Example of BLINK in CFC Blinker BLINK TRUE ENABLE OUT T25 1435 TRUE FALSE 7 7 Output Results of Block BLINK FREQ_ MEASURE Provided by util library This function block measures the average frequency Hz of a boolean input signal You can specify over how many periods it should be averaged A period is the time between two rising edges of the input signal 209 Example of FREQ MEASURE in FBD FREQ MEASURE IN OUT PERIODS VALID RESET Input Variables PERIODS INT Number of perio
60. is not defined POU_2 When applied to a variable its value is TRUE if this particular variable is declared within the current scope Otherwise is FALSE Both have the code below Example Precondition There are two POUs POU_1 and POU_2 Variable g bTest is declared in POU_2 but not in POU_1 IF defined variable g_bTest The following code is only processed in POU_ 2 g blest x gt 300 END_ IF When applied to a type identifier its value is TRUE if a type with that particular name is declared Otherwise is FALSE Example Precondition At first declare the data type of DUT in the project does not state a second time see the difference in the boolean variable bDutDefined IF defined type DUT The following code line only will be processed if have the data type declared bDutDefined TRUE END_IF When applied to a pou name its value is TRUE if a POU or an action with that particular name is defined Otherwise is FALSE Example 68 Hasattribute pou POU name attribute Hasattribute variable name of variable attribute 5 Programming Reference Precondition In a scenario the POU CheckBounds was added to the project and not in another In a POU there is the code below IF defined pou CheckBounds The following line of code will only be processed in the scenario where there is a POU CheckBounds arrTest CheckBounds 0 i 10 arrTest Chec
61. le red blue END TYPE TYPE COLORS 2 green blue yellow END TYPE Use of enumeration value blue in a POU Declaration colofvarl COLORS 15 colorvarz amp COLORS 27 Implementation Possible COLOEVAEL t colors 1 plus COLO VAr 2 COlLOrS 2 Due Not Possible colorvarl blue colorvar2 blue The base data type of the enumeration which by default is INT can be explicitly specified Example The base data type for enumeration BigEnum should be DINT TYPE BigEnum yellow blue green 16 8000 DINT END TYPE Subrange Types A subrange type is a user defined type whose range of values is only a subset of that of the basic data type Notice the possibility of using implicit range boundary checks The declaration can be done in a DUT object but also a variable can be directly declared with a subrange type Syntax for the declaration as a DUT object LIPE Names i lt Inttype gt ug 09 END TYPE 83 5 Programming Reference Must be a valid IEC identifier lt Inttype gt Is one of the data types SINT USINT INT UINT DINT UDINT BYTE WORD DWORD LINT ULINT LWORD lt ug gt Is a constant which must be compatible with the basic type and which sets the lower boundary of the range types The lower boundary itself is included in this range lt 0g gt Is a constant that must be compatible with the basic type and sets the upper boundary of the range types The upper bou
62. of a sequential function chart e See the object properties and the SFC Editor options and SFC defaults for settings concerning compilation resp online display of the SFC elements and their attributes e Consider the possible use of flags for watching and controlling the processing of an SFC Monitoring Active steps are displayed filled blue colored The display of step attributes depends on the currently set SFC editor options 150 6 Programming Languages Editors A E SFC_prog J b x MyPlc Application SFC_prog Expression Type vale Prepare count INT 504 Exit INT 252 iEntry INT 252 iStepActian INT 252 a aa aa r lo Ev 6 38 Online View of a Program Object SFC_prog Structured Text ST Extended Structured Text ExST Structured Text is a textual high level programming language similar to PASCAL or C The program code is composed of expressions and instructions In contrast to IL Instruction List numerous constructions can be used for programming loops thus allowing the development of complex algorithms Example IF value lt 7 THEN WHILE value lt 8 DO value value l END WHILE END IF Extended Structured Text ExST is a MasterTool IEC XE specific extension to the IEC 61131 3 standard for Structured Text ST Examples Assignment as expression Set Reset Operators Expressions An expression is a construction which after its evaluation returns a value This value is used in i
63. of the new file will be valid in the repository If the library includes further libraries you should consider how those referenced libraries should behave later when the ather library will be included in a project This concerns version handling namespace visibility and access properties which can be configured in the properties dialog of the particular referenced library If the library later when it gets included in a project always should reference another device specific library a placeholder can be used when configuring the reference If the library modules should be protected against viewing and accessing a library project can be saved in encoded in encoded format lt project name gt compiled library Data structures of a library can be marked as lib internal These non public objects carry the attribute hide and therefore do not appear within the library manager the List Components functionality or the Input Assistant In order to provide the user with information on a library module in an easy way an appropriate comment can be added to the declaration of a module parameter This comment will be displayed later when the library 1s included in a project on the Documentation tab of the Library Manager The following commands are available by default in the File menu for saving a library project o Save Project As o Save Project As Compiled Library o Save Project And Install Into Library Repository 36 5 Programming Re
64. of the use of not completely defined addresses FUNCTION BLOCK logio VAR xLociIn AT s1 lt BOOL lt TRUE xbocOute AT 2O BOOLI END VAR Here two local I O variables are defined a local In I and a local Out Q Then the final definition of the addresses is to be done in the variables configuration in a global variables list For this purpose add a Global Variable List object GVL to the Devices window by the Add Object command There enter the declarations of the instance variables with the definite addresses between the key words VAR_CONFIG and END_VAR The instance variables must be specified by the complete instance path through which the individual POUs and instance names are separated from one another by periods The declaration must contain an address whose class input output corresponds to that of the incompletely specified address I1 Q in the function block Also the data type must agree with the declaration in the function block Syntax lt Instance variable path gt AT lt I Q gt lt Location gt lt Data type gt Configuration variables whose instance path is invalid because the instance does not exist are denoted as errors On the other hand an error is also reported if no definite address configuration exists for an instance variable assigned to an incomplete address Example for a variable configuration Assume that the following definition for function block locio see the example a
65. on the arithmetic operation See in the following example in hexadecimal notation that you get different results for erg_byte and erg_word depending on the data type of the input variable BYTE or WORD although the values of the input variables in_byte and in_word are the same Example in ST PROGRAM shl st VAR in byte BYTE 16 45 in word WORD 16 45 erg byte BYTE erg word WORD n BYTE 2 END VAR erg byte sShi in byte n erg word SHL in word n Example in FBD Result is 16 14 x Result is 160114 e 7 e 7 1 erg byte 92 5 Programming Reference SHR ROL Example in IL LD in byte SHL a ST erg byte IEC Operator Bitwise right shift of an operand erg SHR in n in Operand to be shifted to the right n Number of bits by which in gets shifted to the right If n exceeds the data type width operands of type BYTE WORD DWORD and LWORD will be filled with zeros operands of signed data types like for example INT will get an arithmetic shift that means they will be filled with the value of the topmost bit NOTES Please note that the amount of bits which is noticed for the arithmetic operation is pretended by the data type of the input variable If the input variable is a constant the smallest possible data type is noticed The data type of the output variable has no effect at all on the arithmetic operation See the following example in hexadecimal notatio
66. order e Exit method exit old instance old_inst fb_exit bInCopyCode TRUE e Init method init new instance new_inst fb_init bInitRetains FALSE bInCopyCode TRUE e Copy function block values copy code copy_fub amp old_inst amp new_inst Besides this in case of inheritance the following call sequence is true whereby for the POUs used for example in this listing the following is assumed SubFB EXTENDS MainFB and SubSubFB EXTENDS SubFB PoouUpSUDE DST BR ARTE easy FDSUD EDs EB EXILE res TOMALE DoE B EXIL v4 FOMA INED EB INTO ewa TOSUDE Ds EP TALE a ES UDSUDED EB LAL rea 56 5 Programming Reference For FB_reinit EbMainib FB Teinit ess TDSubrD EB PeInit era FOouUp UDI De FB ALE Pragma Instructions A pragma instruction is used to affect the properties of one or several variables concerning the compilation and precompilation process This means that a pragma influences the code generation For example it might determine whether a variable will be initialized monitored added to a parameter list made invisible in the library manager or should be added to the symbol configuration Message outputs during the build process can be forced and also conditional pragmas can be used which define how the variable should be treated depending on certain conditions Those pragmas also can be entered as defines in the compile properties of a particular object A pragma can be used in a sep
67. order of processing the POU instances of an application depends on a device specific configuration call stack Each POU consists of a declaration part and an implementation part The body is written in one of the available programming languages e g IL ST SFC FBD LD or CFC The MasterTool IEC XE supports all POUs described by IEC 61131 3 To use these POUs in the project you must include the standard library library The projects created from the template MasterTool Standard Project already have this library loaded NOTE In some examples of this manual the code is declared sequentially but to use it must be separated the top part of the programming language editor is used for declarations and the bottom part should be used for the implementations Calling POUs POUs can call other POUs Recursions however are not allowed When a POU assigned to an application calls another POU just by its name without any namespace added regard the following order of browsing the project for the POU to be called 1 Current application 2 Library Manager of current application 3 POUs view 19 3 Concepts and Basic Components 4 Library Manager in POUS view If a POU with the name specified in the call is available in a library of the applications library manager as well as an object in the POUs view there is no syntax for explicitly calling the POU in the POUs view just by using its name In this case you would have to move the co
68. physical inputs via input driver sensors Output physical outputs via output driver actors Memory location Table 5 14 Supported Memory Area Prefixes 120 5 Programming Reference X Single bit B Byte 8 bits Ww Word 16 bits ob Double Word 32 bits Table 5 15 Supported Size Prefixes Examples Example Description S Table 5 16 Addressing Examples For assigning a valid address within an application first of all you must know the appropriate position within the process image that is the memory area to be used Input 1 Output Q or Memory M area Further on specify the desired size bit byte word dword see above X B W D A decisive role plays the current device configuration and settings hardware structure device description I O settings Especially consider the differences in address interpretation between devices using byte addressing mode or those using word oriented IEC addressing mode So depending on the size and addressing mode different memory cells might be addressed by the same address definition See the table below for a comparison of byte addressing and word oriented IEC addressing for bits bytes words and dwords After all it visualizes the overlapping memory areas in case of byte addressing mode Concerning the notation regard that for bit addresses the IEC addressing mode is always word oriented that means that the place before the dot correspo
69. position of the first character where STR2 appears in STR1 for the first time If STR2 is not found in STR1 then OUT 0 Example in IL LD abode FIND vee oT WarsTRING1 The result is 4 190 7 Libraries Example in FBD FIND abode aTRL WarlWNP1 de STR Example in ST arINT1l1 FIND abcdef de Bistable Function Blocks SR RS Provided by standard library Function block making bistable function blocks dominant Inputs SETI BOOL RESET BOOL Outputs QI BOOL Q1 SR SET1 RESET Q1 NOT RESET AND Q1 OR SETI Declaration example SRInst SR Example in IL CAL SRinst SETl YarBooll RESET i YarBoole LD SRinst 0l ST VYarBools Example in FBD SRinst WarB00L5 Example in ST SRInst SET1 VarBOOL1 RESET VarBOOL2 VarBOOL3 SRInst OQl Provided by standard library Function block resetting bistable function blocks Inputs SET BOOL RESET1 BOOL 191 Trigger R_TRIG 7 Libraries Outputs Q1 BOOL Q1 RS SET RESET1 Q1 NOT RESET1 AND Q1 OR SET Declaration example Roinst Ro y Example in IL CAL Rainst SET i YarBooll 7 RESET1 VarBool LD Esinst 0l ST YarBools Example in FBD Rainst RS YarB00L1 SET Ol YarBO00L5 YarB00Lz RESET1 Example in ST RSInstisBTs VarfBOOLL RESBIL i VarBOOLZ 7 VarBOOL3 RSInst Ql Provided by standard library Function block detecting a rising edge I
70. subnet marker After that an ADD box was added in each sub network 177 6 Programming Languages Editors Figure 6 69 Example in FBD Inserting a Branch To delete a sub network first remove all elements of the sub network that is all elements which are positioned to the right of the sub network s marker then select the marker and use the standard Delete command lt DEL gt See in the Figure 6 70 The 3 input OR element must be deleted before you can select and delete the marker of the lower sub network Figure 6 70 Delete Branch and Sub network Execution in online mode The particular branches will be executed from left to right and then from up to down IL Instruction List Contact In IL a branch resp hanging coil is represented by an appropriate order of instructions See in this context Modifiers and Operators in IL This is a LD element Each network in LD in its left part contains one or several contacts Contacts are represented by two parallel lines bwyarl HH Figure 6 71 Contact Contacts pass on condition ON TRUE or OFF FALSE from left to right 178 FBD IL Coil 6 Programming Languages Editors A Boolean variable is assigned to each contact If this variable is TRUE the condition is passed from left to right and finally to a coil in the right part of the network otherwise the right connection receives the value FALSE Multiple contacts can be connected in series as
71. supported as well as multiple inputs multiple outputs negations comments set reset of outputs and unconditional conditional jumps Each instruction is primarily based on the loading of values into the accumulator by using the LD operator After that the operation is executed with the first parameter taken out of the accumulator The result of the operation again 1s available in the accumulator from where the user should store 1t with the ST instruction In order to program conditional executions or loops IL supports both comparing operators like EQ GT LT GE LE NE and jumps The latter can be unconditional JMP or conditional JMPC JMPCN For conditional jumps the accumulator s value is checked on TRUE or FALSE An instruction list IL consists of a series of instructions Each instruction begins in a new line and contains an operator and depending on the type of operation one or more operands separated by commas The operator might be extended by a modifier In a line before an instruction there can be an identification mark label followed by a colon for example ml in the example shown below A label can be the target of a jump instruction for example JMPC next in the example shown below A comment must be placed as last element of a line Empty lines can be inserted between instructions PROGRAM IL YAR instl TON dwar DWORD dukes DWORD tl TIME toutl TIME instz TOM b ar BOOL EHD
72. synchronization problems Also when accessing other global objects global variables modules consistency problems might occur as soon as the size of the objects exceeds the data width of the processor structures or ARRAYS forming a logical unit Also here the modules of the SysSem library might be used to solve the problems 15 3 Concepts and Basic Components Communication For information about Communication Configuration of a PLC Network topology Addressing and routing Structure of addresses and Network variables see MasterTool IEC XE User Manual MU299609 Code Generation and Online Change Code Generation and Compile Information Machine code will not be generated until the application project gets downloaded to the target device PLC simulation target At each download the compile information containing the code and a reference ID of the loaded application will be stored in the project directory in a file lt project name gt lt device name gt lt application gt compileinfo The compile info will be deleted when the Clean and Clean all command are performed Online Change If the application project currently running on the controller has been changed in the programming system since it has been downloaded last just the modified objects of the project will be loaded to the controller while the program keeps running there ATTENTION Online Change modifies the running application program and does not a
73. system the active CPU performs the control of the system by reading the values of points of entry running the program application and triggering the values of outputs Finite sequence of well defined instructions to solve problems Is the program loaded into a PLC which determines the operation of a machine or process Microprocessor programming language also known as machine language Basic information unit it may be at 1 or O logic level Breakpoint in application for debugging Simultaneous dissemination of information to all nodes connected to a communications network Set of interconnected I O modules to a CPU or to a head of network field Information unit composed by eight bits Communication protocol widely used in automotive networks Set of equipment nodes interconnected by communication channels Dynamic Menu with content according to the current context Central Processing Unit It controls the data flow interprets and executes the program instructions as well as monitors the system devices Complete application program implementation of a programmable controller Preset value for a variable used in case there is no definition Procedure used to detect and isolate faults It is also the set of data used for this determination which serves for the analysis and remediation Load configuration or program in the PLC A unit of information transmitted on the network Equipment for connecting two communication network
74. that is by the POU itself start with prv_ POUs in MasterTool IEC XE Libraries POU names in MasterTool IEC XE libraries do not get a library prefix because using the namespace takes the function of a prefix For creating method names the same rules apply as for actions Possible inputs of a method should get English comments Also a short description of a method should be added in its declaration Visualization Names Currently just avoid to name visualization like another object in the project because this would cause problems in case of visualization changes Variables Initialization The default initialization value is O for all declarations but user defined initialization values can be added in the declaration of each variable and data type The user defined initialization is brought about by the assignment operator and can be any valid ST expression Thus constant values as well as other variables or functions can be used to define the init value The programmer just has to make sure that a variable used for the initialization of another variable is already initialized itself 46 5 Programming Reference Examples for valid variable initializations VAR Var NTE 3S 12 Integer variable with initial value of 12 E INT 1s I3 F g7 Init value defined by an expression with con constants y E ENTS ee ae ey Init value defined by an expression containing a function call be aware of the order in this case
75. the PLC are matching those in the project configuration Appropriate messages will indicate mismatches Task Configuration The Task Configuration Es defines one or several tasks for controlling the processing of an application program It is an essential resource object for an application and it is inserted automatically when you create a new project from MasterTool Standard Project A task can call an application specific program POU which is only available in the device tree below the application as well as a program which is managed in the POUs window In the latter case the project globally available program will be instantiated by the application A task configuration can be edited in the Task Editor the available options being target specific In online mode the Task Editor provides a monitoring view giving information on cycles cycle times and task status Important Notes for Multitasking Systems On some systems real preemptive multitasking is realized In this case the following must be regarded All tasks share one process map Reason An own process map for each task would charge the performance So however the process map always can only be consistent to one task Hence the user when creating a project explicitly must take care that in case of conflicts the input data will be copied to a save area the same problems have to be regarded for the outputs For example modules of the SysSem library could be used to solve the
76. the function is type BYTE and the output is type INT Where a byte should be converted which is not in the BCD format the output is 1 Examples in ST i BCD TO INT 73 Result is 49 Kt BCD TOUINT lolL s Result as 97 1 BCD TO INT 15 Output 1 because it is not in BCD format INT_TO_BCD Provided by util library This function converts an INTEGER value into a byte in BCD format The input value of the function is type INT the output is type BYTE 200 7 Libraries The number 255 will be outputted where an INTEGER value should be converted which cannot be converted into a BCD byte Examples in ST LSS LN lO BODAS gt Resule is o 7 k BCD TO INT 97 Result is 151 LS BCD TO INTE LOO MA ETrOr QUEPUES 200 BIT BYTE Functions Extract Pack Putbit Unpack Provided by util library Inputs to this function are a DWORD X as well as a BYTE N The output is a BOOL value which contains the content of the Nth bit of the input X whereby the function begins to count from the zero bit Examples in ST FLAG EXTRACT X 81 N 4 Result TRUE because 81 is binary T101000L so the 4th bit 1s 1 PLAG EXTRACT X 33 Ni 0 3 Result TRUE because 33 15 binary 100001 so the bit 10 185 1 Provided by util library This function is capable of delivering back eight input bits BO Bl B7 from type BOOL as a BYTE The function block UNPACK is c
77. the modules and variable identifier o Hide this reference in the dependency tree If this option gets activated the current library will not be displayed later when its father library is included in a project This allows to include hidden libraries however needs careful use because in case of library error messages you might have problems to find the causing library NOTE The option Publish all IEC symbols to that project as if this reference would have been included there directly should only be activated if you want to use container libraries not containing own modules but just including other libraries for the purpose of packaging them This packaging for example allows to include multiple libraries in a project at once just by including the container library In this case however it might be desired to get the particular libraries on top level of the projects Library Manager because then the modules can be accessed directly that is the namespace of the container library can be left out Try to Reload the Library This command is part of the Libraries menu and the Library Manager editor window If a library included in a project is for any reason not available at the defined path when opening the project in the programming system an appropriate message will be generated After having checked the error and correctly made available the library again use the Try to Reload Library command when the library entry is selected
78. the parameter Current value Current value of the parameter displayed in the online mode You can modify and correct an input or output Address field To do this select the column address and press lt SPACE gt to open the edit field Now modify or or unchanged the value and close the edit field by pressing lt ENTER gt The address field will be marked by the symbol D Channels Variable Mapping Channel Address Type Unit Description Reserved tk 6081000 Reserved for internal use Figure 5 8 Example of Modified Address Manually You can only change the whole input or output address not its subelements Thus 1f an input or output is represented in the mapping table with any subtree only the highest address field can be edited If you want to remove the fixing of the value reopen the Address field edition delete the value and close by lt ENTER gt The address and the following addresses will be set back to the values they had before the manual modification and the symbol will be removed NOTE For projects created from the MasterTool Standard Project the devices channels will be modified by MasterTool IEC XE in order to maintain a better distribution and organization of channels Therefore they will appear with the symbol D 73 5 Programming Reference Data Types You can use standard data types user defined data types or instances of function blocks when programming Each identifier is assigned to a data t
79. the same scales For example a proportional controller with unitary gain and input PV using the range 0 1000 only be really unit if the output range MV is also 0 1000 In many cases the input and output scales are different There may be mentioned as an example a system where the input analog card 1s 4 20 mA where 4 mA corresponds to the value O and 20 mA corresponds to the value 30000 And the analog output card is O V to 10 V where O V corresponds to the value 0 and 10 V corresponds to the value 1000 In this cases the scales adjustment can be made by the proportional gain instead of a normalization of the input or output values One strategy that can be adopted is initially determine the gain in terms of percentage independent on the scales without worrying about the type of input and output analog modules used After that with this gain determined the scale corrections must be executed before introducing the proportional gain on the PID function block The strategy consists in determining the proportional gain of the system using the percentage range 0 to 100 of both the process variable PV and the manipulated variable MV regardless of the absolute values of both PV and MV It will lead to the determination of a proportional gain called GP This gain GP cannot be used directly in the PID function block Before it is necessary to fix the scales considering the absolute values of these variables WARNING In the pre
80. this position as long as the application is running Reset If value TRUE arrives at a reset output resp coil this output coil will get FALSE and keep FALSE This value cannot be overwritten at this position as long as the application is running hyar 1 Sth ar O HYar a Figure 6 75 Set Output in FBD See also Set Reset Coils IL In IL an instruction list the S and R operators are used to set or reset an operand Set Reset Coils Coils in the coil symbol S can also be defined as set or reset coils One can recognize a set coil by the S A set coil will never overwrite the value TRUE in the appropriate boolean variable That is the variable once set to TRUE remains TRUE One can recognize a reset coil by the R in the coil symbol R A reset coil will never overwrite the value FALSE in the appropriate boolean variable the variable once set to FALSE will remain FALSE In the LD editor Set coils and Reset coils can directly be inserted via drag amp drop from the Toolbox category Ladder elements hyare hyare AED ER Figure 6 76 Set and Reset Coils FBD LD IL Editors in Online Mode In online mode the FBD LD IL Editor provides views for monitoring and for writing and forcing the variables and expressions on the controller Debugging functionality breakpoints stepping etc 1s available See below 180 6 Programming Languages Editors For information on how to open objects in online mode see User Interface in Online Mode in
81. type or variable is declared whether a type or variable has got a certain attribute whether a variable has a certain data type whether a certain POU or task is available and is part of the call tree define identifier During preprocessing all subsequent instances of the identifier will be string replaced with the given sequence of tokens if the token string is not empty which is allowed and well defined The identifier remains defined and in scope until the end of the object or until it is undefined in an undefine directive See Conditional compilation below undefine identifier The identifier s preprocessor definition by define see above will be removed the identifier hence is undefined If the specified identifier is not currently defined this pragma will be ignored 67 IF expr ELSIF expr ELSE END IF Conditional Compilation Operators 5 Programming Reference These are pragmas for conditional compilation The specified expressions exprs are required to be constant at compile time they are evaluated in the order in which they appear until one of the expressions evaluates to a nonzero value The text associated with the successful directive is preprocessed and compiled normally the others are ignored The order of the sections is determinate however the elsifand else sections are optional and elsif sections may appear arbitrarily often Within the constant expr several conditional compilat
82. used to describe a sequence of instructions Like a function a method is not an independent POU but must be assigned to a function block It can be regarded as a function which contains an instance of the respective function block 27 3 Concepts and Basic Components Inserting Methods To assign a method to a function block select the appropriate function block entry in the POUs or Device tree and in the context menu use Add Object Method In the Add Method dialog enter a name the desired return type and the implementation language For choosing the return data type you can use the button LJ to get the Input Assistant dialog After having confirmed the settings via Open the method editor view will be opened Declaration Syntax METHOD lt METHOD NAME gt lt DATA TYPE gt VAR INPUT x INT END VAR Method Call Method calls are also named virtual function calls Please see Method Invocation NOTES All data of a method is temporary and only valid during the execution of the method stack variables In the body of a method access to the function block instance variables is allowed THIS Pointer You can use identifier THIS to point directly to the implicit function block instance which is available automatically Notice that a locally declared variable might hide a function block variable So in case of the example shown above in the syntax description THIS x would not refer to the methods input x but to the fu
83. variable or box parameter will prompt a tooltip showing the respective type and in case of function block instances the initialization value For IEC operators SEL LIMIT MUX a short description on the inputs will appear If defined also the address and the symbol comment will be shown as well as the operand comment in quotation marks in a second line Inserting and arranging elements e Elements also can be directly dragged with the mouse from the toolbox to the editor window or from one position within the editor to another Drag amp Drop For this purpose select the element by a mouse click then keep the mouse button pressed and drag the element into the respective network in the editor view As soon as you have reached the network all possible insert positions for the respective type of element will be indicated by grey position markers When you place the mouse cursor on one of these positions the position marker will change to green and you can release the mouse button in order to place the element at that position e The Cut Copy Paste and Delete commands by default available in the Edit menu can be used to arrange elements Copying an element is also possible by drag and drop Select the element within a network by a mouse click and while keeping the mouse button pressed drag it to the target position As soon as that is reached green position marker a plus symbol will be added to the cursor symbol Release the mouse button to
84. well as in parallel In case of two parallel contacts only one of them must transmit the value TRUE in order to get the parallel branch transmit the value TRUE In case of contacts connected in series all contacts must transmit the condition TRUE in order to get the last contact transmit the TRUE condition So the contact arrangement corresponds to either an electric parallel or a series circuit A contact can also be negated recognizable by the slash in the contact symbol hyarl VF Figure 6 72 Negated Contact A negated contact passes on the incoming condition TRUE or FALSE only if the assigned Boolean variable is FALSE Notice that the Toolbox directly provides negated contact elements A contact can be inserted in a LD network via one of the commands Insert Contact or Insert Contact right Insert Contact Parallel above or Insert Contact Parallel below which by default are part of the FBD LD IL menu Alternatively the element can be inserted via drag amp drop from the Toolbox or from another position within the editor If you are currently working in FBD or IL view the command will not be available but contacts and coils inserted in a LD network will be represented by corresponding FBD elements and IL instructions This is a LD element On the right side of a LD network there can be any number of so called coils which are represented by parentheses biarz Al 1 Figure 6 73 Coil They can only be arranged in parall
85. 09 If a library placeholder is currently selected in the Library Manager this field will contain the name of the library which should replace the placeholder if no device specific library 1s available Please see the correspondent item for information on library placeholder e Version only available if option Enable repository dialog is enabled see Features in the MasterTool IEC XE User Manual MU299609 Here you can configure which version of the library should be used in the project 40 5 Programming Reference o Specific version Exactly the version entered here you can select from the list will be used o Newest version always Always the newest version found in the library repository will be used that is the modules actually used might change because a newer version of the library is available e Visibility only available if option Enable repository dialog is enabled see Features in the MasterTool IEC XE User Manual MU299609 These settings are of interest as soon as the library gets included that is referenced by another library Per default they are deactivated o Publish all IEC symbols to that project as if this reference would have been included there directly As long as this option is deactivated the components of the current library if referenced by another one can be accessed uniquely by using the appropriate namespace path composed of the namespaces of the father library and its own namespace in addition to
86. 170 6 Programming Languages Editors Example Conditional jump instruction in case bCallRestAction is TRUE the program should jump to the network labeled with Cont LDH bl allResetaction JMPC Cont Cursor Positions in FBD LD and IL IL Editor This is a text editor structured in form of a table Each table cell is a possible cursor position See also Working in the IL Editor View FBD and LD Editors These are graphic editors see below examples to showing the possible cursor positions text input output box contact coil line between elements sub network network Actions like Cut Copy Paste Delete and other editor specific commands refer to the current cursor position resp selected element See Working in the FBD e LD Editor View Basically in FBD a dotted rectangle around the respective element indicates the current position of the cursor additionally texts and boxes get blue and red shadowed In LD coils and contacts get red colored as soon as the cursor is positioned on The cursor position determines which elements are available in the context menu for getting inserted Possible cursor positions Every text field in the left picture the possible cursor positions are marked by a red frame the right picture shows a box with the cursor being placed in the AND field Notice the possibility to enter addresses instead of variables names if configured appropriately in the Options dialog tab FBD and LD Editor AN
87. 2 6 PROGRAMMING LANGUAGES EDITORS sivssccsissssccccsvscectcseauecectvsscsshavisccdeavacccesteauctectvascsssavieecsestacevien 123 OOM EDO so E R 123 Continuous Function Chart Languace CPC oda 124 Cursor Posttions ti GPC amene E S S 124 CFC Elements LOO DO Xs sesime A T E E 125 Insert and Organize Elements dada 128 CEC Editor 1 Online MOU Gessie A tias 130 SEC PAP A In I E E E OE E 131 SFC Sequential Function Chat o 132 Cursor POSIIONS MSP isis 132 VV OP RMON PE MO A O e O e aL a o 134 SEC Element Properties scort 135 SFC Elements TOODO dois 136 As A are Te otra ee PE 144 Iniplicit Varnables SEC Plis ie c sia 144 Sequence ol Process EC sosser e a alte re head aie 149 SC Editor m Onine VO esc seis cake oS ates trate aerate a rates ctald a tk biataat a Satta teal hia tereressheiate thee 150 Structured Text ST Extended Structured Text EXST ccccsssccssscccssscccscccccsccccscccccscccccscccccscccesees 151 EXPLESION Si init idde 151 A 152 SIE di a Ges iuwauenstinssastias aeseesetessaune 158 Si Editor Online MOG 0 laos dciniaicia 159 EBD EDIL Editors aaa 161 Function Block Diag rata cuca aiii 162 Ladder coca 162 Mstricuoniaist lla di 162 Working mhe BDE LD Editor VIEW aa 165 W orkaneimthe IY Editor VIEW a ania a ooo cele dos 167 Cursor Positions mM RBD Dad Mina ind 171 EDO COD M tasa Ao 173 EA E a ane he ssa eens atte eas neers asta eat ae eed 174 Summary De MN BR ARI Ss a 186 The Standard ibrary LIDIA Y
88. 2 bit in variable x Since bvar has 8 bits and rvar has 32 bits the bitaccess will be done on the second bit of variable wvar which as a result will get value 4 NOTE Online change might change the contents on addresses Please notice this when using pointers on addresses Memory Location Address You can use any supported size to access the memory location For example the address MD48 would address bytes numbers 192 193 194 and 195 in the memory location area 48 4 192 The number of the first byte 1s O The table below shows the corresponding memory location dependent on the size X bit B byte W word D dword for IEC addressing Examples A 96 0 96 7 96 8 192 15 97 0 97 7 97 8 97 15 mw EEC O a TI IS TE E d Table 5 13 Examples of Memory Positions You can access words bytes and even bits in the same way the address 7MX96 0 allows you to access the first bit in the 96th word Bits are generally saved wordwise See Address for further information on addressing NOTE Online Change might change the contents on addresses Please notice this when using pointers on addresses When specifying an address the memory location and size are indicated by special character sequences Syntax Address with bit lt Memory area prefix gt lt Prefix size gt lt number number gt Address without bit lt Memory area prefix gt lt Prefix size gt lt number number gt Type Input
89. 20 GT 30 oT Yard Result is FALSE Example in ST VARI lt 20 gt 30 gt 40 gt 50 gt 60 gt 70 Example in FBD E Yarl 4 IEC Comparison Operator Less than A Boolean operator that returns the value TRUE when the value of the first operand is less than that of the second The operands can be of any basic data type Example in IL LD 20 LT 30 ST Yard Result is TRUE Example in ST VARL 20 lt 30 Example in FBD LT aU Yarl 30 IEC Comparison Operator Less than or equal to A Boolean operator that returns the value TRUE when the value of the first operand is less than or equal to that of the second The operands can be of any basic data type 98 GE EQ Example in IL LD LE oT Result is TRUE Example in ST VARI 20 lt 30 Example in FBD 5 Programming Reference 20 30 Warl 2 Yarl 30 IEC Comparison Operator Greater than or equal to A Boolean operator that returns the value TRUE when the value of the first operand is greater than or equal to that of the second The operands can be of any basic data type Example in IL LD GE ST Result is TRUE Example in ST VAR1 60 gt 40 Example in FBD 60 40 Warl 6 Yarl IEC Comparison Operator Equal to A Boolean operator that returns the value TRUE when the operands are equal The operands can be of any basic data type Example in IL LD EQ oT Result is TRUE Example in ST VARI 40 40 Example in FBD
90. 40 40 Yarl 99 NE 5 Programming Reference ZAI varl cal IEC Comparison Operator Not equal to A Boolean operator that returns that value TRUE when the operands are not equal The operands can be of any basic data type Example in IL LD 40 HE 40 ST varl Result is FALSE Example in ST VARI 40 lt gt 40 Example in FBD 4 Yarl Address Operators ADR BITADR ADR and BITADR and the content operator are norm extending address operators available in MasterTool IEC XE This address operator is not prescribed by the standard IEC 61131 3 ADR returns the address of its argument in a DWORD This address can be sent to manufacturing functions to be treated as a pointer or it can be assigned to a pointer within the project NOTE The ADR Operator can be used with function names program names function block names and method names thus replacing the INDEXOF operator See in this context Function pointers Notice anyway that function pointers can be passed to external libraries but there is no possibility to call a function pointer within MasterTool IEC XE In order to enable a system call runtime system the respective property category Build must be set for the function object See Function Pointers Example in ST dwVar ADR DVAR Example in IL LD HY ar ADR oT dia r NOTE After an Online Change there might be changes concerning the data on some addresses Notice this in this ca
91. 792 6000 12000 6000 0 6321 K 2 4 static gain of the process 2 4 _ 12000 6000 5000 2500 Tuning Controller As the test opened loop was used it will use the second tuning method described in the Application Notes To use this method besides the process parameters determined in the previous section Tm T and K it is also necessary that the user enter other two parameters e Tr Or response time desired In this example it will be arbitrated in 10 seconds one third of the constant time using opened loop e dt Or cycle time of the PID function block As mentioned above this time must be less than 10 times the contant time using opened loop or even less Therefore the value must be less than 3 seconds It was selected dt 1 second Now it 1s possible appling the equations of the method GP T K Tr Tm Dt 2 30 2 4 10 10 1 2 0 609 Ti T 30 s rep Td Tm 2 Dt 4 10 2 1 2 5 25 s 230 8 Glossary 8 Glossary Active CPU Algorithm Application Program Assembly Language Bit Breakpoint Broadcast Bus Byte CAN Communication network Context Menu CPU Cycle Default Diagnostics Download Frame Gateway Hardware IEC 61131 Interface Input output I O I O Module Kbytes Login Master Menu Module hardware Node Operands PLC POU Programmable Controller Programming Language Protocol RAM Reset RUN Set Slave In a redundant
92. An exit action will be executed if the step is going to get deactivated that is if its entry and step actions if existing have been executed during the last cycle and if the transition for the following step is TRUE Step entry actions All steps are tested in the order which they assume in the sequence to determine whether the requirement for execution of the step entry action is provided and if that is the case this will be executed An entry action will be executed if the step preceding transition condition is TRUE and thus the step has been activated Timeout check Step For all steps the following is done in the order which they assume in Active Actions the sequence IEC Actions IEC actions that are used in the sequence are executed in alphabetical order This is done in two passes through the list of actions In the first pass all the IEC actions that are deactivated in the current cycle are executed In the second pass all the IEC actions that are active in the current cycle are executed Transition check Transitions are evaluated If the step in the current cycle was active and Activating next steps the following transition returns TRUE and if applicable the minimum active time has already elapsed then the following step is activated Table 6 6 Processing Order of Elements in a Sequence NOTES It can come about that an action is carried out several times in one cycle because it is associated with multiple s
93. B E ST varl Example in ST varl 7 2 Example in FBD 7 Warl E IEC Operator Division of one variable by another one Allowed types BYTE WORD DWORD LWORD SINT USINT INT UINT DINT UDINT LINT ULINT REAL and LREAL Example in IL 87 5 Programming Reference LD 5 DIY E ST varl Result in Varl is 4 Example in ST varli 8 25 Example in FBD 5 Warl NOTE Observe que a utiliza o do operador DIV com tipos de dados inteiros retorna apenas o quociente da divis o Caso se queira retornar o resto da divis o o operador a ser utilizado o MOD descrito a seguir Check Functions In order to check the value of the divisor for example in order to avoid a division by 0 you may make use of the provided check functions CheckDivInt CheckDivLint CheckDivReal and CheckDivLReal After they have been included in the application each division occurring in the related code will provoke a preceding call to these functions To include them in the application use the Add Object dialog Therein choose the object POUs for implicit checks mark the checkbox of a corresponding check function select an implementation language and confirm your choice with Open The selected function will be opened in the editor corresponding to the choice of the implementation function Independently of this choice the declaration part of the functions is preset and must not be changed except for adding local variables A default implementatio
94. BYTE 2 END VAR erg Dbyces ROL in Dyte Result as L slo erg word ROL in word n Result is 1o 0114 Example in FBD in byte erg byte Y Example in IL LD in byte ROL r ST erg byte IEC Operator Bitwise rotation of an operand to the right erg ROR in n Allowed data types BYTE WORD DWORD LWORD In will be shifted one bit position to the right n times while the bit that is furthest to the left will be reinserted from the left NOTES Please note that the amount of bits which is noticed for the arithmetic operation is pretended by the data type of the input variable If the input variable is a constant the smallest possible data type is noticed The data type of the output variable has no effect at all on the arithmetic operation See in the following example in hexadecimal notation that you get different results for erg byte and erg_word depending on the data type of the input variable BYTE or WORD although the values of the input variables in_byte and in_word are the same Example in ST PROGRAM ror st VAR in byte BYTE L6 45 in word WORD 16 45 erg byte BYTE erg word WORD n BYTE 2 END VAR erg Dyce ROR in byten Result is 1651 erg word ROR in word n Result is 16 4011 94 5 Programming Reference Example in FBD ROR in byte erg byte n Example in IL LD in byte ROR n ST erg byte Selection Operators SEL MAX All sele
95. Block Fb A property can have additional local variables but no additional inputs and in contrast to a function or method no additional outputs Monitoring a Property Action A property may be monitored in online mode either with help of Online Monitoring or with help of a Watch List The condition precedent to monitoring a property is the addition of the pragma attribute monitoring variable on top of its definition Is A gt Actions CER can be defined and assigned to function blocks and programs using the command Add Object An action is an additional implementation which can be created in a different language than the basic implementation is Each action is given a name An action works with the data of the function block or program which it belongs to It uses the input output variables and local variables defined there and does not contain own declarations 29 3 Concepts and Basic Components FUHCTIOH BLOCK FE 1 3 l out 0 VAR IHPUT 11n B00L gt EHD VAR YAR OUTPUT out IHT Out outt l ELSE out out l1 Figure 3 4 Example of an Action of a Function Block In this example each call of the function block FB1 will increase or decrease the output variable Out depending on the value of the input variable in Calling action Reset of the function block will set the output variable Out to zero The same variable Out is written in both cases An action can be added via command Add Obje
96. CLES defines the corresponding cycle period AMPLITUDE defines in a trivial way the amplitude of the function to be generated The function generator is again set to O as soon as RESET TRUE Function Manipulators CHARCURVE Provided by util library This function block serves to represent values piece by piece on a linear function 212 7 Libraries Example of CHARCURVE in FBD charcurve inst CHAR CURVE i Input IN OO TFi0ut byPoints H ERRHbyError arrCurve B IN of type INT is fed with the value to be manipulated N of type BYTE designates the number of points which defines the presentation function P of type ARRAY P 0 10 OF POINT which is a structure based on two INT values X and Y determines this characteristic curve OUT of type INT contains the manipulated value ERR of type BYTE indicates an error The points P 0 P N 1 in the ARRAY must be sorted according to their X values otherwise ERR receives the value 1 If the input IN is not between P 0 X and P N 1 X ERR 2 and OUT contains the corresponding limiting value P 0 Y or P N 1 Y If N lies outside of the allowed values which are between 2 and 11 then ERR 4 Example in ST First of all ARRAY P must be defined in the header VAR CHARACTERISTIC LINE CHARCURVE KL ARRAY 0 10 OF POINT X 0 Y 0 X 250 Y 50 X 500 Y 150 X 750 Y 400 7 X 1000 Y 1000 COUNTER INT END VAR Then we supply CHARCURVE with for example a constantly
97. D pApplicationInfo POINTER TO IMPLICIT APPLICATION INFO END VAR The programmer now can check the application status via pApplicationInfo and define what should happen 28 Property 3 Concepts and Basic Components Example IF PAPPLICATIONINEFO STATE RUNNING THEN lt INSTRUCTIONS gt END IF A Property E 1s an object type which can be inserted below a program or function block via command Add object Property from the context menu In the Add Property dialog the name return type and desired implementation language have to be specified A property contains two special methods which will be inserted automatically in the objects tree below the property object e The Set method is called when the property is written that is the name of the property is used as input e The Get method is called when the property 1s read that 1s the name of the property is used as output Example Function block FB1 uses a local variable MILLI This variable is determined by the properties Get and Set Code on property Get SECONDS MILLI 1000 Code on property Set MILLI SECONDS 1000 You can write the property of the function block Set method for example by fbinst seconds 22 fbinst is the instance of FB1 or you can read the property of the function block Get method for example by testvar fbinst seconds E fb FB B seconds ER Get Sp Set Figure 3 3 Property Seconds Added to Function
98. D 222 bvar2 ie a Figure 6 52 Text Fields e Every input Eg a RETURN Figure 6 53 Inputs RETURN b Jump target e Every operator function or function block erg Figure 6 54 Operator Function or Function Block 171 6 Programming Languages Editors Outputs if an assignment or a jump comes afterward era Figure 6 55 Output Just before the lined cross above an assignment before a jump or a return instruction era Figure 6 56 Before the Crossed Line The right most cursor position in the network or anywhere else in the network besides the other cursor positions This will select the whole network Zi Teste de chaves software de teste 1 TRUE varinput Varout put Figure 6 57 Cursor Position Right in the Network The lined cross directly in front of an assignment Figure 6 58 Front of Assignment Every contact switchl Figure 6 59 Contact Every coil l ampl Al 1 Figure 6 60 Coil 172 e The connecting line between the contacts and the coils bwar R 6 Programming Languages Editors 77 Figure 6 61 Connecting Line Position e Branch sub network within a network Figure 6 62 Branch or Sub network FBD LD IL Menu When the cursor is placed in the FBD LD IL editor window the FBD LD IL menu by default is available in the menu bar providing the commands for programming in the currently set editor view FED LD IL
99. E EEEE TE En 15 Important Notes for Multitasking Systems cccccccccccssssssssssssseeeececeeeeeeeeeeaaaseeesessseeeeeeeeeeeeeeeeaeaaaaeesseses 15 COMMUNICATION rai AAA AAA NARA AAA ARANA 16 Code Generation and Online Change ooscsccsscsccccsscstscseasstacesecstecssnsstacsnncstscseass adennsstecssssstacssnsstecsvavcdadevedstesawave 16 Code Generation and Compile Informal ON sri siveded euts a a a 16 Onine GAT estas N nse snicker aah Saltash azcrsen ast alc task ENA 16 Boot Applcation Boot Pro Ec A in a 16 Sending Login Project Method without Project Differences oooooooooocncccnnnnnnnnnnnnononononnnnonnnnnnnnnnnnnnnnnnnos 16 Monitorin a APP on duebenkdsesues xeusauescosteccsecneseasesess 17 DCU UNG AAA In a de bacadasvedsessuaciaaascuesee cee bec taduesedvassvecabodscuccuectuscateiseues 17 Supported Programming LAN GuagGEes cccccrcccssssscsssessssssovesssccccssscssssscssvessssssoovssaccccsccssssscssseessssssossssccsosess 17 Program Oreanizanon U its Sii IA 17 OA e eee nee PE OE nna ee me rte vere ee rene ener area Dery ee ree et ee ner eye ee rer em error wh eee se 18 PEO AMM N saa nate O O UE E o scene a sete ante ccoaau Guat nenaueceenaeiaemgntorccua aa ete 20 Summary NA a E 21 o 245s caateeanttean sates gsutacsaesacaateeaniran sun ipasaguntacnds saancenansteca senate seguatacndneancenenitecesouitaee 23 A O erate rere 2 Metodo a Zi PROP Cys seattle O eat 29 PROTO nd oli ei as 29 External Function Function Block Metho
100. Figure 6 66 Position of the Label in a Network See the Options dialog tab FBD LD IL Editor for defining the display of comment and title Boxes in FBD LD IL A box insertable in a FBD LD or IL network is a complex element and can represent additional functions like e g Timers Counters arithmetic operations or also programs IEC functions and IEC function blocks A box can have any desired inputs and outputs and can be provided by a system library or be programmed by the user At least one input and one output however must be assigned to Boolean values If provided with the respective module and if option Show box icon is activated an icon will be displayed within the box Use in FBD LD Use in IL A box can be positioned in the left part of a LD network like a contact resp in a FBD network by using command Insert Box Insert Empty Box Alternatively 1t can be inserted from the Toolbox or copied or moved within the editor via drag amp drop Please see Insert Box in the MasterTool IEC XE User Manual MU299609 In an IL program a CAL instruction with parameters will be inserted in order to represent a box element An update of the box parameters inputs outputs in case the box interface has been changed in the current implementation can be done without having to re insert the box by the Update Parameters command RETURN Instruction in FBD LD IL With a RETURN instruction the FBD LD or IL POU can be left 176
101. Forcing Writing of variables In online mode you can prepare a value for forcing or writing a variable either in the declaration editor or within the implementation part In the implementation part at a mouse click on the variable the following dialog will open 182 6 Programming Languages Editors Prepare Value Expression Device Application MainPrg iInputLevel Type INT Current value 10 What do you want to do Prepare a new value for the next write or force operation 20 Remove preparation with a value Release the force without modifying the value Release the force and restore the variable to the value it had before forcing it Figure 6 81 Dialog Prepare Value You find the name of the variable completed by its path within the Device tree Expression its Type and Current value By activating the corresponding item you may choose whether you want to prepare e Prepare anew value for the next write or force operation e Remove preparation with a value e Release the force without modifying the value e Release the force and restore the variable to the value it had before forcing it The selected action will be carried out on executing the menu command Force Values per default in the Online menu or pressing lt F7 gt Breakpoint and Halt Positions Possible positions which can be defined for a breakpoint halt position for debugging purposes basically are those positions at which values of variables
102. G END_VAR IF hasattribute variable g_globallnt DoCount The following code line will only be processed in POU_1 because there variable g_globallnt has got the attribute DoCount g_globallnt g_globallnt 1 END_ IF 69 5 Programming Reference Hastype variable When applied to a variable its value is TRUE if this particular variable variable type has the specified type spec Otherwise is FALSE ANY ANY_DERIVED ANY_ELEMENTARY ANY_MAGNITUDE ANY_BIT ANY_STRING ANY_DATE ANY_NUM ANY_REAL ANY_INT LREAL REAL LINT DINT INT SINT ULINT UDINT UINT USINT TIME LWORD DWORD WORD BYTE BOOL STRING WSTRING DATE_AND_ TIME DATE TIME_OF_DAY Example Precondition In a POU with the code below at first time the variable g_multitype is declared as LREAL and at second time is declared as STRING IF hastype variable g_multitype LREAL The following line of code will only be processed when the variable is declared as LREAL g_multitype 0 9 g_multitype 1 1 ELSIF hastype variable g_multitype STRING The following line of code will only be processed when the variable is declared as STRING g_multitype this is a multi talented END_IF Hasvalue define ident If the define define ident is defined and it has the specified value string char string then its value is TRUE otherwise is FALSE Example Precondition Variable test is use
103. IGinst F TRIG WarB00L1 CLE Q YarBooLe Example in ST FTRIGInst CLK VarBOOL1 VarBOOL2 FTRIGInst Q Provided by standard library Function block working as an incrementer Inputs CU BOOL a rising edge at this input starts the incrementing of CV RESET BOOL If TRUE CV will be reset to 0 PV WORD upper limit for the incrementing of CV 193 CTD 7 Libraries Outputs Q BOOL gets TRUE as soon as CV has reached the limit given by PV CV WORD gets counted up until it reaches PV Declaration example CTUInst CTU Example in IL CAL CTDinast CD VarBO0Ll LOAD Varb00Lz PY YarWoORrDl C gt YarWoORDe LD CTDinat Q ST YarBooLs Example in FBD CTULns t C TU YarBoOoLL CU YarBooLs Warbool z RESET CYpP YarWOR De WarWORDl PY Example in ST CTUInst CU VarBOOL1 RESET VarBOOL2 PV VarwWORD1 VarBOOL3 CTUInst 0 VarWORD2 CTUlnst CV Provided by standard library Function block working as a decrementer Inputs CD BOOL a rising edge at this input starts the decrementing of CV LOAD BOOL If TRUE CV will be reset to the upper limit given by PV PV WORD upper limit that is start value for decrementing of CV Outputs Q BOOL gets TRUE as soon as CV is 0 CV WORD gets decremented by 1 starting with PV until 0 is reached Declaration example CIDIASE Clb 194 CTUD 7 Libraries Example in IL CAL CTDingt f CI VY
104. IN MAX IN Min Max Max is the upper and Min the lower limit for the result Should the value IN exceed the upper limit Max LIMIT will return Max Should IN fall below Min the result will be Min IN and OUT can be any type of variable 96 MUX 5 Programming Reference Example in IL LD g LIHIT 30 o sT Warl Result 1s 80 Example in ST Varl LIMIT 30 90 80 Result is 80 Example in FBD 10 value 100 IEC Selection Operator multiplexer operator OUT lt MUX K INOy 5 INN Which can be written as OUT INK INO INn and OUT can be any type of variable K must be BYTE WORD DWORD LWORD SINT USINT INT UINT DINT LINT ULINT or UDINT MUX selects the Kth value from among a group of values Example in IL LD 0 MU 30 F 40 r 50 r 60 r 70 r all ST Yard Result is 30 Example in ST Varl MUX 0 30 40 50 60 70 80 Result is 30 Example in FBD g 30 40 30 60 70 a0 Result is 30 97 5 Programming Reference Comparison Operators GT LT LE The following operators matching the IEC1131 3 standard are available GT LT LE GE EQ NE These are Boolean operators each comparing two inputs first and second operand IEC Comparison Operator Greater than A Boolean operator which returns the value TRUE when the value of the first operand is greater than that of the second The operands can be of any basic data type Example in IL LD
105. If the library project is based on further libraries that are target specific that is device specific these libraries have to be included in the library project via placeholders 39 5 Programming Reference This means that instead of specifying one particular library for being included a placeholder will be inserted which will be replaced later when lt library_xy gt is used in another project for a certain device by the name of a device specifically defined library This name must be specified in the respective device description file lt library_xy gt which assigns the placeholder name to a real library name If the library manager for any reason currently is not assigned to a device the placeholder will be replaced by the default library specified here in the dialog This for example allows compilation of the currently edited library project without detected errors even if no suitable device description is available at that moment In the Placeholder Name field enter any string as a name for the placeholder Further on choose a default library from the currently installed libraries This is to be done like described above for adding a library in the Library sub dialog and like there option Display all versions for experts only might be activated to get displayed all currently installed versions of a library After closing the dialog with OK the placeholder library will be entered in the library manager tree When you open the Pr
106. Items The product may be acquired in two ways e Product package contain the following items o MasterTool IEC XE software recorded on CDROM o Altus Software License Contract e Ina product package that contains the license for subsequent download of the software at Altus site www altus com br Versions Licenses Product Code The following codes shall be used for product purchase MasterTool IEC XE Basic L license MasterTool IEC XE Professional L license MasterTool IEC XE Advanced L license Table 2 5 Codes for MasterTool IEC XE Purchase 11 3 Concepts and Basic Components 3 Concepts and Basic Components Introduction MasterTool IEC XE is a device independent PLC software programming Matching the IEC 61131 3 standard it supports all standard programming languages Basic Concepts Regard the following basic concepts determining programming with MasterTool IEC XE Object Orientation The mind of object orientation is not only reflected by the availability of appropriate programming elements and features but also in the structure and version handling of MasterTool IEC XE and in the project organization Component based structure of the programming system The functionality available in the user interface editors menus etc depends on the currently used components defined in a profile There are system components which are essential and optional components Project Organization is also determined by the mind o
107. L TUESDAY CAL WEDNESDAY CAL THIRSDAY CAL FRIDAY CAL SATURDAY CAL SUNDAY 45 5 Programming Reference Declaration eToday CAL Day User Defined Data Types DUTs in MasterTool IEC XE Libraries DUT names in MasterTool IEC XE libraries do not get a library prefix because using the namespace takes the function of a prefix Also enumeration components are defined without library prefixes Example in library with namespace CAL TYPE Day mer a MONDAY TUESDAY WEDNESDAY THIRSDAY FRIDAY SATURDAY SUNDAY Declaration eToday CAL Day Use in application IF eToday CAL Day MONDAY THEN Functions Function blocks Programs POU Actions The names of functions function blocks and programs consist of the library prefix Example CAN an underscore and an expressive short name e g SENDTELEGRAM of the POU Like with variables always the first letter of a word of the POU name should be a capital letter the others should be small letters It is recommended to compose the name of the POU of a verb and a substantive FUNCTION BLOCK Com SendTelegram Prefix comst In the declaration part a short description of the POU should be provided as a comment Further on all inputs and outputs should be provided with comments In case of function blocks the associated prefix for set up instances should follow directly after the name Actions get no prefix just actions which should be called only internally
108. Mnum 0 If a method named FB_reinit is declared for a function block instance this method will be called when the instance gets copied which for example is the case at an online change after a modification of the function block declaration The method will cause a reinitialization of the new instance module that has been created by the copy code A reinitialization might be desired because the data of the original instance will be written to the new instance after the copying but you might want to get the original init values The FB_reinit method has no inputs Regard that in contrast to FB_init the method must be declared explicitly If a reinitialization of the basic function block implementation is desired FB_reinit must be explicitly called for that POU The FB_reinit method has no inputs On the call sequence in case of inheritance please see FB_Exit A special method for a function block is a method named FB_Exit It must be declared explicitly there is no implicit declaration The exit method if present is called for all declared instances of the function block before a new download at a reset or during online change for all moved or deleted instances There is only one mandatory parameter METHOD fb exit BOOL VAR INPUT bInCopyCode BOOL If TRUE the exit method is called for exiting an instance that is copied afterwards online change END VAR Regard also the FB_init method and the following execution
109. O BOOL 213 h Result is TRUE IHT TO BOOL O h Result is FALSE TIME TO BOOL c oms h Result is TRUE STRIHG TO BOOL TROE b Result is TRUE Examples in ST b BYTE TO BOOL 2 11010101 Result is TRUE b INT TO BOOL 0 b TIME TO BOOL T 5ms b STRING TO BOOL TRUE Result is FALSE Result is TRUE Result is TRUE Conversion between Integral Data Types Conversion from an integral number type to another number type Syntax for the conversion operator lt INT data type gt TO SINI data type gt When you perform a type conversion from a larger to a smaller type you risk losing some information If the number you are converting exceeds the range limit the first bytes for the number will be ignored Example in ST Si t INT TO SINT 4223 7 Result 19 Le If you save the integer 4223 16 107f represented in hexadecimal as a SINT variable it will appear as 127 16 7f represented in hexadecimal Example in IL 104 5 Programming Reference LD 4223 INT TO SINT ST si Example in FBD saa bil ea REAL_TO LREAL_TO Conversions IEC Operator Converting from the variable type REAL or LREAL to a different type The value will be rounded up or down to the nearest whole number and converted into the new variable type Exceptions to this are the variable types STRING BOOL REAL and LREAL NOTE If a REAL or LREAL is converted to SINT USINT INT UINT DINT UDINT LINT or ULINT
110. PERSE Sice 78 5 Programming Reference NOTES It is not possible to declare references like REFERENCE TO REFERENCE ARRAY OF REFERENCE or POINTER TO REFERENCE The references will be initializes with 0 Check For Valid References Operator ISVALIDREF can be used to check whether a reference points to a valid value that is a value unequal 0 Syntax lt Boolean variable gt ISVALIDREF lt Id entifier declared with type REFERENCE TO lt Data Type gt lt Boolean variable gt will be TRUE if the reference points to a valid value FALSE if not Example Declaration ivar E TNT fet nt REFERENCE TO INT rer into REFERENCE TO INT testref BOOL FALSE Implementation ivar iva El Let InG RERS hugo PEL Ine REFS U testrer ISVALIDREFP rEeS int WILL be TRUE Decause rer int points to Ivar which 1s unequal 0 testretO gt ISVALIDRER ref ant0 Will DS FALSE because rer int as set to 0 User Defined Data Types Additionally to the standard data types the user can define special data types within a project These definitions are possible via creating DUT Data unit type objects in the POUs window and within the declaration part of a POU Please notice the given recommendations on the naming of objects in order to make it as unique as possible See the following user defined data types ARRAYS Structures Enumerations Subrange Types References
111. PROG Initialize BOOL END VAR mI it Eb Initialize EPrgl SPl gt 22 5 8 Task Configuration gt Init Figure 6 12 SFC Editor 131 6 Programming Languages Editors The elements used in a SFC diagram by default are available in the SFC menu which by default is available as soon as the SFC editor is active They are to be arranged in a sequence parallel sequences of steps which are connected by transitions See also Working in SFC Editor The properties of steps can be edited in a separate Properties box Inter alia there the minimum and maximum time of activity can be defined for each step Implicit variables can be accessed for controlling the processing of a SFC for example step status timeout analysis reset etc The commands for working in the SFC Editor can be called from the context menu or from the SFC menu which by default is available as soon as the SFC Editor is active In the SFC editor e Editing is made more comfortable by the fact that each particular element can be selected and arranged individually During editing the syntax of the SFC not necessarily must be matched syntax errors will not be checked until a Generate Code command e There is only one step type combining the two types IEC steps and non IEC steps which are used in previous versions Actions always must be provided as POUs The actions always are as
112. Prg there is in both cases In a POU there is the following code IF defined pou MAINPRG OR defined pou CheckBounds The following line of code is processed in two scenarios because both contain at least one of the POUs bOrTest TRUE END_ IF Operator Braces the operator Table 5 8 Syntax of Defined List Components Functionality The text input is supported noticing standard IEC 61131 3 The feature List Components Tools Options SmartCoding menu helps to insert a correct identifier If you at any place where a global identifier can be inserted insert a dot instead of the identifier a selection box will appear listing all currently available global variables You can choose one of these elements and press lt ENTER gt to insert it behind the dot You can also insert the element by a double click on the list entry If you enter a function block instance or a structure variable followed by a dot then a selection box listing all input and output variables of the corresponding function block resp listing the structure components will appear where you can choose the desired element and enter it by pressing lt ENTER gt or by a double click Examples n oe Ww M FP erg StEuvar dp Dwar da dwar da Ivar Figure 5 5 List Components Structure 71 5 Programming Reference MainPrg Configuration Bus 1 PROGRAM MainPra 2 VAR 3 fbinst EB z erg INT ivar
113. REAL The type must be written in uppercase letters lt Literal gt specifies the constant The data entered must fit within the data type specified under lt TYPE gt Example varl DINT 34 If the constant cannot be converted to the target type without data loss an error message will be issued Typed literals can be used wherever normal constants can be used Variables Variables can be declared either locally in the declaration part of a POU or in a Global Variable List See Variables Declaration for information on the declaration of a variable including the rules concerning the variable identifier and multiple use Variables can be used anywhere the declared type allows for them You can access available variables through the Input Assistant Accessing Variables Syntax Use the following syntax for accessing two dimensional array lt ARRAY NAME gt INDEX1 INDEX2 Structure variables lt STRUCTURE NAME gt lt VARIABLE NAME gt Block and program variables lt FUNCTION BLOCK NAME gt lt VARIABLE NAME gt 118 5 Programming Reference Addressing Bits In integer variables individual bits can be accessed For this purpose the index of the bit to be addressed is appended to the variable separated by a dot The bit index can be given by any constant Indexing is 0 based Syntax lt Variable name gt lt BIt index gt Example a INT Br BOO LE aid D The third bit of the variable A will be se
114. RING and XOR Additionally all conversion operators as listed in the Input Assistant are handled as keywords Local Variables VAR Between the keywords VAR and END_VAR all local variables of a POU are declared These have no external connection in other words they cannot be written from the outside Regard the possibility of adding an attribute to VAR Example VAR LOOGILINE As Local variable e END VAR Input Variables VAR_INPUT Between the key words VAR_INPUT and END_VAR all variables are declared that serve as input variables for a POU That means that at the call position the value of the variables can be given along with a call Regard the possibility of adding an attribute to VAR_INPUT VAR INPUT TIAS ENT Ce de Input variable END VAR Output Variables VAR_OUTPUT Between the key words VAR_OUTPUT and END_VAR all variables are declared that serve as output variables of a POU That means that these values are carried back to the POU making the call There they can be answered and used further 49 5 Programming Reference Regard the possibility of adding an attribute to VAR_OUTPUT Example VAR OUTPUT TOULLZINT Lo Output variable END VAR Output Variables in Functions and Methods According to IEC 61131 3 draft 2 functions and methods can have additional outputs Those must be assigned in the call of the function like this Funt iinl e ly TINZ Lp outl gt 1bOel 1 UEZ gt 1
115. SAo EA EAo For the previous example R _ 3000 0__ 14 478 8706 6634 This R ratio is a constant that when multiplied by the proportional gain of the controller compensates the differences between the input and output ranges without the necessity of a direct normalization Application Example This section will show a practical example of using the PID function block covering various stages of process design and its control system Process Description The example process has as objective the supply of heated water at controlled temperature for a consumer The heating will be done using a gas burner being controlled from the flow gas variation through a valve The Figure 7 25 illustrates this process burner MV 4 20 m s 4 20 m Py CONTROLLER SP Figure 7 25 Sample Temperature Control 227 7 Libraries It is observed that the temperature transmitter TT is located near the consumer which is 20 meters from the point of heating the water Processes like this are good examples of how dead times can be introduced This is because the heated water at the point of heat takes some time to cover the distance from the measuring point to the consumer Dead times were previously discussed Figure 7 23 Some hypotheses were assumed on this process modeling It is assumed that the water reaches the point on the heating burner is fixed temperature of 30 C It is assumed that water flow is constant I
116. TOD ST tot Result is TOD 00 00 00 001 LD FALSE BOOL TO DATE ST dandt Result is D 1970 01 01 LD TRUE BOOL TO DT ST dandt Result is DT 1970 01 01 00 00 01 Examples in ST i BOOL TO INT TRUE Result is 1 102 5 Programming Reference str BOOL TO STRING TRUE Result is TRUE t BOOL TO TIME TRUE Result is T lms tot s BOOL TO TOD TRUE Result is TOD 00 00 00 001 dat BOOL TO DATE FALSE Result is D 1970 dandt BOOL TO DT TRUE x Result is DT 1970 01 01 00 00 01 Examples in FBD BOOL TO IHT TRUE 1 Result is 1 BOOL TO STRING TRUE str Result is TRUE BOOL TO TIME TRUE t Result is T 1ms BOOL TO TOD TRUE tot Result is TOD 00 00 00 001 BOOL TO DATE FALSE t BOOL TO DT TRUE dandt Result is DT 1970 01 01 00 00 01 Result is D 1970 01 01 TO_BOOL Conversions IEC Operator Converting from another variable type to BOOL Syntax for a TO_BOOL conversion operator lt Data type gt TO BOOL The result is TRUE when the operand is not equal to 0 The result is FALSE when the operand is equal to 0 The result is TRUE for STRING type variables when the operand is TRUE otherwise the result is FALSE Examples in IL LD aLa BYTE TO BOOL ST la Result is TRUE 103 5 Programming Reference LD O IHT TO BOOL ST b Result is FALSE LD T Sms TIME TO BOOL ST h Result is TRUE LD TRUE STRING TO BOOL ST b Result is TRUE Examples in FBD BYTE T
117. TR L P means Delete L characters from STR beginning with the character in the POS position Example in IL LD SU YI DELETE 2 5 ST Wars5TRING1 The result is SUST Example in FBD DELETE SOURS 1 a LR Yar STRING E LEN 4 POs Example in ST Vari DELETE UX Zra 189 7 Libraries REPLACE FIND Provided by standard library Function of type STRING replaces a partial string from a larger string with another string Inputs STR1 STRING string of which a part should be replaced by string STR2 STR2 STRING string which should replace a part of STR1 L INT length of partial string in STR1 which should be replaced P INT position where STR2 should be inserted instead of the existing L characters Return value STRING resulting string REPLACE STR1 STR2 L P means Replace L characters from STR1 by STR2 beginning with the character in the P position Example in IL LD oUa RE PL ACE E P r E oT YarsTRINGl Result is SKYST Example in FBD Yar aTRINGl Example in ST VarsTRING REPLACE SUXYSI RK jara Provided by standard library Function of type INT searches for the position of a partial string within a string Inputs STR1 STRING string within which STR2 should be searched STR2 STRING string whose position should be searched in STR1 Return value INT start position of STR2 in STR1 0 if STR2 is not found in STRI FIND STR1 STR2 means Find the
118. This type of step action will be processed as soon as the step has become active and before the step active action The action is associated to a step via an entry in the Step Entry field of the step properties It is represented by an E in the lower left corner of the respective step box Step Active Action This type of step action will be processed when the step has become active and after a possible step entry action of this step has been processed However in contrast to an IEC step action it is not executed once more when it gets deactivated and it cannot get assigned qualifiers The action is associated to a step via an entry in the Step active field of the step properties It is represented by a small triangle in the upper right corner of the respective step box Step Exit Action An exit action will be executed once when the step has got deactivated Notice however that this execution will not be done in the same but at the beginning of the subsequent cycle The action is associated to a step via an entry in the Step exit field of the step properties It 1s represented by an X in the lower right corner of the respective step box E SFC_PROG Configuration Bus X Properties A Xx PROGRAM SFC_PROG Y Filter F Sortby sortorder VAR Initialize BOOL END VAR Property Value Common row a Ri FP Name Step Comment Symbol Specific Initial step E Times Minimal active Maximal active
119. Value The template lt Value gt included in single quotes has to be replaced by one of the following values available SS ae Aligned i e there will be no memory gaps 1 byte aligned identical to aligned Se Sa 2 byte aligned i e the maximum size of a memory gap is 1 byte Tey 4 byte aligned i e the maximum size of a memory gap is 3 bytes se 8 byte aligned i e the maximum size of a memory gap is 7 bytes Table 5 6 Pack _mode Attribute 65 5 Programming Reference Example attribute pack mode a KLS TYPE YSL cos SL RUE Enable BOOL Counter INT MaxSize BOOL MaxSizeReached BOOL END STRUCT END TYPE A variable of data type myStruct will be instantiated aligned If the address of its component Enable is 0x0100 for example then the component Counter will follow on address 0x0101 MaxSize on 0x0103 and MaxSizeReached on 0x0104 With pack_mode 2 Counter would be found on 0x0102 MaxSize on 0x0104 and MaxSizeReached on 0x0105 Qualified_only Attribute After assigning the pragma attribute qualified_only on top of a global variable list its variables can only be accessed by using the global variable name e g gvl g_var This works even for variables of enumeration type and may be useful to avoid name mismatch with local variables Syntax ateri bute Guar Ped only Example Assume the following global variable list GVL with attribute qualified_only tattribute qualitied
120. a preparation with a value Release the force without modifying the value Release the force and restore the variable to the value it had before forcing it The selected action will be carried out on executing the menu command Force Values menu Online or pressing lt F7 gt Breakpoint Positions in ST Editor The user can set a breakpoint basically at those positions in a POU at which values of variables can change or at which the program flow branches out resp another POU is called In the following descriptions BP indicates a possible breakpoint position 160 6 Programming Languages Editors e Assignment At the beginning of the line Assignments as expressions define no further breakpoint positions within a line FOR loop before the initialization of the counter before the test of the counter and before a statement BP FOR 1 12 TO BP x BP BY 1 DO BP statement 1 BP statement 2 END_FOR e WHILE loop before the test of the condition and before a statement BP WHILE i lt 12 DO BP statement 1 BP statement 1 END WHILE e REPEAT loop before the test of the condition REPEAT BP statement 1 BP statement n 1 BP UNTIL i gt 12 END REPEAT e Call of a program or a function block At the beginning of the line e At the end of a POU When stepping through this position also will be reached after a RETURN instruction Breakpoint Display in ST 1 Z 1d11 e
121. abled or mode manual according the Figure 7 18 Pe ee Figure 7 18 Obtaining the Time Constant Figure 7 18 shows the obtaining of the time constant of the system using two different modes The most common is taken as the system time constant the time required for the system to reach 63 212 of the final value Another way 1s to plot the first derivative of the step response curve the time constant is the one where this line crosses the final value of the system response Once the time constant is defined you only need to define the sample interval as about one tenth of this value It is important to remember that on Nexto series the input and output update occurs on the same order of time of one cycle of the PLC Whenever the PLC cycle time is longer than the sample time it 1s advised to use the functions REFRESH INPUT and REFRESH OUTPUT Feedforward Bias Through the memory operand used to feedforward bias is possible to inject some system variable in the controller output and or apply a displacement on it The objective of the feedforward 1s to measure the main disturbs of the process and calculate the necessary change in the manipulated variable to compensate it before it cause changes on the process variable Can be mentioned as example a system where the variable to be controlled is the temperature of a hot mixture At some stage of the process is necessary to pour cold water in this mixture Without feedforward would be ne
122. advisable the use of an oscilloscope or other device that monitors the PV variation The step on MV should be large enough to cause a noticeable variation on PV The Figure 7 24 represents a step on the MV output applied at time tO and the response of a linear system of first order with dead time PVIDA PV Py PV E Fo s ffs Figure 7 24 Step in MV and System Response to Step Through Figure 7 24 all required constants for the determination of the controller parameters can be obtained The static gain of the process is obtained by varying the ratio between the process variable and the variation rate of manipulated variable that is 225 7 Libraries K _PV2 PVi MV2 MV The dead time Tm is the time between the application instant of the step on MV tO and the beginning of the system response The system time constant T 1s the time between the beginning of the system reaction and 63 212 of the final value of PV that is 0 63212 PV PV PV2 PV From the system constants K Tm and T controller parameters can be obtained using the formulas of the Table 7 12 Tipo de Controlador GP jE K Tr Tm dt 2 Ti T Td Tm 2 dt 4 Proporcional Integral e Derivativo PID Table 7 12 Controller Parameters Gains X Scales It is important to remember that the proportional gain only perform its action correctly when both the input and output of the system are using
123. ady have been assigned those primarily will remain as defined A network is the basic entity of a FBD or LD program In the FBD LD editor the networks are arranged in a vertical list Each network is designated on the left side by a serial network number and has a structure consisting of either a logical or an arithmetic expression a program function or function block call and a jump or a return instruction The IL editor due to the common editor base with the FBD and LD editors also uses the network element If an object initially was programmed in FBD or LD and then is converted to IL the networks will be still present in the IL program Vice versa if you start programming an object in IL 174 6 Programming Languages Editors you at least need 1 network element which might contain all instructions but you also can use further networks to structure the program for example if considering a conversion to FBD or LD A network optionally can get assigned a title a comment and a label The availability of the title and the comment fields can be switched on and off in the Options dialog tab FBD LD IL Editor If the option is activated you can open an edit field for the title by a mouse click in the network directly below the upper border For entering a comment correspondingly open an edit field directly below the title field The comment might be multi lined Linebreaks can be inserted via lt ENTER gt the input of the comment text
124. alues Therefore it is advisable to use the slave controllers with derivative action in function of the measured variable e Slave controller must be fast enough to eliminate the disturbs of its loop before they affect the loop of the master controller 222 7 Libraries Suggetions for Ajusts of the PID Controller Two methods for the determination of the constants of the PID controller are following presented The first method consists in determining the constants in function of the oscillation period and of the critical gain while the second one determines the controller constants in function of the time constant T of the dead time Tm and of the statistics gain of the system K For further details we recommend reading the referenced literature WARNING Altus Sistemas de Automac o S A is not responsible for any damage caused by configuration errors of the constants of the controller or parameterization It 1s recommended that suitably qualified person to execute this task Determination of Controller Constants Through the Period and the Critical Gain This method generates a damped response which damping rate is equal to one quarter That is after tuning a loop through this method it is expected a response as shown in Figure 7 21 Figura 7 21 Damped Response The critical gain is defined as the gain of a proportional controller that generates an oscilation with constant amplitude on the closed loop system while the cri
125. ame output values even if done with identic arguments Examples for accessing function block variables Assume function block fb has an input variable in1 of the type INT See here the call of this variable from within program prog Declaration and implementation in ST PROGRAM PROG VAR TNS ELIEB RE oe CNT END VAR INST1 IN1 22 fb is called and input variable inl gets assigned value 22 INST1 fb is called this is needed for the following access on the output variable 24 3 Concepts and Basic Components RES FBINST OUTL output variable of fb is read Example in FBD instl fh 2 irl outl Ces Assigning Parameters at Call In the text languages IL and ST you can set input and or output parameters immediately when calling the function block The values can be assigned to the parameters in parentheses after the instance name of the function block For input parameters this assignment takes place using just as with the initialization of variables at the declaration position for output parameters gt is to be used In this example a timer function block instance CMD_TMR is called with assignments for the parameters IN and PT Then the result variable Q is assigned to the variable A The result variable is addressed with the name of the function block instance a following point and the name of the variable CMD TMR IN 1X5 0 PT 300 A CMD TMR Q If the instance
126. amed sfcl containing a step s2 which has time limits defined in its step attributes See the attributes displayed below in Figure 6 34 If for any reason the step s2 stays active for a longer time than allowed by its time properties time overflow a SFC flag will be set which might be read by the application In order to allow this access declare the flag in the SFC Settings dialog For this purpose select sfcl in the Devices POUs window and choose command Properties from the context menu Open sub dialog SFC Settings and there on tab Flags set a checkmark each in column Declare and Use for flag SFCError Solely declaring would make the variable visible in the online view of the sfcl declaration part but it would be without function Properties AS_EXAMPLE Device PLC Logic Application Build Access SFC Settings Bitmap 00 Flags Use Variable Declare Description F SFCInit F All steps and actions are reset The init s SFCReset All steps and actions are reset Theinit s SFCError a Gets TRUE if a time check failed SFCEnableLimit Enable time check on steps SFCErrorStep Contains the name of the step that causi SFCErrorPOU Contains the name of the POU that cause Figure 6 34 SFC Settings Now you can read SFCError within the SFC for example in an action via SFCError or from another POU via sfcl SFCError 146 6 Programming Languages Editors 1 PROGRAM Ma
127. an be opened explicitly by command Auto Declare which by default is available in the Edit menu or by lt SHIFT gt lt F2 gt If an already declared variable is selected before its declaration can be edited in the dialog Shortcut Mode The declaration editor as well as other text editors where declarations are done supports the shortcut mode This mode is activated when you end a line of declaration with lt CTRL gt lt ENTER gt and allows to use shortcuts instead of completely typing the declaration 47 5 Programming Reference The following shortcuts are supported e All identifiers up to the last identifier of a line will become declaration variable identifiers e The type of declaration is determined by the last identifier of the line In this context the following will apply lor INT Results in INT R or REAL Results in REAL o Sorstring Results in STRING Table 5 2 Declaration Type e Ifnotype has been established through these rules automatically BOOL is the type and the last identifier will not be used as a type Every constant depending on the type of declaration will turn into an initialization or a string An address as in MD12 is extended by the AT attribute A text after a semicolon becomes a comment All other characters in the line are ignored Example o Shono Declaration pA ESE a ABleo A BINT 23 ST S 2 string A ST STRING 2 String A X MD12 R 5 Real number X AT MD12 REAL
128. and the value of the real number is out of the value range of that integer the result will be undefined and will depend on the target system Even an exception is possible in this case In order to get target independent code handle any range exceedance by the application If the REAL LREAL number is within the integer value range the conversion will work on all systems in the same way Notice at a conversion to type STRING that the total number of digits is limited to 16 If the REAL LREAL number has more digits then the sixteenth will be rounded If the length of the STRING is defined to short it will be cut beginning from the right end When you perform a type conversion from a larger to a smaller type you risk losing some information Example in ST i REAL TO INT 1 5 Result is 2 j REAL TO INT 1 4 Result is 1 i 5 REAL TO sai 9 Result is 2 J BEAL TO INld 1 4 7 Result ig L Example in IL LD Aa REAL TO IHT oT 1 Example in FBD LREAL TO IHT La 1 TIME_TO TIME_OF_DAY Conversions IEC Operator from the variable type TIME or TIME _OF_DAY to a different type Syntax for the conversion operator lt TIME data type gt TO lt Data type gt The time will be stored internally in a DWORD in milliseconds beginning with 12 00 A M for the TIME OF_DAY variable This value will then be converted When you perform a type conversion from a larger to a smaller type you risk losing some in
129. ands The following can be used as an operand e Constant BOOL TIME DATE TIME OF DAY DATE_AND_TIME number REAL LREAL STRING Typed Literals e Variable e Addresses e Functions Constants BOOL Constants BOOL constants are the logical values TRUE and FALSE See also BOOL Standard Data Types TIME Constants TIME constants are generally used to operate the standard timer modules Besides the time constant TIME which is of size 32 Bit and matching the IEC 61131 3 standard LTIME is supported as an extension to the standard as time base for high resolution timers LTIME is of size 64 Bit and resolution nanoseconds Syntax for TIME constant t lt Time declaration gt Instead of t also the following can be used T time TIME The time declaration can include the following time units These must be used in the following sequence but it is not required to use all of them d days h hours m minutes s seconds ms milliseconds Examples of correct TIME constants in a ST assignment 66 TIME1 T 14ms TIME 1 T 100S12ms The highest component may be allowed to exceed its Limite 115 5 Programming Reference TIME t 12h34m15s The following would be incorrect TIME1 lt t 5m68s Limit exceeded in a lower component TIME1 15ms TF is missing TIME1 t 4ms13d Incorrect order of entries Syntax for LTIME constant LTIMF lt Time
130. arBooLl LOAD VYarBooLe PY YarWORD1 CV gt VarWORDzj LD CTDinst Q ST var BODL Example in FBD CTDinst WarB00L1 WarB00L3 YarBoole CYF VarWoRDe YarWORD1 Example in ST CTDInst CD VarBOOL1 LOAD VarBOOL2 PV VarWORD1 VarBOOLS CIDInst 0 VarWORD2 CTDInst CV Provided by standard library Function block working as incrementer and decrementer Inputs CU BOOL if a rising edge occurs at CU incrementing of CV will be started CD BOOL if a rising edge occurs at CU decrementing of CV will be started RESET BOOL If TRUE CV will be set to 0 LOAD BOOL if TRUE CV will be set to PV PV WORD upper limit for incrementing or decrementing CV Outputs QU BOOL returns TRUE when CV has been incremented to gt PV QD BOOL returns TRUE when CV has been decremented to 0 CV WORD gets incremented or decremented Declaration example CIUBLASE CUID 195 Timer TP 7 Libraries Example in IL CAL CTUDinstl CU YarB00Ll FESET Yar DOLS LO amp AD YarBo00L4 PY arWORD1 D YarBO00L6 EY gt VarWO RDe LD CTUDinst QU ST VarBO00L5 Example in FBD CIUDInst VYVarBooLl VarBO0L5 VarBooL2 VarBO0L6 VarBooL3 VarwoR Dz VarBooLd VarWORD1 Example in ST CTUDInst CU VarBOOL1 CD VarBOOL2 RESET VarBOOL3 LOAD VarBOOL4 PV VarWORD1 VarBOOL5 CTUDInst Qu VarBOOL6 CTUDInst OD VarINTL CFUDInst Cv Provided by standard library Ti
131. arate line or in with supplementary text in an implementation or declaration editor line Within the FBD LD IL editor use the command nsert label and replace the default text Label in the arising text field by the pragma In case you want to set a label as well as a pragma insert the pragma first and the label afterwards The pragma instruction is enclosed in curly brackets upper and lower case are ignored lt Instruction text gt The opening bracket can immediately come after a variable name Opening and closing bracket must be in the same line Depending on the type and contents of a pragma the pragma either operates on the line in which it is located or on all subsequent lines until it is ended by an appropriate pragma or until the same pragma is executed with different parameters or until the end of the file is reached A file in this context is a declaration part implementation part global variable list or type declaration If the compiler cannot meaningfully interpret the instruction text the entire pragma is handled as a comment and read over A warning will be issued in this case See the following pragma types e Message pragmas e Attribute pragmas e Additional pragmas Message Pragma Message pragmas can be used to force the output of messages in the Messages window during the compilation build of the project The pragma instruction can be inserted in an existing line or in a separate line in the text editor o
132. ariables Parl and Par2 are O and TRUE respectively CAL INSI PARI 0 PAR2 TRUE Type Conversion Functions It is forbidden to implicitly convert from a larger type to a smaller type for example from INT to BYTE or from DINT to WORD One can basically convert from any elementary type to any other elementary type Syntax lt clemt tyol gt TO Selena 1 yo2 Please notice that at TO_STRING conversions the string is generated left justified If it is defined to short it will be cut from the right side The following type conversions are supported 101 5 Programming Reference BOOL_TO Conversions TO_BOOL Conversions Conversion between integral number types REAL_TO LREAL_TO Conversions TIME_TO TIME_OF_ DAY Conversions DATE_TO DT_TO Conversions STRING_TO Conversions TRUNC conversion to DINT TRUNC_INT ANY_NUM_TO_ lt numeric datatype gt ANY_TO_ lt any datatype gt Conversions BOOL_TO BOOL_TO Conversions IEC Operator Converting from type BOOL to any other type Syntax for a BOOL_TO conversion operator BOOL TO Data Lype For number types the result is 1 when the operand is TRUE and 0 when the operand is FALSE For the STRING type the result is TRUE when the operand is TRUE or FALSE when the operand is FALSE Examples in IL LD TRUE BOOL TO IHT ST 1 Result is 1 LD TRUE BOOL TO STRI ST SEIE Result is TRUE LD TRUE BOOL TO TIME ST t Result is T 1 ms LD TRUE BOOL TO
133. ary of the range that is 4095 The same applies to function CheckRangeUnsigned NOTE If neither of the functions CheckRangeSigned or CheckRangeUnsigned is present no type checking of subrange types occurs during runtime In this case variable 1 could get any value between 32768 and 32767 at any time ATENTION The use of the functions CheckRangeSigned and CheckRangeUnsigned may result in an endless loop for example if a subrange type is used as increment of a FOR loop that does not match the subrange Example of an endless loop VAR Ua LENE Os LOOOO gt END VAR POR u1 0 TO 10000 DO END FOR The FOR loop will never be left as the check function prevents the variable ul to be assigned to values greater than10000 Operators IEC Operators and Norm Extending Functions MasterTool IEC XE supports all IEC operators In contrast to the standard functions these operators are recognized implicitly throughout the project Besides the IEC operators also the following operators are supported which are not prescribed by the standard ANDN ORN XORN INDEXOF and SIZEOF see Arithmetic Operators ADR BITADR and content operator see Address Operators some Scope Operators Operators are used like functions in a POU 85 ADD 5 Programming Reference See the following categories of operators O O O O O 0 0 O O 0 O 0 Arithmetic Operators Assignment Operators MOVE Arithmetic Operators
134. at is elements are inserted each at the current cursor position via the nsert command by default available in the FBD LD IL menu The Cut Copy Paste and Delete commands by default available in the Edit menu can be used to arrange elements See below to the tabular editor is structured and how you can navigate through it using complex operands calls and jumps Structure of the do IL Tabular Editor Each program line is written in a table row structured in fields by the following table columns 1 Operator This field contains the IL operator LD ST CAL AND OR etc or a function name In case of a function block call here also the respective parameters are specified in this case in the Prefix field or gt must be entered Operand This field contains exactly one operand or a jump label If more than one operand is needed multiple extensible operators AND A B C or function calls with several parameters those must be written into the following lines where the operator field is to be left empty In this case add a parameter separating comma In case of a function block program or action call the appropriate opening and or closing brackets must be added Address This field contains the address of the operand as defined in the declaration part The field cannot be edited and can be switched on or off via option Show symbol address Symbol comment This field contains the comment as defined for the operand in the
135. at is the largest not structured datatype used in the referenced variable the data type of 1Gran must be integer compatible e bWrite type of access TRUE write access FALSE read access the data type of bWrite must be BOOL e Return value Address which is used for dereferencing the pointer thus at best the one that has been passed on as the first input parameter ptToTest References This data type is an extension to the IEC 61131 3 standard A REFERENCE is an alias for an object The alias can be written or read via identifiers The difference to a pointer is that the value pointed to is directly affected and that the assignment of reference and value is fix The address of the reference must be set via a separate assignment operation Whether a reference points to a valid value that is unequal 0 can be checked with the help of a special operator see below A reference is declared according to the following syntax Syntax lt Identifier gt REFERENCE TO lt DATA TYPE gt Example declaration ref int REFERENCE TO INT a4 INT by a ENT The ref_int is now available for being used as an alias for variables of type INT Example of use tel ine REPS ay EST nt es non porn oa Perini 2S ue A a does Tow dave ch Value 12 DIS wet INE zo de Dades now have Che Value 26 7 rer Int REPS iby Aref tnt does now point to Per ant sea Ze Mee de 16 ter Ane REPS Ue MARX DEV Treiali ation On Nes
136. ation lt Category Common lt Subcategory O NextoStandard 1144 lt Company m 1 0 0 0 Y Name of library Hl 5 Version Dl standard 4 System Always newest version 3 Standard System 3 Util system Control J Diagnostics ds Network W Group by category Display all versions for experts only Details Find AAA Figure 4 1 Add Library Dialog All Versions Here all libraries currently installed on your system will be listed You can filter the display by setting a certain providing Company from the selection list All companies will list all available libraries If option Group by Category is activated the libraries of the currently set company will be listed according to the available categories otherwise alphabetically If the grouping by categories is activated the categories appear as nodes and for the currently selected category the libraries or further categories will be displayed indented below Choose the desired library If option Display all versions for experts only is activated all installed version s of the libraries appear s indented below the currently selected library entry Additionally to the explicit version identifiers each a is available which means latest version In this case you can choose among the versions By default however this option is deactivated and only the latest version will be displayed In this case a multiselection of libraries is possible Keep th
137. ation code the function block is already initialized via the implicit initialization code In online change the previous values will overwrite the initialization values On the call sequence in case of inheritance please see FB_Exit Regard also the possibility of defining a function block instance method to be called automatically after initialization via FB_init attribute call_after_init Interface of the Init Method METHOD fb init BOOL VAR INPUT binitRetains gt BOOL LE TRUE the retain varrables are initialized warm start cold start bInCopyCode BOOL If TRUE the instance afterwards gets moved into the copy code online change END VAR The return value is not interpreted NOTE Notice also the possible use of an exit method and the resulting execution order See FB_Exit 55 5 Programming Reference User Defined Input FB_Reinit FB Exit In an init method additional inputs can be declared Those must be assigned at the declaration of a function block instance Example for an init method for a function block serialdevice METHOD fb init BOOL VAR INPUT BEATERetalns lt BOOL lnitrali zation of retains bInCopyCode BOOL Instance moved into copy code nCOMnum INT Additional input number of the COM interface to listen ato END VAR Example for declaration of function block serialdevice COM1 serialdevice nCOMnum 1 COMO serialdevice nCO
138. ators which are not part of the 61131 3 standard ExST Set Operator S The value will be set that is if once set to TRUE will remain TRUE Example 153 6 Programming Languages Editors a S b CG 99 Operand a gets the value of b if once set to TRUE it will remain true even if b gets FALSE again Reset Operator R The value will be reset that is if once set to FALSE it will remain FALSE Example a R b Operand a gets set to FALSE when B TRUE NOTE Notice the behavior in case of a multiple assignment All Set and Reset assignments refer to the last member of the assignment Example A S b R fun1 par1 par2 In this case B gets the reset output value of funl But a does not get the set value of b but gets the set output value of funl Notice that an assignment can be used as an expression Calling Function Blocks in ST A function block FB is called in Structured Text according to the following syntax Syntax lt name of instance gt FB input variable lt value or address gt lt further FB input variable lt value or address gt further FB input variables Example In the following example a timer function block TON is called with assignments for the parameters IN and PT Then result variable Q is assigned to variable A The timer FB is instantiated by TMR TON The result variable as in IL is addressed according to syntax lt FB instance na
139. b6eZ 5 The return value of the function fun will be written to the e g locally declared variables loc and loc2 Input and Output Variables VAR_IN_OUT Between the key words VAR_IN_OUT and END_VAR all variables are declared that serve as input and output variables for a POU NOTE With variables of this type the value of the transferred variable is changed transferred as a pointer call by reference That means that the input value for such variables cannot be a constant For this reason even the VAR_IN_ OUT variables of a function block cannot be read or written directly from outside via lt function block instance gt lt in output variable gt Example VAR IN OUT EINOGECLSINT e Ls Input and Output veras le END_VAR Global Variables VAR_ GLOBAL Normal variables constants external or remanent variables that are known throughout the project can be declared as global variables NOTES A variable defined locally in a POU with the same name as a global variable will have priority within the POU Global variables always will be initialized before local variables of POUs The variables have to be declared locally between the keywords VAR_GLOBAL and END_VAR Regard the possibility of adding an attribute to VAR_GLOBAL A variable is recognized as a global variable by a preceding dot for example iGlobVar1 For detailed information on multiple uses of variable names the global scope operator and name spac
140. beginning of the action list of the step resp an action list for the step will be created e Incompatible elements when cutting copying If an associated action list and additionally an element which is not the step to which the action list belongs are selected a message box will appear The current selection contains incompatible elements No data will be filed to the clipboard The selection will not be stored and you cannot paste or copy it somewhere else e Incompatible elements when pasting If you try to paste an action list while the currently selected element is not a step or another association an error box will appear The current clipboard content cannot be pasted at the current selection If you try to paste an element like a 134 6 Programming Languages Editors step branch or transition when currently an associated action list is selected the same message box will appear Delete Elements Select the element s and use command Delete or the lt DEL gt key Notice the following e Deleting a step also deletes the associated action list e Deleting the init step automatically sets the following step to be the initial one that is option Initial step will be activated in the properties of this step e Deleting the horizontal line preceding a branched area will delete all branches e Deleting all particular elements of a branch will delete the branch SFC Element Properties The properties of a SFC e
141. bove is given in a program PROGRAM MainPrg VAR Llosrovarls Locos LlocioVvarzz Locos END VAR 54 5 Programming Reference Then a corrected variable configuration would look this way VAR_CONFIG MainrPro lOC1LOVarl xlOCIM AT ie cO BOOL MalunBrg locuovar lo xLo c outo ALT 2OxX020 4 BOOL MainPrg lOcioOVarZ2 xLOCIn Al SIXL 0 BOOL Main ro Lociovarz xLocout AT 2Ox0 3 BOOL END VAR NOTE Changes on directly mapped I Os are immediately shown in the process image whereas changes on variables mapped via VAR_CONFIG are not shown before the end of the responsible task Declaration and Initialization of User Defined Data Types Besides the standard data types also user defined types might be used For information on declaration and initialization see the pages on Data Types and User Defined Data Types FB Init FB_Reinit Methods FB_Init The method FB_init replaces the INI operator It is a special method for a function block which can be declared explicitly but also and in any case is available implicitly Thus in any case it can be accessed for each function block The init method contains initialization code for the function block as declared in the declaration part of the function block If the init method is declared explicitly the implicit initialization code will be inserted into this method The programmer can add further initialization code NOTE When execution reaches the user defined initializ
142. c data type the output variable must be type REAL or LREAL Example in IL LD ACOS oT Result in q is 1 0472 Example in ST q ACOS 0 5 Example in FBD ACOS 0 5 a IEC Operator Returns the arc tangent inverse function of tangent of a number The value is calculated in arch minutes The input variable can be of any numeric basic data type the output variable must be type REAL or LREAL Example in IL LD ATAN oT Result in q is 0 463648 Example in ST q ATAN 0 5 Example in FBD IEC Operator Exponentiation of a variable with another variable ee lt The input variable can be of any numeric basic data type the output variable must be type REAL or OUT IN1IN2 LREAL Example in IL LD EXPT oT Result is 49 Example in ST varl EXPT 7 2 3 Example in FBD varl 113 5 Programming Reference 7 Yarl IEC Extending Operators Additionally to IEC operators the MasterTool IEC XE supports the operator __ ISVALIDREF __ISVALIDREF This operator is not required by IEC 61131 3 It can be used to verify if the reference points to a valid value To obtain information about its usage and examples see Check For Valid References Norm Extending Scope Operators In extension to the IEC operators there are several possibilities to disambiguate the access to variables or modules if the variables or module name is used multiple times within the scope of a project To defin
143. can also be applied on a variable assignment Figure 5 9 Example in CFC in Conjunction with the EN ENO Function Only if en_1 is TRUE varl will be assigned to var2 Example in IL LD varl HOVE ST vara Result is var2 gets value of var You get the same result with LD varl ST Varese Example in ST ivar2 MOVE ivarl The same result with ivar2 ivarl This arithmetic operator is not prescribed by the standard IEC 61131 3 89 INDEXOF 5 Programming Reference It can be used to determine the number of bytes required by the given variable x The SIZEOF operator returns an unsigned value The type of the return value will be adapted to the found size of variable x Return value of SIZEOF x Data type of the constant implicitly used for the found size O lt size of x lt 256 USINT 256 lt size of x lt 65536 UINT 65536 lt size of x lt 4294967296 UDINT 4294967296 lt size of x ULINT Table 5 11 SIZEOF Operator Example in ST VAR arr1 ARRAY 0 4 OF INT Var ils LNT end var varl SIZEOF arri dhs varl USINTFLOS Example in IL LD arrl SIZEOF ST Varl Result is 10 This arithmetic operator is not prescribed by the standard IEC 61131 3 Perform this function to find the internal index for a POU Example in ST varl INDEXOF POU2 Bitstring Operators AND The following bitstring operators are available matching the IEC1131 3 standard AND OR XOR NOT
144. ce Example The function block POU is provided with all necessary attributes attribute reflection FUNCTION BLOCK POU VAR OUTPUT attribute no IRTE attribute instance path MISTER ENG END_VAR Within the main program MainPrg an instance fb of the function block POU is defined PROGRAM MAINPRG VAR TOS POU newString STRING END_VAR newString fb myStr The variable myStr will be initialized with the current namespace e g Device Application MainPrg fb This value will be assigned to newString within the main program Init_on_onichange Attribute The pragma attribute init_on_onlchange attached to a variable will cause this variable to get initialized with each online change Syntax Vat Cis pute Init on Oonlehange gt Instance path Attribute The pragma attribute instance path may be added to a local string variable that in consequence will be initialized with the device tree path of the POU this string variable belongs to This may be a useful feature for error messages Applying this pragma presumes the use of the attribute reflection for the corresponding POU and the additional attribute noinit for the string variable Syntax attribute instance path Example Assume the following function block being equipped with the attribute reflection attribute reflection FUNCTION BLOCK POU VAR attribute instance path attribute noinit Str so lR LNG
145. cessary to wait until the cool water changes the state of the mixture and then the controller generates the corrective action Using feedforward a value associated to the temperature of cool water would be injected on the controller output making it takes corrective action before the cool watre starts changing the state of the hot mixture improving the controller response The bias is used whenever it is desired to apply some displacement on the controller output 221 7 Libraries Cascade Control Probably the cascade control is one of the most advanced control techniques used in practice It 1s composed by at least two control loops The Figure 7 19 shows a cascade controller with two loops Figure 7 19 Cascade Control with Two Loops The external loop is called master controller and internal loop is the slave controller The master controller has its set point fixed and its output provides the set point of the slave controller MV 1 The manipulated variable of the slave controller MV 2 operate on the process 2 which will operate on the process 1 closing the loop of the master controller This type of controller is applied for example on the temperature control by the steam injection Besides the temperature variation that must be controlled the system is subject to pressure variations on the steam line It 1s therefore desirable a slave flow controller acting as in function of pressure variations and a master controller to man
146. cfc_prog handles an instance of function block fubblo2 which has an output variable fbout of type of a structure strul By using the Selector element the structure components can be accessed Structure strul definition TYPE strul STRUCT ivar INIT Strvar STRING hallo END STRUCT END TYPE Function block fublol declaration and implementation FUNCTION BLOCK FublLoz VAR INPUT CONSTANT Ebinl LNT gt fbin2 DWORD 24354333 fbin3 STRING hallo0 END_VAR 127 6 Programming Languages Editors VAR INPUT froin INT END VAR VAR OUTPUT fooul strul fbout2 DWORD END VAR VAR tvar INT Foyvarz STRING END VAR Program cfc_prog declaration and implementation VAR intva ar INT stringvar STRING Oins is Tublols ergl INT erg2 STRING Eoinsctz TuUploz END VAR Selector Function Block with output fbout of type strut Figure 6 8 Selector Example Insert and Organize Elements Inserting Selecting The elements available for programming in the CFC Editor are provided in a Toolbox which by default is available in a window as soon as the CFC editor is opened The CFC Editor Options define general settings for the working within the editor To insert an element select it in the Toolbox by a mouse click keep the mouse button pressed and draw the element to the desired position in the editor window During drawing the cursor will be displayed as an arrow plus an rectangle and a plus
147. check function will be opened in the editor corresponding to the implementation language selected Independently of that choice the declaration part is preset and may not be modified except for adding further local variables However in contrast to other check functions there is no default implementation of CheckPointer available the implementation is left to the user Function CheckPointer should check whether the address the pointer refers to is within the valid memory range In addition it should be taken care of that the alignment of the referenced memory area fits to the data type of the variable the pointer points to If both conditions are fulfilled 77 5 Programming Reference CheckPointer should return the unchanged input pointer A proper handling of detected error cases is left to the user Template Declaration part Jj Implicitly generated code DO NOT EDIT FUNCTION CheckPointer POINTER TO BYTE VAR INPUT ptTotest lt POINTER TO BYTE Lo me DINI Gran lt DINT bWrite BOOL END VAR Implementation part No standard way of implementation Fill your own code here CheckPointer ptToTest When called the function gets the following input parameters e ptToTest Target address of the pointer e iSize Size of referenced variable the data type of Size must be integer compatible and must cover the maximum potential data size stored at the pointer address e iGran Granularity of the access th
148. ches can be transformed to each other by the commands Parallel and Alternative This might be useful during programming Automatically a branch label is added at the horizontal line preceding the branching which is named Branch lt n gt whereby n is a running number starting with O zero This label can be specified when defining a jump target Figure 6 28 Parallel Branch 141 6 Programming Languages Editors Alternative Branch Jump Symbol Po An alternative branch must begin and end with a transition Alternative branches can contain parallel branches and other alternative branches The horizontal lines before and after the branched area are simple lines If the step which precedes the alternative beginning line 1s active then the first transition of each alternative branch will be evaluated from left to right The first transition from the left whose transition condition has value TRUE will be opened and the following steps will be activated Alternative branches are inserted via command Insert branch right when a transition is currently selected The horizontal lines before and after the branched area are simple lines Notice that parallel and alternative branches can be transformed to each other by the commands Parallel and Alternative This might be useful during programming Figure 6 29 Alternative Branch Symbol Te A jump is represented by a vertical connection line plus a horizontal arrow and the
149. cles in seconds used for calculating the derivative action Maximum value of the effective time of sampling in seconds since MEDIDO ls startup of the PID block Minimum value of the effective time of sampling in seconds since ON REAL startup of the PID block CON OOP WDND Error code displayed by the PID block To remove it just solve the problem and restart the block via the variable Restart In the following the error description 0 without error MaxMV lt MinMV MaxPV lt MinPV PV gt MaxPV ErrorCode UINT PV lt MinPV Ti lt 0 001 s with integral action enabled Td lt 0s with derivative action enabled Gp lt 0 MaxVarMV lt 0 9 DeadBand lt 0 10 SampleTime lt 0 001 s or SampleTime gt 1000 s with MeasureST false Table 7 10 Output Parameters Application Notes Selection of Sample Time The efficiency of the digital controller is directly related to the sample interval used As this interval decreases the result of the digital controller is close to the result of an analog controller It is advised to use a sample time of the order of one tenth of the time constant of the system that is TA T 10 where TA is the sample time used and T is the time constant of the system 220 7 Libraries Example The time constant of a first order system can be obtained from its response graph of the manipulated variable MV to one step in the setpoint SP with open loop control PID dis
150. ct Action when the respective program or function block object is selected in the Devices or POUs tree In the Add Action dialog define the action name and desired implementation language Calling an Action An action 1s called with lt PROGRAM NAME gt lt ACTION NAME gt OU lt INSTANCE NAME gt lt ACTION NAME gt Regard the notation in FBD see example below If it is required to call the action within its own block 1 e in the program or function block it belongs to it is sufficient to just use the action name Examples for the call of the above described action from another POU Declaration for all examples PROGRAM MAINPRG VAR INST COUNTER END VAR Call of action Reset in another POU which is programmed in IL CAL INST RESET IN FALSE LD INSTE QUE ST ERG Call of action Reset in another POU which is programmed in ST INST RESET IN FALSE ERG 3 INST OUT Call of action Reset in another POU which is programmed in FBD inst counter reset FALSE In out ery NOTE The IEC standard does not recognize actions other than actions of the sequential function chart SFC In there actions are an essential part containing the instructions to be processed at the particular steps of the chart 30 3 Concepts and Basic Components External Function Function Block Method For an external function function block or method no code will be generated by the programming system Perform the fo
151. ction operations can also be performed with variables For purposes of clarity we will limit our examples to the following which use constants as operators SEL MAX MIN LIMIT MUX IEC Selection Operator Binary Selection G determines whether INO or IN1 is assigned to OUT OUT SEL G INO IN1 OUT INO If G FALSE OUT IN1 If G TRUE Allowed data types INO IN1 and OUT any type G BOOL Example in IL LD TRUE SEL 3 4 ST Warl Result is 4 LD FALSE SEL 3 ST varl Result is 3 Example in ST Varl SEL TRUE 3 4 Result is 4 Example in FBD TRUE Warl E 4 IEC Selection Operator Maximum function Returns the greater of the two values OUT MAX INO IN1 95 MIN LIMIT 5 Programming Reference INO IN1 e OUT and OUT can be any type of variable Example in IL LD 90 HAX 30 HAX 40 MAX Tt sT Yarl Result is 90 Example in ST Varl MAX 30 40 Result is 40 Varl MAX 40 MAX 90 30 Result is 90 Example in FBD IEC Selection Operator Minimum function Returns the lesser of the two values OUT MIN INO IN1 INO IN1 and OUT can be any type of variable Example in IL LD 90 MIH 30 MIH 40 HILH qi ST varl Result is 30 Example in ST Varl MIN 90 30 Result is 30 Varl MIN MIN 90 30 40 Result is 30 Example in FBD varl IEC Selection Operator limits OUT LIMIT Min IN Max Which can be written as OUT M
152. d ies 31 Global Variable List Vlad iia 31 Persistente Varia DCS ia ee tau 31 I Xte ria Pile nadia 32 COUS Tora HECHAS a e OS 33 Library bie A ccecccensavaccessasceweeaasecoeececcocensesacsesusscauveacvecsecceccoueunaacsesussceusesevescceconrens 33 Installing and Including on Project a baii 34 safe We Yc dD E ae na mene RE ainia tia 34 Library N SU OUYS oh a ga sn ale a 34 Unique Access to Library Modules or Variables ii A cd a ee ea 35 Creatine Libraries Encoding DOCUMENTATION ias 35 4 WENO COMMANDS siceseccsnsvicssccensiis casevacccapenseacteeuaccesnssatacscvaasecssevsvadlssuecsassssatiesssocddssuseadtadiesusssesssasvecssncassoesine 37 PAD Pak y Min aer iaa 37 Library Minas C ommand ice 37 Add LID ion ias 37 A S a O 40 aro AA II Rem cCron meter 4 5 PROGRAMMING REFERENC E siise eaeou eeo nea e Eae aoee occas 42 Declara Ona eaea OOE eE ESE 42 Vanables Dech aoaea as 42 Recommendations on the Naming of the IdentiflerS ooooooooonnnnncnnnnnnnnnnnnnnnononononononcnnnnnnnnnnnnnnnnnonnnnnnos 43 Variables ON a io na ey Oe 46 Arbitrary Expressions For Variable Initialization oooooooooononnnccnncnnnnnnnnnnnnonononononnnnnnnnnnnnnnnnnnnnnnnonnnnnnos 47 DeciataHOR E AI AS ACC oe Ce IA Frere enh oC ed Caren ee ety fre cnn Teen 47 a claro alot iii 4 MOCE O E olaaa ccoo ao 4 ALDEA o ed 48 Fy VOUS ec eee a sak gta dd 49 Local Variables MAR nadadora adas 49 laput Variables VAR INPUT 00 ida iii 49 OUT BUG Varia Dles
153. d area as shown in the following pictures e If the cursor is positioned on a text this will be displayed blue shaded and can be edited The button is available for opening the nput Assistant Primarily after having inserted an element 277 is displayed and must be replaced by a valid identifier T ei T 13 m inst TON IN E Enter pour comment here gt AE PT ET Figure 6 3 Possible Cursor Positions and Two Examples of Selected Texts e Ifthe cursor is positioned on the body of an element box input output jump label return comment this will be displayed red colored and can be moved by moving the mouse met met TON Gl TON a IH F IE LJ FT EJ PT E ET ete E Sum 4 Figure 6 4 Possible Cursor Positions and Example of a Selected Body e If the cursor is positioned on an input or output connection of an element this will get displayed red colored and can be negated or set reset 124 6 Programming Languages Editors Figure 6 5 Possible Cursor Positions and Examples of selected Output and Input Positions CFC Elements Toolbox The graphical elements available for programming in the CFC editor window are provided by a toolbox The toolbox can be opened in a view window by command Toolbox which by default is in the View menu ToolBox Dd X CFC he Pointer Input Output JF Box Ha Jump Label lt gt Return J Composer TE Selector a Comment 3 Input Pin F Output Pin
154. d feature sets chosen by the user are Professional or the option Enable repository dialog is enabled For further information about features see Features in the MasterTool IEC XE User Manual MU299609 The tab Placeholder is dedicated to the following two use cases e Creation of a target independent project e Creation of a library project lt library_xy gt which references another library that is meant to be target specific that 1s device specific Placeholder Within Project If a project shall be designed as compatible for multiple interchangeable target devices the target specific libraries have to be included within the library manager of the project via placeholders As soon as the target device gets specified the placeholders will be cast according to the related device description Even if no device description is actually available the placeholders allow the project to pass a syntactical check To include a library into the library manager via a placeholder the library has to be selected within the bottom part Default library of sub dialog Placeholder Thereby it is possible to constrict the catalogue of proposed libraries according to the providing company In addition the placeholder name has to be inserted in the associated edit field To ensure correct insertion of the name you might use the selection list offering all placeholder names currently defined in device descriptions Placeholder Within Library Project
155. d in a POU it gets value 1 at first and value 2 a second time IF has value test 1 The following code line will be processed when variable test has value 1 xi X 1 ELSIF has value test 2 The following code line will be processed when variable test has value 2 Xi X 2 END_IF NOT operator Inverts the value of the operator Example Precondition In a scenario the CheckBounds function was added to the project and 70 AND operator OR operator 5 Programming Reference not in another there is the POU MainPrg in both cases In a POU there is the following code IF defined pou MainPrg AND NOT defined pou CheckBounds The following line of code will only be processed in the scenario where there is not a CheckBounds function bAndNotTest TRUE END_ IF Is TRUE if both operators are TRUE Example Precondition In a scenario the CheckBounds function was added to the project and not in anothe the POU MainPrg there is in both cases In a POU there is the following code IF defined pou MAINPRG AND defined pou CheckBounds The following line of code will only be processed in the first scenario because only there MainPrg and CheckBounds are defined bAndTest TRUE END_ IF Is TRUE if one of the operators are TRUE Example Precondition In a scenario the CheckBounds function was added to the project and not in another the POU Main
156. der any modifications in the declaration part of the persistent variables list and the effect of the resultantly requested re initialization New declarations only can be added at the end of the list At a download those will be detected as new and will not demand a re initialization of the complete list Legend of the behavior Value gets maintained x and Value gets initialized Situation Behavior After online command VAR VAR RETAIN VAR PERSISTENT VAR RETAIN PERSISTENT VAR PERSISTENT RETAIN Reset warm Cea T x IS ee Reset cold C a C es ee Resetorigin Tooo o o Download lt application gt _ _ __ ___ __ ____x_______ Online Change X X X lt application gt Reboot PLC Oe US AE TSE A SA Table 5 4 Behavior of Remanent Variables Constants Constants are identified by the key word CONSTANT They can be declared locally or globally Syntax VAR CONSTANT lt TdentitLer gt lt Tyoe gt lt inttie lizar Lon gt END VAR Example VAR CONSTANT E ICON LN L 27 oy Constantius END VAR See the Operands description for a listing of possible constants See there also regarding the possibility of using typed constants Typed Literals Basically in using IEC constants the smallest possible data type will be used If another data type must be used this can be achieved with the help of typed literals without the necessity of explicitly declaring the constants For this the constant will be provid
157. ds that is the time intervals between the rising edges over which the average frequency of the input signal should be calculated 1 to 10 RESET BOOL Reset of all parameters to 0 Table 7 7 Input Variables FREQ MEASURE Output Variables Data Type REAL Resulting frequency in Hz VALID BOOL FALSE until the first measure has been finished or if the period gt 3 OUT indicating something wrong with the inputs Table 7 8 Output Variables FREQ MEASURE GEN Provided by util library The function generator generates typical periodic functions Example of GEN in CFC gen inst gen mode LOut b Rase tPeriod Cycles inp 1 bReset 7 Libraries MODE describes the function which should be generated whereby the enumeration values TRIANGLE and TRIANGLE_POS deliver two triangular functions SAWTOOTH_RISE an ascending SAWTOOTH_FALL a descending sawtooth RECTANGL E a rectangular signal and SINE and COSINE the sine and cosine 210 7 Libraries Amplitude TRIANGLE TRIANGLE POS Figure 7 9 Sawtooth Fall 211 7 Libraries Amplitude Amplitude Amplitude Amplitude Figure 7 10 Sine Cosine Amplitude Amplitude RECTANGLE Figure 7 11 Rectangle BASE defines whether the cycle period is really related to a defined time BASE TRUE or whether it is related to a particular number of cycles which means the number of calls of function block BASE FALSE PERIOD or CY
158. e lt SHIFT gt key pressed while selecting the desired libraries After having confirmed with OK the selected libraries will be added to the list in the Library Manager window If you want to include a library which is not yet installed on the local system you might use the Library Repository button to get to the Library Repository dialog for doing the required installation NOTE The Library Repository dialog is only available if predefined feature sets chosen by the user are Professional or the option Enable repository dialog is enabled For further information about features see Features in the MasterTool IEC XE User Manual MU299609 38 5 Programming Reference Sub dialog Placeholder Add Library Placeholder Placeholders are used to include target specific libraries to a project The placeholder will be resolved with a real library depending on information stored in the device description If this library manager is not below a device the placeholder will be resolved with the library specified in the field Default library Placeholder name RedundancyLib Default library Company All companies NextoSOE 1 0 0 244 Nexto Standard 4 Standard 3 4 4 0 4 Standard 3 4 4 0 allen 11 A iri ee E Display all versions for experts only 2 Group by category Library Repository Figure 4 2 Add Library Placeholder NOTE Placeholder is only available if predefine
159. e Structured Text Editor ST Editor provides views for monitoring and for writing and forcing the variables and expressions on the controller Debugging functionality breakpoints stepping etc is available See below For information on how to open objects in online mode see User Interface in Online Mode in the MasterTool IEC XE User Manual MU299609 For information on how to enter prepared values for variables in online mode see the item Forcing of Variables Notice that the Editor window of an ST object also includes the Declaration Editor in the upper part For information on the Declaration Editor in online mode see Declaration Editor in Online Mode in the MasterTool IEC XE User Manual MU299609 Monitoring If the inline monitoring is not explicitly de activated in the Options dialog small monitoring windows will be displayed behind each variable showing the actual value inline monitoring Expression Type Value Prepared value var INT 7075 Fbinst FB1 4 in INT 11 out INT 11 Fbwar INT 0 Fbinst2 FEI erg INT 22 1 ivar 270z8 ivar 27028 tl counter 2 fthinstfinf 11 11 call function block FR1 input parameter 3 erg 22 fbinst out 11 read result from FRi output out 4 fbinst2fin 22 22 call function block FRi input paramete 5 erg 22 fbinst2 out 22 read result from FRi output out Figure 6 39 Online view of a Program Object MainPrg Online view of a funct
160. e expected by the user Example in IL LD 281001 0011 XOR 2 1000_1010 ST varl Result is 2 0001_1001 BYTE type Example in ST Varl lt 271001 0011 XOR 271000 1010 Example in FBD OR 2 l001 0011 varl 21000 1010 IEC Bitstring Operator IEC Bitwise NOT operation of a bit operand The resulting bit will be 1 if the corresponding input bit is 0 and vice versa 91 5 Programming Reference Allowed types BOOL BYTE WORD DWORD LWORD Example in IL LD 2 1001 0011 HOT sT varl Result in Varl is 2 0110_1100 BYTE type Example in ST Varl lt NOT 251001 0011 Example in FBD Bit Shift Operators SHL The following bit shift operators matching the IEC1131 e standard are available SHL SHR ROL and ROR IEC Operator Bitwise left shift of an operand erg SHL in n in Operand to be shifted to the left n Number of bits by which in gets shifted to the left If n exceeds the data type width BYTE WORD DWORD and LWORD operands will be filled with zeros operands of signed data types like for example INT will get an arithmetic shift that means they will be filled with the value of the topmost bit NOTES Please note that the amount of bits which is noticed for the arithmetic operation is pretended by the data type of the input variable If the input variable is a constant the smallest possible data type is noticed The data type of the output variable has no effect at all
161. e represented by the basic diagram of Figure 7 15 o Process Figure 7 15 Diagram Basic PID The Figure 7 16 shows the block diagram of a detailed PID loop as the Nexto CPU execution 216 7 Libraries DeadBand Direct SP iw Er BIAS EnableP 5 roportiona Term Enablel Integral f Xp X Er alla ZE ja Term T 4 DerivPVY EnableD Term 3 2 ae MinMYV MaxMV MaxWVarmMv Manual Anti Reset Windup Manuali PV CONTROLLED PROCESS Figure 7 16 Diagram Full PID Figure 7 17 shows a block diagram of an example of a PID FB controlling a real process They are also showed auxiliare functions that help and the user must put in the application MV to AO Conversion and AI to PV Conversion 217 7 Libraries Analog Input MV to AO vee pe e g 4 20 mA Conversion Actuator e g control valve Real Process Controlled e g heater Transmitter e g temperature Analog Output Module e g 4 20 mA Alto PV Conversion Figure 7 17 PID FB Controlling a Real Process The diagram show only the main parameters of the PID block The analog output AO is the variable written in analog output module The analog input Al is the variable read from an analog input module The AI and AO variables are usually INT type For example some input and output analog modules typically operate in the range between 0 and 30000 where O corresponds to 4 mA and 30000 corresponds to 20 mA
162. e sine of a number The input variable can be of any numeric basic data type the output variable must be type REAL or LREAL Example in IL LD 0 5 SIH oT q Result in q is 0 479426 Example in ST g SIN 045 7 Example in FBD M IEC Operator Returns the cosine of number The value is calculated in arch minutes The input variable can be of any numeric basic data type the output variable must be type REAL or LREAL Example in IL 111 TAN ASIN ACOS 5 Programming Reference LD DS Cos ST q Result in q is 0 877583 Example in ST Gis O 0 5 7 Example in FBD IEC Operator Returns the tangent of a number The value is calculated in arch minutes The input variable can be of any numeric basic data type the output variable must be type REAL or LREAL Example in IL LD eo TAH oT q Result in q is 0 546302 Example in ST ai TANCOS o Example in FBD _ IEC Operator Returns the arc sine inverse function of sine of a number The input variable can be of any numeric basic data type the output variable must be type REAL or LREAL Example in IL LD O AS IH oT q Result in q is 0 523599 Example in ST q ASIN 0 5 Example in FBD M IEC Operator Returns the arc cosine inverse function of cosine of a number The value is calculated in arch minutes 112 ATAN EXPT 5 Programming Reference The input variable can be of any numeric basi
163. e the respective namespace the following scope operators can be used 66 99 global scope operator lt global variable list name gt lt library name gt lt enumeration name gt Global Scope Operator Scope Operator Extension to the IEC 61131 3 standard An instance path starting with opens a global scope namespace So if there is a local variable with the same name lt var name gt as a global variable lt var name gt will refer to the global variable Global Variable List Name Scope Operator Extension to the IEC 61131 3 standard The name of a global variable list can be used as a namespace for the variables enclosed in this list Thus it is possible to declare variables with identical names in different global variable lists and by preceding the variable name by lt globalvariable list name gt it 1s possible to access the desired one Example The global variables lists globlistl and globlist2 each contain a variable named varx In the following line varx out of globlist2 is copied to varx in globlist1 Globlistl varx globlist2 varx In this code line If a variable name declared in more than one global variable lists is referenced without the global variable list name as a preceding operator an error message will be output Library Namespace Scope Operator Extension to the IEC 61131 3 standard The library namespace can be used to explicitly access the librar
164. ecause of type mismatch real int IF b i 1 THEN Wrong assignments use of assignment operator to compare two i i 1 expressions END _IF Table 6 9 Assignments Used As Expressions Instructions Instructions tell what to do with the given expressions The following instructions can be used in ST Instruction Type Example 152 6 Programming Languages Editors Assignment A2 B CV i CV 1 C SIN X Calling a function block and CMD_TMR IN IX5 PT 300 use of FB output A CMD_TMR Q RETURN RETURN D B B IF D lt 0 0 THEN C A ELSIF D 0 0 THEN C B ELSE C D END_IF CASE CASE INT1 OF um BOOL1 TRUE 2 BOOL2 TRUE ELSE BOOL1 FALSE BOOL2 FALSE END_CASE J 101 FOR I 1 TO 100 BY 2 DO IF ARR I 70 THEN Jisl EXIT END_IF END_FOR WHILE J 1 WHILE J lt 100 AND ARRIJ lt gt 70 DO J J 2 END_WHILE REPEAT J 1 REPEAT J J 2 UNTIL J 101 OR ARR J END_REPEAT EXIT EXIT CONTINUE CONTINUE label i i 1 st label Empty instruction Table 6 10 Instructions Assignment Operator On the left side of an assignment there is an operand variable address to which he value of the expression on the right side is assigned by the assignment operator See also the MOVE operator which does the same Example VarL i Varz 10 After completion of this line Var1 has the tenfold value of Var2 Extended Features Further assignment oper
165. ed with a prefix which determines the type Syntax lt Type gt lt Literal gt lt Type gt specifies the desired data type possible entries are all simple data types The type must be written in uppercase letters lt Literal gt specifies the constant The data entered must fit within the data type specified under lt Type gt Example iVarl DINT 34 If the constant cannot be converted to the target type without data loss an error message is issued Typed literals can be used wherever normal constants can be used 53 5 Programming Reference Constants in Online Mode The constants are indicated by a E symbol preceding the value in the value column of the Declaration or Watch window in online mode In this case they cannot be accessed by e g forcing or writing Variables Configuration VAR_CONFIG The variables configuration can be used to map function block variables on the process image that is on the device I Os without the need of specifying the definite address already in the declaration of the function block variable The assignment of the definite address in this case is done centrally for all function block instances in a global VAR_CONFIG list For this purpose you can assign incomplete addresses to the function block variables declared between the key words VAR and END_VAR These addresses are to be identified with an asterisk Syntax lt Identifier gt AT 3 lt 1 0O gt lt Data type gt Example
166. efix c and an attached underscore followed by the type prefix and the variable name Example VAR CONSTANT c uiSyncID UINT 16480 END VAR For global variables g and global constants gc an additional prefix underscore are attached to the library prefix Examples VAR GLOBAL CAN g 1Test INT END VAR VAR GLOBAL CONSTANT CAN gc dwExample DWORD END VAR Variable Names in MasterTool IEC XE Libraries Basically see above Variable Names with the following exception global variables and constants do not need a library prefix because using the namespace takes the function of a prefix Example Quiles ING de o Declaration CAN g 1 Test Implementation Call 11 a application program gt User Defined Data Types DUT Structure The name of each structure data type consists of a library prefix Example CAN an underscore and a preferably short expressive description for example SDOTelegram of the structure The associated prefix for used variables of this structure should follow directly after the colon Example TYPE COM SDOTelegram Pretix sdo STRUCT wIndex WORD bySubIndex BYTE byLen BYTE abyData ARRAY 04 3 OF BYTE END STRUCT END TYPE Enumerations start with the library prefix Example CAL followed by an underscore and the identifier in capital letters ENUM should be defined with correct INT values Example TYPE CAL Day CAL MONDAY CA
167. el A coil transmits the value of the connections from left to right and copies it to an appropriate Boolean variable At the entry line the value ON TRUE or the value OFF FALSE can be present Contacts and coils can also be negated recognizable by the slash in the coil symbol bara iri Figure 6 74 Negated Coil In this case the negated value of the incoming signal will be copied to the appropriate boolean variable thus a negated contact only will connect through if the appropriate boolean value is FALSE 179 6 Programming Languages Editors A coil can be inserted in a network via command Insert Assignment which per default is part of the FBD LD IL menu Alternatively the element can be inserted via drag amp drop from the Toolbox Ladder elements or from another position within the editor See also Set Reset Coils FBD IL If you are currently working in FBD or IL view the command will not be available but contacts and coils inserted in a LD network will be represented by corresponding FBD elements resp IL instructions Set Reset in FBD LD IL FBD and LD A boolean output in FBD or correspondingly a LD coil can be Set or Reset To change between the set states use the respective command Set Reset from the context menu when the output is selected The output coil will be marked by aS oraR Set If value TRUE arrives at a set output resp coil this output coil will get TRUE and keep TRUE This value cannot be overwritten at
168. equences For example an SFC could have two IEC actions A and B which are both implemented in SFC and which both call IEC action C then in IEC actions A and B can both be active in the same cycle and furthermore in both actions IEC action C can be active then C would be called twice If the same IEC action is used simultaneously in different levels of an SFC this could lead to undesired effects due to the processing sequence described above For this reason an error message is issued in this case Notice the possibility of using implicit variables for controlling the status of steps and actions resp the execution of the chart SFC Editor in Online Mode In online mode the SFC Editor provides views for monitoring and for writing and forcing the variables and expressions on the controller See below e For information on how to open objects in online mode see User Interface in Online Mode in the MasterTool IEC XE User Manual MU299609 e Notice that the editor window of an SFC object also includes the Declaration Editor in the upper part For general information on the Declaration Editor in online mode see Declaration Editor in Online Mode in the MasterTool IEC XE User Manual MU299609 In case of having declared implicit variables SFC flags via the SFC Settings dialog those will be added here but will not be viewed in the offline mode of the Declaration Editor e Also please notice the sequence of processing of the elements
169. er Neatly AT SOXD 0S BOO 48 5 Programming Reference lightcabinetimpulse AT 1X7 2 BOOL download AT MX2 2 BOOL Keywords Keywords are to be written in uppercase letters in all editors The following strings are reserved as keywords 1 e they cannot be used as identifiers for variables or POUs ABS ACOS ACTION only used in the Export Format ADD ADR AND ARRAY ASIN AT ATAN BITADR BOOL BY BYTE CAL CALC CALCN CASE CONSTANT COS DATE DINT DIV DO DT DWORD ELSE ELSIF END_ACTION only used in the Export Format END_CASE END_FOR END_FUNCTION only used in the Export Format END_FUNCTION_BLOCK only used in the Export Format END_IF END_PROGRAM only used in the Export Format END_REPEAT END_STRUCT END_TYPE END_VAR END_WHILE EQ EXIT EXP EXPT FALSE FOR FUNCTION FUNCTION_BLOCK GE GT IF INDEXOF INT JMP JMPC JMPCN LD LDN LE LINT LN LOG LREAL LT LTIME LWORD MAX MIN MOD MOVE MUL MUX NE NOT OF OR PARAMS PERSISTENT POINTER PROGRAM R REFERENCE READ ONLY READ_WRITE REAL REPEAT RET RETAIN RETC RETCN RETURN ROL ROR S SEL SHL SHR SIN SINT SIZEOF SUPER SQRT ST STN STRING STRUCT SUPER SUB TAN THEN TIME TO TOD TRUE TRUNC TYPE UDINT UINT ULINT UNTIL USINT VAR VAR_ACCESS only used very specifically depending on the hardware VAR_CONFIG VAR_EXTERNAL VAR GLOBAL VAR_IN_ OUT VAR_INPUT VAR OUTPUT VAR_ STAT VAR_TEMP WHILE WORD WST
170. erve to be able to choose between a standard user interface with a reduced selection of features and less complexity and a professional environment supporting all features When the programming system is initially started after the first installation on the system you will be prompted to choose one of the sets But also later you still can switch the set and also a user defined customization of the currently used feature set is possible For the particular differences between the standard and professional version please see Features in the MasterTool IEC XE User Manual MU299609 Advanced Functionalities In the following you can see the advanced functionalities available in the MasterTool IEC XE Object Orientation in Programming and in the Project Structure Extensions for function blocks Properties Methods Inheritance Method Invocation Applications related to devices such as independents programming objects instances 12 3 Concepts and Basic Components Special Data Types UNION LTIME References Enumerations types of basic data can be specified DI DINT DINT 16 FFFFFFFF Operators and Special Variables Scope operators extended namespaces Function pointer replacing the INSTANCE_OF operator Init Method replacing the INI operator Exit Method Output variables in functions and method calls VAR_TEMP VAR_STAT VAR_RETAIN VAR_PERSISTENT Arbitrary expressions for variables initialization Assignment as expression
171. es see Global Scope Operator Use global variables lists GVLs to structure and handle global variables within a project A GVL can be added via the Add Object command Temporary Variables VAR_TEMP This feature is an extension to the IEC 61131 3 standard VAR_TEMP declarations are only possible within programs and function blocks Those variables are also only accessible within the body of the program or function block VAR_TEMP declared variables are re initialized every time the POU 1s called The variables have to be declared locally between the keywords VAR_TEMP and END_VAR 50 5 Programming Reference Static Variables VAR STAT This feature is an extension to the IEC 61131 3 standard Static variables can be used in function blocks methods and functions They have to be declared locally between the keywords VAR_STAT and END_VAR and will be initialized at the first call of the respective POU Static variables are only accessible within the scope in which they are declared like a static variable in C but like a global variable does not lose its value after the POU is left For example in a function they might be used as a counter for the number of function calls Regard the possibility of adding an attribute to VAR_STAT External Variables VAR_EXTERNAL These are global variables which are imported into the POU They have to be declared locally between the keywords VAR_EXTERNAL and END_VAR and in the global var
172. est 2 YAR 3 ff Nars for first network 4 Tl T2 TON 5 ET1 ET2 TIME Blink BOOL POUToCall MyCounter Counter DowmCount MyDommCounter 2 Decrement bErrorp Err wErrorpErrtode bCallReset ction Y Cont Figure 6 49 FBD Editor Window Ea CallTest 15 UpAndDown AOS 4 px a FUNCTION BLOCK UpindDown IMPLEMENTS HomingDevice A 2 VAR_INPUT Enable BOOL E 4 Amplitude INT GoHome BOOL END VAR v GoHome P ce Cont 3 Cont Enable ll KA AM RETURN 4 EN Mi gt Figure 6 50 LD Editor Window For information on the languages see e Function Block Diagram FBD e Ladder Diagram LD 166 6 Programming Languages Editors Working in the IL Editor View The IL Instruction List editor is a table editor in contrast to the pure text editor used in MasterTool IEC The network structure of FBD or LD programs is also represented in an IL program Basically one network is sufficient in an IL program but considering switching between FBD LD and IL you also might consciously use networks for structuring an IL program Notice the general editor settings in the Options dialog tab FBD LD and IL editor Tooltip containing information on variables or box parameters Please see Working in the FBD e LD Editor View Inserting and arranging elements The commands for working in the editor by default are available in the FBD LD IL menu the most important always also in the context menu Programming units th
173. ethod of the function block and in all derivative function blocks which are subscribing the method SFC Editor The SFC editor is available for programming objects in the IEC 61131 3 programming language Sequential Function Chart SFC The language is to be chosen when adding a new POU object to the project via the Add Object command The SFC editor is a graphical editor General settings concerning behavior and display are done in the SFC Editor Options dialog The SFC editor is available in the lower part of the window which opens when you edit a SFC POU object In its upper part this window contains the Declaration Editor Se SFC_Editor project MasterTool IEC XE File Edit fal l amp EJ Ca et Fs POUs SFC Ator A Project Information E Project Settings View Project Devices Device NX3010 S E PLCLogic 3 Applicatic ES Bill of Config Mi Diagne E Diagn l in Library El E SFC_P MainPi SFC Build Online Debug Tools Window Help Init step Add entry action Add exit action Insert step transition Insert step transition after Parallel Alternative Insert branch Insert branch right Insert action assodation Insert action association after Insert jump Insert jump after Insert macro Insert macro after Zoom into macro Zoom out of macro A El PROG Configuration Bus PROGRAM SFC_
174. f CPU obtained through MasterTool IEC XE programmer and graphical display from CPU Contents of the application program obtained through MasterTool IEC XE programmer e Version of the programmer used 1 Introduction Warning Messages Used in this Manual In this manual warning messages will present the following formats and meanings DANGER Relates potential causes which if not noted generate damages to physical integrity and health property environment and production loss CAUTION Relates configuration details application and installation that shall be followed to avoid condition that could lead to system fail and its related consequences ATTENTION Indicate important details to configuration application or installation to obtain the maximum operation performance from the system 2 Technical Description 2 Technical Description MasterTool IEC XE Versions MasterTool IEC XE MT8500 has four distribution versions each one with an optimized portfolio in accordance with the user s needs Those are e Lite free programming software that allows the programming and project loading of up to 320 I O points on Nexto bus and only in NX3010 CPUs e Basic software that allows the programming and project loading of up to 2048 I O points on CPUs NX3010 and NX3020 e Professional programming software for all Nexto Series CPUs Advanced programming software with tools for large scale applications with half cluster redundanc
175. f a POU Message pragmas positioned within currently not defined sections of the implementation code will not be regarded when the project is compiled On this see the example provided with the description of the defined identifier Conditional Pragma There are four types of message pragmas Message type text string Text The specified textstring will be displayed info string EY Information The specified textstring will be displayed warning digit string Warning The specified textstring will be displayed Unlike a data type global Obsolete Pragma this warning is explicitly defined for the local position error string Error amp The specified textstring will be displayed Table 5 5 Message Pragma Types 57 5 Programming Reference NOTE In case of messages of types Information Warning and Error the source position of the message that is where the pragma is placed in a POU can be reached via the Next Message command This is not possible for the Text type Example of declaration and implementation in ST editor VAR ivar INT info TODO should get another name bvar BOOL arrTest ARRAY 0 10 OF INT 4 Es END VAR arrTest i arrTest i l ivar l1ivartl text Part xy has been compiled completely linio This is a information warning This is a warning error This is a error Messages 0 X Build Description Project Object Position Bu
176. f object orientation A MasterTool IEC XE project contains a PLC program composed of various programming objects and it contains definitions of the resources which are needed to run instances of the program application on defined target systems devices PLCs So there are two main types of objects in a project o Programming objects Programming objects POUs which can be instantiated in the entire project 1 e for all applications defined in the project must be managed in the POUs window These are programs functions function blocks methods actions data type definitions etc The instantiating is done by calling a program POU by an application assigned task Programming objects which are managed in the devices window 1 e which are directly assigned to an application cannot only be instantiated by another application inserted below o Resource objects These are device objects applications task configurations and which are managed in the device tree or in the graphic editor depending on the device type When inserting objects in the devices tree the hardware to be controlled must be mapped according to certain rules Code generation By integrated compilers and use of machine code results in short execution times Data transfer to the controller device The data transfer between MasterTool IEC XE and the device is done via a gateway component and a runtime system Standard and professional interface Predefined feature sets s
177. f the same library can be included in a project It is regulated like described in the following which version of a library an application will use o If multiple versions are available on the same level within the same mananger it will depend on the current library properties which version will be accessed a defined one or always the newest o If multiple versions of the same library are available on different levels within the the same mananger which is the case for referenced libraries unique access to the library modules or variables is reached by adding the appropriate namespace see the following paragraph 34 3 Concepts and Basic Components Unique Access to Library Modules or Variables Basically if there are several modules or variables with the same name within a project the access on a module component must be unique otherwise compile errors will be detected This applies for local project modules or variables as well as those which are available in included libraries and in libraries referenced by the included ones The uniqueness is reached in such cases by prefixing the module name by the appropriate library namespace The default namespace of a library is defined in the library properties If it is not defined explicitly it will equate with the library name However when creating a library project also a different standard namespace can be specified in the Properties dialog Later when the library has got included i
178. f this option is enabled all variables are updated in each cycle of the task no matter if they are used or if they are mapped to an input or output 72 5 Programming Reference Channels Channels Variable Mapping Channel Address Type Unit Description Y Reserved 0QB0 Reserved for internal use 3 Reserved QB0 BYTE Reserved for internal use F Reserved 0X0 0 BOOL Reserved 0QX0 1 BOOL Reserved 0QX0 2 BOOL F Reserved 0X0 3 BOOL p Reserved QX0 4 BOOL F Reserved 0X0 5 BOOL F Reserved QX0 6 BOOL F Reserved 0QX0 7 BOOL F Reserved QB1 BYTE Reserved for internal use Y Reserved IW2 Reserved for internal use Reserved oIW2 WORD Reserved for internal use Reserved IW4 WORD Reserved for internal use Reserved IW6 WORD Reserved for internal use Figure 5 7 Channels Dialog e Variable a variable can be mapped to the channel through the Input Assistant or created a new one by editing the field e Mapping Indicates whether the variable is new UE will be declared internally as a global variable or will be a mapping to an existing K in this case the address will appear scratched and should not be used directly Channel Channel name input or output of the device Address Address of the channel for example TWO Type Data type of the input or output channel for example BOOL Unit The unit of the parameter value for example MS for milliseconds Description Text description for
179. ference 4 Menu Commands This manual treat only menu commands that make the library management to see the commands from other menus see Menu Commands in the MasterTool IEC XE User Manual MU299609 Library Manager This category provides the Library Manager editor commands for the management of the libraries used in the project Library Manager Commands Provides the commands listed below They are part of the Libraries menu when the Library Manager is active Available commands e Add Library e Properties e Try to Reload the Library For general information on the library management in MasterTool IEC XE please see Library Manager Add Library This command is part of the Libraries menu and the Library Manager editor window Activate the command if you want to include libraries via the currently opened Library Manager into the project Only libraries which are already installed on your system can be added Multiple versions of a library can be included in the project at the same time within one or multiple library managers The command opens the Add Library dialog with its tabs Library and Placeholder Placeholder feature is only available with the option Enable repository dialog enabled for further information see the item Features in the MasterTool IEC XE User Manual MU299609 37 5 Programming Reference Sub dialog Library Add Library Library Placeholder Company All companies 000 OT He Applic
180. ffect a restart process Make sure that the new application code nevertheless will affect the desired behavior of the system Depending on the controlled system damages to machines and parts could result or even health and life of persons could be endangered NOTES When an online change is done the application specific initializations homing etc will not be executed because the machine keeps its state For this reason the new program code might not be able to work as desired Pointer variables keep their values form the last cycle If there is a pointer on a variable which has changed its size due to an online change the value will not be correct any longer Make sure that pointer variables get re assigned in each cycle Boot Application Boot Project A boot application is the project which will be started automatically when the controller gets started For this purpose the project must be available on the PLC in a file lt project name gt app This file can be created in offline mode via the Create boot application command Online menu Each sending was successful the active application will be automatically stored in the file lt application gt app in the system folder of the device thus available as a startup application The Create boot application command also lets you save a file in this application in offline mode Sending Login Project Method without Project Differences In order to ensure that the user won t
181. formation For the STRING type variable the result is a time constant 105 5 Programming Reference Examples in IL LD T 1l2ms TIME TO STTI ST str Result is T 12ms LD T 300000ms TIME TO DWORD ST dw Result is 300000 LD T 00 00 00 012 TIME TO SIHT ST si Result 1s 12 Examples in ST str TIME TO STRING T 12ms Result is T 12ms dw TIME TO DWORD T 5m Result 1s 300000 si3 TOD TO DINT TODFO0UO 700 0127 Result 1s 12 Examples in FBD TIME TO STRIHG t l ems Str TIME TO DWORD t 5w clu TOD TO SIHT TOD 00 00 00 Ole si DATE TO DT_ TO Conversions IEC Operator Converting from the variable type DATE or DATE_AND_TIME to a different type Syntax for the conversion operator lt DATE data type gt TO lt Data Cype gt The date will be stored internally in a DWORD in seconds since Jan 1 1970 This value will then be converted When you perform a type conversion from a larger to a smaller type you risk losing some information For STRING type variables the result is the date constant Examples in IL LD D 1970 01 01 DATE TO BOOL oT h Result is FALSE LD D 1970 01 01 DATE_TO_ IHT ST 1 Result 1s 29952 106 5 Programming Reference LD D 1970 01 15 05 05 DATE TO BYTE ST byt Result is 129 LD Dg 1995 02 153 14 20 DATE TO STEI ST Str Result is DT 1998 02 13 14 20 Examples in ST b DATE TO BOOL D 1970 01 01 i DATE TO INT D 1970 01 15 Re
182. function blocks as well as data types global variables and even visualizations which can be used in the project just like the other POUs and variables which are defined directly within the project The default extension for a library file is library The management of the libraries in a project is done in the Library Manager i the preceding installation on the system in the Library Repository dialog NOTE The Library Repository dialog is only available if predefined feature sets chosen by the user are Professional or the option Enable repository dialog is enabled For further information about features see Features in the MasterTool IEC XE User Manual MU299609 The project functions for local and global search and replace also work for included libraries See general information on Installation and Including in project Referenced Libraries Library Versions Unique access to library modules or variables Creating libraries Encoding Documentation MasterTool IEC XE Internal and external library modules 33 3 Concepts and Basic Components Installing and Including on Project Libraries can be managed on the local system in one or various repositories folders locations A library cannot be included in a project before it has got installed in a repository on the local system The installation is to be done in the Library Repository dialog As a precondition for installation a library must have got assigned a title a ve
183. gt Remove the current line that is where you have currently selected any field Cut Copy Paste To copy one or several lines select at least one field of the line s and use the copy command To cut a line use the Cut command Paste will insert the previously copied cut lines before the line where currently a field is selected If no field 1s selected they will be inserted at the end of the network lt CTRL gt lt HOME gt scrolls to the begin of the document and marks the first network lt CTRL gt lt END gt scrolls to the end of the document and marks the last network lt PAGEUP gt scrolls one screen up and marks the topmost rectangle lt PAGEDOWNs scrolls one screen down and marks the topmost rectangle Multiple Operands Extensible Operators If the same operator is used with multiple operands two ways of programming are possible The operands are entered in subsequent lines separated by commas example 4 LD T ADD ae 4 T ST 1Var 168 6 Programming Languages Editors e The instruction is repeated in subsequent lines example 3 LD T ADD 2 ADD 4 ADD T ST 1 AR Complex Operands If a complex operand is to be used enter an opening bracket before then use the following lines for the particular operand components and below those in a separate line enter the closing bracket Example rotating a string by character at each cycle 4 LD stRotate RIGHT stRotate LEH SUB 1 COHC AT stR
184. h expressions of an object on the PLC For more information see Monitoring in the MasterTool IEC XE User Manual MU299609 Debugging To evaluate programming errors you can use the MasterTool IEC XE debugging functionality in online mode In this context regard the possibility to check an application in simulation mode 1 e without the need of connecting to a real hardware target device Breakpoints can be set at certain positions to force an execution break Certain conditions such as which tasks are concerned and in which cycles the breakpoint should be effective can be set for each breakpoint Stepping functions are available to get a program executed in controlled steps At each break the current values of the variables can be examined A call stack can be viewed for the currently reached step position For further information about this item see Breakpoints in the MasterTool IEC XE User Manual MU299609 Supported Programming Languages All of the programming languages mentioned in the IEC standard IEC 61131 are supported via specially adapted editors e FBD LD IL editor for Function Block Diagram FBD Ladder Logic Diagram LD and Instruction List IL e SFC editor for Sequential Function Chart e ST editor for Structured Text Additionally MasterTool IEC XE provides an editor for programming in CFC that is not part of the IEC standard CFC editor for Continuous Function Chart Program Organization Units It is basically
185. h the lowest number which is 0 The execution order can be modified by commands which are by default available in submenu Execution Order in the CFC menu When adding an element the number will automatically be given according to the topological sequence from left to right and from above to below The new element receives the number of its topological successor if the sequence has already been changed and all higher numbers are increased by one Notice that the number of an element remains constant when it is moved Consider that the sequence influences the result and must be changed in certain cases Figure 6 9 Example of Element Numbers 129 6 Programming Languages Editors Changing Size of the Working Sheet In order to get more space around an existing CFC chart in the editor window the working area working sheet size can be changed This might be done by selecting and dragging all elements with the mouse or by the Cut and Paste commands see above Moving Alternatively a special dimensions settings dialog can be used which might save time in the case of big charts See Edit Working Sheet in the MasterTool IEC XE User Manual MU299609 for a description CFC Editor in Online Mode In online mode the CFC editor provides views for monitoring and for writing and forcing the variables and expressions on the controller Debug functionality breakpoints stepping etc 1s available For information on how to open objects
186. have problems on sending and logging same projects in the CPUs running from different stations it can be performed the following steps after sending a project e Inthe Additional files dialog Project Project Settings Source Download menu and Additional files button select the option Download information files Close all dialogs by clicking OK Run the command Source download File menu In the Select Device dialog that opens choose the CPU on which the project was sent Close the dialog by clicking OK wait for the download of the project 16 3 Concepts and Basic Components To login on running CPUs without generating changes on project from different stations you must open a Project Archive generated from the original project and execute the Login command In the absence thereof may be made of the following steps Run the command Source upload File menu In the Select Device dialog that opens choose the CPU on which the project was sent Close the dialog by clicking OK wait for the loading of the project In the Project Archive dialog which opens at the end of the loading process choose the folder to extract and click on Extract e The project will open and Login command can be executed in the corresponding CPU For further information see File Menu and Online Menu in the MasterTool IEC XE User Manual MU299609 Monitoring In online mode there are various possibilities to display the current values of the watc
187. he following table it will be necessary a software update of MasterTool IEC XE to the version 1 29 or higher NX202000 toOttorhighler AC or higher NXB030_ 1 2 1 0orhigher AL orhigher NX50000 tOtdorhigher AJorhigher Table 2 2 Version 1 29 Compatibility MasterTool IEC XE versions before version 1 40 are not able to configure MODBUS communication drivers by Symbolic Mapping The same behavior happens when using the LibLogs Library It will be necessary to use the Nexto Series products with software version or product revision as described in the following table when loading projects into the CPU using these drivers or library If the use of MODBUS communication driver by Symbolic Mapping or LibLogs Library is not necessary there is no restriction to use this version Table 2 3 Minimum Requirements Minimum Requirements The following products are presented as minimum requirements for installation and use of MasterTool IEC XE for any of its distributions versions MasterTool IEC XE PC with Windows XP 32bits Windows Vista 32 bits or Windows 7 32bits or 64bits Processor Intel Core 2 Duo 1 66 GHz minimum Disc Space 1 Gbyte minimum 2 Gbytes recommendable RAM Memory 2 Gbytes minimum 3 Gbytes recommendable Resolution 1024 x 768 recommendable Language Any language Table 2 4 Minimum Requirements 10 2 Technical Description Data for Purchase Included
188. hidden variable a_invisible Hide_all_locals Attribute With the help of the pragma attribute hide_all_locals you may prevent all local variables of a signature from being displayed within the List Components functionality or Input Assistant This attribute is identical to assigning the attribute hide to each of the local variables Syntax latiri ute thie all locale Example The function block myPOU is implemented making use of the attribute attribute ALde arl Loca ls FUNCTION BLOCK myPOU VAR INPUT a INT END_VAR VAR OUTPUT BD BOO LS END VAR VAR POE INTs END VAR In the main program two instances of function block myPOU are defined PROGRAM MainPrg VAR POUL POQUZS myPOU END VAR When assigning e g an input value to POU1 the List Components function working on typing POU in the implementation part of MainPrg will display the variables A and B but none of the hidden local variables C or D Init_ Namespace Attribute A variable of type STRING or WSTRING which is provided with the pragma attribute init_namespace will be initialized with the current namespace this is the path of the instance of the function block this variable is contained Applying this pragma presumes the use of the additional attribute no1nit for the string variable and the attribute reflection for the corresponding function block Syntax tattribute init mamespace 61 5 Programming Referen
189. his parameter the user can enter a condition of performance of the controlled loop e dt Sample time in seconds that is the period to call the functional block and update the PV input PV and MV output The constant dt symbolizes an additional dead time which must be added to Tm In practice dt 2 1s added to the Tm value as this is the average dead time inserted The response time Tr can be compared with a time constant of the closed loop as shown in Figure 7 23 224 Mv MW Mas 7 Libraries 63 21 Ten Figure 7 23 Tr Compared with a Time Constant The parameter Tr on Figure 7 23 shows the response time desired It is the measured time between the start of the system response after the dead time Tm and when PV reaches 63 21 of its total excursion Through Tr the user can specify a performance requirement for the controlled loop It should be careful to not specify response times lower than one tenth of the constant time of the system because otherwise the system can become unstable Than Lower as 1s the value of Tr as greater is the necessary gain Afterwards 1t 1s described how to determine through an opened loop test the other parameters K Tm and T that characterize the process A simple way to determine these process constants is putting the PID function block in manual mode generate a small step on MV and plot the PV response time For slow process it can be done manually but for rapid processes it is
190. iable list The declaration must exactly match the global declaration If the global variable does not exist an error message will appear Example VAR EXTERNAL 1VarExtl INT First external variable END VAR Attribute Keywords for Variable Types The following attribute keywords can be added to the declaration of the variables type in order to specify the scope e RETAIN See Remanent Variables of type RETAIN e PERSISTENT See Remanent Variables of type PERSISTENT e CONSTANT See Constants Remanent Variables Remanent variables can retain their value throughout the usual program run period The declaration determines the degree of resistance of a remanent variable in the case of resets downloads or a reboot of the PLC In applications mainly the combination of both remanent flags will be required See in the following e Retain Variables e Persistent Variables Retain Variables Variables declared as retains will be kept PLC dependently but typically in a separate memory area They get the keyword RETAIN in their declaration in a POU and in a global variable list Example VAR RETAIN iReml INT 1 Retain variable END VAR 51 5 Programming Reference Retain variables are identified by the keyword RETAIN These variables maintain their value even after an uncontrolled shutdown of the controller as well as after a normal switch off and on of the controller and at the online command Reset warm When the progra
191. ild started Application Device Application typify code TODO should get another name Untitled64 MainPra Device PLC Logic Application Line 3 Decl Part xy has been compiled completely Untitled64 MainPrq Device PLC Logic Application Line 3 Column 1 Impl This is a information Untitled64 MainPrq Device PLC Logic Application Line 4 Column 1 Impl This is a warning Untitled64 MainPrg Device PLC Logic Application Line 5 Column 1 Impl This is a error Untitled64 MainPrqg Device PLC Logic Application Line 6 Column 1 Impl Compile complete 1 errors 1 warnings Figure 5 1 Output in Messages Window Attribute Pragmas Attribute pragmas might be assigned to a signature in order to influence the compilation and pre compilation 1 e the code generation There are user defined pragmas which might be used in combination with conditional pragmas and there are also the following predefined standard attribute pragmas Attribute displaymode Attribute global_init_slot Attribute hide Attribute hide_all_locals Attribute Init_Namespace Attribute init_on_onlchange Attribute instance path Attribute linkalways Attribute Monitoring Attribute no_check Attribute noinit Attribute obsolete Attribute pack_mode Attribute qualified_only Attribute reflection Attribute symbol 58 5 Programming Reference User Defined Attributes It is possible to assign
192. imum preset time to a communication to take place When exceeded then retry procedures are started or diagnostics are activated Is a tag that indicates who is the master of the bus at the time Text box with a help or where you can enter with the help Data structure for hardware configuration Reading of the program or configuration from the PLC Electronic circuit that checks the equipment operation integrity Information unit composed by 16 bits Extensible Markup Language is a standard for generating markup languages In the context of keyboard function window is used for the exchange of screens 232
193. in the Library Manager Thus the library can be reloaded without the necessity of leaving the project 41 5 Programming Reference 5 Programming Reference Declaration The variables of a project are to be declared manually in the declaration editor or via the Auto Declare dialog See the further related help pages referring for example on the various categories of variables local global input output etc the initialization the use of pragmas init method etc Variables Declaration The declaration of a variable can be done in the declaration part of a POU or via the Auto Declare dialog as well as in a DUT or GVL editor The sort in the declaration dialog it is named scope of the variable s to be declared is specified by the keywords embracing the declaration of one or several variables The common variable declaration for example is embraced by VAR and END_VAR VAR INPUT VAR OUTPUT VAR IN OUT VAR GLOBAL VAR TEMP VAR STAT VAR EXTERNAL VAR CONFIG The variable type keywords may be supplemented by attribute keywords like for example RETAIN VAR_INPUT RETAIN The declaration of a variable must match the following rules Syntax lt IDENTIFIER gt AT lt ADDRESS gt lt TYPE gt lt INITIALIZATION gt The parts in braces are optional The identifier is the name of a variable The items listed in the following in each case must be regarded when defining an identifier but please also consider to fo
194. inPrg z YAR 3 err BOOL 4 step STRING 5 END VAR v iw i a 2 sfc d PROGRAM sfcl YAR timeoverflow BODL tl BOOL TRUE te BOOL x INT Y IHT status 32 BO0L EHD VAR Access to an action of the same SFC mW Oo 7 mh om 4 0 Fr FP Init Figure 6 35 Accessing SFCError SFCError will get TRUE as soon as a timeout within sfc2 occurs Expression Type value Prepared value tl BOOL TRUE tz BOOL FALSE x INT 122 Py INT 0 status s BOOL timeoverflow BOOL TRUE a SFCEnableLimit BOOL Gil E SFCError BOOL TRUE SFCErrorstep STRING a s1 Init T 0na ca add action E show timeor T 63100ms Re Pad WELCe tga z9 T 0ms step action Figure 6 36 Online view of SFC sfc1 The following implicit variables flags can be used For this purpose they must be declared and activated in the SFC Settings SFCInit BOOL If this variable gets TRUE the sequential function chart will be set back 147 6 Programming Languages Editors to the Init step All steps and actions and other SFC flags will be reset initialization The Init step will remain active but not be executed as long as the variable is TRUE SFCInit must be set back to FALSE in order to get back to normal processing SFCReset BOOL This variable behaves similarly to SFCInit Unlike the latter however further processing takes place after the initialization of the Init step Thus in this case for exam
195. increasing value COUNTER COUNTER 10 CHARACTERISTIC LINE IN COUNTER N 5 P KL COUNTER CHARACTERISTIC LINE OUT Figure 7 12 Illustration of the Resulting Curves 213 7 Libraries RAMP_INT Provided by util library RAMP_INT serves to limit the ascendance or descendance of the function being fed The input consists on the one hand out of three INT values IN the function input and ASCEND and DESCEND the maximum increase or decrease for a given time interval which is defined by TIMEBASE of the type TIME Setting RESET to TRUE causes RAMP_INT to be initialized anew The output OUT of the type INT contains the ascend and descend limited function value When TIMEBASE is set to t 0s ASCEND and DESCEND are not related to the time interval but remain the same Example of RAMP_INT in CFC RAMP IN 25 20 T 1S RES RAMP INT IN RAMP INT CUT Figure 7 13 RAMP_INT Behavior RAMP_REAL Provided by util library RAMP_REAL functions in the same way as RAMP_INT with the simple difference that the inputs IN ASCEND DESCEND and the output OUT are of the type REAL Analogue Value Processing HYSTERESIS Provided by util library 214 7 Libraries Example of HYSTERESIS in FBD HYSTERESIS The input to this function block consists of three INT values IN HIGH and LOW The output OUT is of type BOOL If IN goes below the limiting value LOW OUT becomes TRUE If IN exceeds the upper limi
196. ing actions programmed in SFC 136 6 Programming Languages Editors Stepo Trans Figure 6 18 Step and Subsequent Transition Figure 6 19 Initial Step and Subsequent Transition Transition A transition is represented by a small rectangle box connected to the preceding and subsequent steps by a line It provides the condition on which the following step will get active as soon as the condition is TRUE The transition name and the transition condition is displayed right to the box By default automatically a transition trans lt n gt is inserted whereby n is a running number This default name can be selected and modified e A valid name is either the name of a transition object Er available in the POUs tree this allows multiple use of transitions see for example t1 in the left column e A valid conditional expression 5 FARO ES in Library Manager E AS EXAMPLE PRG Sh acti EN act2 EN count E tt Bi ee ee Figure 6 20 Transition in POUs Tree 137 Action 6 Programming Languages Editors Transition conditions _ inserted directly POU FE la Di Prop E Get E Set Et TRANS Figure 6 22 Transition or Property Object Indicated by a Triangle A transition condition must have the value TRUE or FALSE Thus it can consist of either a Boolean variable a Boolean address a Boolean constant or a series of instructions having a Boolean result But a transition may
197. ing the content operator after the pointer identifier see for example pt in the example below The Address Operator ADR can be used to assign the address of a variable to a pointer 76 5 Programming Reference Example VAR pt POINTER TO INT Declaration of pointer pt var mel INTE 2 97 Declaration OF variables var NEL ud var Tnt var ntar INT END VAR pt S ADR var intl Address Of Varin us assigned t porter pt var IDe r pers e Value SOL var anmtl qets assigned to var Int vid dereferencing of pointer pt Function Pointers Function pointers are supported replacing the INDEXOF operator These pointers can be passed to external libraries but there is no possibility to call a function pointer within an application in the programming system The runtime function for registration of callback functions system library function expects the function pointer and depending on the callback for which the registration was requested then the respective function will be called implicitly by the runtime system for example at STOP In order to enable such a system call runtime system the respective property category Build must be set for the function object The ADR operator can be used on function names program names function block names and method names Since functions can move after online change the result is not the address of the function but the address of a pointer to the function
198. insert the element e For all possible cursor positions see Cursor Positions in FBD LD and IL Navigating e The arrow keys might be used to jump to the next previous cursor position also possible between networks The lt TAB gt key might be used to jump to the next previous cursor position within a network lt CTRL gt lt HOME gt scrolls to the begin of the document and marks the first network lt CTRL gt lt END gt scrolls to the end of the document and marks the last network lt PAGEUP gt scrolls one screen up and marks the topmost rectangle lt PAGEDOWN gt scrolls one screen down and marks the topmost rectangle Selecting 165 6 Programming Languages Editors e An element also network can be selected via taking the respective cursor position by a mouse click or using the arrow or tabulator keys e Miultiselection of non adjacent elements resp networks is possible by keeping the while selecting the desired elements one after the other e Inthe LD editor multiselection of adjacent elements or networks can be done by keeping pressed the lt SHIFT gt key while selecting two contacts determining start and end of the desired network section If you want to cut copy and paste a section of a network it will be sufficient to keep the lt CTRL gt key pressed while selecting just two contacts defining the borders of this section Then the elements between will be noticed automatically A CallTest l PROGRAM CallT
199. ion Then in online view of the POU using the property and in a watch list the name type and value of the variables of the property will be displayed Therein you may also enter prepared values to force variables belonging to the property Devices Il X gt Untitedss a Device NX3010 8 0 PLC Logic C3 Application Es Bill of Materials E Configuration and Consumption 13 Diagnostic Explorer ad Diagnostic ral Library Manager J E fb1 FB mar Prop E ce Ef Set Ep fbi Prop Configuration Bus Z PROPERTY PUBLIC Prop INT Figure 5 3 Example of Property Prepared for Variable Monitoring 63 5 Programming Reference Expression Type Value Prepared value Comment SP1 REAL 60 42 SP2 REAL 454 1 Se 45 36 a 3 Figure 5 4 Example of Monitoring View There are two different ways to get monitored the current value of the property variables For the particular use case consider carefully which attribute is suitable to actually get the desired value This will depend on whether operations on the variables are implemented within the property e Pragma attribute monitoring variable e Pragma attribute monitoring call In the first case attribute monitoring variable an implicit variable is created for the property which will get the current property value always when the application calls the Set or Get method The value of this implicit variable will be monitored In the second case
200. ion operators can be used which are described below Table 5 7 Conditional Pragmas Within the constant expression expr of a conditional compilation pragma if or elsif several operators can be used These operators itself may not be undefined or redefined via undefine or define respectively Regard that these expressions as well as the definition done by define can also be used in the Compiler defines in the Properties dialog of an object The following operators are supported SYNTAX Defined Identifier Defined variable name of variable Defined type identifier Defined pou POU name When applied to an identifier its value is TRUE if that identifier has been defined with a define instruction and not later undefined using undefine otherwise its value is FALSE Example Precondition there are two POUs The variable pdefi is defined by a define on POU_1 but not in POU_2 Both have the code below IF DEFINED PDEF1 This code is processed in POU_1 INFO PDEF1 DEFINED IVAR IVAR SINT 1 ELSE This code is processed in POU_2 INFO PDEF1 NOT DEFINED IVAR IVAR SINT 1 END_ IF Here additionally an example of a message pragma is included Only information string pdef1 defined will be displayed in the message window when the POU_1 was called because pdef1 actually is defined Info message pdef1 not defined will be displayed in case pdef1
201. ion block POU No values will be viewed Instead the term lt Value of the expression gt will be displayed in column Value and the inline monitoring fields in the implementation part will show three question marks each 159 6 Programming Languages Editors Expression Type Value Prepared value a in INT lt Value of the express out INT lt Value of the express ivar INT Value of the express 1 ou sid bivar Figure 6 40 Online view of a Function Block FB1 Forcing of Variables In addition to the possibility to enter a prepared value for a variable within the declaration of any editor the ST Editor provides to click on the monitoring box of a variable within the implementation part in online mode whereon you may enter the prepared value in the rising dialogue Figure 6 41 Prepare Value Expression Device Application MainPrg iInputLevel Type INT Current value 10 What do you want to do Prepare a new value for the next write or force operation 20 Remove preparation with a value Release the force without modifying the value Release the force and restore the variable to the value it had before forcing it Figure 6 41 Prepare Value Dialog You find the name of the variable completed by its path within the Device tree Expression its type and current value By activating the corresponding item you may choose Prepare a new value for the next write or force operation Remove
202. iple selection is possible by the following e Keep the lt SHIFT gt key pressed and subsequently click on the particular elements to be selected e Press the left mouse key and draw a rectangle dotted line around the elements to be selected e Use command Select All Edit menu Editor Texts By a mouse click on a text cursor position at once the edit field opens where you can edit the text If a text area has been selected via the arrow keys the edit field must be opened explicitly by using the lt SPACE gt bar Edit Associated Actions A double click on an step entry active or exit or transition action association opens the associated action in the corresponding editor For example perform a double click on the transition element or on the triangle indicating an exit action in a step element Cut Copy Paste Elements Select the element s and use command Cut Copy and Paste Edit menu or the corresponding keys Notice the following behavior e When you paste one or several cut or copied element s the content of the clipboard will be inserted before the currently selected position If nothing is currently selected the element s will be appended at the end of the currently loaded chart e Ifyou paste a branch while the currently selected element is also a branch the pasted branch elements will be inserted left to the existing ones e If you paste an action list at a currently selected step the actions will be added at the
203. ipulate the slave reference then controlling the process temperature This example can be represented graphically according the Figure 7 20 PROCESS TEMPERATURE Figure 7 20 Example of Cascade Control Applied If only a temperature controller were used acting directly on the steam valve there would not be as to compensate eventual pressure variations on the steam line There are three main advantages to use cascade controllers e Any disturb that affects the slave controller is detected and compensated by this one before affecting the variable manipulated by the master controller e Increased controllability of the system In case of temperature control by steam injection the system response is improved by the flow controller increasing the controllability of the main loop e Non linearities of an internal loop are manipulated into this loop and not perceived by the external loop In the previous example the pressure variations are compensated by the slave controller and the master controller notices only a linear relationship between the valve and the temperature Important Considerations To use cascade controllers the following precautions should be taken e As the slave controllers setpoint is manipulated as the master controllers output sudden variation can occur on the slave controller error If the slave controllers are with the derivative action acting in function of the error derivative actions will be generated witht big v
204. is inserted via Input Assistant lt F2 gt with option Insert With Arguments in the implementation window of a ST or IL POU it will be displayed automatically according to the syntax showed in the following example with all of its parameters But you not necessarily must assign these parameters For the above mentioned example the call would be displayed as follows Example insert via Input Assistant with arguments CMD TMR ins Sp PLS gt gt CMD IMA 1N bvar pts tr200mse G bres Extension of a Function Block Supporting object orientated programming a function block can be derived from another function block This means a function block can extend another thus automatically getting the properties of the basing function block in addition to its own The extension 1s done by using the keyword EXTENDS in the declaration of a function block You can choose the extends option already during adding a function block to the project via the Add Object dialog Syntax FUNCTION BLOCK lt function block name gt EXTENDS lt function block name gt This 1s followed by the declaration of the variables Example of definition of function block fbA FUNCTION BLOCK fbA VAR INPUT SLOT Definition of function block fbB FUNCTION BLOCK fbB EXTENDS fbA VAR INPUT ivari1int In the above example e FbB does contain all data and methods which are defined by fbA An instance of fbB can now be used in any context were a function
205. is terminated by lt CTRL gt lt ENTER gt To add a label which then can be addressed by a jump use the command Insert label If a label is defined it will be displayed below the title and comment field resp if those are not available directly below the upper border of the network 1 Title Network Comment Network Label Network Figure 6 65 Positions of Title Comment and Label in a Network A network can be set in comment state which effects that the network is not processed but displayed and handled like a comment On a currently selected network the default commands for Copy Cut Insert and Delete can be applied NOTE The right mouse click being executed over a title comment or label will select this entry only instead of the whole network So the execution of the default commands will have no influence on the network itself To insert a network use command Insert Network or drag it from the toolbox A network with all belonging elements can also be copied or moved by drag amp drop within the editor Notice the possibility to create sub networks by inserting branches RET Network In online mode automatically an additional empty network will be displayed below the existing networks Instead of a network number it is identified by RET It represents the position at which the execution will return to the calling POU and provides a possible halt position Assignment in FBD LD IL Depending on the selected po
206. ited The action will be started when the step becomes active and it will continue for the specified time or until a reset Table 6 4 Qualifiers The qualifiers L D SD DS and SL need a time value in the TIME constant format Implicit Variables SFC Flags Each SFC step and IEC action provides implicitly generated variables for watching the status of steps and IEC actions during runtime Also variables can be defined for watching and controlling the execution of a SFC timeouts reset tip mode These variables also might be generated implicitly by the SFC object 144 6 Programming Languages Editors Basically for each step and each IEC action an implicit variable is generated A structure instance named like the element for example step for a step with step name step1 Notice the possibility to define in the element properties whether for this flag a symbol definition should be exported to the symbol configuration and how this symbol should be accessible in the PLC The data types for those implicit variables are defined in library IecSFC library This library will automatically be included in the project as soon as an SFC object is added Step and Action Status and Step Time Basically for each step and each IEC action an implicit structure variable of type SFCStepType and SFCActionType is created The structure components flags describe the status of a step action or the currently processed time of an active step The
207. ithin a POU An enumeration is created as a DUT object via the Add Object dialog Syntax EXE lt Tdentitier gt gt lt Enum 0 gt EDU des e Enum n gt Base data type END TYPE A variable of type lt Identifier gt can take on one of the enumeration values lt Enum_ gt and will be initialized with the first one These values are compatible with whole numbers which means that you can perform operations with them just as you would do with integer variables You can assign a number x to the variable If the enumeration values are not initialized with specific values within the declaration counting will begin with 0 When initializing make sure that the initial values are increasing within the row of components The validity of the number will be checked at the time it is run Example Definition of two enumerations TEE RAPE IC SIGNAL red Yellow green U F The anitial value for each of the colors is red 0 yellow 1 green 10 82 5 Programming Reference END TYPE Declaration TRAFFIC SIGNAL1 TRAFFIC SIGNAL Use of enumeration TRAFFIC SIGNAL in a POU TRAP HIG SIGNADLS 07 Ue The value of the Tralo cignal 18 red e Extensions to the IEC 61131 3 Standard The type name of enumerations can be used as a scope operator to disambiguate the access to an enumeration constant So 1t 1s possible to use the same constant in different enumerations Example Definition of two enumerations BPE COLORS
208. ithin the current SFC Macrol gt Macroz Br a Figure 6 33 Title Line of the Macro Editor In order to configure in which way the actions should be associated to the IEC steps some qualifiers are available which are to be inserted in the qualifier field of an action element These qualifiers are handled by the SFCActionControl function block of the IecSfc library which automatically is included in a project by the features of SFC The available qualifiers SE Name Description _ S e The action is active as long as the step is active The action gets deactivated The action will be started when the step becomes active and will be continued after the step is deactivated until the action gets reset Time Limited The action will be started when the step becomes active and it will continue until the step goes inactive or a Set time has passed Time Delayed A delay timer will be started when the step becomes active If the step is still active after the time delay the action will start and continue until it gets deactivated Pulse The action will be started when the step becomes active deactive and will be executed once Pulse stored and time The action will be started after the set time delay delayed and it will continue until it gets reset Delayed and stored If the step is still active after the specified time delay the action will start and it will continue until it gets reset SL Stored and time lim
209. kBounas 0 i 10 1 ELSE The following line of code will only be processed in the scenario where there is not a POU CheckBounds arrTest i arrTest i 1 END_ IF TRUE if this particular attribute is specified in the first line of the POUs declaration part Example Precondition There are two function blocks fun1 and fun2 but in fun1 additionally has got an attribute vision Definition of fun1 attribute vision FUNCTION fun1 INT VAR_INPUT i INT END _VAR VAR END _VAR Definition of fun2 FUNCTION fun2 INT VAR_INPUT i INT END _VAR VAR END _VAR In a POU exists the following code IF hasattribute pou fun1 vision The following code line will be processed ergvar fun1 ivar END_ IF IF hasattribute pou fun2 vision The following code line not will be processed ergvar fun2 ivar END_ IF When applied to a variable its value is TRUE if this particular attribute is specified via the attribute instruction in a line before the variable s declaration Example Precondition There are two POUs POU_1 and POU_2 Variable g_globallnt is used in POU_1 and POU_ 2 but in POU_1 additionally has got an attribute DoCount Declaration of g_globallnt in POU_1 VAR_GLOBAL attribute DoCount g_globallnt INT g_multiType STRING END_VAR Declaration of g_globallnt in POU_2 VAR_GLOBAL g_globallnt INT g_multiType STRIN
210. lement can be viewed and edited in the Element properties window This window can be opened via command Element Properties View menu It depends on the currently selected element which properties are displayed The properties are grouped and the particular group sections can be opened or closed by using the plus minus signs Notice that in the View tab of the SFC Editor options you can configure whether the particular types of properties should be displayed next to an element in the SFC chart Common Property Element name by default lt element gt lt running number gt for example step name Step0 Step1 branch name brancho etc Symbol Specific Element comment text string for example Reset the counter Line breaks can be inserted via lt Ctrl gt lt Enter gt For each SFC element implicitly a flag is created named like the element Here you can specify whether this flag variable should be exported to the symbol configuration and how the symbol then should be accessible in the PLC Perform a double click on the value field resp select the value field and use the space key in order to open a selection list from which you can choose one of the following access options None The symbol will be exported to the symbol configuration but it won t not be accessible in the PLC Read The symbol will be exported to the symbol configuration and it will be readable in the PLC Write The symbol will be exported to the
211. llow some recommendations which are given in Recommendations on the Naming of the Identifiers e It must not contain spaces or special characters e Itis not case sensitive which means that for example VARI Varl and varl are all the same variable e The underscore character is recognized in identifiers for example A_BCD and AB_CD are considered two different identifiers but an identifier must not have more than one underscore character in a row e The length of the identifier as well as the meaningful part of it are unlimited e The rules listed in the following text box concerning multiple uses must be regarded Multiple Use of Identifiers Namespaces An identifier must not be used duplicate locally and must not be identical to any keyword Globally an identifier can be used plurally thus a local variable can have the same name as a global one Within a POU in this case the local variable will have priority A variable defined in a Global Variables List can have the same name as a variable defined in another Global Variables List In this context notice the following IEC 61131 3 extending features e Global scope operator An instance path starting with opens a global scope So if there is a local variable for example ivar with the same name as a global variable ivar refers to the global variable 42 5 Programming Reference e The name of a global variables list can be used as a namespace for the included variables
212. llowing steps to create an external POU e Add the desired POU object in the POUs view of your project like any internal object and define the respective input and output variables NOTE Local variables must be defined in external function blocks but may not be defined in external functions or methods Also notice that VAR STAT variables cannot be used in the runtime system In the runtime system an equivalent function function block or method must be implemented Ata program download for each external POU the equivalent will be searched in the runtime system and if found will be linked Global Variable List GVL A ab Global Variables List GVL is used to declare global variables If a GVL is placed in the POUs view the variables will be available all over the project if a GVL is assigned to a certain application the variables will be valid within this application A GVL can be added via command Add Object and Add Global Variable List To assign it to an existing application choose the command from the context menu while the application is selected in the device tree Otherwise the new GVL object will be added to the POUs view The GVL editor is used to edit a Global Variable List If the target system supports the network functionality the variables contained in a GVL can be defined to be available as network variables 1 e for a broadcast data exchange with other devices in the network For this purpose appropriate ne
213. losely related to this function See Unpack for details and examples Provided by util library The input to this function consists of a DWORD X a BYTE N and a Boolean value B PUTBIT sets the Nth bit from X on the value B whereby it starts counting from the zero bit Example in ST Arenos E Binary LOOlLG Bs PUTBIT A 4 TRUE E Result 54 27110170 C PUTBIT A 1 FALSE Result 36 2 100100 Provided by util library UNPACK converts the input B from type BYTE into 8 output variables BO B7 of the type BOOL and this is the opposite to PACK 201 7 Libraries TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE Figure 7 4 Example in FBD Output Mathematical Auxiliary Function Derivative Provided by util library This function block approximately determines the local derivation The function value is delivered as a REAL variable by using IN TM contains the time which has passed in msec in a DWORD By an input TRUE of RESET the function block can be restarted The output OUT is of the type REAL In order to obtain the best possible result DERIVATIVE approximates using the last four values in order to hold errors which are produced by inaccuracies in the input parameters as low as possible Example in FBD derivative inst DERTYATIVE r Input dwlime hRe set 202 Integral 7 Libraries Figure 7 5 FB DERIVATIVE Behavior Provided by util library This function block approxi
214. lt INSTRUCTIONS gt are carried out until the lt BOOLEAN EXPRESSION gt returns TRUE If lt BOOLEAN EXPRESSION gt is produced already at the first TRUE evaluation then lt INSTRUCTIONS gt are executed only once If lt BOOLEAN EXPRESSION gt never assumes the value TRUE then the lt INSTRUCTIONS gt are repeated endlessly which causes a relative time delay Example REPEAT Varli Varl 2 Counter Counter 1 UNTIL Counter 0 END REPEAT The CONTINUE instruction can be used within a REPEAT loop CONTINUE Instruction As an extension to the IEC 61131 3 standard ExST the CONTINUE instruction is supported within FOR WHILE and REPEAT loops CONTINUE makes the execution proceed with the next loop cycle Example FOR Counter 1 TO gt BY 1 DO ING SS INTL IF INT1 0 THEN CONTINUE To avotoa division by Zero END IF Var bks Varl SINT n Only executed atk INTL Ss not TUT E END FOR Erg Varl EXIT Instruction If the EXIT instruction appears in a FOR WHILE or REPEAT loop then the innermost loop is ended regardless of the break off condition JMP Instruction The JMP instruction can be used for an unconditional jump to a code line marked by a jump label 157 6 Programming Languages Editors Syntax lt LABEL gt JMP lt LABEL gt lt LABEL gt is an arbitrary but unambiguous identifier that is placed at the beginning of a program line The instruction JMP has to be follo
215. lt QUIPUT VARIABLE 1 gt QUEZ gt lt OUTPUT VARIABLE A gt ss FURTHER OUTPUT VARIABLES Example Function fun is defined with two input variables inl and in2 The return value of fun will be written to the locally declared output variables VAR_OUTPUT locl and loc2 22 3 Concepts and Basic Components BUN ENT Ly INA 2 22 OUTI gt GOC1L OUTA gt LOC2 gt 3 Function Block A function block is a POU which provides one or more values during the processing of a PLC program As opposed to a function the values of the output variables and the necessary internal variables shall persist from one execution of the function block to the next So invocation of a function block with the same arguments input parameters need not always yield the same output values In addition to the functionality described by standard IEC 61131 3 object oriented programming will be supported and function blocks can be defined as extensions of other functions This means that inheritance can be used when programming with function blocks A function block always is called via an instance which is a reproduction copy of the function block A function block can be added to the project via command Add Object POU To assign the function block to an existing application select the application entry in the Devices view and use the command from the context menu Otherwise it will be added to the POUs view In the Add object dialog choose type Fu
216. lyfor steps no matter whether there is a minimum time configured in the step attributes or not see also below SFCError For steps lt stepname t lt stepname gt G mot usable for external purposes For actions the implicit time variables are not used Control of SFC Executions Timeouts Reset Tip Mode Some implicitly available variables also named SFC flags see table below can be used to control the operation of an SFC for example for indicating time overflows or enabling tip mode for switching transitions 145 6 Programming Languages Editors In order to be able to access these flags and to get them work they must be declared and activated This is to be done in the SFC Settings dialog which is a sub dialog of the object Properties dialog Manual declaration as it was needed in previous versions is only necessary to enable write access from another POU see below Accessing Flags In this case however regard the following If you declare the flag globally you must deactivate the Declare option in the SFC Settings dialog in order not to get a implicitly declared local flag which then would be used instead of the global one Keep in mind that the SFC Settings for a SFC POU initially are determined by the definitions currently set in the SFC Options dialog Notice that a declaration of a flag variable solely done via the SFC Settings dialog will only be visible in the online view of the SFC POU There is aSFC POU n
217. m It is composed of a CPU a power supply and I O modules A set of rules and conventions used for the elaboration of a program Procedural rules and conventional formats which upon control signals allow the establishment of a data transmission and error recovery between equipment Random access memory Is the memory where all addresses can be accessed directly in a random way and with the same speed Is volatile i e its content is lost when the equipment is de energized unless if you have a battery for retaining values Command to reboot the PLC Command to put PLC in execution mode Action to assign the logical high level state to a boolean variable Equipment connected to a communications network that transmits data only if it is requested by other 231 Software STOP Sub network Supervisory Station Tag Timeout Token Tooltip Tree Upload Watchdog Word XML Zoom 8 Glossary equipment called master Computer programs procedures and rules related to the operation of a data processing system Command to freeze the PLC in its current state Segment of a communication network that connects a group of devices nodes with the goal of isolating the local data traffic or using different protocols or physical media Equipment connected to a PLC network with the goal of monitoring and controlling the process variables Name associated with an operand or the logic that allows a brief identification of your content Max
218. m is run again the stored values will be processed further All other variables are newly initialized either with their initialized values or with the standard initializations Contrary to persistent variables retain variables are reinitialized at a new download of the program Retain variables however are re initialized at Reset origin and in contrast to persistent variables at Reset cold and an application download The Retain property can be combined with the Persistent property NOTES If a local variable in a program is declared as VAR RETAIN then exactly that variable will be saved in the retain area like a global retain variable If a local variable in a function block is declared as VAR RETAIN then the complete instance of the function block will be saved in the retain area all data of the POU whereby only the declared retain variable will be handled as a retain If a local variable in a function is declared as VAR RETAIN then this will be without any effect The variable will not be saved in the retain area If a local variable is declared as PERSISTENT in a function then this will be without any effect also Persistent Variables Persistent variables are identified by keyword PERSISTENT VAR_GLOBAL PERSISTENT They get only re initialized at a Reset origin In contrast to Retain variables they maintain their values after a download An application example for persistent variables would be a counter for
219. mately determines the integral of the function Analogous to DERIVATIVE the function value is delivered as a REAL variable by using IN TM contains the time which has passed in msec in a DWORD By TRUE in input RESET the function block can be restarted Output OUT is of type REAL The integral is approximated by two step functions The average of these 1s delivered as the approximated integral Example in FBD 203 7 Libraries integral inst rlnput OUT riut OVERFLOW F bOvert low Figure 7 6 FB INTEGRAL Behavior Lin_ TRAFO This function block util library transforms a REAL value which lies in a value range defined by a lower and upper limit value to a REAL value which lies correspondingly in another range also defined by a lower and upper limit The following equation is basis of the conversion IN IN_MIN IN_MAX IN OUT OUT_MIN OUT_MAX OUT Example in FBD Input Variables Data type O N REAL Input value NMN REAL Lower limit of input value range INMAX REAL Upper limit of input value range OUT_MIN REAL Lower limit of output value range OUT_MAX REAL Upper limit of output value range Table 7 1 Input Variables LIN_TRAFO Output Variables 204 7 Libraries REAL Output value ERROR BOOL Error occurred TRUE if IN_MIN IN_MAX or if IN is outside of the specified input value range Table 7 2 Output Variables LIN_TRAFO Example A temperature senso
220. me de dt and stores these values internally The output that is the manipulated variable Y is calculated as follows Y KP x D TV dD dt Y OFFSET onde D SET_POINT ACTUAL 206 7 Libraries So besides the P part also the current change of the controller error D part influences the manipulated variable Additionally Y is limited on a range prescribed by Y_MIN and Y_MAX If Y exceeds these limits LIMITS_ACTIVE will get TRUE If no limitation of the manipulated variable is desired Y_MIN and Y_MAX have to be set to 0 As long aa MANUAL TRUE Y_MANUAL will be written to Y A P controller can be easily created by setting TV 0 PID The library util library provides the following PID controller function block Example of PID in FBD ACTUAL SET_POINT LIMITS ACTIVE KP OVERFLOW TN TW Y_MANUAL Unlike the PD controller this function block contains a further REAL input TN for the readjusting time in sec for example 0 5 for 500 msec Inputs of the Function Block Desired value command variable KP REAL Proportionality coefficient unity gain of the P part TN REAL Reset time reciprocal unity gain of the I part given in seconds for example 0 5 for 500 msec TV REAL Derivative action time unity gain of the D part in seconds for example 0 5 for 500 msec Y_ MANUAL REAL Defines output value Y in case of MANUAL TRUE Y_OFFSET REAL Offset for the manipulated variable Y Y_MIN Y_MAX REAL Lower u
221. me gt lt FB variable gt IMR CIN t IXo PT lt 300 A TMR Q RETURN Instruction The RETURN instruction can be used to leave a POU for example depending on a condition Syntax RETURN Example IF b TRUE THEN RETURN END IF a a l If b is TRUE instruction a a 1 will not be executed the POU will be left immediately IF Instruction With the IF instruction you can check a condition and depending upon this condition execute instructions Syntax IF lt Boolean Expression 1 gt THEN SLP TASTLUCLLORS gt ELSIF lt Boolean expression 2 gt THEN lt ELSLE INSEXUCEELONS 1 gt ELSIF lt Boolean expression 2 gt THEN 154 6 Programming Languages Editors lt ELSIF Instructions n 1 gt KLSE lt BuSE instructions gt END IF The part in braces is optional If the lt Boolean_expression1 gt returns TRUE then only the lt IF_Instructions gt are executed and none of the other instructions Otherwise the Boolean expressions beginning with lt Boolean_expression 2 gt are evaluated one after the other until one of the expressions returns TRUE Then only those instructions after this Boolean expression and before the next ELSE or ELSIF are evaluated If none of the Boolean expressions produce TRUE then only the lt ELSE_instructions gt are evaluated Example IF temp lt 17 THEN heating on TRUE ELSE heating ob FALSE END IF Here the HEATING_ON variable is turned on whe
222. mer function block working as a trigger A timer is counted up until a given limit is reached During counting up a pulse variable is TRUE otherwise it is FALSE Inputs IN BOOL At a rising edge counting up the time in ET will be started PT TIME Upper limit of the time Outputs Q BOOL TRUE as long as the time is being counted up in ET pulse ET TIME Current state of the time TP N PT Q ET If IN is FALSE Q will be FALSE and ET will be 0 As soon as IN becomes TRUE the time will begin to be counted in milliseconds in ET until its value is equal to PT It will then remain constant Q is TRUE as from IN has got TRUE and ET is less than or equal to PT Otherwise it is FALSE Q returns a signal for the time period given in PT 196 TON 7 Libraries J OWN L t0 1 Z3 td Ib a Y E DPTO 12124PT td 14 PT LAS Figure 7 1 Graphic Display of the TP Time Sequence Declaration example TPINSE TP Example in IL CAL TPinst IN Yarbo00L1l r PT T 53 f ET gt VYarTimelur 1 LD TPinst Q ST VYarbooLe Example in FBD TPinst VYarBooLl VYarBooLe T 53 ETF arTimelur Example in ST TPInst IN lt VarBOOLl PT TH5s gt VarBOOL2 TPInst Q Provided by standard library Timer function block implements a turn on delay When the input gets TRUE first a certain time will run through until also the output gets TRUE Inputs IN BOOL Rising edge starts counting up ET
223. mode dec attribute display mode decimal For display in hexadecimal format attribute display mode hex attribute display mode hexadecimal Example VAR attribute display mode hex dwVarl DWORD END_VAR 59 5 Programming Reference Global_init_slot Attribute The pragma attribute global_init_slot can only be applied for signatures Per default the order of initializing the variables of a global variable list is arbitrary However in some cases prescribing an order is necessary e g if variables of one global list are referring to variables of another list In this case you may make use of the pragma to arrange the order for global initialization Syntax attrisute e teb al anat elon 7s Value The template lt Value gt has to be replaced by an integer value describing the initialization order of the signature The default value is 50000 A lower value provokes an earlier initialization In case of signatures carrying the same value for the attribute global_init_slot the sequence of their initialization rests undefined Example Assume the project including two global variable lists GVL_1 and GVL_2 mperoject a ot Dd ena 4 Project Settings Figure 5 2 Global Variable Lists The variables B and C are members of global variable list GVL_1 their initial values depend on the variable A VAR GLOBAL B INT A 1 C INT A 1 END VAR The global variable A is member of the gl
224. must be specified completely The pragma definition can be assigned to particular variables or collectively to all variables declared in a program e To be valid for a single variable the pragma has to be placed in the line before the variables declaration e To be valid for all variables contained in the declaration part of a program the pragma has to be placed in the first line of the declaration editor Anyway also in this case the settings for particular variables might be modified by an explicit adding of a pragma The possible access on a symbol is defined by the pragma parameter none read write or readwrite If no parameter is defined the default readwrite will be valid Example With the following configuration the variables A and B will be exported with read and write access Variable D will be exported with read access attribute symbol readwrite PROGRAM MAINPRG VAR A INT B INT attribute symbol none E ENTES attribute symbol read De 3 INT END VAR Conditional Pragmas The ExST Extended ST language supports several conditional pragma instructions which affect the code generation in the pre compile and compile process The implementation code which will be regarded for compilation for example might depends on d O O O NOTE It is not possible for a POU or GVL declared in the POUS tree to use a define declared in an application whether a certain data
225. n a project the namespace always can be modified locally by the user again in the Properties dialog Examples Assume that for the following examples the namespace of library Lib is specified in the library properties to be Lib1 See in the right column the use of the namespaces for unique access on variable var 1 which is defined in the modules module and POU1 Variable var1 is available at the following Access on var1 via using the appropriate locations namespace path In library Lib1 in the global Library Manager Lib1 module1 var1 in the POUs window In library Lib1 in the Library Manager below Dev1 App1 Lio1 module1 var1 Application App1 of Device Dev1 in the Devices window In library Lib1 which is included in library By default option Publish in the library F_Lib in the global Library Manager in the Properties is deactivated POUs window F_Lib Lib1 module1 var1 If option Publish was activated module1 would be treated like a component of a top level library Thus accessing would be possible by Lib1 module1 var1 or module1 var1 In the current example this however would cause compiler errors because the access path is not unique see 1 and 4 In object module1 which is defined in the module1 var1 POUs window In object POU1which is defined in the POUs POUxy var1 window Table 3 1 Unique Access Creating Libraries Encoding Documentation A MasterTool IEC XE project can be saved as library lt project
226. n of the functions that might be modified is available in ST See the following example for an implementation of the function CheckDivReal Declaration part Implicitly generated code DO NOT EDIT FUNCTION CheckDivReal REAL VAR_INPUT divisor REAL END VAR Implementation part Implicitly generated code Only an suggestion for implementation IF divisor O THEN CheckDivReal 1 ELSE CheckDivReal divisor END IF The operator DIV uses the output of function CheckDivReal as divisor In the following example a division by 0 1s prohibited as the implicitly with O initialized value of the divisor D is changed to 1 by CheckDivReal prior to the execution of the division Therefore the result of the division is 799 PROGRAM MAINPRG VAR erq REAL vl REAL 799 88 MOD MOVE SIZEOF 5 Programming Reference d REAL END VAR erg vl d IEC Operator Modulo Division of one variable by another one Allowed types BYTE WORD DWORD LWORD SINT USINT INT UINT DINT UDINT LINT ULINT The result of this function will be the remainder of the division This result will be a whole number Example in IL LD a MOD 2 ST varl Result in Varl is 1 Example in ST varl 9 MOD 2 Example in FBD a Yarl IEC Operator Assignment of a variable to another variable of an appropriate type As MOVE is available as a box in the graphic editors FBD LD CFC there the unlocking EN ENO functionality
227. n the MasterTool IEC XE User Manual MU299609 A project contains the POU objects which make up a PLC program as well as the definitions of resource objects necessary to run one or several instances of the program application on certain target systems PLCs devices POU objects are managed in the POUs view window device specific resource objects are managed in the Devices view window A project is saved in a file lt project name gt project In the Devices window device tree the hardware can be mapped on which the application 1s to run Each device object represents a specific target hardware object Examples controller field bus node bus coupler I O module monitor Each device is defined by a device description and must be installed on the local system in order to be available for inserting in the Device tree see below The device description file defines the properties of a device concerning configurability programmability and possible connections to other devices In the Device tree are managed objects needed to run an application on the device controller CP including implementation configuration tasks and tasks However specific programming objects POUs global variable lists and Library Manager can instead of being managed as units 14 3 Concepts and Basic Components instantiable global design in the window of POUs ONLY be managed in the Device tree and in this case are available only
228. n the active steps will be reset Precondition SFCError must be defined SFCPause BOOL As long as this variable is TRUE the execution of the SFC diagram is stopped SFCTrans BOOL This variable gets TRUE as soon as a transition is actuated SFCCurrentStep This variable stores the name of the currently active step STRING independently of the time monitoring In case of simultaneous sequences the name of the outer right step will be registered SFCTip SFCTipMode This variables allow using the inching mode within the current chart BOOL When this mode has been switched on by SFCTipMode TRUE you can only skip to the next step by setting SFCTip TRUE rising edge As long as SFCTipMode is set to FALSE it is possible to skip by the transitions Table 6 5 Implicit Variables A timeout has been detected in step s1 in SFC object POU by flag SFCError E vou 4 MyPlc Application POU Expression Type Value Prepared value E2111 BOL FALSE 1222 BOOL FALSE da SECError BOL TRUE SFCError POU STRIMG POL SFCErrorstep STRING 51 E SPCcuitError BOL FALSE T 2hs7us4s99ons This ia Step sl Minimal active t zs Maximal active t 4s Step active actl Figure 6 37 Example of Some SFC Error Flags in Online Mode of the Editor 148 6 Programming Languages Editors Accessing Flags For enabling access on the flags for the control of SFC execution timeouts reset tip mode the flag variables must be declared and
229. n the temperature sinks below 17 degrees Otherwise it remains off FALSE CASE Instruction With the CASE instructions one can combine several conditioned instructions with the same condition variable in one construct Syntax CASE lt Varl gt OF lt Value i gt lt instruction 1 gt lt Value 2 gt lt Instruction 2 gt sValue Sy Value 4 Value 5 gt s lt IAsStructrton 3 gt lt Value 6 Value 10 gt lt Instruction 4 gt lt Value n gt lt Instruction n gt ELSE ELSE Instruction END CASE A CASE instruction is processed according to the following model e Ifthe variable in lt Var1 gt has the value lt Value 1 gt then the instruction lt Instruction 1 gt will be executed e If lt Var 1 gt has none of the indicated values then the lt ELSE instruction gt will be executed e If the same instruction is to be executed for several values of the variables then one can write these values one after the other separated by commas and thus condition the common execution e Ifthe same instruction is to be executed for a value range of a variable one can write the initial value and the end value separated by two dots So you can condition the common condition Example CASE INT1 OF 1 5 BOOLI TRUE BOOL3 FALSE 2 BOOL2 FALSE BOOL3 TRUE LO e620 2 BOOLA gt TRUE S BOOL3 TRUE ELSE BOOL1 NOT BOOLI BOOL2 BOOL1 OR BOOL2 END CASE 155 6 Programming Languages Editors
230. n to notice the results of the arithmetic operation depending on the type of the input variable BYTE or WORD Example in ST PROGRAM shr st VAR in byte BYTE 16 45 in word WORD 16 45 erg byte BYE erg word WORD n BYTE 2 END VAR erg byte SHR in byte n erg word SHR in word n Result is 11 Result is 0011 e 7 e 7 Example in FBD in byte erg byte E Example in IL LD in byte SHR E ST erg byte IEC Operator Bitwise rotation of an operand to the left erg ROL in n Allowed data types BYTE WORD DWORD LWORD In will be shifted one bit position to the left n times while the bit that is furthest to the left will be reinserted from the right 93 ROR 5 Programming Reference NOTES Please note that the amount of bits which is noticed for the arithmetic operation is pretended by the data type of the input variable If the input variable 1s a constant the smallest possible data type is noticed The data type of the output variable has no effect at all on the arithmetic operation See in the following example in hexadecimal notation that you get different results for erg_byte and erg word depending on the data type of the input variable BYTE or WORD although the values of the input variables in_byte and in_word are the same Example in ST PROGRAM rol st VAR in byte BYTE 16 45 in word WORD 16 45 erg byte BYTE erg word WORD n
231. name gt library and optionally can be installed at the same time in the System Library Repository Only the objects managed in the POUs window will be regarded for a library project If you pointedly are going to create a library project it is recommended to choose template Empty library in the New Project dialog Notice further on the following In the Project Information a title and a version and the company must be specified If the Default namespace should be another than the library name this can be defined immediately here Additionally it is recommended to specify a category because these will later serve for sorting the entries in the Library Repository and Library Manager dialogs If the library should belong to another category than the default Miscellaneous an appropriate category description must be loaded either from a XML file libcat xml or from another library which already contains the information of such a description file If necessary a new category description file must be issued or an existing one must be modified The information of the selected categories and the basic category description file will be transferred to the local library project and later when installing the library to the Library Repository So the categories will be known in the 35 3 Concepts and Basic Components repository If afterwards another library again brings a description file with the same ID but different content then the information
232. name of the jump target A jump defines the next step to be processed as soon as the preceding transition is TRUE Jumps might be needed because the processing lines must not cross or lead upward Besides the default jump at the end of the chart a jump may only be used at the end of a branch It gets inserted via command Insert jump after when the last transition of the branch is selected The target of the jump is specified by the associated text string which can be edited inline It can be a step name or the label of a parallel branch 142 6 Programming Languages Editors gt atepl Figure 6 30 Jump Macro Symbol EIt l Figure 6 32 Macro Editor View for Macrol A macro is represented by a bold framed box containing the macro name It includes a part of the SFC chart which thus is not directly visible in the main editor view The process flow is not influenced by using macros it 1s just a way to hide some parts of the program for example in order to simplify the display A macro box is inserted by command Insert macro after The macro name can be edited inline 143 Qualifier 6 Programming Languages Editors To open the macro editor perform a double click on the macro box or use command Zoom in to macro You can edit here just as in the main editor view and enter the desired section of the SFC chart To get out use Zoom out of macro The title line of the macro editor always shows the path of the macro w
233. ncerned library from the applications library manager to the POUs view library manager Then you could call the POU from the POUs view just by its name and if needed that from the library by preceding the library namespace For further information see also the item POUs for Implicit Checks Program A program is a POU which returns one or several values during operation All values are retained from the last time the program was run until the next A program POU can be added to the project via the Add Object command To assign the program to an existing application select the application entry in the Devices view and use the command from the context menu Otherwise it will be added to the POUs view In the Add POU dialog choose type Program enter a name for the program and set the desired implementation language After confirming the settings with button Open the editor window for the new program will open and you can start editing the program The syntax for declaring a program PROGRAM lt PROGRAM NAME gt This is followed by the variable declarations of input output and program variables optionally also access variables _ E PRGexample d gt x at PROGRAM Priexample Ay 2 VAR INPUT 1 c in var INT p EHD VAR 5 VAR OUTPUT 6 out war INT 7 END YAR 8 VAR a a ivar INT 10 bvar BOOL 11 END YAR a 1 out varisin Var ivar Pe E IF out var i 253 J 3 THEH byar TRUE 4 4 EHD IF Ei v ES Figure 3 2
234. nction Block enter a function block name lt identifier gt and choose the desired implementation language Additionally the following options may be set e Extends Enter here the name of another function block available in the project which should be the base for the current one After having confirmed the settings with button Open the editor window for the new function block will open and you can start editing Declaration Syntax FUNCTION BLOCK lt FUNCTION BLOCK NAME gt EXTENDS lt FUNCTION BLOCK NAME gt This is followed by the declaration of the variables Example FBexample shown in the following picture has two input variables and two output variables outl and out2 Out is the sum of the two inputs out2 is the result of a comparison for equality Example of a function block in ST FUNCTION BLOCK FBEXAMP LE VAL ENE UL LNE IS oN Es INP2Z TINE END VAR VAR OUTPUT OUTIL INT QUT 7 BOO lis END VAR 0UT1 INP1 INPZ2 OUT2 INP1 INP2 Function Block Instance Function blocks are always called through an instance which is a reproduction copy of a function block 23 3 Concepts and Basic Components Each instance has its own identifier instance name and a data structure containing its inputs outputs and internal variables Instances like variables are declared locally or globally whereby the name of the function block is indicated as the data type of an identifier Syntax for declaring
235. nction block variable x VAR_IN_OUT or VAR_TEMP variables of the function block cannot be accessed in a method Methods like functions can have additional outputs Those must be assigned during method invocation Special Methods for a Function Block e Init Method A method named FB_Init always is declared implicitly but also can be declared explicitly It contains initialization code for the function block as declared in the declaration part of the function block See FB_ Init e Reinit Method If a method named FB_Reinit is declared for a function block instance it will be called after the instance has been copied and will reinitialize the new instance module See FB_Reinit e Exit Method If an exit method named FB_Exit is desired for example for deallocating any it must be declared explicitly There is no implicit declaration The exit method will be called for each instance of the function block before a new download a reset or during online change for all moved or deleted instances See FB_Exit e Properties Set and Get methods see Property Method Call also Application is Stopped In the device description file it can be defined that a certain method should always be called task cyclically by a certain function block instance of a library module If this method has the following input parameters it will be processed also when the active application currently is not running VAR INPUT pTaskInfo POINTER TO DWOR
236. ndary itself is included in this basic type Table 5 10 Subrange Types Examples TYPE Sublime 2 INT SAUS DOSIS END TYPE Direct declaration of a variable with a subrange type VAR Lo INT 42005 24095 7 ur 7 UINT 0s T0000 z END VAR If a value is assigned to a subrange type in the declaration or in the implementation but does not match this range for example 1 5000 in the upper shown declaration example an error message will be issued Check Functions In order to check the range limits during runtime the functions CheckRangeSigned or CheckRangeUnsigned must be available to the application Therefore add the object POUs for implicit checks to the application using the Add Object dialog Mark the checkbox related to the type CheckRangeSigned or CheckRange Unsigned choose an implementation language and confirm your settings with Open whereon the selected function will be opened in the editor corresponding to the implementation language selected Independently of that choice the declaration part is preset and may not be modified except for adding further local variables A proposal default implementation of the function that might be modified is given in the ST editor The purpose of this check function is the proper treatment of violations of the subrange for example by setting a detected error flag or changing the value The function will be called implicitly as soon as a variable of subrange type is assigned
237. nds to the number of the word the place behind names the number of the bit Obs n number of the byte DWords Words X bits 0 1 2 o Ee a AAA AAA Ea 3 5 Programming Reference alo j Xx fno xais xias Table 5 17 Comparison of Byte and Word Oriented Addressing for the Address Sizes D W B and X Overlap of memory ranges in case of byte addressing mode example DO contains BO B3 WO contains BO and B1 W1 contains B1 and B2 W2 contains B2 and B3 In order to get around the overlap W1 D1 D2 D3 must not be used for addressing NOTES Boolean values will be allocated bytewise if no explicit single bit address is specified Example A change in the value of varbooll AT QWO affects the range from QX0 0 to QX0 7 Online Change might change the contents on addresses Please notice this when using pointers on addresses Functions In ST a function call can also appear as an operand Example Result Ect 7 3 TIME Function This function returns the time based on milliseconds which has been passed since the system was started The data type is TIME Example in IL TIME ST tempo Example in ST time TIME 122 6 Programming Languages Editors 6 Programming Languages Editors CFC Editor The CFC Editor is available for programming objects in the programming language Continuous Function Chart CFC which is an extension to the IEC 61131 3 programming lang
238. nguage which approaches the structure of an electric circuit The Ladder Diagram is suitable for constructing logical switches on the other hand one can also create networks as in FBD Therefore the LD is very useful for controlling the call of other POUs The Ladder Diagram consists of a series of networks each being limited by vertical current lines power rail on the left and on the right A network contains a circuit diagram made up of contacts coils optionally additional POUs boxes and connecting lines On the left side there is a series of contacts passing from left to right the condition ON or OFF which corresponds to the Boolean values TRUE and FALSE To each contact a Boolean variable is assigned In case of contacts if this variable is TRUE the condition is transmitted from left to right along the line connector On the other hand if this variable is FALSE the condition spread to the right will always be OFF In case of negated contacts if this variable is TRUE the condition spread to the right will always be OFF However in the case where the variable is FALSE the condition is transmitted from left to right along the line connector Figure 6 46 LD Network Instruction List IL The Instruction List is similar to Assembly language programming in accordance with IEC 61131 3 162 6 Programming Languages Editors This language supports programming based on an accumulator All IEC 61131 3 operators are
239. not contain programs function blocks or assignments A transition condition is handled like a method call It be entered according to the syntax lt Transition name gt lt Transition condition gt for example transl a 100 Or lt Transition condition for example a 100 See example above t1 In online mode the subsequent step can only get active 1f the preceding transition has become TRUE Symbol Es An action can contain a series of instructions written in one of the valid programming languages It is assigned to a step and in online mode it will be processed according to the defined sequence of processing Each action to be used in SFC steps must be available as a valid POU within the SFC POU and the project EA The Add Object command is available for adding an action POU below a SFC POU 138 6 Programming Languages Editors POUS E FERO E fi Library Manager E AS_EXAMPLE PRG EA acti EY acta EY count E MA estrias ios ett Figure 6 23 Actions in POUs Tree E SFCPOL Ef count SFCPOU 1 LCount 1Countt l Figure 6 24 Example of an Action Written in ST There are the following types of actions e IEC Actions e JEC extending step actions IEC Conforming Step Action IEC Action This is an action according to standard 1EC1131 3 which will be processed according to its qualifier when the step has got active and a second time when it has got deactivated
240. nputs CLK BOOL incoming Boolean signal to be checked for rising edge Outputs Q BOOL becomes TRUE if a rising edge occurs at CLK The output Q and an internal Boolean help variable M will remain FALSE as long as the input variable CLK is FALSE As soon as CLK returns TRUE Q will first return TRUE then M will be set to TRUE This means each time the function is called up Q first will be set TRUE then return FALSE followed by a rising edge in CLK Declaration example RIRIGLASE 7 R ERIG Example in IL CAL RTRIGinst CLE YarBooll LD RTRIGinst Q ST VarBoole 192 F_TRIG Counter CTU 7 Libraries Example in FBD RTRIGinst R TRIG YarBooLl CLE Q YarBooLe Example in ST RTRIGInst CLK VarBOOLl1 VarBOOL2 RTRIGInSt Q Provided by standard library Function block detecting a falling edge Inputs CLK BOOL incoming Boolean signal to be checked for rising edge Outputs Q BOOL becomes TRUE if a falling edge occurs at CLK The output Q and an internal Boolean help variable M will remain FALSE as long as the input variable CLK returns TRUE As soon as CLK returns FALSE Q will first return TRUE then M will be set to TRUE This means each time the function 1s called up Q first will be set TRUE then return FALSE followed by a falling edge in CLK Declaration example FIRIGINSE 2 E TRIG Example in IL CAL FTRIGinst CLE VarBO0Ll LD FTRIGinst Q ST YarBooLe Example in FBD FTR
241. nsional ARRAY using the following syntax lt Name gt Index 1 Index 2 Example Care game 19 24 Check Functions In order to a proper access to ARRAY elements during runtime the function CheckBounds must be available to the application Therefore add the object POUs for implicit checks to the application using the Add Object dialog Mark the checkbox related to the type CheckBounds choose an implementation language and confirm your settings with Open whereon the function CheckBound will be opened in the editor corresponding to the implementation language selected Independently of that choice the declaration part is preset and may not be modified except for adding further local variables A proposal default implementation of the function that might be modified is given in the ST Editor This check function has to treat boundary violations by an appropriate method for example by setting a detected error flag or changing the index The function will be called implicitly as soon as a variable of type array 1s assigned ATTENTION In order to maintain the check functionality do not change the declaration part of an implicit check function 80 5 Programming Reference Example for the use of function CheckBounds The default implementation of the check function is the following Declaration part Ef Implicitly generated code lt DO NOT EDIT FUNCTION CheckBounds DINT VAR INPUT index lower upper DINT END VAR Im
242. nstructions Expressions are composed of operators operands and or assignments An operand can be a constant a variable a function call or another expression Examples Expression non OOOO po B3 Constant fct a b c Function call a AND b ey z 151 6 Programming Languages Editors real_var2 int_var Assignment Table 6 7 Expressions Valuation of Expressions The evaluation of expression takes place by means of processing the operators according to certain binding rules The operator with the strongest binding is processed first then the operator with the next strongest binding etc until all operators have been processed Operators with equal binding strength are processed from left to right Below you find a table of the ST operators in the order of their binding strength Symbol Put in parentheses expression Function name parameter list A Neg i S A D R Not equal to lt gt Pp Boolean OR OR Table 6 8 ST Operators Assignment as Expression As extension to the IEC 61131 3 standard ExST MasterTool IEC XE allows assignments to be used as an expression Examples Expressions Comment int_var1 int_var2 Assignment of the result of an expression to int_var2 and int_var3 9 int_var1 real vari real_var2 Correct assignments real_var1 and real_var2 will get the value int_var of int_var int_var real_var1 int_var This will lead to an error message b
243. nts can also be combined to form so called DATE_AND_ TIME constants Syntax AA 5 Programming Reference dt lt date and time declaration gt Instead of dt also the following can be used DT date_and_time DATE_AND_TIME The date and time declaration is to be entered in format lt year month day hour minute second gt Seconds can be entered as real numbers that is also fractions of a second can be specified DATE_AND_TIME values are internally handled as DWORD values containing the time span in seconds since 01 01 1970 00 00 clock Examples DATE AND TIME 1996 05 06 15 36 30 dt 1972 03 29 00 00 00 See also Time Data Types Number Constants Number values can appear as binary numbers octal numbers decimal numbers and hexadecimal numbers If an integer value is not a decimal number the base must be followed by the number sign in front of the integer constant The values for the numbers 10 15 in hexadecimal numbers will be represented by the letters A F You may include the underscore character within the number Examples 14 decimal number 21001 OO dual number 807 octal number 16 A hexadecimal number These number values can be of type BYTE WORD DWORD SINT USINT INT UINT DINT UDINT REAL or LREAL Implicit conversions from larger to smaller variable types are not permitted This means that a DINT variable cannot simply be used as an INT variable
244. nts can be placed everywhere within the declaration or implementation part of the ST Editor Nested comments Comments can be placed within other comments Example a inst out to be checked be b hs In this example the comment that begins with the first bracket is not closed by the bracket following checked but only by the last bracket ST Editor The ST Editor is used to create programming objects in the IEC programming language Structured Text ST resp Extended Structured Text which provides some extensions to the IEC 61131 3 standard 158 6 Programming Languages Editors The ST Editor is a text editor and thus the corresponding text editor settings in the Options dialog can be used to configure behavior appearance and menus There you can define the default settings for highlight coloring line numbers tabs indenting and many more Notice that block selection is possible by pressing lt ALT gt while selecting the desired text area with the mouse The editor will be available in the lower part of a window which also includes the Declaration Editor in the upper part Notice that in case of syntactic errors during editing the corresponding messages will be displayed in the Precompile Messages window An update of this window is done each time you re set the focus to the editor window for example put cursor in another window and then back to the editor window ST Editor in Online Mode In online mode th
245. o IEC 61131 Manual de Programaci n IEC 61131 Table 1 1 Support Documentation English Portuguese Spanish English Portuguese Spanish English Portuguese Spanish English Portuguese Spanish English Portuguese Spanish English Portuguese Spanish English Portuguese Spanish Document Code Nexto Series Features and Configuration S rie Nexto Caracter sticas e Configura es Serie Nexto Especificaciones y Configuraciones potentials accrued in the body For this touch with nude hands in a metallic surface grounded before modules handling Such procedure ensures that the levels of static electricity supported by the module will not be overcome It is important to record the serial number of each item received as well as software revisions if any This information will be necessary if you need to contact Altus Technical Support Technical Support To contact Altus Technical Support in S o Leopoldo RS call 55 51 3589 9500 To find the existent centers of Altus Technical Support in other locations see our website www altus com br or send an email to altus altus com br If the equipment is already installed please have the following information when requesting assistance Models of equipment used and the configuration of installed system Serial number of CPU Equipment review and executive software version listed on the label affixed to the product side Information about the operation o
246. obal variable list GVL_2 tatrribuce Global ante slot 7S 300 VAR GLOBAL A INT 1000 END_VAR Setting the attribute global_init_slot of GVL_2 to 300 lowest value in order of initializing ensures that the expression A 1 1s defined during initialization of B and C so you can use these variables normally in any POU of the project If the pragma is removed from GVL_2 and variables of GVL_1 are used in any POU it will show an error during project building Hide Attribute With the help of the pragma attribute hide you may prevent variables or even whole signatures from being displayed within the List Components functionality the Input Assistant or the declaration part in online modus Only the variable subsequent to the pragma will be hidden Syntax attribute hide To hide all local variables of a signature use this attribute Example The function block myPOU is implemented making use of the attribute FUNCTION BLOCK my POU VAR INPUT a INT attribute hide a invisible BOOL 60 5 Programming Reference a visible BOOL END_VAR VAR OUTPUT bz LNT END VAR VAR END VAR In the main program two instances of function block myPOU are defined PROGRAM mainprg VAR POUL POUZs myPOU END VAR When assigning e g an input value to POU1 the List Components function working on typing POU in the implementation part of MainPrg will display the variables a a_visible and a but not the
247. of the POUs and thus some existing assignments might be removed To move an element select the element by a mouse click on the element body see possible cursor positions and drag it while keeping the mouse button pressed to the desired position Then leave the mouse button to place the element You also can use the Cut and Paste commands for this purpose Connecting Copying Editing Deleting The connections between the inputs and outputs of elements can be drawn with the mouse The shortest possible connection will be created taking into account the other elements and connections If the course of connection lines is painted light grey colored this might indicate that elements are positioned covering each other To copy an element select it and use the Copy and Paste commands After inserting an element by default the text part is represented by To replace this by the desired text POU name label name instance name comment etc select the text by a mouse click to get an edit field Also button will be available then to open the Input Assistant A selected element can be deleted by command Delete which 1s available in the context menu or by the lt DEL Execution Order Element Numbers The sequence in which the elements in a CFC network are executed in online mode 1s indicated by numbers in the upper right corner of the box output jump return and label elements The processing starts at the element wit
248. ogramming Languages Editors e gt for output parameters Second column operand actual parameter and 66 99 e gt if further parameters follow e after the last parameter e in case of parameter less calls Example Call of POUToCAII with two input and two output parameters PROGRAM IL EXAMPLE YAR hErr BOOL Result WORD EHD VAR SS n w M FP CAL POUToaCall ifounter 1 ibecrement 1000 WError gt Result LD POUToCall bError ST HE rr Action Call To be done like a function block or program call The action name is to be appended to the instance name or program name Example of calling the action ResetAction in IL CAL Inst Resetaction Method Call To be done like a function call The instance name with appended method name is to be entered in the first column operator Example of calling the method Home in IL LD TRUE IHome Home TRUE TRUE ST Z Jump A jump is programmed by JMP in the first column operator and a label name in the second column operand The label is to be defined in the target network in the label field Remark that the statement list preceding the unconditional jump has to end with one of the following commands ST STN S R CAL RET or another JMP This is not the case for a conditional jump being programmed by JMPC in the first column operator instead of JMP The execution of the jump depends on the value loaded
249. ol IEC XE Support Documentation occcccnnnncncncnnnnnononononnnnnnnnnnnnnnnnnnonononnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnns 7 Visual TMS PECUION ciesoriaus reann aa a 7 Technical SUP DOLE aeee a E EA A neos 7 Warning Messages Used in this Manual sssesesssccececccccoccossocccesccccesecocososeoscccesecccecscecoososseseceseccececeesosssssssesees 8 Ze TECHNICAL DESCRIPTION siscticissdcsiecaddedicestiaunscstestvcissssciecaddalscstecsncesdeciucsisdacsecadssssessteasvuesdesseessedeescdecssaens 9 Master Lool IEC AE Verso iia AAA an 9 LANUS Aaa aa 9 Compatibility With Other Products siccsssscsesss ecsencsiscsescs adsvnstecsnasstacsencsteaseas adsvadetecsnavstassensstecsseestadteussseeseuss 10 Minimum Keguirements ud rinden A A A TN 10 Data tor PULCHASE anilla 11 TiC MWe GMC TAS A NEC PO cant hesaeuiaes 11 Exodus allioli ass 11 3 CONCEPTS AND BASIC COMPONENTS sisi asesir oio indi 12 EARO CUI OND M OE A AE OOE OO OI EE E OA ET 12 Basie CONCE DUIS iii 12 Advanced Funcionales ini ea E i EEEE EEE OSETE 12 Object Orientation in Programming and in the Project Structure ooooonnnnnccncnnncnnnnnnnononnnnnnnnnnnnnnnnnnnnnnnnnnos 12 Special Data POS A E 13 Operators and Special VD daa 13 User Management and Access Rights Conc Piu an etnies seen A E aii rane iecesaaten 13 Characteristics IT EdIOS nca a 13 D y V E OS E E N 13 Additional Funcionales sd di 13 A AN 14 A AN 14 PP ON 14 PPP CATION A NAS AAA A AA EAS AAA AAA AAA AAA AA 15 EAN O EEE OEEO E
250. olute value of a number ABS 2 returns 2 In and output can be of any numeric basic data type Example in IL ST 1 Result in 1 is 2 Example in ST 1 ABS 2 109 SQRT LN LOG 5 Programming Reference Example in FBD IEC Operator Returns the square root of a number The input variable can be of any numeric basic data type the output variable must be type REAL or LREAL Example in IL LD 16 SORT ST a n_n Result in q 1s 4 Example in ST q SORT 16 Example in FBD IEC Operator Returns the natural logarithm of a number The input variable can be of any numeric basic data type the output variable must be type REAL or LREAL Example in IL LD 45 LH ST Result in q is 3 80666 Example in ST q LN 45 Example in FBD LH 45 a IEC Operator Returns the logarithm of a number in base 10 The input variable can be of any numeric basic data type the output variable must be type REAL or LREAL Example in IL LD ald a LOG ST a Result in q 1s 2 49762 110 EXP SIN COS 5 Programming Reference Example in ST q LOG 314 5 Example in FBD 314 5 q IEC Operator Returns the exponential function The input variable can be of any numeric basic data type the output variable must be type REAL or LREAL Example in IL LD E EXP oT q Result in q 1s 7 389056 Example in ST a EXP 2 Example in FBD A IEC Operator Returns th
251. on of the PID block If false Sele BOOL the derivative action is set to zero When true enables the integral action of the PID block If false the BOOL cae integral action is set to zero When true the derivative action is calculated in the process variable being different from zero only when PV is changed If false Denya BOOLE the derivative action is calculated in error being dependent on the variables SP and PV When true enables the manual mode If false enables the BOOL automatic mode The control mode of the PID block affects the way the MV and the action integral is calculated When true you select the direct control so that MV is considered in BOOL the response to be included in the PV If false it selects the reverse control In this case MV is not considered in the response to be included in the PV When true the sampling time is measured If false the sampling aca time is entered by the user in the variable SampleTime When true resets PID block initializing all variables It can also be BOOL used to clear the integral and derivative action and error codes in the block output IntegralAction REAL Stores the integral action which is deleted in error state Table 7 9 Input Parameters Output parameters REAL Manipulated variable Effective time of sampling in seconds used for calculating the derivative action and rate limit of MV EFf3ST REAL Effective time sampling of the last three cy
252. on the application Free allocation of code and data memory 13 3 Concepts and Basic Components e Each object can be specified as internal or external late link on the runway system e Pre building notes concerning syntactic errors Profiles Project Device A MasterTool IEC XE project profile is a set of rules common characteristics and patterns used in the development of an industrial automation solution It s a profile that influences the form of implementation of the application With the diversity of types of applications supported by Nexto Series Runtime System to follow a profile is a way to reduce the complexity in programming Applications can be created as one of the following profiles Single Basic Normal Expert Custom MasterTool IEC XE software provides a template called MasterTool Standard Project which shall be selected by the user as a model in the project creation The new application will be developed as a specific profile also chosen by the user adopting rules features and predefined patterns Each project profile defines To ensure compatibility of a project to a certain profile throughout development we use two approaches e MasterTool IEC XE only allows the creation of projects based on a template by selecting at the same time the profile to be used e Incode generation MasterTool IEC XE checks all the rules defined for the valid profile to the project For details see Profiles i
253. ool IEC XE Support Documentation It is advisable to consult the following documents as a source of additional information CE114000 CT114000 CS114000 CE114100 CT114100 CS114100 CE103705 CT103705 CS103705 MU214600 MU214000 MU214300 MU214605 MU214100 MU214305 MU299609 MU299048 MU299800 MU399609 MU399048 MU399800 Visual Inspection Prior to installation we recommend performing a careful visual inspection of equipment by checking if there is damage caused by shipping Make sure all components of your order are in perfect condition In case of defects inform the transportation company and the nearest Altus representative or distributor CAUTION Before removing modules from the package it is important to discharge eventual static CPUs Nexto Series Features and Configuration UCPs S rie Nexto Caracter sticas e Configura es UCPs Serie Nexto Especificaciones y Configuraciones MasterTool IEC XE Features and Configuration MasterTool IEC XE Caracter sticas e Configura es MasterTool IEC XE Especificaciones y Configuraciones Nexto Series User Manual Manual de Utilizac o S rie Nexto Manual Del Usuario Serie Nexto Nexto Series CPUs User Manual Manual de Utiliza o UCPs S rie Nexto Manual del Usuario UCPs Serie Nexto MasterTool IEC XE User Manual Manual de Utilizac o MasterTool IEC XE Manual del Usuario MasterTool IEC XE IEC 61131 Programming Manual Manual de Programac
254. operating hours which should continue counting even after a power fail or download See below the synoptic table Persistent variables ONLY can be declared in a special global variables list of object type Persistent Variables which is assigned to an application There might be only ONE such list per application NOTE A declaration with VAR GLOBAL PERSISTENT effects the same as a declaration with VAR_GLOBAL PERSISTENT RETAIN or VAR_GLOBAL RETAIN PERSISTENT Like retain variables the persistent variables get stored in a separate memory area Example VAR GLOBAL PERSISTENT RETAIN iVarPersl DINT 1 Persistent Retain Variable Appl bVarPers BOOL 2 Persistent Retain Variable Appl END VAR NOTE Currently only global persistent variables are possible except that there is some mechanism that allows the PLC using this type of operation The target system must provide a separate memory area for the persistent variables list of each application At each re load of the application the persistent variables list on the PLC will be checked against that of the project The list on the PLC inter alia is identified by the application name In case of inconsistencies the user will be prompted to re initialize all persistent variables of the application Inconsistency might result from renaming or removing or other modifications of the existing declarations in the list 52 5 Programming Reference NOTE So carefully consi
255. operties dialog for the library placeholder you get information on the currently set default library Properties This command is available in the Library Manager editor window It opens the Properties dialog for the library which is currently selected in the Library Manager window and allows the following settings concerning namespace version handling availability and visibility of library references Properties NextoStandard 1 0 0 11 WAA General Version Namespace NextoStandard Spedfic version 1 0 0 11 Newest version always Visibility If the current project is referenced as a library by another project Publish all IEC symbols to that project as if this reference would have been included there directly Hide this reference in the dependency tree Gama Figure 4 3 Properties Dialog for Library e Namespace The current namespace of the library is displayed By default the namespace of a library primarily 1s identic with the library name except another string has been defined explicitly in the Project Information when creating the library project You can edit the namespace anytime here in the properties dialog For further information on the namespace of libraries see the item editor window see the Library Manager Editor in the MasterTool IEC XE User Manual MU2996009 e Default library only available if option Enable repository dialog is enabled see Features in the MasterTool IEC XE User Manual MU2996
256. oscillations Tc To determine the controller constants just apply the values of Tc and GPc on the formulas of the Table 7 11 223 7 Libraries n PV Te ap dpe o ee oe oe A ffs Figure 7 22 Oscillations with Constant Amplitude Controller Type Proportional P GP 0 5 GPc Proportional and Integral PI cie oo Gp 0 75 GPc Proportional Integral and Derivative PID Ti Tc 1 6 Td Tc 10 Table 7 11 Values of GPc e Tc Determination of Controller Constants Through the Process Constants This method is applied well to linear processes of first order similar to a RC circuit and with dead time In practice many industrial processes fit into this model The method requires initially to determine the following process characteristics using opened loop e K Static gain of process It is defined as the ratio between a PV variation and a MV variation that is K APV AMV e Tm Dead time defined as the time between the beginning of a variation on output MV t0 and the start of the system reaction e T Time constant of the system defined as the time which the process variable takes to reach 63 212 of its final value Furthermore the method requires two additional parameters which are not characteristics of the process itself and should be entered by the user e Tr Response time desired after the loop sintony This is an interesting feature because through t
257. otate LEFT 1 ST stRotate Function Calls Enter the function name in the operator field The first input parameter is to be given as an operand in a preceding LD operation If there are further parameters the next one must be given in the same line as the function name The further ones can also be added in this line separated by commas or in subsequent lines The function return value will be stored in the accumulator but notice the following restriction concerning the IEC standard A function call with multiple return values is not possible only one return value can be used for a succeeding operation Example Function GeomAverage which has three input parameters is called The first parameter is given by X7 in a preceding operation the second one 25 is given behind the function name The third one is given by variable tvar either in the same line or in the subsequent one The return value is assigned to variable Ave Example for function call GEOMAVERAGE in ST Ave GeomAverage X7 25 tvar Example for function call GEOMAVERAGE in IL LD E Geomirerage 25 oT Ave Function Block Calls Program Calls Use the CAL or CALC operator Enter the function block instance name resp the program name in the operand field second column followed by the opening bracket Enter the input parameters each in one of the following lines First column operator parameter name and e for input parameters 169 6 Pr
258. ple a reset to FALSE of the SFCReset flag could be done in the Init step SFCError BOOL As soon as any timeout occurs at one of the steps in the SFC this variable will get TRUE Precondition SFCEnableLimit must be TRUE Notice that any further timeout cannot be registered before a reset of SFCError SFCError must be defined if you want to use the other time controlling flags SFCErrorStep SFCErrorPOU SFCQuitError SFCEnableLimit This variable can be used for the explicit activation TRUE and BOOL deactivation FALS of the time control in steps via SFCError This means that If this variable is declared and activated SFC Settings then it must be set TRUE in order to get SFCError working Otherwise any timeouts of the steps will not be registered The usage might be reasonable during start ups or at manual operation If the variable is not defined SFCError will work automatically Of course as a precondition SFCError must be defined SFCErrorStep STRING This variable stores the name of a step at which a timeout was registered by SFCError timeout Precondition SFCError must be defined SFCErrorPOU STRING This variable stores the name of the SFC POU in which a timeout has occurred Precondition SFCError must be defined SFCQuitError BOOL As long as this variable is TRUE the execution of the SFC diagram is stopped and variable SFCError will be reset As soon as the variable has been reset to FALSE all current time states i
259. plementation part Implicitly generated code Only an Implementation suggestion IF index lt lower THEN CheckBounds lower ELSIF index gt upper THEN CheckBounds upper ELSE CheckBounds index END IF When called the function gets the following input parameters e Index Field element index e Lower The lower limit of the field range e Upper The upper limit of the field range As long as the index is within the range the return value is the index itself Otherwise in correspondence to the range violation either the upper or the lower limit of the filed range will be returned In the program beyond the upper limit of the ARRAY A is exceeded PROGRAM MAINPRG VAR a ARRAY 0 7 OF BOOL b INT 10 END VAR alo ls TRUE In this case the implicit call to the CheckBounds function preceding the assignment effects that the value of the index is changed from 10 ten into the upper limit 7 seven Therefore the value TRUE will be assigned to the element a 7 of the ARRAY This is how attempted access outside the field range can be corrected via the function CheckBounds Structures Structures are created as DUT Data Type Unit objects via the Add Object dialog They begin with the keywords TYPE and STRUCT and end with END_STRUCT and END_TYPE The syntax for structure declarations is as follows TYPE lt Structure name gt STRUCT lt Declaration of variables 1 gt lt Declaration Of variables g
260. pper limit for the manipulated variable Y If Y exceeds these limits output LIMITS ACTIVE will be set to TRUE and Y will be kept within the prescribed range This control will only work if Y_MIN lt Y_ MAX MANUAL BOOL If TRUE manual operation will be active that is the manipulated value will be defined by Y_ MANUAL RESET BOOL TRUE resets the controller During reinitialization Y Y_ OFFSET Table 7 5 Input Variables PID Outputs of the Function Block Datatype REAL Manipulated value calculated by the function block LIMITS ACTIVE BOOL TRUE indicates that Y has exceeded the given limits Y_MIN 207 7 Libraries PO ANTES OVERFLOW BOOL TRUE indicates an overflow Table 7 6 Output Variables PID Y_OFFSET Y_MIN und Y_MAX serve for transformation of the manipulated variable within a prescribed range MANUAL can be used to switch to manual operation RESET can be used to re initialize the controller In normal operation MANUAL RESET LIMITS_ACTIVE FALSE the controller calculates the controller error e as difference from SET POINT ACTUAL generates the derivation with respect to time de dt and stores these values internally The output that is the manipulated variable Y unlike the PD controller contains an additional integral part and is calculated as follows Y KP x D 1 TN ledt TV dD dt Y_OFFSET So besides the P part also the current change of the controller error and the
261. project via the Add Object command To assign it to an existing application first select the application entry in the Devices view Otherwise it will be added to the POUs view In the Add DUT dialog enter a name for the new data type unit and choose the desired type Structure Enumeration Alias or Union In case of type Structure you might utilize the principle of inheritance thus supporting object oriented programming Optionally you can specify that the DUT should extend another DUT which is already defined within the project This means that the definitions of the extended DUT will be automatically valid within the current one For this purpose activate option Extends and enter the name of the other DUT After confirming the settings with button Open the editor window for the new DUT will open and you can start editing Syntax for declaration of a DUT TYPE lt IDENTIFIER gt lt DUT COMPONENTS DECLARATION gt END LIPE The DUT components declaration depends on the type of DUT e g a structure or an enumeration Example See in the following two DUTS defining structures struct1 and struct2 struct2 extends struct1 which means that you can use struct2 a in your implementation to access variable a TYPE SECUCEL STRUCT A INT B BOUL END STRUCI END TYPE TYPE struct2 EXTENDS structl STRUCT C DWORD D STRING END STRUCT END TYPE he f LE Supporting object oriented programming Methods lt M can be
262. pulate name b Example TYPE name UNION a LREAL DE BINT END UNION END TYPE LTIME As extension to the IEC 61131 3 LTIME is supported as time base for high resolution timers LTIME is of size 64 Bit and resolution nanoseconds Syntax LTIMEF lt Time declaration gt The time declaration can include the time units as used with the TIME constant and additionally microseconds us and nanoseconds ns Example LTIME1 LTIME 1000d15h23m12s34ms2us44ns Compare to TIME Constants size 32 Bit and resolution milliseconds WSTRING This string data type is an extension to the IEC 61131 3 standard It differs from the standard STRING type ASCII by getting interpreted in Unicode format Example WStr wSTRING s This vs a WStraing See also See also REAL LREAL Constants STRING and STRING Constants Operands Pointers As an extension to the IEC 61131 3 standard it is possible to use pointers Pointers save the addresses of variables programs function blocks methods and functions while an application program is running A pointer can point to any of those objects and to any data type even to user defined data types Notice the possibility of using an implicit pointer check function Syntax lt Identifier gt POINTER TO lt Data type Function block Program Method PUNCE VON Dereferencing a pointer means to obtain the value currently stored at the address to which it is pointing A pointer can be dereferenced by add
263. r provides Volt values input IN These are to be converted to temperature values in degree centigrade output OUT The input Volt values range is defined by the limits IN_MIN 0 and IN_MAX 10 The output degree centigrade value range is defined by the limits OUT_MIN 20 and OUT_MAX 40 Thus for an input of 5 V a temperature of 10 C will result STATISTICS INT Provided by util library This function block calculates some standard statistical values The input IN is of the type INT All values are initialized anew when the boolean input RESET is TRUE The output MN contains the minimum MX of the maximum value from IN AVG describes the average that is the expected value of IN All three outputs are of the type INT Example of STATISTICS INT in FBD STAT STATISTICS INT STATISTICS REAL Provided by util library This function block corresponds to STATISTICS_INT except that the input IN is of the type REAL like the outputs MN MX AVG VARIANCE Provided by util library VARIANCE calculates the variance of the entered values The input IN is of the type REAL RESET is of the type BOOL and the output OUT is again of the type REAL This block calculates the variance of the inputted values VARIANCE can be reset with RESET TRUE The standard deviation can easily be calculated as the square root of the VARIANCE Controllers PD The library util library provides the PD controller function block Example of PD in FBD 205
264. ress using the keyword AT In function blocks you can also specify variables with incomplete address statements In order that such a variable can be used in a local instance there must be an entry for 1t in the variable configuration Valid data type optionally extended by a lt initialization gt Optionally pragma instructions can be added in the declaration part of an object in order to affect the code generation for various purposes Recommendations on the Naming of the Identifiers Identifiers are defined at the declaration of variables variable names user defined data types and at the creation of POUs functions function blocks programs In addition to the items to be regarded anyway when defining an identifier you might consider to follow some recommendations in order to make the naming as unique as possible Variable Names The naming of variables in applications and libraries as far as possible should follow the Hungarian notation For each variable a meaningful short description should be found the base name The first letter of each word of a base name should be a capital letter the others should be small ones Example FileSize Before the base name corresponding to the data type of the variable prefix es are added in small letters 43 5 Programming Reference See in the following table some information and the recommended prefixes on the particular data types Data type Lower limit Info
265. rg TF huarEsi tel THEI Figure 6 42 Breakpoint in Online Mode 1 in Jo pe trins TF hwa Al SF E THF seas 6 43 Breakpoint Disabled 1l ldlij 210 Ergo fbinst 3 TF Wrarkal sel THEE Figure 6 44 Program Stop at Breakpoint NOTE The following must be noticed for breakpoints in methods A breakpoint will be set automatically in all methods which might be called If a method is called via a pointer on a function block breakpoints will be set in the method of the function block and in all derivative function blocks which are subscribing the method FBD LD IL Editor The FBD LD IL editor provides commands for working in the combined editor for Function Block Diagram FBD Ladder Logic Diagram LD and Instruction List IL 161 6 Programming Languages Editors Function Block Diagram FBD The Function Block Diagram is a graphically oriented programming language It works with a list of networks whereby each network contains a graphical structure of boxes and connection lines which represents either a logical or arithmetic expression the call of a function block a jump or a return instruction Tl T2 TON TON T2 0 IN Q Y IN Q Blink T 23 PT Gif ETL T ls PT ETF ET2 Inst UpindD own TRUE Enable Value x 100 Amplitude Upf Up Blink GoHome Downp Down stRotate Figure 6 45 Function Block Diagram Network Ladder Diagram LD The Ladder Diagram is a graphics oriented programming la
266. riable List Method Property Program Function Function Block Persistent Vars POUs for Implicit Checks Besides the Program Organization Unit objects there are Device objects used for running the program on the target system resource application task configuration etc Those are managed in the Devices view A POU in this context is a Program Organization Unit of type Program Function or Function block In order to add a POU EJ select an appropriate entry in the POUs or Devices tree for example an application object use command Add Object from the context menu and select POU from the appearing submenu The Add POU dialog will open where you have to configure the POU concerning name type and implementation language In case of a function block optionally EXTENDS and IMPLEMENTS properties can be defined in case of a function also the return type must be specified See the respective chapters on Program Function and Function Block 18 3 Concepts and Basic Components Add POU H Create a new POU Program Organization Unit Name fbscale Type Program 2 Function Block 4 Extends fbAss1 Implements Continuous Function Chart CFC Function Implementation language Structured Text ST Games Figure 3 1 Add POU Dialog Depending on the type the POU can be supplemented by methods properties actions transitions For this also use the Add Object command The hierarchical
267. rmation Comment content BIT pit pb BOOL FALSE TRUE tet BYTE 8 Bits by Bit string not for arithm operations O EAT rr operations IA operations oO a ln operations 127 8Bis si o o osm o 8Bis fst 3 O m 32767 teBits i UNT o ss gt teBts uw DINT 2147 483 648 2 147 483 647 32Bis di _____ uon o 4294967295 s2Bits ud o punts tits ip punt o 77a oss al oo o Re s r o Re its e e a is SS Ooo me i ti TIMEOFDAY CT DATE AND TIME ENM ee Table 5 1 Data Types Notes x Pointedly for Boolean variables x is chosen as prefix in order to differentiate from BYTE and also in order to accommodate the perception of an IEC programmer see addressing IX0 0 Examples Sublndex BYTE sFileName STRING var Counters UBDINTS In nested declarations the prefixes are attached to each other in the order of the declarations Example pabyTelegramData POINTER TO ARRAY 0 7 OF BYTE Function block instances and variables of user defined data types as a prefix get a shortcut for the FB and data type name for example sdo Example cansdoReceivedTelegram CAN SDOTelegram TPB CAN SDOtelegral y 0 Pretist Gdo a gt IRUCT wIindex WORD bySublndex BYTE 44 5 Programming Reference byLen BYTE aby ARRAY 0 3 OF BYTE END STRUCT END TYPE Local constants c start with pr
268. rned in CDT as long as EN is TRUE As soon as EN is reset to FALSE CDT is reset to the initial value DT 1970 01 01 00 00 00 199 7 Libraries Example in IL CAL RTCinst i EN VarBO0Ll F PDT DT 2006 035 30 14 00 CDT gt VYarTinelur LD RTCingst ST YarBooLe Example in FBD ETCinst WarBO00Ll DT 2006 03 30 14 00 00 WarBo00L Example in ST RIC EN VarBOOL1 PDT DT 2006 03 30 14 00 00 O gt VarBOOL2 CDT gt VarTimeCur The UTIL library Library This library contains an additional collection of various blocks which can be used for BCD conversion bit byte functions mathematical auxiliary functions as controller signal generators function manipulators and for analogue value processing BCD Conversion Provided by util library A byte in the BCD format contains integers between O and 99 Four bits are used for each decimal place The ten decimal place is stored in the bits 4 7 Thus the BCD format is similar to the hexadecimal presentation with the simple difference that only values between 0 and 99 can be stored in a BCD byte whereas a hexadecimal byte reaches from 0 to FF Example The integer 51 should be converted to BCD format Five in binary is 0101 one in binary is 0001 which makes the BCD byte 01010001 which corresponds to the value 51 81 BCD_TO_INT Provided by util library This function converts a byte in BCD format into an INT value The input value of
269. rsion info and a company name in its Project Information Optionally a category can be defined which might serve later for sorting in the Library Manager If no category assignment is defined in the Project Information the library automatically will belong to category Miscellaneous Further categories might be defined in one or several xml files libcat xml which can be loaded in the Project Information dialog in order to select one of the categories Please see also below Creating Libraries Encoding Documentation The Library Manager 1s used to include libraries in a project In a MasterTool Standard Project a Library Manager object by default is automatically assigned to the default device However a Library Manager object can also be added explicitly in the Devices or POUs view window This is to be done like for other objects with the Add Object dialog Libraries referenced in other libraries by default are also displayed in the Library Manager however also hidden libraries are possible see below Referenced Libraries If the library file is available and not only its compiled version compiled library the POUs of the related library may be opened by a double click on their referencing within the library manager If a library module is called by an application all libraries and repositories will be searched in that order which is defined in the Library Repository dialog See below for unique accessing Referenced Libraries Librarie
270. ruction List IL and Continuous Function Chart CFC MasterTool IEC XE allows the use of different languages on the same application providing to the user a powerful way to organize the application and to reuse codes used in previous applications This product offers features for every stage of an automation application starting from initial graphical architecture topology analyses passing through a programming environment that supports IEC 61131 3 languages and a realistic simulation tool where the user can verify application s behavior before running in a real system and ending in a complete diagnostics and status visualization interface MasterTool IEC XE also offers two different protection schemes as application security features IP Protection and Secure PLC Login IP Protection is targeted to protect user s intellectual property allowing the user to protect the complete project and files by defining a password to access them This means that these files will be available both read and write operations only after unlocking them with the correct password Secure PLC Login provides a way to protect the user application from any unauthorized access By enabling this feature Nexto CPU will request a user and a password before performing any available command in MasterTool IEC XE and Nexto CPU as stopping programming and forcing of outputs in the target CPU MasterTool IEC XE allows the use of fieldbus interfaces in an easier way than
271. s can include further libraries referenced libraries whereby the nesting can have any desired depth When you add a library including other libraries in the library manager the referenced libraries will be added automatically too When creating a library project which includes other libraries in the Properties of each referenced library it can be defined how it should behave later when getting inserted in a project with its father library Its pure visibility in the Library Manager indented below the father library can be deactivated Thus hidden libraries can be available in a project If you are just creating a pure container library that is a library projects which is not defining own modules but only is referencing other libraries the access on the modules of these libraries can be simplified A container library is created because you want to include a complete set of libraries in a project at the same time by just including the container library In this case it might be desired to simplify the access on the modules of these libraries by making them top level libraries which allows leaving out the namespace of the container library in the access path This can be reached by activating option Publish However this option should really only be activated when creating a container library and should be handled with great caution Library Versions Multiple versions of the same library can be installed on the system Multiple versions o
272. s dialog have the button Display file properties 1t opens the standard dialog for the properties of a file which also appears when you select the file object in the POUs window and use command 32 3 Concepts and Basic Components Properties The dialog 1 e contains a tab External file where the properties which have been set in the Add Object dialog can be viewed and modified POUS for Implicit Checks Below an application you might add special POUs which must be available there if the implicitly provided check functionality for array and range boundaries divisions by zero and pointers during runtime should be used For this purpose the Add Object menu in category POUs for Implicit Checks E presents the following functions CheckBounds CheckDivDInt CheckDivLInt CheckDivReal CheckDivLReal CheckRangeSigned CheckRangeUnsigned CheckPointer After having inserted a check POU it will be opened in the editor corresponding to the implementation language selected A default implementation that might be adapted to your requirements is available in the ST editor After having inserted a certain check POU the option will not be available in the dialog any longer thus avoiding a double insertion If all types of check POUs have already been added below the application the Add Object dialog at all will not provide the POUs for Implicit Checks category any longer Library Management Libraries can provide functions and
273. s recommended that whenever discarding this type of product it should be forwarded to recycling plants which guarantee proper waste management It is essential to read and understand the product documentation such as manuals and technical characteristics before its installation or use Altus warrants its equipment as described in General Conditions of Supply attached to the commercial proposals Altus guarantees that their equipment works in accordance with the clear instructions contained in their manuals and or technical characteristics not guaranteeing the success of any particular type of application of the equipment Altus does not acknowledge any other guarantee directly or implied mainly when end customers are dealing with third party suppliers Requests for additional information about the supply and or characteristics of Altus equipment and services must be made in writing Altus is not responsible for information provided about its equipment without formal registration COPYRIGHTS Nexto and MasterTool IEC IEC XE are registered trademarks of Altus Sistemas de Automac o S A Windows is a registered trademark of Microsoft Corporation Summary Summary SUMMARY AA docs dassssdececadsbacusvcisnadeadesddenssdeceuadobasuevsauaadetdesddansasdccsudenaseousiinaded dostssasestecesedsaasveseus H ly INTRODUCTION iia 6 Documents Related to thts Mammalia eE ea a a aiai 6 General Regards on ALTUS Documentation uni tia 6 MasterTo
274. s with different protocols Physical equipment used in data processing which normally run programs software Generic standard for operation and use of PLCs Former IEC1131 Adapts electric and or logically the transfer of signals between two devices Also called I O I O devices on a system In the case of PLCs typically correspond to modules digital or analogue output or input monitoring or driving the controlled device See Input Output Module belonging to subsystem of inputs and outputs Memory size unit Represents 1024 bytes Action to establish a communication channel with the PLC Equipment connected to a communications network where originate command requests to other network equipment Set of options available and displayed by a program in the video and that can be selected by the user to activate or to perform a particular task Basic element of a system with very specific functionality It s normally connected to the system by connectors and may be easily replaced Any station of a network with communication skills using an established protocol Elements on which the instructions work Can represent constants variables or a set of variables Acronym for programmable controller See Programmable Controller Program Organization Unit is a subdivision of the application program that can be written in any of the available languages Also known as PLC Equipment controlling a system under the command of an application progra
275. se of using pointers on addresses This address operator is not prescribed by the standard IEC 61131 3 100 5 Programming Reference BITADR returns the bit offset within the segment in a DWORD Notice that the offset value depends on whether the option byte addressing in the target settings 1s activated or not VAR varl AT I1X2 3 BOOL bitoffset DWORD END VAR Example in ST bitoffset BITADR varl Result 16 80000013 Example in IL LD varl BITADR ST hitoftfset NOTE After an Online Change there might be changes concerning the data on some addresses Please notice this in this case of using pointers on addresses Content Operator This address operator is not prescribed by the standard IEC 61131 3 IEC A pointer can be dereferenced by adding the content operator after the pointer identifier Example in ST DLA POINTER TO INT var Intl INT var int INI PE ADR v r intl var ILAS pu NOTE After an Online Change there might be changes concerning the data on some addresses Please notice this in this case of using pointers on addresses Calling Operator CAL IEC Operator for calling a function block or a program Use CAL in IL to call up a function block instance The variables that will serve as the input variables are placed in parentheses right after the name of the function block instance Example Calling up the instance Inst from a function block where input v
276. sign When you leave the mouse button the element will be inserted To select an inserted element for further actions like editing or rearranging notice the possible cursor positions for element bodies in and outputs and text By a mouse click on a elements body the element gets selected and will be displayed by default red shaded now By additionally keeping pressed the lt SHIFT gt key you can click on and thereby select further elements You also can press the left mouse button and draw a dotted rectangle around all elements which should be selected As soon as you leave the button the selection will be indicated By command Select all which by default is available in the context menu all elements are selected at once By using the arrow keys the selection mark can be shifted to the next possible cursor position The sequence depends on the execution order or the elements which is indicated by element numbers see below 128 6 Programming Languages Editors When an input pin is selected and lt CTRL gt lt LEFT ARROW gt are pressed the corresponding output will be selected When an output pin 1s selected and lt CTRL gt lt LEFT ARROW gt are pressed the corresponding output s will be selected Replacing Boxes Moving To replace an existing box element replace the currently inserted identifier by that of the desired new element Notice that the number of input and output pins will be adapted if necessary due to the definition
277. signed via the step element properties e Macros can be used for structuring purposes SFC Sequential Function Chart The Sequential Function Chart SFC is a graphically oriented language which allows to describe the chronological order of particular actions within a program These actions are available as separate programming objects written in any available programming language In a SFC they get assigned to step elements and the sequence of processing is controlled by transition elements For a detailed description on how the steps will be processed in online mode see Sequence of Processing in SFC Parallel BE l Figure 6 13 Example for a Sequence of Steps in a SFC Module Cursor Positions in SFC A possible cursor position in a SFC diagram in the SFC Editor is indicated per default by a grey shadow when moving with the cursor over the elements There are two categories of cursor positions Texts and element bodies See the possible positions indicated by a grey shaded area as shown in the following pictures 132 6 Programming Languages Editors Texts ell Step name Transition name arama Qualifier of action Branch name i 3tepl A E Action name Jump Figure 6 14 Possible Cursor Positions Texts When you click on a text cursor position the string will get editable m NES Figure 6 15 Select Action Name for Editing Element Bodies be Step name Transition name Brancho Fall
278. sition in FBD or LD an assignment will be inserted directly in front of the selected input directly after the selected output or at the end of the network In an LD network an assignment will be displayed as a coil Alternatively drag the assignment element from the toolbox or copy or move it by drag amp drop within the editor view After insertion the text string can be replaced by the name of the variable that is to be assigned For this via the button you can use the nput Assistant ad In IL an assignment is programmed via LD and ST instructions See in this context Modifiers and Operators in IL 175 Jump Label 6 Programming Languages Editors Depending on the selected position in FBD or LD a jump will be inserted directly in front of the selected input directly after the selected output or at the end of the network Alternatively drag the jump element from the Toolbox or copy or move it by drag amp drop within the editor After insertion the automatically entered can be replaced by the label to which the jump should be assigned In IL a jump is inserted via an JMP instruction Each FBD LD or IL network below the network comment field has a text input field for defining a label see command nsert label The label is an optional identifier for the network and can be addressed when defining a jump It can consist of any sequence of characters 1 Title Network Comment Network Label Network
279. sult is FALSE pye DT TO PIE Diao 00115 05705 205 7 4 i Result is 29952 Result is 129 Result is DT 1998 02 13 20 stei DT TO STRING DI 1998302213714720 A gt Examples in FBD DATE TO BOOL C 1970 01 0l1 b DATE TO IHT D 1970 01 15 i DATE TO BYTE D41970 01 15 05 05 05 i DT TO STRING D41998 02 13 14 20 Str STRING_TO Conversions IEC Operator Converting from the variable type STRING to a different type The conversion works according to the standard C compilation mechanism STRING to INT and then INT to BYTE The higher byte will be cut thus only values of 0 255 result This way 1t 1s possible on most processors to generate optimal code because the conversion can be performed by a single machine instruction Syntax for the conversion operator STRING TO lt Data type gt The operand from the STRING type variable must contain a value that is valid in the target variable type otherwise the result will be 0 LD TRUE STRING TO BOOL ST b Result is TRUE LD ahos4 STRING TO WORD ST W Result is O TRUNC 5 Programming Reference LD t 1ll7ms STRING TO TIME ST E Result is T 117ms LD reba STRIHG TO BYTE ST hy Result is 244 Examples in ST b gt STRING TO BOOL TRUE Result is TRUE w STRING TO WORD abc34 Result is 0 E t STRING TO TIME T 127ms Result is T 127ms bv s STRING TO_BYTE 500 Result is 244 Examples in FBD STRING
280. symbol configuration and it will be written in the PLC Read Write Combination of Read and Write By default nothing is entered here which means that the symbol not at all is exported to the symbol configuration Table 6 2 Common Properties Description Property Initial Step This option always is activated in the properties of the current initial step init step By default it is activated for the first step in a SFC and deactivated for other steps Notice that if you activate this option for another step you must deactivate it in the previous init step in order to avoid a compiler error Notice the possibility to detect timeouts in steps by the SFCError flag Minimal active Minimum length of time the processing of this step should take permissible values time according to IEC syntax for example t 8s or TIME variable default t 0s Maximal active Maximum length of time the processing of this step should take permissible values time according to IEC syntax for example t 8s or TIME variable default t 0s 135 6 Programming Languages Editors Define here the actions to be performed when the step is active Notice the description of the sequence of processing for details Step entry This action will be executed after the step has got active Active step This action will be executed when the step is active and possible entry actions have been already processed This action will be executed in the subsequent
281. syntax for the implicitly done variable declaration 1s lt sStep name gt SFCStepType E SACELON namest SFCACTLONT ype The following Boolean flags for step or action states are available e lt step name gt x shows the current activation status e lt step name gt _x shows the activation status for the next cycle If lt step name gt x TRUE the step will be executed in the current cycle If lt step name gt _x TRUE and lt step name gt x FALSE the step will be executed in the following cycle that 1s lt step name gt _x gets copied to lt step name gt x at the beginning of a cycle The following Boolean flags for step or action states are available e lt action name gt x is TRUE if the action is executed e lt action name gt _x is TRUE if the action is active Symbol Generation In the element properties of a step or an action you can define whether for the step or action name flag a symbol definition should be added to a possibly created and downloaded symbol application For this purpose make an entry for the desired access right in column Symbol of the element properties view NOTE The flags described above might be used to force a certain status value for a step that 1s for setting an step active but be aware that this will effect uncontrolled states within the SFC Time Via TIME Variables The flag t gives the current time span which has passed since the step had got active This is on
282. t END STRUCT END PE lt Structure name gt is a type that is recognized throughout the project and can be used like a standard data type 81 5 Programming Reference Interlocking structures are allowed The only restriction 1s that variables may not be assigned to addresses the AT declaration is not allowed Example for a structure definition named Polygonline TYPE Polyoonlane STRUCT SeAEESARRAY L s2 OF INT POLACLIARRAY lLlesz OF INE POIMEZIARRAY Llasa OF INT PONES ARRAS ope OF ENT PoOince4s ARRAY real OE INT End ARRAY 1 2 OF INT END_STRUCT END TYPE Initialization of Structures Example for the initialization of a structure Poly L1spolygon lane iC Startz S 517 Point Lap Points pois Points oS Poantas 5 dle Bnd 2 675 3 Initializations with variables are not possible See an example of the initialization of an array of a structure under ARRAYS Access on Structure Components You can gain access to structure components using the following syntax lt structure name gt lt Component name gt So for the above mentioned example of the structure polygonline you can access the component start by Poly_1 Start Enumerations An enumeration is an user defined data type that is made up of a number of string constants These constants are referred to as enumeration values Enumeration values are recognized globally in all areas of the project even if they were declared w
283. t HIGH FALSE is output If IN falls below limit LOW OUT will get TRUE Not before in the further run IN exceeds the upper limit FALSE will be output again until IN once more falls below LOW and thus OUT again gets TRUE HYSTERESIS IN HYSTERESIS OUT Figure 7 14 Graphical Comparison of Hysteresis IN and Hysteresis OUT LIMITALARM Provided by util library This function block specifies whether the input value is within a set range and which limits it has violated if it has done so The input values IN HIGH and LOW are each of the type INT while the outputs O U and IL are of the type BOOL If the upper limit HIGH is exceeded by IN O becomes TRUE and when IN is below LOW U becomes TRUE IL is TRUE if IN lies between LOW and HIGH Example of LIMITALARM in FBD 215 7 Libraries 12 IN o 10 5 NextoPID library Library PID The PID function block is used to control a real process The block is present in the library NextoPID which must be added to project From a process variable PV and setpoint SP the functional block calculates the manipulated variable MV for the controlled process This is calculated periodically considering the proportional integral and derivative factors programmed This is a control algorithm PID where the proportional gain is the gain of the controller applied to both the error as to the portions of the integral and derivative of the controller The functional block can b
284. t Enter gt Input Pin Depending on the box type an additional input might be added For this purpose select the box element in the CFC network and draw the Input Pin i element on the box Output Pin Depending on the box type an additional output might be added For this purpose select the box i element in the CFC network and draw the Output i i Pin element on the box Table 6 1 Elements in the Editor Window Return RETURN Composer Example of the Composer element A CFC program cfc_prog handles an instance of function block fubblo1 which has an input variable struvar of type of a structure By using the Composer element the structure components can be accessed 126 6 Programming Languages Editors Structure strul definition TYPE Stra STRUCT ivar TNT strvar STRING hallo END_STRUCT END TYPE Function block fublol declaration AND implementation FUNCTION BLOCK fublol VAR_INPUT Striuver SlRUL END VAR VAR OUTPUT fbout 1 INT Tout STIs STRING END VAR VAR fovar STRING world END VAR EDOUL _AS SCLUVal sivarrZ fboout strs CONCAT struvar strvar tbvat Programa cfc_prog declaration and implementation PROGRAM cfc prog VAR intver INT stringvar STRING TDinste Tublol gt ergl INT erg2 STRING END_VAR Fbirist fublol lar struvar fbout_i Stacey ee tise fbout_str F f Composer Function Block with input struvar of type stru1 Figure 6 7 Composer Example A CFC program
285. t is assumed that the gas pressure is constant Some characteristics of this process and the elements used are defined following The heated water must have its temperature set between 50 C and 80 C The temperature transmitter TT have output from 4 to 20 mA and it behaves linearly such that 4 mA correspond to 30 C and 20 mA corresponds to 130 C e tis assumed that to increase the water temperature in 10 C it is necessary to inject 1 m h of gas This behavior is linear e The gas valve closes with 4 mA injecting O m h of gas On the other hand with 20 mA it injects 8 m h of gas Description of Analog Modules Setpoint As can be see in the Figure 7 25 1t requires an analog output of 4 20 mA and an analog input of 4 20 mA such as interfaces between the controller and process Internally to the controller these ranges of 4 20 mA correspond to variables PV and MV These numerical range values can vary depending on the input and output analog modules selected In this example it is assumed the following PV analog input 0 to 30000 PV 0 gt 4 mA gt 30 C PV 30000 gt 20 mA gt 130 C MV analog output 0 to 10000 MV 0 gt 4 mA 0 gt 0 m h MV 10000 gt 20 mA gt 8 m h The variable SP must be used to program the desired temperature between 50 C and 80 C As this variable must be compared with PV it must have the same numeric range of PV that is SP 0 gt 30
286. t to the value of the variable B If the index 1s greater than the bit width of the variable the following error message will be issued Index lt n gt outside the valid range for variable lt var gt Bit addressing 1s possible with the following variable types SINT INT DINT USINT UINT UDINT BYTE WORD DWORD If the variable type does not allow bit accessing the following error message will be issued Invalid data type lt type gt for direct indexing A bit access must not be assigned to a VAR_IN_OUT variable Bitaccess Via a Global Constant If you have declared a global constant defining the bit index you can use this constant for a bitaccess Examples for a bit access via a global constant on a variable and on a structure variable Declaration in Global Variables List Variable Enable defines which bit should be accessed VAR GLOBAL CONSTANT enable int 2 END VAR Example 1 Bit access on an integer variable Declaration in POU VAR AE END_VAR Bitaccess xxx enable true The third bit in variable xxx will be set TRUE Example 2 Bit access on an integer structure component Declaration of structure strul EY Pe Strul STRUCT bpbv ar BOOL rvar REAL wvar WORD bitaccess enable 42 Start drive END STRUCT END Eta Declaration in POU VAR 119 5 Programming Reference Address x strul END VAR Bit access X wvar enable true This will set TRUE the 4
287. tate Wars For Fifth network STRING pcom abc ove Wars For Fifth network DINT 35 a TRUE 200 FALSE 4 POUToCall MyCounter 40 Counter DowmCount MyDomCounter 2 Decrement bErrorpErr ErrCode ws 5 etRotate stRotate Figure 6 78 Online View of a FBD Program 181 6 Programming Languages Editors da War a Res Temp LD PLC FRG ix ess ADD ae add 22 ST iTemp NES store to tenp LD FLC_PRG iX ADD 1 ST iVar 3 CAL PREl call programm Prol iIn i ar iDut gt iRes NNF store iut to ies Figure 6 79 Online View of an IL Program In online view ladder networks have animated connections Connections with value TRUE are displayed in bold blue connections with value FALSE in bold black whereas connections with no known value or with an analog value are displayed in standard outline black and not fat Expression Type Value Prepared value A T66 TON 167 TOF T50 TON TSI TON 152 TON 153 TON lt i 13 F TEMPLATE CHAIN CONV 1X143 0 1X143 6 1X145 1 1X145 1 MX5 0 1 1P1430 IP1436 IP1451 IP1451 501 JE i i O MX5 0 1 1X143 7 M501 1P1437 O I l4 va lt lt Figure 6 80 Online View of a LD Program Notice for the online view of a POU of type function block In the implementation part no values will be viewed in the monitoring windows but lt Value of the expression gt and the inline monitoring fields in the implementation part will show three question marks each
288. the MasterTool IEC XE User Manual MU299609 Notice that the editor window of an FBD LD or IL object also includes the Declaration Editor in the upper part See also in this context Declaration Editor in Online Mode in the MasterTool IEC XE User Manual MU299609 Monitoring If the inline monitoring is not explicitly deactivated in the Options dialog it will be supplemented in FBD or LD editor by small monitoring windows behind each variable resp by an additional monitoring column showing the actual values inline monitoring This is even the case for not assigned function block inputs and outputs The inline monitoring window of a variable shows a little red triangle in the upper left corner if the variable currently is forced a blue one in the lower left corner if the variable currently is prepared for writing or forcing On Figure 6 85 an example for a variable which is currently forced and prepared for releasing the force MyCounter Figure 6 77 Variable Which is Forced and Prepared for Releasing the Force Expression Comment Type Value Prepared value Inst Up ndEowrm d Enable BOOL 44 Amplitude INT 200 aa GoHome BOOL FALSE Fa Value INT 41 F Up BOOL FALSE Down BOOL Counter DINT 2159 divale DINT 41 da Xx EDOL k INT 0 xz INT o Up BOOL TRUE Down BOL FALSE MyCounter Wars For third network DINT 40 lt Unforce and restore gt MyDownCounter DINT 2 a Err BOL FALSE ErrCode WORD 0 stRo
289. the PID block BAS REAL Compensation added to the manipulated variable ManualMV REAL Value attributed to the manipulated variable when using the manual mode Maximum variation in the manipulated variable between the current MaxVarMV REAL and previous cycle If zero or negative the PID block has no limit of MV variation Maximum value of the manipulated variable If the calculated value REAL is greater than the configured value the MV is equal to MaxMV MinMV REAL Minimum value of the manipulated variable If the calculated value Is less than the configured value the MV is equal to MinMV Dead time Minimum amount of error that will cause the correction DeadBand of MV in automatic mode i e small errors less than deadbandq will not cause changes in the manipulated variable Maximum value of the process variable If PV value is larger than the configured value PID calculation will stop and will generate an error code output Minimum value of the process variable If PV value is smaller than the configured value PID calculation will stop and will generate an error code output Sampling time Defines the calling period of PID block in seconds SampleTime ranging from 0 001 s to 1000 s This parameter is disregarded if the MeasureST is true When true enables the proportional action of the PID block If false SILA BOOL the proportional action is set to zero 219 7 Libraries When true enables the derivative acti
290. tical period is the period of oscillation The critical gain is a measure of system controllability that is it is easier as controlling the system as higher is the critical gain The critical period of oscillation is a measure of the response speed of the closed loop system that is the period of oscilation is longer as the system as will be slower During this chapter the critical gain is named as GPc and a period critical as Tc It is important to remember that gains slightly less than GPc generate oscillations which period decreases along the time while the gains higher than GPc generate oscillations which amplitude increases along the time In case of gains 1s higher than GPc it is necessary to be careful and do not make the system critically unstable The process to determine GPc and Tc consists in closing the loop with the controller in automatic mode and disabling the integral and derivative actions The steps are the following e Remove the integral and derivative actions through the respective input parameters e Increase the proportional gain with small increments After each increment insert a small system disturb on the system using a small step on the set point SP e To verify the behavior of the system PV the oscillation amplitude must increase as the gain increases The critical gain GPc will be which generates oscillations with constant amplitude or almost constant according the Figure 7 22 e Measure the period of these
291. tion That is that the function name is used as an output variable Example of a function in ST FUNCTION FCT INT VAR INPUT IVARI INT IVAR2 INT IVAR3 INT END VAR FCT IVAR1 IVAR2 IVAR3 This function takes three input variables and returns the product of the second two added to the first one Function Call The call of a function in ST can appear as an operand in expressions In IL a function call only can be positioned within actions of a step or within a transition Functions in contrast to a program or function block contain no internal state information that is invocation of a function with the same arguments input parameters always will yield the same values output For that reason functions may not contain global variables and addresses Examples of function calls In IL LD 5 Fct 3 F ae ST result In ST RESULT FCT LS 3 22 3 In FBD 5 result 3 Ze In function calls it is no longer possible to mix explicit parameter assignment with implicit ones This allows changing the order of parameter input assignments Example FUN FORMAL1 ACTUALI ACTUAL2 gt Error Message FUN FORMAL2 ACTUAL2 FORMAL1 ACTUAL1 Same Semantics As The Following FUN FORMALI ACTUAL1 FORMAL2 ACTUALZ2 According to the IEC 61131 3 standard functions can have additional outputs Those must be assigned in the call of the function for example in ST according to syntax OUT gt
292. tional of a PROGRAM or FUNCTION BLOCK if accumulator is TRUE RET Early return of the POU and jump back to the RET calling POU RET C Conditional if accumulator is TRUE Early RETC return of the POU and jump back to the calling POU RET CN Conditional if accumulator is FALSE Early return of the POU and jump back to the calling POU A D Evaluate deferred Operation Table 6 12 Operators and Modifiers CAL prog1 RETCN See Operators 164 6 Programming Languages Editors See also Working in the IL Editor View for how to use and handle multiple operands complex operands function method function block program action calls and jumps AHD TRUE load TRUE to accumulator AHDH b ar 1 execute AND with negated value of bVari JMPC ml if aocum is TRUE jump to label ni LDH h are Store negated valne of Sais eas ST hRes so IH bees zZ mi LD hv are store value of bYarz ST bRes A RES Figure 6 48 IL Program with Operators Working in the FBD e LD Editor View Networks are the basic entities in FBD and LD programming Each network contains a structure that displays a logical or an arithmetical expression a POU function program function block call etc a Jump a return instruction When creating a new object the editor window automatically contains one empty network Notice the general editor settings in the Options dialog tab FBD LD and IL editor The cursor being placed on the name of a
293. tor and the AND bVar2 negated operand Bitwise OR of the accumulator and the OR xVar negated operand XOR Bitwise exclusive OR of the accumulator and XOR Bitwise negation of the accumulator s content Addition of accumulator and operand Result is ADD iVar1 iVar2 copied to the accumulator Z O the negated operand N bVar1 bVar2 Subtraction of accumulator and operand Result SUB iVar2 is copied to the accumulator MUL Multiplication of accumulator and operand MUL iVar2 Result is copied to the accumulator DIV Division of accumulator and operand Result is DIV 44 copied to the accumulator GT 23 Check if accumulator is greater than operand gt Result BOOL is copied into the accumulator Check if accumulator is greater than or equal to GE iVar2 the operand gt Result BOOL is copied into the accumulator Check if accumulator is equal to the operand EQ Var2 Result BOOL is copied into the accumulator Check if accumulator is not equal to the NE iVar1 operand lt gt Result BOOL is copied into the accumulator m m Check if accumulator is less than or equal to the LE 5 operand lt Result BOOL is copied into the accumulator Check if accumulator is less than operand lt LT cVar1 Result BOOL is copied into the accumulator Unconditional conditional jump to the label JMPN next CAL CN Call Condi
294. twork properties must be configured for the GVL Regard that variables declared in GVLs always get initialized before local variables of POUs Persistent Variables This object T isa global variables list which however only contains persistent variables of an application Thus it must be assigned to an application and for this purpose be inserted in the device tree via the Add Object dialog below this application Persistent variables only get re initialized at a Reset Origin For further information please see the Remanent Variables A persistent variables list is edited in the GVL Editor whereby VAR_GLOBAL PERSISTENT RETAIN already is preset in the first line 31 3 Concepts and Basic Components Devices 1 X ad PersistentVars gt Teste 1 VAR GLOBAL PERSISTENT Device NX3010 2 ivarl INT PLE Logic 3 bvarl INT C3 Application END VAR E Bill of Materials Configuration and Consumption d Diagnostic Explorer ad Diagnosis Til Library Manager MainPrg PRG 8 Task Configuration S MainTask T PersistentWars Devices ES ad PersistentVars El Testy a _ 1 PERSISTENT RETAIN Device NX3010 2 ivarl INT E PLC Logic 3 bvarl INT a END VAR l 4 Application E Bill of Materials Configuration and Consumption 4 Diagnostic Explorer al Diagnostics Til Library Manager MainPrg PRG pe Task Configuration 2 MainTask T PersistentVars Figure 3 5 Persistent Variable List
295. uages You choose the language when adding a new POU object via the Add Object command in your project The CFC Editor is a graphical editor The editor will be available in the lower part of the window which opens when opening a CFC POU object and which also includes the Declaration Editor in its upper part StartPage Configuration Bus 2 MainPrg w x ToolBox I X 1 PROGRAM MainPrg E CFC a a 2 VAR gt k Pointer 3 Result INT E Input o O a Output gt MF Box co E T Jump Label gt Return Zi Composer THE Selector z a Comment 3 F Input Pin Output Pin a 5H Figure 6 1 CFC Editor The CFC editor in contrast to the network editors allows free positioning of the elements which for example allows direct insertion of feedback paths The sequence of processing is determined by a list which contains all currently inserted elements and can be modified The following elements are available in a Toolbox for inserting box operators functions function blocks and programs input output comment label jump composer selector The input and output lines of the elements can be connected by dragging a connection with the mouse The course of the connecting line will be created automatically and noticing the shortest possible way The connecting lines are automatically adjusted as soon as the elements are moved See also Insert and Organize Elements You may change the dimension of the editor window b
296. used for all objects which are used to create a PLC program POUs which are managed in the POUs view are not device specific but they might be instantiated for the use on a device application For this purpose program POUs must be called by a task of the respective application POUs which are ONLY managed in the Devices view 1 e which are inserted in the device tree explicitly below an application can only be instantiated by applications indented below this application child application For further information see the descriptions of the Device Tree and Application in the MasterTool IEC XE User Manual MU299609 17 POU 3 Concepts and Basic Components But POU also is the name of a certain sub category of these objects in the Add Object menu at this place just comprising programs function blocks and functions So a Program Organization Unit object in general is a programming unit an object which is managed either non device specifically in the POUs window or device specifically in the Devices window and can be viewed and edited in an editor window A POU object can be a program function function block as well as a method action DUT Data Unit Type or an external file of any format Regard the possibility to set certain properties like e g build conditions etc for each particular POU object The following POU object types can be used per default POU Action DUT Data Type Unit External file Global Va
297. vious section Suggetions for Ajusts of the PID Controller are suggested methods of adjustment in which the scale corrections are implicit to the method and it should not be considered In the next section Application Example the scale corrections are also unnecessary because it is used one of the methods discussed in the section Suggetions for Ajusts of the PID Controller The scale corrections is decribed by the following example Consider an air conditioning system where the analog input module is reading a PTC resistor positive termic coefficient and the analog output module generates a voltage of 0 to 10V to act on the valve responsible for circulating the water that cools the air blown 226 7 Libraries The input module works with a range from 0 to 30000 but the useful range is 6634 to 8706 with the following meaning e EAO 6634 0 884 6 Q corresponding to the minimum temperature which can be measured e All 8706 100 1160 9 Q ecorresponding to the maximum temperature that can be measured The output module uses the same range from O to 30000 with no restrictions and with the following meaning e SA0 0 0 0 V corresponding to the minimum water flow through the valve e SAI 30000 100 10 V corresponding to the maximum water flow through the valve Assuming that the gain GP was previously determined the gain GP can be calculated using the following equation GP GP R Where R _SAi
298. wed by the indication of the jump destination that has to equal a predefined label When arriving the JMP instruction a flyback to the program line that is provided with the indicated label will be effected Example Li 05 Label meres INSTEUCELONS IF i lt 10 THEN JMP labell END_IF As long as the variable 1 being initialized with O has a value less than 10 the conditional jump instruction of the example above will effect a repeated flyback to the program line provided with label labell and therefore it will effect a repeated processing of the instructions comprised between the label and the JMP instruction Since these instructions include also the increment of the variable 1 we can be sure that the jump condition will be FALSE at the 9th check and program flow will be proceeded 66299 1 This functionality may also be achieved by using a WHILE or REPEAT loop in the example Generally the use of jump instructions can and should be avoided because they reduce the readability of the code Comments in ST There are two possibilities to write comments in a Structured Text object e Start the comment with and close it with This allows comments which run over several lines Example This is a comment e Single line comments as an extension to the IEC 61131 3 standard denotes the start of a comment that ends with the end of the line Example This is a comment The comme
299. y Each one of these versions has unique characteristics purposes and features for each specific objective The Table 2 1that follows elucidates those differences lite Basic Professional Advanced Available languages 6 6 6 6 Structured Text ST Yes Sequential Function Chart SFC Function Block Diagram FBD Ladder Diagram LD Instruction List IL Continuous Function Chart CFC Supported Nexto Series CPUs 1 2 3 3 NX3010 Yes Yes Yes Yes NX3020 No Yes Yes Yes NX3030 No No Yes Yes Table 2 1 MasterTool IEC XE Versions Features Notes Fieldbus support Nexto Series architectures use the PROFIBUS DP as the fieldbus Maximum number of I O points There is no maximum number of I O points on MasterTool IEC XE in its Professional and Advanced versions In this case MT8500 does not verify anything However there is a limit depending of the CPU model na the I na Q memory occupation Languages MasterTool IEC XE software is available in Portuguese and English After the installation the interface assumes the language of Computer Operating System The language can be changed after installation without the need for resettlement 9 2 Technical Description Compatibility with Other Products MasterTool IEC XE versions before version 1 29 are not compatible with all product revisions of Nexto Series modules If you are using any software version or product revision of Nexto Series products as informed on t
300. y components Example If a library which is included in a project contains a module fun and there is also a POU fun defined locally in the project then add the namespace of the library can be added to the module name in order to make the access unique The syntax is lt namespace gt lt module name gt for example lib1 fun By default the namespace of a library is identic with the library name however you can define another one either in the Project Information when creating a library project or later in the Properties dialog for a library Example 114 5 Programming Reference There is a function fun in library lib There is also a function fun declared in the project By default the namespace of library lib is named lib rest e unen 5 12 7 7 Call 0f the project function Tun resZ2 2 Jib tuntin 12 call of the library function fun Enumeration Name Scope Operator Extension to the IEC 61131 3 standard The type name of enumerations can be used to disambiguate the access to an enumeration constant In this case lt enumeration name gt precedes the constant name So it is possible to use the same constant in different enumerations Example The constant Blue is a component of enumeration Colors as well as of enumeration Feelings color z Colores Blue Access to enum value Blue in type Colors feeling Feelings Blue Access to enum value Blue in type Feelings Oper
301. y zooming Use the E button in the lower right corner of the window and choose between the listed zoom factors Alternatively you may select the entry Lu to open a dialog where you can enter any arbitrary factor by typing The commands for working in the CFC editor can be called from the context menu or from the CFC menu which is available as soon as the CFC editor is active 123 6 Programming Languages Editors Continuous Function Chart Language CFC The Continuous Function Chart in extension to the IEC 61131 3 standard is a graphical programming language basing on the Function Block Diagram language However in contrast to that no networks are used but free positioning of graphic elements which for example allows feedback loops For creating CFC programming objects in MasterTool IEC XE see CFC Editor Figure 6 2 Example of a CFC Network Cursor Positions in CFC A possible cursor position in a CFC program is indicated by default by a grey shadow when moving with the cursor over the elements As soon as you click on one of these shadowed areas still before you are leaving the mouse button the area will change color to red As soon as you leave the pressed mouse button this will become the current cursor position the respective element or text being selected and displayed red colored There are three categories of cursor positions See on Figure 6 3 Figure 6 4 and Figure 6 5 the possible positions indicated by a grey shade
302. ype which dictates how much memory space will be reserved and what type of values it stores Standard Data Types All data types described by standard IEC 61131 3 are supported by MasterTool IEC XE See here the following BOOL BIT Integer Data Types REAL LREAL STRING WSTRING Time Data Types Notice that there are also some norm extending data types and that you can also define types on your own user defined data types BOOL BOOL type variables may be given the values TRUE 1 and FALSE 0 8 bits of memory space will be reserved See also BOOL Constants BIT As the BOOL type variables the BIT type variables may have values TRUE and FALSE Unlike the BOOL type the BIT type occupies only one bit of memory space However for this allocation can happen correctly this data type can only be declared in Function Blocks or Structures defined on DUT type objects Integer Data Types See below a list of all available integer data types Each of the different number types covers a different range of values The following range limitations apply to the integer data types Type Lowerimit Upper imn memory space BYTE 0 255 word oT o _ eB DwoRrD o 42949672935 3a2Bis peword Oa Bits ust its UNT 85 teBits vont o o 4oaoe7ea5 3a2Bis Ur Bits Table 5 9 Integer Data Types As a result when larger types are converted to smaller types information may be lost See also Number Constants
Download Pdf Manuals
Related Search
Related Contents
SFAT 1.接続・準備編 EPSON PA-W11G2 取扱説明書 User Guide - Cyberbajt Mode d`emploi Mobilisation Philips Halogen spot 8711500413222 DL05 PLC Units Specs Copyright © All rights reserved.
Failed to retrieve file