Page 1
PROGRAΜMABLE CONTROLLER FP Series Programming Manual...
Page 2
We invite your comments on this manual. Please e-mail us at: techdoc.peweu@eu.panasonic.com. Please direct support matters and technical questions to your local Panasonic representative. LIMITED WARRANTY If physical defects caused by distribution are found, PEWEU will replace/repair the product free of charge.
Page 3
Important symbols One or more of the following symbols may be used in this documentation: DANGER! The warning triangle indicates especially important safety instructions. If they are not adhered to, the results could be fatal or critical injury. CAUTION Indicates that you should proceed with caution. Failure to do so may result in injury or significant damage to instruments or their contents, e.g.
Page 4
Table of Contents Part I Basics Basics......................26 1.1 Operands ..........................27 1.1.1 Inputs/Outputs ..........................27 1.1.2 Internal Relays..........................27 1.1.3 Special Internal Relays........................27 1.1.4 Timers and Counters........................28 1.1.5 Data Registers (DT) ........................28 1.1.6 Special Data Registers (DT)......................29 1.1.7 File Registers (FL)...........................29 1.1.8 Link Relays and Registers (L/LD)....................29 1.2 Addresses ..........................
Page 5
Table of Contents 1.4 Data types ..........................40 1.4.1 Elementary data types........................40 1.4.1.1 BOOL ..........................40 1.4.1.2 ..........................41 1.4.1.3 UINT ..........................41 1.4.1.4 DINT ..........................41 1.4.1.5 UDINT ..........................41 1.4.1.6 REAL ..........................41 1.4.1.7 WORD ..........................42 1.4.1.8 DWORD ..........................42 1.4.1.9 TIME ..........................42 1.4.1.10 DATE_AND_TIME .........................43 1.4.1.11 DATE ..........................44 1.4.1.12 TIME_OF_DAY ........................44...
Page 6
Table of Contents Part II IEC instructions Data transfer instructions................ 59 MOVE Move value to specified destination Arithmetic instructions ................61 Subtract Multiply Divide Absolute Value Modular arithmetic division, remainder stored in output variable SQRT Square root Sine with Radian Input Data ASIN Arcsine Cosine...
Page 7
Table of Contents Bit-shift instructions .................93 Shift bits to the right Shift bits to the left Rotate N bits the right Rotate N bits to the left Comparison instructions................103 Greater than Greater than or equal to Equal to Less than or equal to Less than Not equal WITHIN_LIMITS...
Page 8
Table of Contents DINT_TO_DWORD DOUBLE INTEGER into DOUBLE WORD UINT_TO_DWORD Unsigned INTEGER into DOUBLE WORD UDINT_TO_DWORD Unsigned DOUBLE INTEGER into DOUBLE WORD REAL_TO_DWORD REAL into DOUBLE WORD TIME_TO_DWORD TIME into DOUBLE WORD STRING_TO_DWORD STRING (Hexadecimal Format) to DOUBLE WORD STRING_TO_DWORD_STEPSAV STRING (Hexadecimal Format right-justified) to DOUBLE WORD BOOL_TO_INT...
Page 9
Table of Contents TIME_TO_DINT TIME into DOUBLE INTEGER STRING_TO_DINT STRING (Decimal Format) to DOUBLE INTEGER STRING_TO_DINT_STEPSAVER STRING (Decimal Format right-justified) to DOUBLE INTEGER BOOL_TO_UDINT BOOL into Unsigned DOUBLE INTEGER WORD_TO_UDINT WORD in Unsigned DOUBLE INTEGER DWORD_TO_UDINT DOUBLE WORD in Unsigned DOUBLE INTEGER DWORD_BCD_TO_UDINT Binary value of DOUBLE WORD in Unsigned INTEGER INT_TO_UDINT...
Page 10
Table of Contents UDINT_TO_STRING Unsigned DOUBLE INTEGER into STRING DINT_TO_STRING_LEADING_ZE DOUBLE INTEGER into STRING UDINT_TO_STRING_LEADING_Z Unsigned DOUBLE INTEGER into STRING EROS UINT_TO_STRING Unsigned INTEGER into STRING UINT_TO_STRING_LEADING_ZE Unsigned INTEGER into STRING REAL_TO_STRING REAL into STRING TIME_TO_STRING TIME into STRING IPADDR_TO_STRING IP Address to STRING IPADDR_TO_STRING_NO_LEADI IP Address to STRING...
Page 11
Table of Contents CONCAT Concatenate (attach) a string DELETE Delete characters from a string FIND Find string's position INSERT Insert characters REPLACE Replaces characters 10. Date and time instructions ..............281 ADD_DT_TIME Add TIME to DATE_AND_TIME ADD_TOD_TIME Add TIME to TIME_OF_DAY CONCAT_DATE_INT Concatenate INT values to form a date CONCAT_DATE_TOD...
Page 12
Table of Contents Down counter CTUD Up/down counter 14. Timer instructions .................. 323 Timer with switch-off delay Timer with switch-on delay Timer with defined period ADD_TIME Add TIME CONCAT_TIME_INT Concatenate INT values to form a time DIV_TIME_INT Divide TIME by INTEGER DIV_TIME_DINT Divide TIME by DOUBLE INTEGER DIV_TIME_REAL...
Page 13
Table of Contents F48_DBSUB2 8-digit BCD subtraction, destination can be specified F37_DEC 16-bit decrement F38_DDEC 32-bit decrement F57_BDEC 4-digit BCD decrement F58_DBDEC 8-digit BCD decrement F30_MUL 16-bit multiplication, destination can be specified F31_DMUL 32-bit multiplication, destination can be specified F34_MULW 16-bit data multiply (result in 16 bits) F39_DMULD 32-bit data multiply (result in 32 bits)
Page 14
Table of Contents F352_FMEAN Total and mean numbers calculation in floating point data table F282_SCAL Linearization of 16-bit data F283_DSCAL Linearization of 32-bit data F284_RAMP Inclination output of 16-bit data F354_FSCAL Scaling of Real Number Data F96_SRC Table data search (16-bit search) F97_DSRC 32-bit table data search 15.1 Introduction into the FIFO buffer ...................
Page 15
Table of Contents F136_DBCU Number of ON bits in 32-bit data F84_INV 16-bit data invert (one's complement) F93_UNIT 16-bit data combine F94_DIST 16-bit data distribution F182_FILTER Time constant processing 18. Bit-shift instructions ................555 Left shift register F100_SHR Right shift of 16-bit data in bit units F101_SHL Left shift of 16-bit data in bit units F102_DSHR...
Table of Contents 21. Counter instructions................701 CT_FB Down Counter Counter F118_UDC UP/DOWN counter 22. Data transfer via communication ports ..........711 22.1 Description of the communication modes................712 22.2 Setting the communication parameters .................714 22.2.1.1 Setting the CPU's COM Ports in PROG Mode via System Registers .........714 22.2.1.2 Setting the CPU's COM Ports in PROG Mode via DIP Switches (FP10SH) .......715 22.2.1.3 Setting in RUN Mode with SYS instructions (FP-Sigma, FP-X) ..........717 22.2.1.4 Changing the communication mode in RUN mode..............717...
Page 18
Table of Contents IsReceptionDone Evaluation of "reception done" flag for all ports IsReceptionDoneByTimeout Evaluation of "reception done" condition by time-out for all ports IsTransmissionDone Evaluation of "transmission done" flag for all ports IsCommunicationError Evaluation of communication error flag for all ports 22.5 Data transfer in master/slave mode (MEWTOCOL/Modbus RTU) ........
Page 19
Table of Contents F10_BKMV_NUMBER_OFFSET Block move by number to an offset from source F11_COPY Block copy F12_EPRD EEPROM read from memory F12_ICRD IC card extended memory read F13_ICWT IC card extended memory write F14_PGRD Program Read from IC card P13_EPWT EEPROM write to memory F15_XCH 16-bit data exchange...
Page 20
Table of Contents 27. Edge detection instructions ..............883 Rising edge differential Falling edge differential Rising edge differential (initial execution type) Alternative out 28. High-speed counter instructions ............889 28.1 Introduction ........................... 890 28.2 Writing the high-speed counter control code ................ 891 28.3 High-speed counter: writing and reading the elapsed value ..........
Page 21
Table of Contents SCALE_REAL Scale REAL data SCALE_UINT Scale UINT data SCALE_UINT_INT Scales UINT input data to INT output data SmoothSignal_INT Smooth INT signals SmoothSignal_REAL Smooth REAL signals SmoothSignal_UINT Smooth UINT signals 31. FP-e display instructions ...............969 F180_SCR Screen display instruction F180_SCR_DUT Configuring the Display of the FP-e F181_DSP...
Page 22
Table of Contents 35. Pulse output instructions ..............1019 35.1 Introduction ......................... 1020 35.2 Writing the pulse output control code.................. 1021 35.3 Pulse output: writing and reading the elapsed value ............1026 F166_PulseOutput_Set Target value match ON (pulse output) 1027 F167_PulseOutput_Reset Target value match OFF (pulse output) 1030...
Page 23
Table of Contents 37. GT panel instructions ................1133 GT_ActivateScreen Control the GT panel screen 1134 GT_ChangeBacklightBrightness Changes the backlight brightness of a GT panel 1136 38. High-speed counter instructions............1137 38.1 Introduction..........................1138 38.2 High-speed counter control instructions ................1139 HscControl_CountingDisable Disables counting on a high-speed counter channel 1140 HscControl_CountingEnable Enables counting on a high-speed counter channel...
Page 24
Table of Contents PulseOutput_Jog_Positioning1_FB JOG operation and positioning 1185 PulseOutput_Jog_TargetValue_FB JOG operation with target value 1187 Description PulseOutput_Linear_FB Linear interpolation 1189 PulseOutput_Pass_FB Circular interpolation (pass position) 1192 PulseOutput_Trapezoidal_FB Trapezoidal control 1195 39.3 Pulse control instructions ....................1198 PulseControl_CountingDisable Disables counting on a pulse output channel 1199 PulseControl_CountingEnable Enables counting on a pulse output channel...
Page 25
Table of Contents 39.5 Pulse output target value match control ................1237 Pulse_TargetValueMatch_Reset Target value match OFF (pulse output) 1238 Pulse_TargetValueMatch_Set Target value match ON (pulse output) 1241 40. Appendix Programming Information...........1245 40.1 FP TOOL Library .........................1246 40.2 Floating Point Instructions ....................1248 40.3 Index Registers........................1250 40.4 Real Numbers........................1251 40.4.1 Floating Point Constant (f)......................1251...
Page 26
Table of Contents 40.8.7 System registers for FP2/FP2SH/FP10SH .................1300 40.9 Error codes ......................... 1306 40.9.1 Table of syntax check error ......................1306 40.9.2 Table of self-Diagnostic errors ....................1307 40.9.3 Table of communication check error ...................1311 40.10 Error codes ........................1312 40.10.1 Error Codes E1 to E8......................1312 40.10.2 Self-Diagnostic Error Codes ....................1312...
Page 28
Basics 1.1 Operands In FPWIN Pro the following operands are available: in- and outputs (X/Y) as well as internal memory areas internal relays special internal relays timers and counters data registers special data registers file registers ...
Page 29
Basics Special internal relays can only be read. 1.1.4 Timers and Counters Timers and Counters use one common memory and address area. Define in system registers 5 and 6 how the memory area is to be divided between timers and counters and which timers/counters are supposed to be holding or non-holding.
Page 30
Basics saved. Set the holding/non-holding areas in system register 8 by entering the start address of the holding area. The amount of data registers available depends on the PLC type (see hardware description). 1.1.6 Special Data Registers (DT) Special data registers are like the special internal relays reserved for special functions and are in most cases set/reset by the PLC.
Page 31
Basics 1.2 Addresses In the List of Global Variables, enter the physical address in the field “Address” for each global variable used in the PLC program. The operand and the address number are part of the address. In FPWIN Pro you can use either FP and/or IEC addresses.
Page 32
Basics 1.2.2 IEC Addresses The composition of an IEC-1131 address depends on: operand type data type slot no. of the unit (word address) relay no. (bit address) PLC type In- and Outputs are the most important components of a programmable logic controller (PLC). The PLC receives signals from the input relays and processes them in the PLC program.
Page 33
Basics Memory Type Example %MW4.100 = elapsed value of the timer no. 100 Elapsed Value counters/timers (EV) %MW5.9001 = data register DT9001 Data Registers (DT, DDT) %MD5.90001 = 32-bit data register DDT90001 %MW7.63 = link relay 63 Link Relay (WL) %MW8.127 = link register 127 Link Register (LD) %MW9.800 = file register 800...
Page 34
Basics number begins at zero for the outputs. In-/Output addresses are numbered serially. Supposing the first slot of your PLC contains an input module with 16 inputs and the second slot of your PLC contains an output module with 32 outputs, the input module occupies the addresses: %IX0.0 - %IX0.15, the output module: %QX1.0 - %QX2.15.
Page 35
Basics Example Configuration of external input relay (X) XF, XE, XD, XC, XB, XA, X9, X8, X7, X6, X5, X4, X3, X2, X1, X0 X1F, , X10 X2F, , X20 X510F, , X5100 , X5110 X511F, 1.2.4 Timer Contacts (T) and Counter Contacts (C) Addresses of timer contacts (T) and counter contacts (C) correspond to the TM and CT instruction numbers and depend on the PLC type.
Page 36
Basics The diagram below illustrates the internal structure and address assignment in the special data register area of this error buffer. POU Header Error alarm diagram DT90400 DT90401 DT90402 DT90403 DT90404 DT90405 DT90420 DT90421 DT90422 DT90400 Number of alarms that have occurred DT90401–DT90419 Error alarm relays stored in the order they were set to TRUE Error alarm E15 is set to TRUE...
Page 37
Basics R9040 and the special data registers DT90400 to DT90422. When all error alarm relays are set to FALSE, R9040 will be set to FALSE. To monitor alarm relays using Control FPWIN Pro: Monitor Special Relays and Registers Alarm Relays.
Page 38
Basics Execution with a falling edge: 1.2.6.1 Restrictions of pulse relay (P) A pulse relay can only be used once in a program as an output destination, i.e. duplicate output is prohibited. There is no limitation on the number of times a pulse relay can used as a contact. A pulse relay cannot be specified as an output destination for a KP, SET, RST or ALT instruction.
Page 39
Basics Example: Configuration of word external input relay (WX) XF XEXDXCXB XA X9X8 X7 X6 X5X4 X3X2 X1 X0 X12X11X10 X1FX1EX1D X12FX12EX12D X122X121X120 WX12 Since the contents of the word relay correspond to the state of its relays (components), if some relays are turned ON, the contents of the word change.
Page 40
Basics 1.3 Constants A constant represents a fixed value. Depending on the application, a constant can be used as an addend, multiplier, address, in-/output number, set value, etc. There are 3 types of constants: decimal hexadecimal 1.3.1 Decimal Constants Decimal constants can have a width of either 16 or 32 bits.
Page 41
Basics 1.4 Data types In Control FPWIN Pro, variable declarations require a data type. All data types conform to IEC61131-3. For details, please refer to the Programming Manual or to the online help of Control FPWIN Pro. 1.4.1 Elementary data types Keyword Data type Range...
Page 42
Basics 1.4.1.2 INT Variable values of the data type INTEGER are natural numbers without decimal places. The range of values for INTEGER values is from -32768 to 32767. The default initial value of a variable of this data type is 0. Numbers can be entered in decimal, hexadecimal or binary format.
Page 43
Basics For FP-e and FP0 only: Do not use REAL instructions in interrupt programs. You can enter REAL values in the following format: [+-] Integer.Integer [(Ee) [+-] Integer] Examples: 5.983e-7 -33.876e12 3.876e3 0.000123 123.0 The REAL value always has to be entered with a decimal point (e.g. 123.0). 1.4.1.7 WORD A variable of the data type WORD consists of 16 binary states.
Page 44
Basics resolution amounts to 10 ms. Default for 16 and 32 values = T#0 (corresponds to 0 seconds) NOTE Duration data must be delimited on the left by the prefix T# or TIME#. The units of duration literals can be separated by the character "_". ...
Page 45
Basics 1.4.1.11 DATE Variable values of the data type DATE are date literals. The range of values for DATE values is from D#2001-01-01–D#2099-12-31. Description Examples Short prefix D#2010-06-07 d#2010-06-07 Long prefix DATE#2010-06-07 date#2010-06-07 Internal Seconds after 2001-01-01 representation Advantages: Facilitates all kinds of calculations for date and time ...
Page 46
Basics 1.4.1.13 STRING The data type STRING consists of a series (a string) of up to 32767 ASCII characters. The maximum number of characters depends on the memory size of the PLC. Change the default setting under Extras Options Compile options...
Page 47
Basics Combination Interpretation when printed $T or $t Tab ($09) Examples of string literals Example Explanation Empty string (length 0) String of length 1 containing the single character A String of length 1 containing the space character '$'' String of length 1 containing the single quote character '$R$L' String of length 2 containing CR and LF characters '$$1.00'...
Page 48
Basics other in LD and FBD. First connect the STRING instructions without EN/ENO and then add an instruction with EN/ENO in the final position. The enable input (EN) then controls the output of the overall result. EXAMPLE This arrangement is not possible: This arrangement is possible: Instruction list (IL) STRING instructions with EN/ENO may be connected to each other in IL.
Page 49
Basics Program with conditional jump The difficulty of programming with a dummy string lies in correctly choosing its length. When connecting unconditional string instructions in series, the length is calculated automatically. 2. MakeMessage2...
Page 50
Basics From these commands one gets the following address occupation: Another use with functions from the FP TOOL Library (Adr_OfVarOffs..):...
Page 51
Basics 1.4.2 Generic data types Generic data types are used internally by system functions and function blocks and cannot be selected in user-defined POUs. Generic data types are identified by the prefix ANY. NOTE Generic data types are not available in user-defined POUs. Hierarchy of generic data types ANY_NUM REAL, ANY_INT...
Page 52
Basics 1.4.3 DUT A DUT (data unit type) is composed of several elementary data types which may differ in type. 1.4.3.1 Creating DUTs 1. Object New DUT or 2. Enter DUT name If desired, select the check box for DUTs with overlapping elements (see page 53). 3.
Page 53
Basics 14. Object Save NOTE A DUT defined in the global variable list can be used in a POU body only when copied into the header of the corresponding POU beforehand. 1.4.3.3 Using DUTs in a POU header 1. Open POU header from "Project" pane 2.
Page 54
Basics All elements of the data type ARRAY OF BOOL are lumped together in a block and allocated in a memory area reserved for bits, beginning at a 16-bit word address. All other elements are lumped together and allocated one after the other in a block in a memory area reserved for 16-bit words.
Page 55
Basics Declaration To declare ARRAY type variables in the POU header use the following syntax: ARRAY[A...B,C...D,E...F] OF <data type> where: first element index first dimension last element index first element index second dimension (optional) last element index first element index third dimension (optional) last element index Arrays can be 1, 2 or 3-dimensional.
Page 56
Basics TIME_OF_DAY UDINT UINT WORD Data Unit Type A Data Unit Type (DUT) is a group of variables composed of several different elementary data types (BOOL, WORD etc.). These groups are used when tables are edited, such as for data table control, e.g. F174_PulseOutput_DataTable (see page 1069).
Page 57
Basics by the compiler. All DUTs with exactly 32 members of the data type BOOL Note: These are automatically placed by the compiler in area R. 1.4.5.3 BCD_WORD The data type BCD_WORD (binary-coded decimal) only occurs in the conversion functions INT_TO_BCD_WORD (see page 243) and UINT_TO_BCD_WORD (see page 245).
Page 58
Basics Example: Value Conversion function Result 16#01020304 IPADDR_TO_STRING 004.003.002.001 IPADDR_TO_STRING_NO 4.3.2.1 _LEADING_ZEROS NOTE If you want an interpretation of the DWORD in direct order, use the conversion functions that invoke the data type ETLANADDR. 1.4.5.8 ETLANADDR The data type ETLANADDR only occurs in the following conversion functions: ETLANADDR_TO_STRING (see page 234) ...
Page 59
Basics of the global variable list or for local variables, they are automatically placed in DT, DDT, FL or DFL by the compiler. Arrays with the data type BOOL under the condition that the total number of elements can be ...
Page 61
Data transfer instructions Move value to specified destination MOVE MOVE assigns the unchanged value of the input variable to the output variable. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 63
Arithmetic instructions This function adds the input variables IN1 + IN2 +... and writes the addition result into the output Description variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 64
Arithmetic instructions Subtract The content of the accumulator is subtracted from the operand defined in the operand field.The Description result is transferred to the accumulator. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 65
Arithmetic instructions Multiply MUL multiplies the values of the input variables with each other and writes the result into the output Description variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 66
Arithmetic instructions Divide DIV divides the value of the first input variable by the value of the second. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 67
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables which are required for programming the function are declared in the POU header.
Page 68
Arithmetic instructions Absolute Value ABS calculates the value in the accumulator into an absolute value. The result is saved in the Description output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 69
Arithmetic instructions Modular arithmetic division, remainder stored in output variable MOD divides the value of the first input variable by the value of the second. The rest of the integral Description division (5 : 2 : 2 + rest = 1) is written into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 70
Arithmetic instructions Square root SQRT SQRT calculates the square root of an input variable of the data type REAL (value 0.0). The Description result is written into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 71
Arithmetic instructions Sine with Radian Input Data SIN calculates the sine of the input variable and writes the result into the output variable. The angle Description data has to be specified in radians (value < 52707176). To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 72
Arithmetic instructions Arcsine ASIN ASIN calculates the arcsine of the input variable and writes the angle data in radians into the output Description variable. The function returns a value from - /2 to /2. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 73
Arithmetic instructions Cosine COS calculates the cosine of the input variable and writes the result into the output variable. The Description angle data has to be specified in radians (value < 52707176). To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 74
Arithmetic instructions Arccosine ACOS ACOS calculates the arccosine of the input variable and writes the angle data in radians into the Description output variable. The function returns a value from 0.0 to . To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 75
Arithmetic instructions When programming with structured text, enter the following: output_value:=ACOS(input_value);...
Page 76
Arithmetic instructions Tangent TAN calculates the tangent of the input variable and writes the result into the output variable. The Description angle data has to be specified in radians (value < 52707176). To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 77
Arithmetic instructions Arctangent ATAN ATAN calculates the arctangent of the input variable (value 52707176) and writes the angle data Description in radians into the output variable. The function returns a value greater than -/2 and smaller than /2. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 78
Arithmetic instructions Returns the angle of the Cartesian coordinates (x,y) ATAN2_YX ATAN2_YX returns the angle of the Cartesian coordinates (x,y) within the range of -to. Description Each position P of the two-dimensional coordinates can be defined by Cartesian coordinates P(x,y) or by polar coordinates P(r,) (r = radius, ...
Page 79
Arithmetic instructions Data types Data type Function REAL Cartesian y coordinate REAL Cartesian x coordinate In this example the function has been programmed in ladder diagram (LD) and structured text (ST). Example The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 80
Arithmetic instructions Natural logarithm LN calculates the logarithm of the input variable (value > 0.0) to the base e (Euler’s number = Description 2.7182818) and writes the result into the output variable. This function is the reversion of the EXP (see page 80) function.
Page 81
Arithmetic instructions Logarithm to the Base 10 LOG calculates the logarithm of the input variable (value > 0.0) to the base 10 and writes the result Description into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 82
Arithmetic instructions Exponent of input variable to base e EXP calculates the power of the input variable to the base e (Euler’s number = 2.7182818) and Description writes the result into the output variable. The input variable has to be greater than -87.33 and smaller than 88.72.
Page 83
Arithmetic instructions Raises 1st input variable by the power of the 2nd input variable EXPT EXPT raises the first input variable to the power of the second input variable (OUT = IN1 ) and Description writes the result into the output variable. Input variables have to be within the range -1.70141 x 10 to 1.70141 x 10 E To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 84
Arithmetic instructions When programming with structured text, enter the following: output_value:=input_value_1**input_value_2;...
Page 85
Arithmetic instructions Cyclic Redundancy Check CRC16 This function calculates the CRC16 (Cyclic Redundancy Check) for all PLC types by using 8 bytes Description (8 bits) specified with the parameter NumberOfBytes and the starting address StartAddress. Depending on the PLC type, one of the following two implementations of the function will be used: ...
Page 86
Arithmetic instructions Data types Input variables (VAR_INPUT): Variable Data Function type Starting address for the calculation of the check sum. For PLCs StartAddress which do not support the instruction F70_BCC (see page 411) with CRC16 calculation (FP0, FP5, FP10), the starting address must be in the DT or FL area.
Page 87
Arithmetic instructions Limit value for input variable LIMIT In LIMIT the 1st input variable forms the lower and the 3rd input variable the upper limit value. If the Description 2nd input variable is within this limit, it will be transferred to the output variable. If it is above this limit, the upper limit value will be transferred;...
Page 89
Bitwise Boolean instructions Logical AND operation The content of the accumulator is connected with the operand defined in the operand field by a Description logical AND operation. The result is transferred to the accumulator. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 90
Bitwise Boolean instructions Logical OR operation The content of the accumulator is connected with the operand defined in the operand field by a Description logical OR operation. The result is transferred to the accumulator. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 91
Bitwise Boolean instructions Exclusive OR operation The content of the accumulator is connected with the operand defined in the operand field by a Description logical XOR operation. The result is transferred to the accumulator. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 92
Bitwise Boolean instructions Bit inversion NOT performs a bit inversion of input variables. The result will be written into the output variable. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 95
Bit-shift instructions Shift bits to the right SHR shifts a bit value by a defined number of positions (N) to the right and fills the vacant positions Description with zeros. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 96
Bit-shift instructions Body The last N bits (here 4) of source_register are right-shifted. The vacant positions on the left are filled with zeros. The result is written into target_register.
Page 97
Bit-shift instructions Shift bits to the left SHL shifts a bit value by a defined number of positions (N) to the left and fills the vacant positions Description with zeros. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 98
Bit-shift instructions Body The first N bits (here 4) of source_register are left-shifted, the vacant positions on the right are filled with zeros. The result is written into target_register.
Page 99
Bit-shift instructions Rotate N bits the right ROR rotates a defined number (N) of bits to the right. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 101
Bit-shift instructions Rotate N bits to the left ROL rotates a defined number (N) of bits to the left. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 105
Comparison instructions Greater than The content of the accumulator is compared with the operand defined in the operand field. If the Description accumulator is greater than the reference value, "TRUE" is stored in the accumulator, otherwise "FALSE". To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 107
Comparison instructions Greater than or equal to The content of the accumulator is compared with the operand defined in the operand field. If the Description accumulator is greater or equal to the reference value, "TRUE" is stored in the accumulator, otherwise "FALSE".
Page 109
Comparison instructions Equal to The content of the accumulator is compared with the operand defined in the operand field. If both Description values are equal, "TRUE" is stored in the accumulator, otherwise "FALSE". To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 110
Comparison instructions Less than or equal to The content of the accumulator is compared with the operand defined in the operand field. If the Description accumulator is less or equal to the reference value, "TRUE" is stored in the accumulator, otherwise "FALSE".
Page 111
Comparison instructions Less than The content of the accumulator is compared with the operand defined in the operand field. If the Description accumulator is less than the reference value, "TRUE" is stored in the accumulator, otherwise "FALSE". To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 112
Comparison instructions Not equal The content of the accumulator is compared with the operand defined in the operand field. If both Description values are not equal, "TRUE" is stored in the accumulator, otherwise "FALSE". To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 113
Comparison instructions Evaluate if a value is within the limits WITHIN_LIMITS This instruction evaluates whether the value at the input IN is within the limits set at minimum (MN) Description and maximum MX. see see page 1333 PLC types Data type Data types Variable Function...
Page 115
Conversion instructions WORD in BOOL WORD_TO_BOOL WORD_TO_BOOL converts a value of the data type WORD into a value of the data type BOOL. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 116
Conversion instructions DOUBLE WORD in BOOL DWORD_TO_BOOL DWORD_TO_BOOL converts a value of the data type DOUBLE WORD into a value of the data Description type BOOL. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 117
Conversion instructions INTEGER into BOOL INT_TO_BOOL INT_TO_BOOL converts a value of the data type INT into a value of the data type BOOL. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 118
Conversion instructions DOUBLE INTEGER into BOOL DINT_TO_BOOL DINT_TO_BOOL converts a value of the data type DINT into a value of the data type BOOL. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 119
Conversion instructions Unsigned INTEGER into BOOL UINT_TO_BOOL UINT_TO_BOOL converts a value of the data type Unsigned INTEGER into a value of the data Description type BOOL. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 120
Conversion instructions Unsigned DOUBLE INTEGER into BOOL UDINT_TO_BOOL UDINT_TO_BOOL converts a value of the data type Unsigned DOUBLE INTEGER into a value of Description the data type BOOL. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 121
Conversion instructions BOOL into WORD BOOL_TO_WORD BOOL_TO_WORD converts a value of the data type BOOL into a value of the data type WORD. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 122
Conversion instructions BOOL16 to WORD BOOL16_TO_WORD This function copies a variable of the special data type BOOL16 (see page 55) (an array with 16 Description elements of the data type BOOL or a DUT of 16 members of the data type BOOL) at the input to the data type WORD at the output.
Page 123
Conversion instructions 16 Variables of the data type BOOL to WORD BOOLS_TO_WORD This function converts 16 values of the data type BOOL bit-wise to a value of the data type WORD. Description The inputs Bool0 to Bool15 need not be allocated in LD or FBD, or used explicitly in the ST editor's formal list of parameters.
Page 124
Conversion instructions Data types Variable Data type Function BOOL 16 input variables of the data type BOOL BOOL0 ... BOOL15 WORD output variable POU header: Body with and without EN/ENO:...
Page 125
Conversion instructions DOUBLE WORD in WORD DWORD_TO_WORD DWORD_TO_WORD converts a value of the data type DOUBLE WORD into a value of the data Description type WORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 126
Conversion instructions INTEGER into WORD INT_TO_WORD INT_TO_WORD converts a value of the data type INT into a value of the data type WORD. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 127
Conversion instructions DOUBLE INTEGER into WORD DINT_TO_WORD DINT_TO_WORD converts a value of the data type DINT into a value of the data type WORD. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 128
Conversion instructions Unsigned INTEGER into WORD UINT_TO_WORD UINT_TO_WORD converts a value of the data type Unsigned INTEGER into a value of the data Description type WORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 129
Conversion instructions Unsigned DOUBLE INTEGER into WORD UDINT_TO_WORD UDINT_TO_WORD converts a value of the data type Unsigned DOUBLE INTEGER into a value of Description the data type WORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 130
Conversion instructions TIME into WORD TIME_TO_WORD TIME_TO_WORD converts a value of the data type TIME into a value of the data type WORD. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 131
Conversion instructions STRING (hexadecimal format) to WORD STRING_TO_WORD This function converts a STRING in hexadecimal format to a value of the data type WORD. Description Thereby the attached string is first converted to a value of the data type STRING[32]. Finally this is converted to a value of the data type WORD via a sub-program of approx.
Page 132
Conversion instructions STRING (Hexadecimal Format right-justified) to WORD STRING_TO_WORD _STEPSAVER This function converts the string with the maximum possible number of characters that are right Description aligned in hexadecimal format to a value of the data type WORD. Examples Input Defined as Results in STRING[1]...
Page 133
Conversion instructions BOOL into DOUBLE WORD BOOL_TO_DWORD BOOL_TO_DWORD converts a value of the data type BOOL into a value of the data type Description DWORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 134
Conversion instructions BOOL32 to DOUBLE WORD BOOL32_TO_DWORD This function copies a variable of the special data type BOOL32 (see page 55) (an array with 32 Description elements of the data type BOOL or a DUT of 32 members of the data type BOOL) at the input to the data type DWORD at the output.
Page 135
Conversion instructions 32 Variables of the data type BOOL to DWORD BOOLS_TO_DWORD This function converts 32 values of the data type BOOL bit-wise to a value of the data type Description DWORD. The inputs Bool0 to Bool31 need not be allocated in LD or FBD, or used explicitly in the ST editor's formal list of parameters.
Page 136
Conversion instructions Body with and without EN/ENO:...
Page 137
Conversion instructions WORD in DOUBLE WORD WORD_TO_DWORD WORD_TO_DWORD converts a value of the data type WORD into a value of the data type Description DWORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 138
Conversion instructions INTEGER into DOUBLE WORD INT_TO_DWORD INT_TO_DWORD converts a value of the data type INT into a value of the data type DWORD. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 139
Conversion instructions DOUBLE INTEGER into DOUBLE WORD DINT_TO_DWORD DINT_TO_DWORD converts a value of the data type DINT into a value of the data type DWORD. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 140
Conversion instructions Unsigned INTEGER into DOUBLE WORD UINT_TO_DWORD UINT_TO_DWORD converts a value of the data type Unsigned INTEGER into a value of the data Description type DWORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 141
Conversion instructions Unsigned DOUBLE INTEGER into DOUBLE WORD UDINT_TO_DWORD UDINT_TO_DWORD converts a value of the data type Unsigned DOUBLE INTEGER into a value Description of the data type DWORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 142
Conversion instructions REAL into DOUBLE WORD REAL_TO_DWORD REAL_TO_DWORD moves bitset information of a REAL variable to a DWORD variable. The same Description functionality can be obtained using DWORD_OVERLAPPING_DUT. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 143
Conversion instructions TIME into DOUBLE WORD TIME_TO_DWORD TIME_TO_DWORD converts a value of the data type TIME into a value of the data type DWORD. Description The time 10ms corresponds to the value 1, e.g. an input value of T#1s is converted to the value 100 (16#64).
Page 144
Conversion instructions STRING (Hexadecimal Format) to DOUBLE WORD STRING_TO_DWORD This function converts a string in hexadecimal formal to a value of the data type DWORD. Description At first the string is converted to a value of the data type STRING[32]. Finally this is converted to a value of the data type DWORD in a subprogram of approximately 270 steps, which is also used by the functions STRING_TO_INT, STRING_TO_WORD, STRING_TO_DINT and STRING_TO_DWORD.
Page 145
Conversion instructions STRING (Hexadecimal Format right-justified) to DOUBLE WORD STRING_TO_DWORD _STEPSAVER This function converts the string with the maximum possible number of characters that are right Description aligned in hexadecimal format to a value of the data type DWORD. Explanation Input Defined as Results in...
Page 146
Conversion instructions BOOL into INTEGER BOOL_TO_INT BOOL_TO_INT converts a value of the data type BOOL into a value of the data type INT. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 147
Conversion instructions WORD value in INTEGER WORD_TO_INT WORD_TO_INT converts a value of the data type WORD into a value of the data type INT. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 148
Conversion instructions Binary WORD value into INTEGER WORD_BCD_TO_INT WORD_BCD_TO_INT converts a binary coded BCD value of WORD into binary values of type Description INT. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 149
Conversion instructions DOUBLE WORD in INTEGER DWORD_TO_INT DWORD_TO_INT converts a value of the data type DWORD into a value of the data type INT. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 150
Conversion instructions DOUBLE INTEGER into INTEGER DINT_TO_INT DINT_TO_INT converts a value of the data type DINT into a value of the data type INT. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 151
Conversion instructions Unsigned DOUBLE INTEGER into INTEGER UINT_TO_INT UINT_TO_INT converts a value of the data type Unsigned INTEGER into a value of the data type Description INT. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 152
Conversion instructions Unsigned DOUBLE INTEGER into INTEGER UDINT_TO_INT UDINT_TO_INT converts a value of the data type Unsigned DOUBLE INTEGER into a value of the Description data type INT. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 153
Conversion instructions REAL into INTEGER REAL_TO_INT REAL_TO_INT converts a value of the data type REAL into a value of the data type INTEGER. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 154
Conversion instructions Truncate (cut off) decimal digits of REAL input variable, convert to TRUNC_TO_INT INTEGER TRUNC_TO_INT cuts off the decimal digits of a REAL number and delivers an output variable of Description the data type INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 155
Conversion instructions TIME into INTEGER TIME_TO_INT TIME_TO_INT converts a value of the data type TIME into a value of the data type INT. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 156
Conversion instructions STRING (decimal format) to INTEGER STRING_TO_INT This function converts a STRING in decimal format to a value of the data type INT. Description Thereby the attached string is first converted to a value of the data type STRING[32]. Finally this is converted to a value of the data type INT via a sub-programm of approx.
Page 157
Conversion instructions STRING (Decimal Format right-justified) to INTEGER STRING_TO_INT_ STEPSAVER This function converts a right-justifed decimal number in a string to a value of the data type INT. Description The basic instruction F76_A2BIN (see page 637) with approx. 7 steps is used. The PLC delivers an operation error especially when a character appears that is not a decimal number “0 - 9”, not a “+”...
Page 158
Conversion instructions BOOL into Unsigned INTEGER BOOL_TO_UINT BOOL_TO_UINT converts a value of the data type BOOL into a value of the data type Unsigned Description INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 159
Conversion instructions WORD to Unisgned INTEGER WORD_TO_UINT WORD_TO_UINT converts a value of the data type WORD into a value of the data type Unsigned Description INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 160
Conversion instructions Binary coded WORD value in Unsigned INTEGER WORD_BCD_TO_UINT WORD_BCD_TO_UINT converts a binary coded value of the data type WORD into a value of the Description data type Unsigned INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 161
Conversion instructions DOUBLE WORD into Unsigned INTEGER DWORD_TO_UINT DWORD_TO_UINT converts a value of the data type DWORD into a value of the data type Description Unsigned INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 162
Conversion instructions INTEGER to Unsigned INTEGER INT_TO_UINT INT_TO_UINT converts a value of the data type INT into a value of the data type Unsigned Description INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 163
Conversion instructions DOUBLE INTEGER into Unsigned INTEGER DINT_TO_UINT DINT_TO_UINT converts a value of the data type DINT into a value of the data type Unsigned Description INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 164
Conversion instructions Unsigned DOUBLE INTEGER into Unsigned INTEGER UDINT_TO_UINT UDINT_TO_UINT converts a value of the data type Unsigned DOUBLE INTEGER into a value of Description the data type Unsigned INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 165
Conversion instructions REAL into Unsigned INTEGER REAL_TO_UINT REAL_TO_UINT converts a value of the data type REAL into a value of the data type Unsigned Description INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 166
Conversion instructions Truncate (cut off) decimal digits of REAL input variable, convert to TRUNC_TO_UINT UNSIGNED INTEGER TRUNC_TO_UINT cuts off any digits following the decimal of a REAL number and delivers an Description output variable of the data type Unsigned INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 167
Conversion instructions STRING (decimal format) to Unsigned INTEGER STRING_TO_UINT STRING_TO_UINT converts a string in decimal formal to a value of the data type Unsigned Description INTEGER. See also: STRING_TO_UINT_STEPSAVER (see page 166) First, the string is converted to a value of the data type STRING[32], which is subsequently converted to a value of the data type UINT in a subprogram with approximately 270 steps.
Page 168
Conversion instructions STRING (Decimal Format right-justified) to Unsigned INTEGER STRING_TO_UINT_ STEPSAVER STRING_TO_UINT_STEPSAVER converts a right-justifed decimal number in a string to a value of Description the data type Unsigned INTEGER. The basic instruction F76_A2BIN (see page 637) with approx. 7 steps is used. The PLC issues an operation error especially if anything other than acceptable characters are used (see the following table "Acceptable characters").
Page 169
Conversion instructions BOOL into DOUBLE INTEGER BOOL_TO_DINT BOOL_TO_DINT converts a value of the data type BOOL into a value of the data type DINT. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 170
Conversion instructions WORD in DOUBLE INTEGER WORD_TO_DINT WORD_TO_DINT converts a value of the data type WORD into a value of the data type DINT. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 171
Conversion instructions Binary coded DWORD value into DOUBLE INTEGER DWORD_BCD_TO_ DINT DWORD_BCD_TO_DINT converts a binary coded value of the data type DWORD into a binary Description value of the data type DINT in order to be able to process a BCD value in double word format. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 172
Conversion instructions DOUBLE WORD in DOUBLE INTEGER DWORD_TO_DINT DWORD_TO_DINT converts a value of the data type DOUBLE WORD into a value of the data type Description DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 173
Conversion instructions INTEGER into DOUBLE INTEGER INT_TO_DINT INT_TO_DINT converts a value of the data type INT into a value of the data type DINT. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 174
Conversion instructions Unsigned INTEGER into DOUBLE INTEGER UINT_TO_DINT UINT_TO_DINT converts a value of the data type Unsigned INTEGER into a value of the data type Description DINT. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 175
Conversion instructions Unsigned DOUBLE INTEGER into DOUBLE INTEGER UDINT_TO_DINT UDINT_TO_DINT converts a value of the data type Unsigned DOUBLE INTEGER into a value of Description the data type DINT. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 176
Conversion instructions REAL into DOUBLE INTEGER REAL_TO_DINT REAL_TO_DINT converts a value of the data type REAL into a value of the data type DOUBLE Description INTEGER. The result is rounded off to the nearest whole number for the conversion. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 177
Conversion instructions Truncate (cut off) decimal digits of REAL input variable, convert to TRUNC_TO_DINT DOUBLE INTEGER TRUNC_TO_DINT cuts off the decimal digits of a REAL number and delivers an output variable of Description the data type DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 178
Conversion instructions TIME into DOUBLE INTEGER TIME_TO_DINT TIME_TO_DINT converts a value of the data type TIME into a value of the data type DINT. The Description time 10ms corresponds to the value 1, e.g. an input value of T#1m0s is converted to the value 6000.
Page 179
Conversion instructions STRING (Decimal Format) to DOUBLE INTEGER STRING_TO_DINT This function converts a string in decimal formal to a value of the data type DINT. Description At first the string is converted to a value of the data type STRING[32]. Finally this is converted to a value of the data type DINT in a subprogram of approximately 270 steps, which is also used by the functions STRING_TO_INT, STRING_TO_WORD, STRING_TO_DINT and STRING_TO_DWORD.
Page 180
Conversion instructions STRING (Decimal Format right-justified) to DOUBLE INTEGER STRING_TO_DINT_ STEPSAVER This function converts a right-justifed decimal number in a string to a value of the data type DINT. Description The basic instruction F78_DA2BIN (see page 643) with approx. 11 steps is used. The PLC delivers an operation error especially when a character appears that is not a decimal number “0 - 9”, not a “+”...
Page 181
Conversion instructions BOOL into Unsigned DOUBLE INTEGER BOOL_TO_UDINT BOOL_TO_UDINT converts a value of the data type BOOL into a value of the data type Unsigned Description DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 182
Conversion instructions WORD in Unsigned DOUBLE INTEGER WORD_TO_UDINT WORD_TO_UDINT converts a value of the data type WORD into a value of the data type Description Unsigned DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 183
Conversion instructions DOUBLE WORD in Unsigned DOUBLE INTEGER DWORD_TO_UDINT DWORD_TO_UDINT converts a value of the data type DWORD into a value of the data type Description Unsigned DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 184
Conversion instructions Binary value of DOUBLE WORD in Unsigned INTEGER DWORD_BCD_TO_ UDINT DWORD_BCD_TO_UDINT converts a binary value of the data type DWORD into a value of the Description data type Unsigned DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 185
Conversion instructions INTEGER into Unsigned DOUBLE INTEGER INT_TO_UDINT INT_TO_UDINT converts a value of the data type INT into a value of the data type Unsigned Description DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 186
Conversion instructions Unsigned INTEGER to Unsigned DOUBLE INTEGER UINT_TO_UDINT UINT_TO_UDINT converts a value of the data type Unsigned INTEGER into a value of the data Description type Unsigned DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 187
Conversion instructions DOUBLE INTEGER into Unsigned DOUBLE INTEGER DINT_TO_UDINT DINT_TO_UDINT converts a value of the data type DINT into a value of the data type Unsigned Description DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 188
Conversion instructions REAL into unsigned DOUBLE INTEGER REAL_TO_UDINT REAL_TO_UDINT converts a value of the data type REAL into a value of the data type Unsigned Description DOUBLE INTEGER. The result is rounded off to the nearest whole number for the conversion. See also: TRUNC_TO_UDINT (see page 187) To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 189
Conversion instructions Truncate (cut off) decimal digits of REAL input variable, convert to TRUNC_TO_UDINT Unsigned DOUBLE INTEGER TRUNC_TO_UDINT cuts off the digits following the decimal of a REAL number and delivers an Description output variable of the data type Unsigned DOUBLE INTEGER. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 190
Conversion instructions STRING (Decimal Format) into Unsigned DOUBLE INTEGER STRING_TO_UDINT STRING_TO_UDINT converts a string in decimal format to a value of the data type Unsigned Description DOUBLE INTEGER. First, the string is converted to a value of the data type STRING[32], which is subsequently converted to a value of the data type UDINT in a subprogram with approximately 270 steps.
Page 191
Conversion instructions DATE into Unsigned DOUBLE INTEGER DATE_TO_UDINT DATE_TO_UDINT converts a value of the data type DATE into a value of the data type Unsigned Description DOUBLE INTEGER according to its internal format, which is seconds elapsed since "2001-01-01". To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 192
Conversion instructions DATE_AND_TIME into Unsigned DOUBLE INTEGER DT_TO_UDINT DT_TO_UDINT converts a value of the data type DATE_AND_TIME into a value of the data type Description Unsigned DOUBLE INTEGER according to its internal format, which is seconds elapsed since "2001-01-01-00:00:00". To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 193
Conversion instructions TIME_OF_DAY into Unsigned DOUBLE INTEGER TOD_TO_UDINT TOD_TO_UDINT converts a value of the data type TIME_OF_DAY into a value of the data type Description Unsigned DOUBLE INTEGER according to its internal format, which is seconds elapsed since "00:00:00". To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 194
Conversion instructions DWORD into REAL DWORD_TO_REAL DWORD_TO_REAL moves the bitset information of a DWORD variable to a REAL variable. The Description same functionality can be obtained using DWORD_OVERLAPPING_DUT. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 195
Conversion instructions INTEGER into REAL INT_TO_REAL INT_TO_REAL converts a value of the data type INTEGER into a value of the data type REAL. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 196
Conversion instructions DOUBLE INTEGER into REAL DINT_TO_REAL DINT_TO_REAL converts a value of the data type DOUBLE INTEGER into a value of the data type Description REAL. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 197
Conversion instructions Unsigned INTEGER into REAL UINT_TO_REAL UINT_TO_REAL converts a value of the data type Unsigned INTEGER into a value of the data Description type REAL. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 198
Conversion instructions Unsigned DOUBLE INTEGER into REAL UDINT_TO_REAL UDINT_TO_REAL converts a value of the data type Unsigned DOUBLE INTEGER into a value of Description the data type REAL. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 199
Conversion instructions TIME into REAL TIME_TO_REAL TIME_TO_REAL converts a value of the data type TIME to a value of the data type REAL. 10ms of Description the data type TIME correspond to 1.0 REAL unit, e.g. when TIME = 10ms, REAL = 1.0; when TIME = 1s, REAL = 100.0.
Page 200
Conversion instructions STRING to REAL STRING_TO_REAL function converts a STRING in floating-point format into a value of the data type REAL. Description Thereby the attached string is first converted to a value of the data type STRING[32]. Finally this is converted to a value of the data type REAL via a sub-program that requires approximately 290 steps.
Page 201
Conversion instructions WORD in TIME WORD_TO_TIME WORD_TO_TIME converts a value of the data type WORD into a value of the data type TIME. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 202
Conversion instructions DOUBLE WORD in TIME DWORD_TO_TIME DWORD_TO_TIME converts a value of the data type DWORD into a value of the data type TIME. Description A value of 1 corresponds to a time of 10ms, e.g. the input value 12345 (16#3039) is converted to a TIME T#2m3s450.00ms.
Page 203
Conversion instructions INTEGER into TIME INT_TO_TIME INT_TO_TIME converts a value of the data type INT into a value of the data type TIME. The Description resolution is 10ms, e.g. when the INT value = 350, the TIME value = 3s500ms. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 204
Conversion instructions DOUBLE INTEGER into TIME DINT_TO_TIME DINT_TO_TIME converts a value of the data type DINT into a value of the data type TIME. A value Description of 1 corresponds to a time of 10ms, e.g. an input value of 123 is converted to a TIME T#1s230.00ms.
Page 205
Conversion instructions REAL into TIME REAL_TO_TIME REAL_TO_TIME converts a value of the data type REAL to a value of the data time TIME. 10ms of Description the data type TIME correspond to 1.0 REAL unit, e.g. when REAL = 1.0, TIME = 10ms; when REAL = 100.0, TIME = 1s.
Page 206
Conversion instructions Unsigned DOUBLE INTEGER into DATE_AND_TIME UDINT_TO_DT UDINT_TO_DT converts a value of the data type Unsigned DOUBLE INTEGER into a value of the Description data type DATE_AND_TIME. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 207
Conversion instructions DATE_AND_TIME to DATE DT_TO_DATE DT_TO_DATE converts a value of the data type DATE_AND_TIME to a value of the data type Description DATE. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 208
Conversion instructions Unsigned DOUBLE INTEGER into DATE UDINT_TO_DATE UDINT_TO_DATE converts a value of the data type Unsigned DOUBLE INTEGER into a value of Description the data type DATE. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 209
Conversion instructions DATE_AND_TIME to TIME_OF_DAY DT_TO_TOD DT_TO_TOD converts a value of the data type DATE_AND_TIME to a value of the data type Description TIME_OF_DAY. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 210
Conversion instructions Unsigned DOUBLE INTEGER into TIME_OF_DAY UDINT_TO_TOD UDINT_TO_TOD converts a value of the data type Unsigned DOUBLE INTEGER into a value of Description the data type TIME_OF_DAY. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 211
Conversion instructions BOOL into STRING BOOL_TO_STRING The function BOOL_TO_STRING converts a value of the data type BOOL to a value of the data Description type STRING[2]. The resulting string is represented by ' 0' or ' 1'. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 212
Conversion instructions Example 2 If you wish to have the result 'TRUE' or 'FALSE' instead of ' 0' or ' 1', you cannot use the function BOOL_TO_STRING. This example illustrates how you create a STRING[5] that contains the Result string = 'TRUE' or characters 'TRUE' or 'FALSE' from an input value of the data type BOOL.
Page 213
Conversion instructions WORD into STRING WORD_TO_STRING The function WORD_TO_STRING converts a value of the data type WORD to a value of the data Description type STRING. Generates a result string in right-aligned decimal representation, filled with leading spaces up to the predefined maximum number of characters.
Page 214
Conversion instructions When programming with structured text, enter the following: result_string:=WORD_TO_STRING(input_value); This example illustrates how you create STRING[4] out of the data type WORD in which the Example 2 leading part of the string '16#' is cut out. The example is programmed in LD and IL. The same POU header is used for both programming languages.
Page 215
Conversion instructions DOUBLE WORD into STRING DWORD_TO_STRING The function DWORD_TO_STRING converts a value of the data type DWORD to a value of the Description data type STRING. Generates a result string in right-aligned decimal representation, filled with leading spaces up to the predefined maximum number of characters.
Page 216
Conversion instructions When programming with structured text, enter the following: result_string:=DWORD_TO_STRING(input_value); This example illustrates how you create STRING[10] out of the data type DWORD in which the Example 2 leading part of the string '16#' is replaced by the string '0x'. The example is programmed in LD and IL.
Page 217
Conversion instructions DATE into STRING DATE_TO_STRING DATE_TO_STRING converts a value of the data type DATE into a value of the data type Description STRING[10]. The range for the input date is from D#2001-01-01 to D#2099-12-31. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 218
Conversion instructions DATE_AND_TIME into STRING DT_TO_STRING DT_TO_STRING converts a value of the data type DATE_AND_TIME into a value of the data type Description STRING[19]. The range for the input date is from DT#2001-01-01-00:00:00 to DT#2099-12-31-23:59:59. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 219
Conversion instructions INTEGER into STRING INT_TO_STRING The function INT_TO_STRING converts a value of the data type INT to a value of the data type Description STRING. Generates a result string in right-aligned decimal representation, filled with leading spaces up to the predefined maximum number of characters.
Page 220
Conversion instructions Body The INT_value of the data type INT is converted into STRING[8]. The converted value is written to result_string. When the variable INT_value = -12345, result_string shows ' -12345'. When programming with structured text, enter the following: result_string:= INT_TO_STRING(input_value); This example illustrates how you create a STRING[2] that appears right justified out of the data Example 2 type INT.
Page 221
Conversion instructions INTEGER into STRING INT_TO_STRING_ LEADING_ZEROS The function INT_TO_STRING_LEADING_ZEROS converts a value of the data type INT (positive Description values) to a value of the data type STRING. Generates a result string in right-aligned decimal representation, filled with leading spaces up to the predefined maximum number of characters.
Page 222
Conversion instructions DOUBLE INTEGER into STRING DINT_TO_STRING The function DINT_TO_STRING converts a value of the data type DINT to a value of the data type Description STRING. Generates a result string in right-aligned decimal representation, filled with leading spaces up to the predefined maximum number of characters.
Page 223
Conversion instructions Body The input_value of the data type DINT is converted into STRING[11]. The converted value is written to result_string. When the variable input_value = 12345678, result_string shows ' 12345678'. When programming with structured text, enter the following: result_string:=DINT_TO_STRING(input_value); This example illustrates how you create, from an input value of the data type DINT, a STRING[14] Example 2 that contains a DINT number representation with commas after every three significant figures.
Page 224
Conversion instructions Unsigned DOUBLE INTEGER into STRING UDINT_TO_STRING The function UDINT_TO_STRING converts a value of the data type UDINT to a value of the data Description type STRING. Generates a result string in right-aligned decimal representation, filled with leading spaces up to the predefined maximum number of characters.
Page 225
Conversion instructions Body The input_value of the data type DINT is converted into STRING[11]. The converted value is written to result_string. When the variable input_value = 12345678, result_string shows ' 12345678'. When programming with structured text, enter the following: result_string:=UDINT_TO_STRING(input_value);...
Page 226
Conversion instructions DOUBLE INTEGER into STRING DINT_TO_STRING_ LEADING_ZEROS This function converts a value of the data type DINT (positive value) to a value of the data type Description STRING. It generates a result string in decimal representation that is right aligned. It is filled with leading zeros up to the maximum number of characters defined for the string.
Page 227
Conversion instructions Unsigned DOUBLE INTEGER into STRING UDINT_TO_STRING _LEADING_ZEROS This function converts a value of the data type UDINT (positive value) to a value of the data type Description STRING. It generates a result string in decimal representation that is right aligned. It is filled with leading zeros up to the maximum number of characters defined for the string.
Page 228
Conversion instructions Unsigned INTEGER into STRING UINT_TO_STRING UINT_TO_STRING converts a value of the data type Unsigned INTEGER into a value of the data Description type STRING. Generates a result string in right-aligned decimal representation, filled with leading spaces up to the predefined maximum number of characters.
Page 229
Conversion instructions Unsigned INTEGER into STRING UINT_TO_STRING_ LEADING_ZEROS UINT_TO_STRING_LEADING_ZEROS converts a value of the data type Unsigned INTEGER into Description a value of the data type STRING. Generates a result string in right-aligned decimal representation, filled with leading spaces up to the predefined maximum number of characters.
Page 230
Conversion instructions REAL into STRING REAL_TO_STRING The function REAL_TO_STRING converts a value from the data type REAL into a value of the data Description type STRING[15], which has 7 spaces both before and after the decimal point. The resulting string is right justified within the range '-999999.0000000' to '9999999.0000000'.
Page 231
Conversion instructions This example illustrates how you create a STRING[7] with 4 positions before and 2 positions after Example 2 the decimal point out of the data type REAL. The example is programmed in LD and IL. The same POU header is used for both programming languages.
Page 232
Conversion instructions TIME into STRING TIME_TO_STRING The function TIME_TO_STRING converts a value of the data type TIME to a value of the data type Description STRING[20]. In accordance with IEC-1131, the result string is displayed with a short time prefix and without underlines.
Page 233
Conversion instructions This example shows how, from an input value of the data type TIME, a TIME STRING[9] with the Example 2 format 'xxhxxmxxs' is created (only hours, minutes and seconds are output). The example is programmed in LD and IL. The same POU header is used for both programming languages.
Page 234
Conversion instructions IP Address to STRING IPADDR_TO_STRING This function converts a binary IP address of the data type DWORD into a STRING in IP address Description format. Example Permissible format: 'Octet1.Octet2.Octet3.Octet4', e.g.: '192.168.206.004' Permissible characters: Decimal numbers "0“-"9“, maximal 3 positions, without leading zeros in Octets 1-4 the range 0-255 The conversion is such that the highest byte of the ET-LAN address represents the fourth octet and...
Page 235
Conversion instructions IP Address to STRING IPADDR_TO_STRING_ NO_LEADING_ZEROS This function converts a binary IP address of the data type DWORD into a STRING in IP address Description format. Example Permissible format: 'Octet1.Octet2.Octet3.Octet4', e.g.: '192.168.206.4' Permissible characters: Decimal numbers "0“-"9“, maximal 3 positions, without leading zeros in Octets 1-4 the range 0-255 The conversion is such that the highest byte of the ET-LAN address represents the fourth octet and...
Page 236
Conversion instructions ETLAN Address to STRING ETLANADDR_TO_ STRING This function converts a binary ETLAN address of the data type DWORD into a STRING in ETLAN Description address format. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 237
Conversion instructions ETLAN Address to STRING ETLANADDR_TO_STRING _NO_LEADING_ZEROS This function converts a binary ETLAN address of the data type DWORD into a STRING in ETLAN Description address format. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 238
Conversion instructions TIME_OF_DAY into STRING TOD_TO_STRING Description TOD_TO_STRING converts a value of the data type TIME_OF_DAY into a value of the data type STRING[8]. The range for the input time of day is from TOD#00:00:00 to TOD#23:59:59. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 239
Conversion instructions WORD to BOOL16 WORD_TO_BOOL16 This function copies data of the data type WORD at the input to an array with 16 elements of the Description data type BOOL at the output. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 240
Conversion instructions DOUBLE WORD to BOOL32 DWORD_TO_BOOL32 This function copies data of the data type DWORD at the input to an array with 32 elements of the Description data type BOOL at the output. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 241
Conversion instructions WORD to 16 variables of the data type BOOL WORD_TO_BOOLS This function converts a value of the data type WORD bit-wise to 16 values of the data type BOOL. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 243
Conversion instructions DOUBLE WORD to 32 variables of the data type BOOL DWORD_TO_BOOLS This function converts a values of the data type DWORD bit-wise to 32 values of the data type Description BOOL. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 245
Conversion instructions INTEGER into BCD value of WORD INT_TO_BCD_WORD INT_TO_BCD_WORD converts a binary value of the data type INT into a binary coded decimal Description integer (BCD) value of the type WORD in order to be able to output BCD values in word format. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 246
Conversion instructions DOUBLE INTEGER into BCD DOUBLE WORD DINT_TO_BCD_DWORD DINT_TO_BCD_DWORD converts a value of the data type DINT into a BCD value of the data type Description DWORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 247
Conversion instructions Unsigned INTEGER into BCD value of WORD UINT_TO_BCD_WORD UINT_TO_BCD_WORD converts a value of the data type Unsigned INTEGER into a BCD value of Description the data type WORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 248
Conversion instructions Unsigned DOUBLE INTEGER into BCD DOUBLE WORD UDINT_TO_BCD_ DWORD UDINT_TO_BCD_DWORD converts a value of the data type Unsigned DOUBLE INTEGER into a Description BCD value of the data type D WORD. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 249
Conversion instructions STRING to IP Address STRING_TO_IPADDR This function converts a STRING in IP address format into a value of the data type DWORD. Description Thereby the attached string is first converted to a value of the data type STRING[32]. Finally this is converted to a value of the data type DWORD via a sub-programm of approx.
Page 250
Conversion instructions STRING (IP-Address Format 00a.0bb.0cc.ddd) to DWORD STRING_TO_IPADDR _STEPSAVER This function converts a STRING in IP address format into a value of the data type DWORD. Description The function uses for approx. 50 steps of generated code the basic instruction F76_A2BIN (see page 637).
Page 251
Conversion instructions STRING to ETLAN Address STRING_TO_ETLAN ADDR This function converts a STRING in IP address format into a value of the data type DWORD. Description Thereby the attached string is first converted to a value of the data type STRING[32]. Finally this is converted to a value of the data type DWORD via a sub-programm of approx.
Page 252
Conversion instructions STRING (IP-address format 00a.0bb.0cc.ddd) to ETLAN Address STRING_TO_ETLAN ADDR_STEPSAVER This function converts a STRING in IP address format into a value of the data type DWORD. Description The function uses for approx. 50 steps of generated code the basic instruction F76_A2BIN (see page 637).
Page 255
Selection instructions Maximum value MAX determines the input variable with the highest value. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 256
Selection instructions Minimum value MIN detects the input variable with the lowest value. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 257
Selection instructions Select value from multiple channels The function Multiplexer selects an input variable and writes its value into the output variable. The Description 1st input variable determines which input variable (IN1or IN2 ...) is to be written into the output variable.
Page 258
Selection instructions Body In channel_select you find the integer value (0, 1...n) for the selection of channel_0 or channel_1. The result will be written into output. When programming with structured text, enter the following: output:=MUX( K:= channel_select , IN0:= channel_0 IN1:= channel_1...
Page 259
Selection instructions Select value from one of two channels With the first input variable (data type BOOL) of SEL you define which input variable is to be written Description into the output variable. If the Boolean value = 0 (FALSE), the input variable IN0 will be written into the output variable, otherwise IN1.
Page 260
Selection instructions When programming with structured text, enter the following: output SEL(G := channel_select, := channel_0, := channel_1);...
Page 263
In this example the input variable (input_string) has been declared. Instead, you may enter the string ('Panasonic') directly into the function. The string has to be put in inverted commas, both in the POU header and in the function.
Page 264
String instructions When programming with structured text, enter the following: output_value:=LEN(input_value);...
Page 265
String instructions Copy characters from the left LEFT LEFT copies, starting from the left, n characters of the string of the first input variable to the output Description variable. You define the number of characters to be delivered n by the second input variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 266
String instructions In this example the input variables (input_string and character_number) have been declared. Instead, you may enter the string ('Ideas for life') and the number of characters to be delivered directly into the function. The string has to be put in inverted commas, both in the POU header and in the function.
Page 267
String instructions Copy characters from the right RIGHT RIGHT copies, starting from the right, n characters of the string of the first input variable to the Description output variable. You define the number of characters to be delivered n by the second input variable.
Page 268
String instructions In this example the input variables (input_string and character_number) have been declared. Instead, you may enter the string ('Ideas for life') and the number of characters to be delivered directly into the function. The string has to be put in inverted commas, both in the POU header and in the function.
Page 269
String instructions Copy characters from a middle position MID copies L characters of the string IN starting at position P with 1 denoting the first character of Description the string. The result is written into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 270
String instructions POU header All input and output variables used for programming this function have been declared in the POU header. In this example the input variables (input_string, character_number and start_position) have been declared. Instead, you may enter the string ('Ideas for life'), the number of characters to be delivered and the start position directly into the function.
Page 271
String instructions Concatenate (attach) a string CONCAT CONCAT concatenates (attaches) the second and the following input strings (IN1 + IN2 + ...) to the Description first input string and writes the resulting string into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 272
String instructions When programming with structured text, enter the following: output_string:=CONCAT(input_string1, input_string2, input_string3);...
Page 273
String instructions Delete characters from a string DELETE DELETE deletes L characters in the string IN starting at position P with 1 denoting the first Description character of the string. The result is written into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 274
String instructions deleted and the start position directly into the function. The string has to be put in inverted commas, both in the POU header and in the function. Body Starting from start_position (6), character_number (8) is deleted from input_string (‘Ideas for life’).
Page 275
String instructions Find string's position FIND FIND returns the position at which the second input string first occurs in the first input string. The Description result is written into the output variable. If the second input string does not occur in the first input string, the value ZERO is returned.
Page 276
String instructions When programming with structured text, enter the following: output_value:= FIND(input_string_1, input_string_2);...
Page 277
String instructions Insert characters INSERT INSERT inserts the string IN2 into the string IN1 beginning after the character position P, where 0 Description denotes the beginning of the string, 1 the position after the first string character, etc. The result is written into the output variable.
Page 278
String instructions Body In this example the input variables input_string1, input_string2 and position have been declared. However, you may enter the values directly at the function's input contact pins instead. The STRING values have to be put in inverted commas, both in the POU header and at the contact pins.
Page 279
String instructions Replaces characters REPLACE REPLACE replaces the characters in the string IN1 with P denoting the first position to be replaced Description and L denoting the number of characters to be replaced with the characters specified by IN2. The result is written into the output variable.
Page 283
Date and time instructions Add TIME to DATE_AND_TIME ADD_DT_TIME ADD_DT_TIME adds the value of a variable of the data type TIME to the date and time stored in Description the variable of the data type DATE_AND_TIME. The result is stored in a variable of the data type DATE_AND_TIME.
Page 284
Date and time instructions Add TIME to TIME_OF_DAY ADD_TOD_TIME ADD_TOD_TIME adds a variable of the data type TIME to the time of day. The result is stored in a Description variable of the data type TIME_OF_DAY. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 285
Date and time instructions Concatenate INT values to form a date CONCAT_DATE_INT CONCAT_DATE_INT concatenates the INTEGER values of year, month, and day.The result is Description stored in the output variable of the data type DATE. The Boolean output ERROR is set if the input values are invalid date or time values.
Page 286
Date and time instructions Concatenate date and time of day CONCAT_DATE_TOD CONCAT_DATE_TOD concatenates a value of the data type DATE with a value of the data type Description TIME_OF_DAY.The result is stored in the output variable of the data type DATE_AND_TIME. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 287
Date and time instructions Concatenate INT values to form date and time CONCAT_DT_INT CONCAT_DT_INT concatenates the INT values of year, month, day, hour, minute, second, and Description millisecond. The result is stored in the output variable of the data type DATE_AND_TIME. The Boolean output ERROR is set if the input values are invalid date or time values.
Page 288
Date and time instructions When programming with structured text, enter the following: DT_value CONCAT_DT_INT(YEAR := YEAR_value, MONTH := MONTH_value, := DAY_value, HOUR := HOUR_value, MINUTE := MINUTE_value, SECOND := SECOND_value, MILLISECOND := MILLISECOND_value, ERROR => ERROR);...
Page 289
Date and time instructions Concatenate INT values to form the time of day CONCAT_TOD_INT CONCAT_TOD_INT concatenates the INTEGER values for hour, minute, second, and millisecond. Description The result is stored in the output variable of the data type TIME_OF_DAY. The Boolean output ERROR is set if the input values are invalid date or time values.
Page 290
Date and time instructions Return the day of the week DAY_OF_WEEK1 DAY_OF_WEEK1 returns the day of the week for any date as an INT. The number 1 corresponds Description to Monday; 7 corresponds to Sunday. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 291
Date and time instructions Read the Real-Time Clock GET_RTC_DT GET_RTC_DT reads the PLC's real-time clock value for the clock/calendar function. If the PLC has Description no real-time clock or if the real-time clock is not functioning, the result is an invalid date and time value.
Page 292
Date and time instructions Check whether a DATE is valid IS_VALID_DATE_INT IS_VALID_DATE_INT checks whether the combination of the INT values for the year, month, and Description day is a valid DATE value. The Boolean output flag is set if the date is valid. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 293
Date and time instructions Check whether DATE_AND_TIME is valid IS_VALID_DT_INT IS_VALID_DT checks whether the combination of INT values for year, month, day, hour, minute, Description second, and millisecond is a valid date and time value. The Boolean output flag is set if the date and time value is valid.
Page 294
Date and time instructions When programming with structured text, enter the following: VALID IS_VALID_DT_INT(YEAR := YEAR_value, MONTH := MONTH_value, := DAY_value, HOUR := HOUR_value, MINUTE := MINUTE_value, SECOND := SECOND_value, MILLISECOND := MILLISECOND_value);...
Page 295
Date and time instructions Check whether the TIME_OF_DAY is valid IS_VALID_TOD_INT IS_VALID_TOD_INT checks whether the combination of INT values for hour, minute, second, and Description millisecond is a valid time of day value. The Boolean output flag is set if the time of day value is valid.
Page 296
Date and time instructions Set the Real-Time Clock SET_RTC_DT SET_RTC_DT sets the real-time clock value in the PLC for the clock/calendar function. If the PLC Description has no real-time clock or if the real-time clock is not functioning, the result is an invalid date and time value.
Page 297
Date and time instructions Split a date into INTEGER values SPLIT_DATE_INT SPLIT_DATE_INT splits a value of the data type DATE into INT values for year, month, and day. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 298
Date and time instructions Split a date and time into INTEGER values SPLIT_DT_INT SPLIT_DT_INT splits a value of the data type DATE_AND_TIME into INT values for year, month, Description day, hour, minute, second, and millisecond. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 299
Date and time instructions When programming with structured text, enter the following: SPLIT_DT_INT(IN := DT_value, YEAR => YEAR_value, MONTH => MONTH_value, => DAY_value, HOUR => HOUR_value, MINUTE => MINUTE_value, SECOND => SECOND_value, MILLISECOND => MILLISECOND_value);...
Page 300
Date and time instructions Split the time of day into INT values SPLIT_TOD_INT SPLIT_TOD_INT splits a value of the data type TIME_OF_DAY into INT values for hour, minute, Description second, and millisecond. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 301
Date and time instructions Subtracts a date from another date SUB_DATE_DATE SUB_DATE_DATE subtracts a value of the data type DATE from another DATE value. The result Description is stored in the output variable of the data type TIME. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 302
Date and time instructions Subtract date and time from date and time SUB_DT_DT SUB_DT_DT subtracts a value of the data type DATE_AND_TIME from another DATE_AND_TIME Description value. The result is stored in the output variable of the data type TIME. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 303
Date and time instructions Subtracts time from date and time SUB_DT_TIME SUB_DT_TIME subtracts a value of the data type TIME from a value of the data type Description DATE_AND_TIME. The result is stored in the output variable of the data type TIME_OF_DAY. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 304
Date and time instructions Subtracts a TIME value from the time of day SUB_TOD_TIME SUB_TOD_TIME subtracts a TIME value from a value of the data type TIME_OF_DAY. The result Description is stored in the output variable of the data type TIME_OF_DAY. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 305
Date and time instructions Subtract Time of Day from Time of Day SUB_TOD_TOD SUB_TOD_TOD subtracts a value of the data type TIME_OF_DAY from another TIME_OF_DAY Description value. The result is stored in the output variable of the data type TIME. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 307
Bistable instructions Set/reset The function block SR (set/reset) allows you to both set and reset an output. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 308
Bistable instructions POU header All input and output variables which are used for programming the function block SR are declared in the POU header. This also includes the function block (FB) itself. By declaring the FB you create a copy of the original FB. This copy is saved under copy_name, and a separate data area is reserved.
Page 309
Bistable instructions Reset/set The function block RS (reset/set) allows you to both reset and set an output. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 310
Bistable instructions POU header All input and output variables which are used for programming the function block RS are declared in the POU header. This also includes the function block (FB) itself. By declaring the FB you create a copy of the original FB. This copy is saved under copy_name, and a separate data area is reserved.
Page 313
Edge detection instructions Rising edge trigger R_TRIG The function block R_TRIG (rising edge trigger) allows you to recognize a rising edge at an input. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 314
Edge detection instructions Falling edge trigger F_TRIG The function block F_TRIG (falling edge trigger) allows you to recognize a falling edge at an input. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 317
Counter instructions Up counter The function block CTU (count up) allows you to program counting procedures. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 318
Counter instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables which are used for programming the function block CTU are declared in the POU header.
Page 319
Counter instructions Down counter The function block CTD (count down) allows you to program counting procedures. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 320
Counter instructions Data types Data type Function input CD subtracts 1 from CV at rising edge BOOL input LOAD resets counter to PV input PV preset value BOOL output Q signal output, set if CV = 0 output CV current value In this example, the same POU header is used for all programming languages.
Page 321
Counter instructions Up/down counter CTUD The function block CTUD (count up/down) allows you to program counting procedures (up and Description down). To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 322
Counter instructions Time chart Data types Data type Function input CU count up input CD count down BOOL input RESET resets CV if set input LOAD loads PV to CV input PV set value output QU signal output count up BOOL output QD signal output count down...
Page 323
Counter instructions Body Count up: If reset is set, the current_value (CV) will be reset. If up_clock is set, the value 1 is added to the current_value. This procedure is repeated for each rising edge detected at up_clock until the current value is greater than/equal to the set_value.
Page 325
Timer instructions Timer with switch-off delay The function block TOF allows you to program a switch-off delay, e.g. to switch off the ventilator of Description a machine at a later point in time than the machine itself. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 326
Timer instructions Data types Data type Function BOOL (IN) input internal timer on a falling edge TIME (PT) input switch off delay BOOL (Q) output signal output reset if PT = ET TIME (ET) output elapsed time In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 327
Timer instructions Timer with switch-on delay The function block TON allows you to program a switch-on delay. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 328
Timer instructions Data types Data type Function BOOL (IN) input internal timer starts at rising edge TIME (PT) input switch on delay BOOL (Q) output signal output set if PT = ET TIME (ET) output elapsed time In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 329
Timer instructions Timer with defined period The function block TP allows you to program a pulse timer with a defined clock period. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 330
Timer instructions Data types Data type Function BOOL input IN clock generated according to clock period at rising edge TIME input PT clock period BOOL output Q signal output TIME output ET elapsed time In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 331
Timer instructions Add TIME ADD_TIME ADD_TIME adds the times of the two input variables and writes the sum in the output variable. Description To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the context menu or press <Ctrl>+<Shift>+<v>...
Page 332
Timer instructions Concatenate INT values to form a time CONCAT_TIME_INT The highest non-zero time unit may be greater than its apparent limit, e.g. T#25h is a valid time Description value whereas T#1d25h is not. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 333
Timer instructions Divide TIME by INTEGER DIV_TIME_INT DIV_TIME_INT divides the value of the first input variable by the value of the second input variable Description and writes the result into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 334
Timer instructions Divide TIME by DOUBLE INTEGER DIV_TIME_DINT DIV_TIME_DINT divides the value of the first input variable by the value of the second and writes Description the result into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 335
Timer instructions Divide TIME by REAL DIV_TIME_REAL DIV_TIME_REAL divides the value of the first input variable of the data type TIME by the value of Description the second input variable of the data type REAL. The REAL value is rounded off to the nearest whole number.
Page 336
Timer instructions Multiply TIME by INTEGER MUL_TIME_INT MUL_TIME_INT multiplies the values of the two input variables with each other and writes the Description result into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 337
Timer instructions Multiply TIME by DOUBLE INTEGER MUL_TIME_DINT MUL_TIME_DINT multiplies the values of the input variables and writes the result to the output Description variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 338
Timer instructions Multiply TIME by REAL MUL_TIME_REAL MUL_TIME_REAL multiplies the value of the first input variable of the data type TIME by the value Description of the second input variable of the data type REAL. The REAL value is rounded off to the nearest whole number.
Page 339
Timer instructions Split a time into INTEGER values SPLIT_TIME_INT The highest non-zero time unit may be greater than its apparent limit, e.g. T#25h is a valid time Description value whereas T#1d25h is not. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 340
Timer instructions Subtract TIME SUB_TIME SUB_TIME subtracts the value of the second input variable from the value of the first input variable Description and writes the result into the output variable. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 343
Arithmetic instructions 16-bit addition F20_ADD The 16-bit equivalent constant or 16-bit area specified by s and the 16-bit area specified by d are Description added together if the trigger EN is in the ON-state. The result is stored in d. All 16-bit values are treated as integer values.
Page 344
Arithmetic instructions Operands Relay Register Constant dec. or hex. Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 16-bit R9009 data (overflow or underflow). In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages.
Page 345
Arithmetic instructions 32-bit addition F21_DADD The 32-bit equivalent constant or 32-bit area specified by s and the 32-bit data specified by d are Description added together if the trigger EN is in the ON-state. The result is stored in d. All 32-bit values are treated as double integer values.
Page 346
Arithmetic instructions Operands Relay Register Constant dec. or hex. Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 32-bit R9009 data (overflow or underflow). In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages.
Page 347
Arithmetic instructions 16-bit addition, destination can be specified F22_ADD2 The 16-bit data or 16-bit equivalent constant specified by s1 and s2 are added together if the Description trigger EN is in the ON-state. The result is stored in d. All 16-bit values are treated as integer values.
Page 348
Arithmetic instructions Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 16-bit R9009 data (overflow or underflow). In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages.
Page 349
Arithmetic instructions 32-bit addition, destination can be specified F23_DADD2 The 32-bit data or 32-bit equivalent constant specified by s1 and s2 are added together if the Description trigger EN is in the ON-state. The added result is stored in d. All 32-bit values are treated as double integer values.
Page 350
Arithmetic instructions Operands Relay Register Constant dec. or hex. s1, s2 Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 32-bit R9009 data (overflow or underflow). In this example, the same POU header is used for all programming languages.
Page 351
Arithmetic instructions 4-digit BCD addition F40_BADD The 4-digit BCD equivalent constant or 16-bit area for 4-digit BCD data specified by s and the Description 16-bit area for 4-digit BCD data specified by d are added together if the trigger EN is in the ON-state.
Page 352
Arithmetic instructions Operands Relay Register Constant dec. or hex. Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 4-digit R9009 BCD data (overflow). In this example, the same POU header is used for all programming languages.
Page 353
Arithmetic instructions 8-digit BCD addition F41_DBADD The 8-digit BCD equivalent constant or 8-digit BCD data specified by s and the 8-digit BCD data Description specified by d are added together if the trigger EN is in the ON-state. The result is stored in d. Example value 16#12342000 (BCD) 31 .
Page 354
Arithmetic instructions Operands Relay Register Constant DWX DWY dec. or hex. Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 8-digit R9009 BCD data (overflow). In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages.
Page 355
Arithmetic instructions 4-digit BCD addition, destination can be specified F42_BADD2 The 4-digit BCD equivalent constant or 16-bit area for 4-digit BCD data specified by s1 and s2 are Description added together if the trigger EN is in the ON-state. The result is stored in d. Example value 16#4321 (BCD) 15 .
Page 356
Arithmetic instructions Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 4-digit R9009 BCD data (overflow). In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages.
Page 357
Arithmetic instructions 8-digit BCD addition, destination can be specified F43_DBADD2 The 8-digit BCD equivalent constant or 32-bit area for 8-digit BCD data specified by s1 and s2 are Description added together if the trigger EN is in the ON-state. The result is stored in d. Example value 16#12345678 (BCD) 31 .
Page 358
Arithmetic instructions Operands Relay Register Constant DWX DWY dec. or hex. s1, s2 Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 8-digit R9009 BCD data (overflow).
Page 359
Arithmetic instructions 16-bit increment F35_INC Adds "1" to the 16-bit data specified by d if the trigger EN is in the ON-state. The result is stored in Description Example value 17 15 . . 12 10 . . 8 7 . . 4 3 . . 0 0 0 0 0 0 0 0 0 0 0 0 1...
Page 360
Arithmetic instructions DF(start) THEN F35_INC(increment_value); END_IF;...
Page 361
Arithmetic instructions 32-bit increment F36_DINC Adds "1" to the 32-bit data specified by d if the trigger EN is in the ON-state. The result is stored in Description Example value 131081 31 . . 28 27 . . 24 23 . . 20 19 . . 16 15 .
Page 362
Arithmetic instructions DF(start) THEN F36_DINC(increment_value); END_IF;...
Page 363
Arithmetic instructions 4-digit BCD increment F55_BINC Adds "1" to the 4-digit BCD data specified by d if the trigger EN is in the ON-state. The result is Description stored in d. Example value 16#4320 (BCD) 15 . . 12 10 . . 8 7 . . 4 3 . . 0 0 1 0 0 0 0 1 1 0 0 1 0...
Page 364
Arithmetic instructions Body When the variable start is set to TRUE, the function is carried out. DF(start) THEN F55_BINC(increment_value); END_IF;...
Page 365
Arithmetic instructions 8-digit BCD increment F56_DBINC Adds "1" to the 8-digit BCD data specified by d if the trigger EN is in the ON-state. The result is Description stored in d. Example value 16#87654320 (BCD) 31 . . 28 27 . . 24 23 . . 20 19 . . 16 15 .
Page 366
Arithmetic instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start changes from FALSE to TRUE, the function is carried out. DF(start) THEN F56_DBINC(increment_value); END_IF;...
Page 367
Arithmetic instructions 16-bit subtraction F25_SUB Subtracts the 16-bit equivalent constant or 16-bit area specified by s from the 16-bit area specified Description by d if the trigger EN is in the ON-state. The result is stored in d (minuend area). All 16-bit values are treated as integer values.
Page 368
Arithmetic instructions Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 16-bit R9009 data (overflow or underflow). In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 369
Arithmetic instructions 32-bit subtraction F26_DSUB Subtracts the 32-bit equivalent constant or 32-bit data specified by s from the 32-bit data specified Description by d if the trigger EN is in the ON-state. The result is stored in d (minuend area). All 32-bit values are treated as double integer values.
Page 370
Arithmetic instructions Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 32-bit R9009 data (overflow or underflow). In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages.
Page 371
Arithmetic instructions 16-bit subtraction, destination can be specified F27_SUB2 Subtracts the 16-bit data or 16-bit equivalent constant specified by s2 from the 16-bit data or 16-bit Description equivalent constant specified by s1 if the trigger EN is in the ON-state. The result is stored in d. All 16-bit values are treated as integer values.
Page 372
Arithmetic instructions Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 16-bit R9009 data (overflow or underflow). In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 373
Arithmetic instructions 32-bit subtraction, destination can be specified F28_DSUB2 Subtracts the 32-bit data or 32-bit equivalent constant specified by s2 from the 32-bit data or 32-bit Description equivalent constant specified by s1 if the trigger is in the ON-state. The result is stored in d. All 32-bit values are treated as double integer values.
Page 374
Arithmetic instructions Operands Relay Register Constant DWX DWY DWR dec. or hex. s1, s2 DWY DWR Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 32-bit R9009 data (overflow or underflow).
Page 375
Arithmetic instructions 4-digit BCD subtraction F45_BSUB Subtracts the 4-digit BCD equivalent constant or 16-bit area for 4-digit BCD data specified by s Description from the 16-bit area for 4-digit BCD data specified by d if the trigger EN is in the ON-state. The result is stored in d.
Page 376
Arithmetic instructions Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 4-digit R9009 BCD data (overflow). In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages.
Page 377
Arithmetic instructions 8-digit BCD subtraction F46_DBSUB Subtracts the 8-digit BCD equivalent constant or 8-digit BCD data specified by s from the 8-digit Description BCD data specified by d if the trigger EN is in the ON-state. The result is stored in d. Example value 16#23210044 (BCD) 31 .
Page 378
Arithmetic instructions Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 8-digit R9009 BCD data (overflow). In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages.
Page 379
Arithmetic instructions 4-digit BCD subtraction, destination can be specified F47_BSUB2 Subtracts the 4-digit BCD equivalent constant or 16-bit area for 4-digit BCD data specified by s2 Description from the 4-digit BCD equivalent constant or 16-bit area for 4-digit BCD data specified by s1 if the trigger EN is in the ON-state.
Page 380
Arithmetic instructions Operands Relay Register Constant dec. or hex. s1, s2 Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 4-digit R9009 BCD data (overflow). In this example, the same POU header is used for all programming languages.
Page 381
Arithmetic instructions 8-digit BCD subtraction, destination can be specified F48_DBSUB2 Subtracts the 8-digit BCD equivalent constant or 8-digit BCD data specified by s2 from the 8-digit Description BCD equivalent constant or 8-digit BCD data specified by s1 if the trigger EN is in the ON-state. The result is stored in d.
Page 382
Arithmetic instructions Operands Relay Register Constant DWX DWY dec. or hex. s1, s2 Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the result exceeds the range of 8-digit R9009 BCD data (overflow).
Page 383
Arithmetic instructions 16-bit decrement F37_DEC Subtracts "1" from the 16-bit data specified by d if the trigger EN is in the ON-state. The result is Description stored in d. Example value 17 15 . . 12 10 . . 8 7 . . 4 3 . . 0 0 0 0 0 0 0 0 0 0 0 0 1...
Page 384
Arithmetic instructions DF(start) THEN F37_DEC(decrement_value); END_IF;...
Page 385
Arithmetic instructions 32-bit decrement F38_DDEC Subtracts "1" to the 32-bit data specified by d if the trigger EN is in the ON-state. The result is Description stored in d. Example value 131081 31 . . 28 27 . . 24 23 . . 20 19 . . 16 15 .
Page 386
Arithmetic instructions Body When the variable start changes from FALSE to TRUE, the function is carried out. DF(start) THEN F38_DDEC(decrement_value); END_IF;...
Page 387
Arithmetic instructions 4-digit BCD decrement F57_BDEC Subtracts "1" from the 4-digit BCD data specified by d if the trigger EN is in the ON-state. The Description result is stored in d. Example value 4322 (BCD) 15 . . 12 10 . . 8 7 . . 4 3 . . 0 0 1 0 0 0 0 1 1 0 0 1 0...
Page 388
Arithmetic instructions Body When the variable start changes from FALSE to TRUE, the function is carried out. DF(start) THEN F57_BDEC(decrement_value); END_IF;...
Page 389
Arithmetic instructions 8-digit BCD decrement F58_DBDEC Subtracts "1" from the 8-digit BCD data specified by d if the trigger EN is in the ON-state. The Description result is stored in d. Example value 87654322 (BCD) 31 . . 28 27 . . 24 23 . . 20 19 . . 16 15 .
Page 390
Arithmetic instructions All input and output variables used for programming this function have been declared in the POU header. Body When the variable start changes from FALSE to TRUE, the function is carried out. DF(start) THEN F58_DBDEC(decrement_value); END_IF;...
Page 391
Arithmetic instructions 16-bit multiplication, destination can be specified F30_MUL Multiplies the 16-bit data or 16-bit equivalent constant s1 and the 16-bit data or 16-bit equivalent Description constant specified by s2 if the trigger EN is in the ON-state. The result is stored in d (32-bit area). All 16-bit values are treated as integer values.
Page 392
Arithmetic instructions Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 393
Arithmetic instructions 32-bit multiplication, destination can be specified F31_DMUL Multiplies the 32-bit data or 32-bit equivalent constant specified by s1 and the one specified by s2 if Description the trigger EN is in the ON-state. The result is stored in d[0], d[1] (64-bit area). All 32-bit values are treated as double integer values.
Page 394
Arithmetic instructions start THEN F31_DMUL(multiplicand, multiplicator, output_value); END_IF;...
Page 395
Arithmetic instructions 16-bit data multiply (result in 16 bits) F34_MULW The function multiplies the value specified at input s1 by the value specified at input s2. The result Description of the function is returned at output d. The result at output d lies between -32768 and 32767 (i.e. between 16#0 and 16#FFFF).
Page 396
Arithmetic instructions Error flags IEC address %MX0.900.7 permanently the result calculated exceeds the 16-bit R9007 area specified at output b. %MX0.900.8 for an instant R9008 %MX0.900.11 for an instant the result calculated is 0. R900B In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 397
Arithmetic instructions 32-bit data multiply (result in 32 bits) F39_DMULD The function multiplies the value specified at input s1 by the value specified at input s2. The result Description of the function is returned at output d. The result at output 'd' lies between -2147483648 and 2147483647 (i.e.
Page 398
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 399
Arithmetic instructions 4-digit BCD multiplication, destination can be specified F50_BMUL Multiplies the 4-digit BCD equivalent constant or 16-bit area for 4-digit BCD data specified by s1 Description and s2 if the trigger EN is in the ON-state. The result is stored in d (8-digit area). 15 .
Page 400
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 401
Arithmetic instructions 8-digit BCD multiplication, destination can be 11 specified F51_DBMUL Multiplies the 32-bit BCD (8-digit) equivalent constant or 8-digit BCD data specified by s1 and the Description one specified by s2 if the trigger EN is in the ON-state. The result is stored in the ARRAY d[0], d[1] (64-bit area).
Page 402
Arithmetic instructions Data types Variable Data type Function DWORD multiplicand, 32-bit area for 8-digit BCD data or equivalent constant DWORD multiplier, 32-bit area for 8-digit BCD data or equivalent constant ARRAY [0..1] of result DWORD Operands Relay Register Constant DWX DWY dec.
Page 403
Arithmetic instructions 16-bit division, destination can be specified F32_DIV The 16-bit data or 16-bit equivalent constant specified by s1 is divided by the 16-bit data or 16-bit Description equivalent constant specified by s2 if the trigger EN is in the ON-state. The quotient is stored in d and the remainder is stored in the special data register DT9015 (DT90015 for FP2/2SH and FP10/10S/10SH).
Page 404
Arithmetic instructions Operands Relay Register Constant dec. or hex. s1, s2 Error flags IEC address %MX0.900.11 for an instant the calculated result is 0. R900B %MX0.900.9 for an instant the negative minimum value -32768 R9009 (16#8000) is divided by -1 (16#FFFF) In this example, the same POU header is used for all programming languages.
Page 405
Arithmetic instructions 32-bit division, destination can be specified F33_DDIV The 32-bit data or 32-bit equivalent constant specified by s1 is divided by the 32-bit data or 32-bit Description equivalent constant specified by s2 if the trigger EN is in the ON-state. The quotient is stored in d and the remainder is stored in the special data registers DDT9015 (DDT90015 for FP2/2SH and FP10/10S/10SH).
Page 406
Arithmetic instructions Data types Variable Data type Function dividend divisor ANY32 quotient The variables s1, s2 and d have to be of the same data type. Operands Relay Register Constant dec. or hex. s1, s2 In this example, the same POU header is used for all programming languages. Example POU header All input and output variables used for programming this function have been declared in the POU...
Page 407
Arithmetic instructions 4-digit BCD division, destination can be specified F52_BDIV The 4-digit BCD equivalent constant or the 16-bit area for 4-digit BCD data specified by s1 is Description divided by the 4-digit BCD equivalent constant or the 16-bit area for 4-digit BCD data specified by s2 if the trigger EN is in the ON-state.
Page 408
Arithmetic instructions Data types Variable Data type Function WORD dividend, 16-bit area for BCD data or 4-digit BCD equivalent constant WORD divisor, 16-bit area for BCD data or 4-digit BCD equivalent constant WORD quotient, 16-bit area for BCD data (remainder stored in special data register DT9015/DT90015) Operands Relay...
Page 409
Arithmetic instructions 8-digit BCD division, destination can be specified F53_DBDIV The result is stored in the area specified by d, and the remainder is stored in the special data Description registers DT9016 and DT9015 (DT90016 and DT90015 for FP2/2SH and FP10/10S/10SH). Example value 16#00001110 (BCD) 31 .
Page 410
Arithmetic instructions Data types Variable Data type Function DWORD dividend, 32-bit area for BCD data or 8-digit BCD equivalent constant DWORD divisor, 32-bit area for BCD data or 8-digit BCD equivalent constant DWORD quotient, 32-bit area for BCD data (remainder stored in special data register DT9016 and DT9015/DT90016 and DT90015) Operands...
Page 411
Arithmetic instructions Floating Point Data Divide F313_FDIV The real number data specified by s1 is divided by the real number data specified by s2 when the Description trigger turns on. The result is stored in d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 412
Arithmetic instructions Body When the variable Start is set to TRUE, the real number entered for the variable RealNumber1 is divided by the real number entered for RealNumber2 and the result stored at the address assigned by the compiler to the variable Result. The monitor value icon is activated.
Page 413
Arithmetic instructions Block check code calculation F70_BCC Calculates the Block Check Code (BCC), which is used to detect errors in message transmission, Description of s3 bytes of ASCII data starting from the 16-bit area specified by s2 according to the calculation method specified by s1.
Page 414
Arithmetic instructions Error flags IEC address %MX0.900.7 permanently the number of specified bytes for the R9007 target data exceeds the limit of the %MX0.900.8 for an instant specified data area. R9008 In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages.
Page 415
Arithmetic instructions This result is then compared to the ASCII BIN code of the next character, i.e. "1". ASCII BIN code Sign for comparison 00010101 Exclusive OR result 00110001 00100100 Next exclusive OR And so on until the final character is reached. start THEN F70_BCC( s1_Control:= BCC_Calc_Methode,...
Page 416
Arithmetic instructions 32-bit data square root F160_DSQR The square root of the 32-bit data or constant value specified by s is calculated if the trigger EN is Description in the ON-state. The result (square root) is stored in d. The figures of the first decimal place and below are disregarded. Example value 64 31 .
Page 417
Arithmetic instructions In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 418
Arithmetic instructions BCD type Sine operation F300_BSIN The function calculates the sine of BCD code angular data (input s) and stores the result (output d) Description as a BCD value in an array with three elements. BCD values for input s lie in the area from 0° to 360° (16#0 to 16#360) in 1° steps. With this, output d can yield a result in the range of -1.0000 to 1.0000.
Page 419
Arithmetic instructions In this example, the input variable input_value is declared. However, you can write a constant (e.g. 16#45 for 45°) directly at the input contact of the function. Body In the body, the value 90° is assigned to the variable input_value. When the variable start is set to TRUE, the function F300_BSIN is carried out.
Page 420
Arithmetic instructions BCD type Cosine operation F301_BCOS The function calculates the cosine of BCD code angular data (input s) and stores the result (output Description d) as a BCD value in an array with three elements. BCD values for input s lie in the area from 0° to 360° (16#0 to 16#360) in 1° steps. With this output d can yield a result in the range of -1.0000 to 1.0000.
Page 421
Arithmetic instructions POU header In the POU header, all input and output variables are declared that are used for programming this function. In this example, the input variable input_value is declared. However, you can write a constant (e.g. 16#45 for 45°) directly at the input contact of the function. Body In the body, the value 16#45°...
Page 422
Arithmetic instructions BCD type Tangent operation F302_BTAN The function calculates the tangent of BCD code angular data (input s) and stores the result Description (output d) as a BCD value in an array with three elements. BCD values for input s lie in the area from 0° to 360° (16#0 to 16#360) in 1° steps. With this output d yields a result in the range of -57.2900 to 57.2900.
Page 423
Arithmetic instructions POU header In the POU header, all input and output variables are declared that are used for programming this function. In this example, the input variable input_value is declared. However, you can write a constant (e.g. 16#89 for 89°) directly at the input contact of the function. Body When the variable start is set to TRUE, the function is carried out.
Page 424
Arithmetic instructions BCD type Arcsine operation F303_BASIN The function calculates the arcsine of a BCD value that is entered at input s as an ARRAY with Description three elements. The result is returned as BCD angular data in the range of 0° to 360° (16#0 to 16#360) at output d.
Page 425
Arithmetic instructions Body The first element of the ARRAY’s input_value is given the value 1 (- sign). The second element has 0 as its whole number value, and in the third element 16#4500 is written as the value after the decimal point.
Page 426
Arithmetic instructions BCD type Arccosine operation F304_BACOS The function calculates the arccosine of a BCD value that is entered at input s as an ARRAY with Description three elements. The result is returned as BCD angular data in the range of 0° to 360° (16#0 to 16#360) at output d.
Page 427
Arithmetic instructions Body When the variable start is set to TRUE, the function is carried out. The input_value = 0 (+ sign) in the ARRAY’s first element. 0 represents the whole in the second element, and the value after the decimal point is 8660.
Page 428
Arithmetic instructions BCD type Arctangent operation F305_BATAN The function calculates the arctangent of a BCD value that is entered at input s as an ARRAY with Description three elements. The result is returned as BCD angular data in the range 0° to 90° (16#0 to 16#90) or 270°...
Page 429
Arithmetic instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable Start is set to TRUE, the Arctangent of the real number entered for the variable TangentofAngle is calculated and the result stored at the address assigned by the compiler to the variable Angle (units are radians).
Page 430
Arithmetic instructions 16-bit data absolute value F87_ABS Gets the absolute value of 16-bit data with the sign specified by d if the trigger EN is in the Description ON-state. The absolute value of the 16-bit data with +/- sign is stored in d. This instruction is useful for handling data whose sign (+/-) may vary.
Page 431
Arithmetic instructions start THEN F87_ABS(abs_value); END_IF;...
Page 432
Arithmetic instructions 32-bit data absolute value F88_DABS Gets the absolute value of 32-bit data with the sign specified by d if the trigger EN is in the Description ON-state. The absolute value of the 32-bit data with sign is stored in d. This instruction is useful for handling data whose sign (+/-) may vary.
Page 433
Arithmetic instructions start THEN F88_DABS(abs_value); END_IF;...
Page 434
Arithmetic instructions 16-bit data deadband control F287_BAND The function compares the input value at input s3 with a deadband whose lower limit is specified at Description input s1 and whose upper limit is specified at s2. The result of the function is returned at output d as follows: ...
Page 435
Arithmetic instructions Error flags IEC address %MX0.900.7 permanently the value at s1 > s2. R9007 %MX0.900.8 for an instant R9008 %MX0.900.11 TRUE the input value at s3 is 0. R900B In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 436
Arithmetic instructions 32-bit data deadband control F288_DBAND The function compares the input value at input s3 with a deadband whose lower limit is specified at Description input s1 and whose upper limit is specified at s2. The result of the function is returned at output d as follows: ...
Page 437
Arithmetic instructions Error flags IEC address %MX0.900.7 permanently R9007 the value at s1 > s2. %MX0.900.8 for an instant R9008 %MX0.900.11 to TRUE the input value at s3 is 0. R900B In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 438
Arithmetic instructions Floating point data deadband control F348_FBAND The function compares the input value at input s3_In with a deadband whose lower limit is Description specified at input s1_Min and whose upper limit is specified at s2_Max. The result of the function is returned at output d as follows: Output value d Lower limit of...
Page 439
Arithmetic instructions DWY DWR Error flags IEC address %MX0.900.7 permanently the values at inputs s1_Min, s2_Max, R9007 and s3_In are not REAL numbers or the value at s1_Min > s2_Max. %MX0.900.8 for an instant R9008 %MX0.900.11 to TRUE the result is 0. R900B %MX0.900.9 for an instant...
Page 441
Arithmetic instructions 16-bit data zone control F289_ZONE The function adds an offset value to the input value at input s3. The offset values for the negative Description and positive areas are entered at inputs s1 and s2. The result of the function is returned at output d as follows: If the input value at input s3 <...
Page 442
Arithmetic instructions Operands Relay Register Constant dec. or hex. s1, s2, s3 Error flags IEC address %MX0.900.11 for an instant the calculation results in an overflow or R900B an underflow of output d. %MX0.900.9 for an instant the input value s3 is 0. R9009 In this example, the same POU header is used for all programming languages.
Page 443
Arithmetic instructions 32-bit data (double word data) zone control F290_DZONE The function adds an offset value to the input value at input s3. The offset value for the negative Description and positive area are entered at inputs s1 and s2. The result of the function is returned at output d as follows: If the input value at input s3 <...
Page 444
Arithmetic instructions Operands Relay Register Constant DWX DWY DWR dec. or hex. s1, s2, s3 DWY DWR Error flags IEC address %MX0.900.11 for an instant the calculation results in an overflow or R900B an underflow of output d. %MX0.900.9 for an instant ...
Page 445
Arithmetic instructions Floating point data zone control F349_FZONE The function adds an offset value to the input value at input s3. The offset value for the negative Description and positive area are entered at inputs s1 and s2. The result of the function is returned at output d as follows: If the input value at input s3 <...
Page 446
Arithmetic instructions Operands Relay Register Constant DWX DWY DWR dec. or hex. s1, s2, s3 DWY DWR Error flags IEC address %MX0.900.7 permanently the values at inputs s1, s2, and s3 are R9007 not REAL numbers. %MX0.900.8 for an instant R9008 %MX0.900.11 to TRUE...
Page 448
Arithmetic instructions 16-bit data two's complement F85_NEG Takes two's complement of 16-bit data specified by d if the trigger EN is in the ON-state. Two's Description complement of the original 16-bit data is stored in d. Two’s complement is a number system used to express positive and negative numbers in binary format.
Page 449
Arithmetic instructions DF(start) THEN F85_NEG(negotiate_value); END_IF;...
Page 450
Arithmetic instructions 32-bit data two's complement F86_DNEG Takes two's complement of 32-bit data specified by d if the trigger EN is in the ON-state. Two's Description complement of the original 32-bit data is stored in d. Two’s complement is a number system used to express positive and negative numbers in binary format.
Page 451
Arithmetic instructions Body When the variable start changes from FALSE to TRUE, the function is carried out. DF(start) THEN F86_DNEG(negotiate_value); END_IF;...
Page 452
Arithmetic instructions Maximum value search in 16-bit data table F270_MAX The function searches for the maximum value and its position in a 16-bit data table. Description Input s1 specifies the starting area of the data table, and s2 specifies the end. The maximum value is returned at output max and its position at output pos.
Page 454
Arithmetic instructions Maximum value search in 32-bit data table F271_DMAX The function searches for the maximum value and its position in a 32-bit data table. Description Input s1 specifies the starting area of the data table, and s2 specifies the end. The maximum value is returned at output max and its position at output pos.
Page 455
Arithmetic instructions Body When the variable start is set to TRUE, the function is carried out. It searches for the maximum value and its position in the data_field. The result is here: maximum_value = 222222 and position = 2. start THEN F271_DMAX( s1_Start:= data_field[0], s2_End:= data_field[4],...
Page 456
Arithmetic instructions Maximum value search in real number data table (floating point data) F350_FMAX The function searches for the maximum value and its position in a floating point data table. Description Input s1 specifies the starting area of the data table, and s2 specifies the end. The maximum value is returned at output max and its position at output pos.
Page 457
Arithmetic instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start is set to TRUE, the function is carried out. It then searches the data_field for a maximum value and its position.
Page 458
Arithmetic instructions Minimum value search in 16-bit data table F272_MIN The function searches for the minimum value and its position in a 16-bit data table. Description Input s1 specifies the starting area of the data table, and s2 specifies the end. The minimum value is returned at output min and its position at output pos.
Page 459
Arithmetic instructions Body When the variable start is set to TRUE, the function is carried out. It searches for the minimum value and its position in the data_field. The result is here: minimum_value = -3 and position = 3. start THEN F272_MIN( s1_Start:= data_field[0], s2_End:= data_field[4],...
Page 460
Arithmetic instructions Minimum value search in 32-bit data table F273_DMIN The function searches for the minimum value and its position in a 32-bit data table. Description Input s1 specifies the starting area of the data table, and s2 specifies the end. The minimum value is returned at output min and its position at output pos.
Page 461
Arithmetic instructions Body When the variable start is set to TRUE, the function is carried out. It searches for the minimum value and its position in the data_field. The result is here: minimum_value = -333333 and position = 3. start THEN F273_DMIN( s1_Start:= data_field[0], s2_End:= data_field[4],...
Page 462
Arithmetic instructions Minimum value search in real number data table (floating point data) F351_FMIN The function searches for the minimum value and its position in a floating point data table. Description Input s1 specifies the starting area of the data table, and s2 specifies the end. The minimum value is returned at output min and its position at output pos.
Page 463
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 464
Arithmetic instructions Total and mean numbers calculation in 16-bit data table F275_MEAN This function calculates the sum and the arithmetic mean of numbers (both with +/- signs) in the Description specified 16-bit data table. Input s1_Start specifies the starting area of the data table, and s2_End specifies the end. The sum of all elements in the data table is returned at output Sum and the arithmetic mean of all elements in the data table is returned at output Mean.
Page 465
Arithmetic instructions Body When the variable output is set to TRUE, the function F275_MEAN is carried out. The function calculates the sum of all elements of the data table (sum = 4 + 3 + 8 + (-2) + 1 + (-6) = 8) and writes the result (in this case 8) to the variable sum.
Page 466
Arithmetic instructions Total and mean numbers calculation in 32-bit data table F276_DMEAN This function calculates the sum and the arithmetic mean of numbers (both with +/- signs) in the Description specified 32-bit data table. Input s1 specifies the starting area of the data table, and s2 specifies the end. The sum of all elements in the data table are returned at output sum and the arithmetic mean of all elements in the data table are returned at output mean.
Page 467
Arithmetic instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start is set to TRUE, the function is carried out. The function calculates the sum of all elements of ARRAY data_field (sum = 2 + 3 + 222222 + (-333333) + 1 = -111105) and transfers the result to the variable sum.
Page 468
Arithmetic instructions Total and mean numbers calculation in floating point data table F352_FMEAN This function calculates the sum and the arithmetic mean (both with +/- signs) of floating point Description values in the specified 32-bit data table. Input s1 specifies the starting area of the data table, and s2 specifies the end. The sum of all elements in the data table are returned at output sum, and the arithmetic mean of all elements in the data table are returned at output mean.
Page 469
Arithmetic instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start is set to TRUE, the function is carried out. It calculates the sum = 2.0 + 3.45 + (-6.91) + 5.44 + 1.3 = 5.28 and the mean = Sum/5 = 5.28/5 = 1.056 of the elements of the data_field.
Page 470
Arithmetic instructions Linearization of 16-bit data F282_SCAL The function renders the value y at position x by performing a linear interpolation based on the Description neighboring reference points Pw and Pw+1 . In this example, w is the nearest (xw, yw) (xw+1, yw+1) reference point whose x value is smaller than the input value x, i.e.
Page 471
Arithmetic instructions Limitations of the output value y: If the input value x is smaller than the x-coordinate of the first reference point (P1: x < x1), the output y is set to the first reference point’s y-coordinate (output y = y1, horizontal dashed line in the graph’s upper left corner).
Page 472
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. In the DUT Pool the number of reference points and the xy value pairs are declared. POU header In the POU header, all input and output variables are declared that are used for programming this function.
Page 473
Arithmetic instructions Linearization of 32-bit data F283_DSCAL The function renders the value y at position x by performing a linear interpolation based on the Description neighboring reference points Pw(xw, yw) and Pw+1(xw+1, yw+1). In this example, w is the nearest reference point whose x value is smaller than the input value x, i.e. the function connects the individual reference points in series and renders the output value y based on the input value s.
Page 474
Arithmetic instructions Error flags IEC address %MX0.900.7 permanently the number of reference points is not R9007 between 2 ... 100, or the x values are not %MX0.900.8 for an instant R9008 in ascending order (x1 < x2 < x3 < ...). ...
Page 475
Arithmetic instructions value 511. In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. In the DUT Pool, the number of reference points and the xy value pairs are declared. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 476
Arithmetic instructions Inclination output of 16-bit data F284_RAMP Executes linear ramp output based on the parameters set. Description Availability of F284_RAMP (see page 1323) PLC types Data types Variable Data type Function The initial value from which the output value increases or s1_InitialValue decreases after the trigger's rising edge has been detected by the system...
Page 477
Arithmetic instructions Body When the variable bRun is switched to TRUE, the function is carried out and iOutputValue increases from 3000 (the initial value of iInitialValue) to 6000 (the initial value of iTargetValue) in 1000ms (according to the initial value of iRiseTime). Time chart for increasing the output value: Example values: iInitialValue = 3000, iTargetValue = 6000, iRiseTime = 1000 bRun (Trigger)
Page 479
Arithmetic instructions Scaling of Real Number Data F354_FSCAL This function performs scaling (linearization) of a real number data table and renders the output (Y) Description for an input value (X). For a detailed description, refer to the instructions: F282_SCAL (see page 468) and F283_DSCAL (see page 471).
Page 480
Arithmetic instructions Table data search (16-bit search) F96_SRC Searches for the value that is the same as s1 in the block of 16-bit areas specified by s2 (starting Description area) through s3 (ending area) if the trigger EN is in the ON-state. When the search operation is performed, the search results are stored as follows: ...
Page 481
Arithmetic instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start is set to TRUE, the function is carried out. start THEN F96_SRC( s1:= search_value s2_Start:= data_array[0] , s3_End:= data_array[3] );...
Page 482
Arithmetic instructions 32-bit table data search F97_DSRC The function searches for the value specified at input s1 in a block of 32-bit areas whose beginning Description is specified at input s2 and whose end is specified at input s3. Value searched for 32-bit table data The number of data items that match s1 is stored in special data register DT90037.
Page 483
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 484
Arithmetic instructions 15.1 Introduction into the FIFO buffer The FIFO buffer is a first-in-first-out buffer area realized as a ring buffer. Data is stored in the order in which it is written to the buffer, and then read out in the order stored, starting from the first data item stored. It is convenient for buffering objects in sequential order.
Page 485
Arithmetic instructions FIFO buffer area definition F115_FIFT F115 specifies the starting area d1 for the FIFO (First-In-First-Out) buffer and the memory size n of Description the FIFO buffer. n: memory size (number of words (16-bit)) of FIFO buffer, n = 1 to 256. d1: the starting 16-bit area of FIFO buffer How to use the FIFO buffer (see page 483) Definition of the area using the FIFT instruction should be carried out only once, before writing to or...
Page 486
Arithmetic instructions Operands Relay Register Constant dec. or hex. Error flags IEC address %MX0.900.7 permanently n = 0 R9007 n > 256 %MX0.900.8 for an instant R9008 The area specified by n exceeds the limit This example illustrates the FIFO buffer by incorporating the functions F115_FIFT (see page 483), Example F116_FIFR (see page 487) and F117_FIFW (see page 491).
Page 487
Arithmetic instructions Body The example below illustrates the status of the buffer after FIFO_Write has been enabled twice and FIFO_Read once. When FIFO_Write was activated the first time, the value 1 was written into FIFO.Data[0]. When FIFO_Read was enabled, Read_Data then read this value. When FIFO_Write was enabled the second time, the Writing pointer was incremented by one and the value 2 written into FIFO.Data[1].
Page 488
Arithmetic instructions DF(FIFO_Initalize) THEN (* Create the FIFO buffer *) F115_FIFT( n_Number:= Size_Of_Var(FIFO.Data), d1_Start:= FIFO.Size); REPEAT (* Initialize FIFO buffer with values *) Write_Data:=Write_Data+1; F117_FIFW( s:= Write_Data, d1_Start:= FIFO.Size); UNTIL(FIFO.Number>=FIFO.Size) END_REPEAT; END_IF; DF( FIFO_Write) THEN (* Write value of Write_Data to FIFO buffer *) (* at rising edge of FIFO_Write *) F117_FIFW( s:= Write_Data, d1_Start:= FIFO.Size);...
Page 489
Arithmetic instructions Read from FIFO buffer F116_FIFR F/P116 reads the data d1 from the FIFO (First-In-First-Out) buffer and stores the data in area Description specified by d2. How to use the FIFO buffer (see page 483) Reading of data is done starting from the address specified by the reading pointer when the instruction is executed.
Page 490
Arithmetic instructions An error occurs if this is executed when the number of stored data items is 0 or when the reading pointer is equal to the writing pointer. Reading is only carried out when the reading pointer is not equal to the writing pointer.
Page 491
Arithmetic instructions Body The example below illustrates the status of the buffer after FIFO_Write has been enabled twice and FIFO_Read once. When FIFO_Write was activated the first time, the value 1 was written into FIFO.Data[0]. When FIFO_Read was enabled, Read_Data then read this value. When FIFO_Write was enabled the second time, the Writing pointer was incremented by one and the value 2 written into FIFO.Data[1].
Page 492
Arithmetic instructions DF(FIFO_Initalize) THEN (* Create the FIFO buffer *) F115_FIFT( n_Number:= Size_Of_Var(FIFO.Data), d1_Start:= FIFO.Size); REPEAT (* Initialize FIFO buffer with values *) Write_Data:=Write_Data+1; F117_FIFW( s:= Write_Data, d1_Start:= FIFO.Size); UNTIL(FIFO.Number>=FIFO.Size) END_REPEAT; END_IF; DF( FIFO_Write) THEN (* Write value of Write_Data to FIFO buffer *) (* at rising edge of FIFO_Write *) F117_FIFW( s:= Write_Data, d1_Start:= FIFO.Size);...
Page 493
Arithmetic instructions Write to FIFO buffer F117_FIFW F/P117 writes the data specified by s into the FIFO buffer specified by d1. Description How to use the FIFO buffer (see page 483) The specified data is written to the address indicated by the writing pointer when the instruction is executed.
Page 494
Arithmetic instructions Operands Relay Register Constant dec. or hex. Error flags IEC address %MX0.900.7 permanently the size (n) of the FIFO specified by d1 is R9007 n = 0, or when n > 256. the number of stored data items of the FIFO = 0.
Page 495
Arithmetic instructions Body The example below illustrates the status of the buffer after FIFO_Write has been enabled twice and FIFO_Read once. When FIFO_Write was activated the first time, the value 1 was written into FIFO.Data[0]. When FIFO_Read was enabled, Read_Data then read this value. When FIFO_Write was enabled the second time, the Writing pointer was incremented by one and the value 2 written into FIFO.Data[1].
Page 496
Arithmetic instructions DF(FIFO_Initalize) THEN (* Create the FIFO buffer *) F115_FIFT( n_Number:= Size_Of_Var(FIFO.Data), d1_Start:= FIFO.Size); REPEAT (* Initialize FIFO buffer with values *) Write_Data:=Write_Data+1; F117_FIFW( s:= Write_Data, d1_Start:= FIFO.Size); UNTIL(FIFO.Number>=FIFO.Size) END_REPEAT; END_IF; DF( FIFO_Write) THEN (* Write value of Write_Data to FIFO buffer *) (* at rising edge of FIFO_Write *) F117_FIFW( s:= Write_Data, d1_Start:= FIFO.Size);...
Page 497
Arithmetic instructions Data table shift-out and compress F98_CMPR Shifts out non-zero data stored at the highest address of the table to the specified area and Description compresses the data in the table to the higher address. The data in the table specified by d1 and d2 is rearranged as follows: Contents of d2 (highest address) are shifted out to the area specified by d3.
Page 498
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example 1 using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 499
Arithmetic instructions In Step 1 the F99 function is activated, shifting in the value given in the variable ShiftinData at s, i.e. 31, and compressing the rest of the data. In Step 2 the F98 function is activated, and the value defined in the variable at d3, i.e. 11, is shifted out.
Page 500
Arithmetic instructions Data table shift-in and compress F99_CMPW Shifts in data to the smallest address of the specified data table and compresses the data in the Description table toward the higher address. The data in the table specified by d1 and d2 is rearranged as follows: ...
Page 501
Arithmetic instructions Error flags IEC address %MX0.900.7 permanently d1 > d2 R9007 %MX0.900.8 for an instant d1 and d2 are not in the same memory area R9008 In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 502
Arithmetic instructions Sort data in 16-bit data table (in smaller or larger number order) F277_SORT The function sorts values (with +/- sign) in a data table in ascending or descending order. Description Input s1 specifies the starting area of the data table, and s2 specifies the end. You determine the sorting order at input s3.
Page 503
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 504
Arithmetic instructions Sort data in 32-bit data table (in smaller or larger number order) F278_DSORT The function sorts values (with +/- sign) in a data table in ascending or descending order. Description Input s1 specifies the starting area of the data table, and s2 specifies the end. You determine the sorting order at input s3.
Page 505
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 506
Arithmetic instructions Sort data in real number data table (floating point data table) F353_FSORT The function sorts values (with +/- sign) in a data table in ascending or descending order. Description Input s1 specifies the starting area of the data table, and s2 specifies the end. You determine the sorting order at input s3.
Page 507
Arithmetic instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 509
Bistable instructions Serves as a relay with set and reset inputs KEEP KEEP serves as a relay with set and reset points. Description When the SetTrigger turns ON, output of the specified relay goes ON and maintains its condition. Output relay goes OFF when the ResetTrigger turns ON. The output relay’s ON state is maintained until a ResetTrigger turns ON regardless of the ON or OFF states of the SetTrigger.
Page 510
Bistable instructions SET, RESET SET: When the execution conditions have been satisfied, the output is turned on, and the on status Description is retained. RST: When the execution conditions have been satisfied, the output is turned off, and the off status is retained.
Page 511
Bistable instructions In ladder diagram, specify a rising edge in the contact and SET or RESET in the coil: When programming with structured text, enter the following: (*TRUE and FALSE are assigned to Y0*) IF DF(X0) THEN Y0:= TRUE; END_IF; IF DF(X1) THEN Y0:= FALSE;...
Page 513
Bitwise Boolean instructions Bit data move F5_BTM 1 bit of the 16-bit data or constant value specified by s is copied to a bit of the 16-bit area specified Description by d according to the content specified by n if the trigger EN is in the ON-state. When the 16-bit equivalent constant is specified by s, the bit data move operation is performed internally converting it to 16-bit binary expression.
Page 514
Bitwise Boolean instructions Operands Relay Register Constant dec. or hex. Explanation with example value 16#8888 and bit at position 2 moves to destination value at bit position 15 source bit pos target bit pos result bit pos Bit at position 15 is exchanged, destination value in this example: 16#7FFF In this example, the same POU header is used for all programming languages.
Page 515
Bitwise Boolean instructions Digit data move F6_DGT The hexadecimal digits in the 16-bit data or in the 16-bit equivalent constant specified by s are Description copied to the 16-bit area specified by d as specified by n. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 516
Bitwise Boolean instructions hexadecimal digit 1 of the destination. digit ↓ digit Specify n: 16#003 (short form: 16#3) when hexadecimal digit 3 of the source is copied to hexadecimal digit 0 of the destination. digit digit Specify n: 16#212 when multiple hexadecimal digits (hexadecimal digits 2 and 3) of the source are copied to multiple hexadecimal digits (hexadecimal digits 2 and 3) of the destination.
Page 517
Bitwise Boolean instructions Specify n: 16#130 when 4 hexadecimal digits (hexadecimal digits 0 to 3) of the source are copied to 4 hexadecimal digits (hexadecimal digits 0 to 3) of the destination. digit digit Availability of F6_DGT (see page 1325) PLC types Data types Variable...
Page 518
Bitwise Boolean instructions When programming with structured text, enter the following: start THEN F6_DGT( s:= source, n:= specify_n, d=> output); END_IF;...
Page 519
Bitwise Boolean instructions 16-bit data AND F65_WAN Executes AND operation of each bit in 16-bit equivalent constant or 16-bit data specified by s1 and Description s2 if the trigger EN is in the ON-state. The AND operation result is stored in the 16-bit area specified by d.
Page 520
Bitwise Boolean instructions Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: start THEN F65_WAN(value_1, value_2, output_value); END_IF;...
Page 521
Bitwise Boolean instructions 16-bit data OR F66_WOR Executes OR operation of each bit in 16-bit equivalent constant or 16-bit data specified by s1 and Description s2 if the trigger EN is in the ON-state. The OR operation result is stored in the 16-bit area specified by d.
Page 522
Bitwise Boolean instructions Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: start THEN F66_WOR(value_1, value_2, output_value); END_IF;...
Page 523
Bitwise Boolean instructions 16-bit data exclusive OR F67_XOR Executes exclusive OR operation of each bit in 16-bit equivalent constant or 16-bit data specified Description by s1 and s2 if the trigger EN is in the ON-state. The exclusive OR operation result is stored in the 16-bit area specified by d.
Page 524
Bitwise Boolean instructions Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: start THEN F67_XOR(value_1, value_2, output_value); END_IF;...
Page 525
Bitwise Boolean instructions 16-bit data exclusive NOR F68_XNR Executes exclusive NOR operation of each bit in 16-bit equivalent constant or 16-bit data specified Description by s1 and s2 if the trigger EN is in the ON-state. The exclusive NOR operation result is stored in the 16-bit area specified by d.
Page 526
Bitwise Boolean instructions In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 527
Bitwise Boolean instructions 16-bit data unite F69_WUNI The function combines the two values at inputs s1 and s2 with the value at input s3 by bit-unit Description processing. The result of the function is returned at output d. The data-unite is calculated as follows: [d] = ([s1] AND [s3]) OR ([s2] AND (NOT[s3])) 1010 1011 1100 1101...
Page 528
Bitwise Boolean instructions Operands Relay Register Constant dec. or hex. s1, s2, s3 Error flags IEC address %MX0.900.11 for an instant the result calculated is 0. R900B In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 529
Bitwise Boolean instructions 32-bit data AND F215_DAND Description The function performs a bit-wise AND operation on two 32-bit data items at inputs s1 and s2. The result of the function is returned at output d. Truth Table: This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 530
Bitwise Boolean instructions can write constants directly at the input contact of the function instead. Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: START THEN F215_DAND(dint1, dint2, dint3); END_IF;...
Page 531
Bitwise Boolean instructions 32-bit data OR F216_DOR Description The function performs a bit-wise OR operation on two 32-bit data items at inputs s1 and s2. The result of the function is returned at output d. Truth Table: This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 532
Bitwise Boolean instructions can write constants directly at the input contact of the function instead. Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: start THEN F216_DOR(input_value_1, input_value_2, output_value); END_IF;...
Page 533
Bitwise Boolean instructions 32-bit data XOR F217_DXOR Description The functions a bit-wise exclusive OR operation on two 32-bit data items at inputs s1 and s2. The result of the function is returned at output d. Truth Table: Using this instruction you can check how many bits in the two 32-bit data items are different, for example.
Page 534
Bitwise Boolean instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 535
Bitwise Boolean instructions 32-bit data XNR F218_DXNR Description The function performs a bit-wise exclusive NOR operation on two 32-bit data items at inputs s1 and s2. The result of the function is returned at output d. Truth Table: Using this instruction you can check how many bits in the two 32-bit data items are the same. At each position in which the bits at inputs s1 and s2 match, a 1 is produced in the result.
Page 536
Bitwise Boolean instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable output is set to TRUE, the function F218_DXNR is carried out. When programming with structured text, enter the following: start THEN F218_DXNR(input_value_1, 2#11110001010100111, output_value);...
Page 537
Bitwise Boolean instructions 32-bit data unites 12 F219_DUNI The function combines the two values at inputs s1 and s2 bit-wise with the value at input s3. The Description result of the function is returned at output d. The data-unite is calculated as follows: [d] = ([s1] AND [s3]) OR ([s2] AND (NOT[s3])) 1010 1011 1100 1101 1010 1011 1100 1101...
Page 538
Bitwise Boolean instructions Operands Relay Register Constant DWX DWY DWR dec. or hex. s1, s2, s3 DWY DWR Error flags IEC address %MX0.900.11 for an instant the result calculated (output d) is 0. R900B In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 539
Bitwise Boolean instructions 16-bit data bit set F130_BTS Turns ON the bit specified by the bit position at n of the 16-bit data specified by d if the trigger EN Description is in the ON-state. Bits other than the bit specified do not change. The range of n is 0 to 15. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 540
Bitwise Boolean instructions 16-bit data bit reset F131_BTR Turns OFF the bit specified by the bit position at n of the 16-bit data specified by d if the trigger EN Description is in the ON-state. Bits other than the bit specified do not change. The range of n is 0 to 15. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 541
Bitwise Boolean instructions 16-bit data bit invert F132_BTI Inverts [1 (ON) 0 (OFF) or 0 (OFF) 1 (ON)] the bit at bit position n in the 16-bit data area Description specified by d if the trigger EN is in the ON-state. Bits other than the bit specified do not change. The range of n is 0 to 15.
Page 542
Bitwise Boolean instructions 16-bit data test F133_BTT Checks the state [1 (ON) or 0 (OFF)] of bit position n in the 16-bit data specified by d if the trigger Description EN is in the ON-state. The specified bit is checked by special internal relay R900B. ...
Page 543
Bitwise Boolean instructions Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: start THEN F133_BTT( n:= 0, d:= value); R900B THEN bit0_is_TRUE := FALSE; ELSE bit0_is_TRUE := TRUE; END_IF;...
Page 544
Bitwise Boolean instructions Number of ON bits in 16-bit data F135_BCU Counts the number of bits in the ON state (1) in the 16-bit data specified by s if the trigger EN is in Description the ON-state. The number of 1 (ON) bits is stored in the 16-bit area specified by d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 545
Bitwise Boolean instructions Number of ON bits in 32-bit data F136_DBCU Counts the number of bits in the ON state (1) in the 32-bit data specified by s if the trigger EN is in Description the ON-state. The number of 1 (ON) bits is stored in the 16-bit area specified by d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 546
Bitwise Boolean instructions 16-bit data invert (one's complement) F84_INV Inverts each bit (0 or 1) of the 16-bit data specified by d if the trigger EN is in the ON-state. The Description inverted result is stored in the 16-bit area specified by d. This instruction is useful for controlling an external device that uses negative logic operation.
Page 547
Bitwise Boolean instructions When programming with structured text, enter the following: DF(start) THEN F84_INV(invert_value); END_IF;...
Page 548
Bitwise Boolean instructions 16-bit data combine F93_UNIT Extracts each lower 4 bits (bit position 0 to 3) starting with the 16-bit area specified by s and Description combines the extracted data into 1 word if the trigger EN is in the ON-state. The result is stored in the 16-bit area specified by d.
Page 549
Bitwise Boolean instructions Error flags IEC address %MX0.900.7 permanently the area specified using the index R9007 modifier exceeds the limit %MX0.900.8 for an instant R9008 the value at n 5 In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 550
Bitwise Boolean instructions 16-bit data distribution F94_DIST Divides the 16-bit data specified by s into 4-bit units and distributes the divided data into the lower Description 4 bits (bit position 0 to 3) of 16-bit areas starting with d if the trigger EN is in the ON-state. n specifies the number of data to be divided.
Page 551
Bitwise Boolean instructions Error flags IEC address %MX0.900.7 permanently the area specified using the index R9007 modifier exceeds the limit %MX0.900.8 for an instant R9008 the value at n 5 the last area for the result exceeds the limit In this example, the same POU header is used for all programming languages.
Page 552
Bitwise Boolean instructions Time constant processing F182_FILTER Filter processing is executed for specified bits and output bitwise. The instruction can be useful to Description negate the effects of bounce, e.g. for a switching device. For bits stored in the area specified by s1_InputData a debouncing is executed if the resulting value for s2_InputMask is "1".
Page 553
Bitwise Boolean instructions When the system detects a trigger's rising edge, all the bits of the input specified by s1_InputData Pre- cautions are output directly in d_OutputData and the effects of bounce are not prevented. A scan time error during may occur during filter processing, for a maximum of 1 scan.
Page 554
Bitwise Boolean instructions Operands Relay Register Const. dec. or hex s2, s3 Error flags IEC address %MX0.900.7 permanently The filter processing time specified by R9007 s3_FilterTime is less than 0 or greater %MX0.900.8 for an instant R9008 than 30000. In this example, the same POU header is used for all programming languages.
Page 557
Bit-shift instructions Left shift register Shifts 1 bit of the specified data area (d_WR) to the left (to the higher bit position). When Description programming the LSR instruction, be sure to program the data input (DataInput), shift (ShiftLeftTrigger) and reset triggers (Reset). DataInput: specifies the state of new shift-in data: ...
Page 558
Bit-shift instructions Body When programming with structured text, enter the following: Output:=LSR(DataInput, ShiftTrigger, ResetTrigger);...
Page 559
Bit-shift instructions Right shift of 16-bit data in bit units F100_SHR Shifts n bits of 16-bit data area specified by d to the right (to the lower bit position) if the trigger EN Description is in the ON-state. Bit position 1211 ·...
Page 560
Bit-shift instructions When programming with structured text, enter the following: DF(start) THEN F100_SHR( n:= d=> data END_IF;...
Page 561
Bit-shift instructions Left shift of 16-bit data in bit units F101_SHL Shifts n bits of 16-bit data area specified by d to the left (to the higher bit position) if the trigger EN Description is in the ON-state. Bit position 1211 ·...
Page 562
Bit-shift instructions When programming with structured text, enter the following: DF(start) THEN F101_SHL( n:= 4, d=> data); END_IF;...
Page 563
Bit-shift instructions Right shift of 32-bit data in bit units F102_DSHR The function shifts the value at output d to the right. The number of bits at output d to be shifted to Description the right is specified by the value assigned at input n. This shift can lie between 0 and 255 (only the lower value byte of n is effective).
Page 564
Bit-shift instructions POU header In the POU header, all input and output variables are declared that are used for programming this function. Body When the variable start changes from FALSE to TRUE, the function is carried out. It shifts out 4 bits (corresponds to one position in a hexadecimal representation) to the right.
Page 565
Bit-shift instructions Left shift of 32-bit data in bit units F103_DSHL The function rotates the value at output d to the left. The number of bits at output d to be shifted to Description the left is specified by the value assigned at input n. This shift can lie between 0 and 255 (only the lower value byte of n is effective).
Page 566
Bit-shift instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 567
Bit-shift instructions Right shift of one hexadecimal digit (4 bits) of 16-bit data F105_BSR Shifts one hexadecimal digit (4 bits) of the 16-bit area specified by d to the right (to the lower digit Description position) if the trigger EN is in the ON-state. Bit position 1211 ·...
Page 568
Bit-shift instructions Body When the variable start changes from FALSE to TRUE, the function is carried out. When programming with structured text, enter the following: DF(start) THEN F105_BSR(data); END_IF;...
Page 569
Bit-shift instructions Left shift of one hexadecimal digit (4 bits) of 16-bit data F106_BSL Shifts one hexadecimal digit (4 bits) of the 16-bit area specified by d to the left (to the higher digit Description position) if the trigger EN is in the ON-state. Bit position 1211 ·...
Page 570
Bit-shift instructions All input and output variables used for programming this function have been declared in the POU header. Body When the variable start changes from FALSE to TRUE, the function is carried out. When programming with structured text, enter the following: DF(start) THEN F106_BSL(data);...
Page 571
Bit-shift instructions Right shift of multiple bits of 16-bit data range F108_BITR The function shifts the bits of a specified data range, whose beginning and end are specified by the Description outputs d1 and d2 to the right. The number of bits by which the data range is to be shifted to the right is specified by the value assigned at input n.
Page 572
Bit-shift instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 573
Bit-shift instructions Left shift of multiple bits of 16-bit data range F109_BITL The function shifts the bits of a specified data range, whose beginning and end are specified by the Description outputs d1 and d2 to the left. The number of bits by which the data range is to be shifted to the left is specified by the value assigned at input n.
Page 574
Bit-shift instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 575
Bit-shift instructions Right shift of one word (16 bits) of 16-bit data range F110_WSHR Shifts one word (16 bits) of the data range specified by d1 (starting) and d2 (ending) to the right (to Description the lower word address) if the trigger EN is in the ON-state. When one word (16 bits) is shifted to the right, the starting word is shifted out and the data in the ending word becomes 0.
Page 576
Bit-shift instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start changes from FALSE to TRUE, the function is carried out. When programming with structured text, enter the following: DF(start) THEN F110_WSHR( d1_Start=>...
Page 577
Bit-shift instructions Left shift of one word (16 bits) of 16-bit data range F111_WSHL Shifts one word (16 bits) of the data range specified by d1 (starting) and d2 (ending) to the left (to Description the higher word address) if the trigger EN is in the ON-state. When one word (16 bits) is shifted to the left, the ending word is shifted out and the data in the starting word becomes 0.
Page 578
Bit-shift instructions All input and output variables used for programming this function have been declared in the POU header. Body When the variable start changes from FALSE to TRUE, the function is carried out. When programming with structured text, enter the following: DF(start) THEN F111_WSHL( d1_Start=>...
Page 579
Bit-shift instructions Right shift of one hex. digit (4 bits) of 16-bit 5 data range F112_WBSR Shifts one hexadecimal digit (4 bits) of the data range specified by d1 (starting) and d2 (ending) to Description the right (to the lower digit position) if the trigger EN is in the ON-state. When one hexadecimal digit (4 bits) is shifted to the right: ...
Page 580
Bit-shift instructions Operands Relay Register Constant d1, d2 In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 581
Bit-shift instructions Left shift of one hex. digit (4 bits) of 16-bit data range F113_WBSL Shifts one hexadecimal digit (4 bits) of the data range specified by d1 (starting) and d2 (ending) to Description the left (to the higher digit position) if the trigger EN is in the ON-state. When one hexadecimal digit (4 bits) is shifted to the left, ...
Page 582
Bit-shift instructions Operands Relay Register Constant d1, d2 In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 583
Bit-shift instructions LEFT/RIGHT shift register F119_LRSR Shifts 1 bit of the 16-bit data range to the left or to the right. Description Left/right shift is a shift register which shifts 1 bit of the specified data area to the left (to the higher bit position) or to the right (to the lower bit position).
Page 585
Bit-shift instructions Operands Relay Register Constant LeftDirection, DataInput, ShiftTrigger, Reset Carry d1, d2 In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 586
Bit-shift instructions When programming with structured text, enter the following: carry_out_value:=F119_LRSR( LeftDirection:= enable_leftShift, DataInput:= input, ShiftTrigger:= shift_trigger, Reset:= reset, d1_Start:= data_array[0], d1_End:= data_array[2]);...
Page 587
Bit-shift instructions 16-bit data right rotate F120_ROR Rotates n bits of the 16-bit data specified by d to the right if the trigger EN is in the ON-state. Description The following example rotates one bit to the right: Bit position 12 11 ·...
Page 588
Bit-shift instructions Body When the variable start changes from FALSE to TRUE, the function is carried out. When programming with structured text, enter the following: DF(start) THEN F120_ROR( n:= 4, d=> rot_value); END_IF;...
Page 589
Bit-shift instructions 16-bit data left rotate F121_ROL Rotates n bits of the 16-bit data specified by d to the left if the trigger EN is in the ON-state. Description The following example rotates one bit to the left: Bit position 12 11 ·...
Page 590
Bit-shift instructions In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 591
Bit-shift instructions 16-bit data right rotate with carry-flag data F122_RCR Rotates n bits of the 16-bit data specified by d including the data of carry-flag to the right if the Description trigger EN is in the ON-state. This example rotates one bit to the right: Bit position 1211 ·...
Page 592
Bit-shift instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 593
Bit-shift instructions 16-bit data left rotate with carry-flag data F123_RCL Rotates n bits of the 16-bit data specified by d including the data of carry-flag to the left if the Description trigger EN is in the ON-state. This example rotates one bit to the left: Bit position 12 11 ·...
Page 594
Bit-shift instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start changes from FALSE to TRUE, the function is carried out. When programming with structured text, enter the following: DF(start) THEN F123_RCL( n:= 4,...
Page 595
Bit-shift instructions 32-bit data right rotate F125_DROR The function rotates the value at output d to the right. The number of bits at output d to be rotated Description to the right is specified by the value assigned at input n. This shift can lie between 0 and 255 (only the lower value byte of n is effective).
Page 596
Bit-shift instructions Body When the variable start changes from FALSE to TRUE, the function is carried out. It rotates 4 bits (corresponds to one position in a hexadecimal representation) to the right. At input n the constant 4 is assigned directly to the function. You may, however, declare an input variable in the POU header instead.
Page 597
Bit-shift instructions 32-bit data left rotate F126_DROL The function rotates the value at output d to the left. The number of bits at output d to be rotated to Description the left is specified by the value assigned at input n. This shift can lie between 0 and 255 (only the lower value byte of n is effective).Left rotate means that the bits shifted out of bit position 31 (MSB) are shifted via bit position 0 (LSB) into the value at output d.
Page 598
Bit-shift instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start changes from FALSE to TRUE, the function is carried out. It rotates 4 bits (corresponds to one position in a hexadecimal representation) to the left.
Page 599
Bit-shift instructions 32-bit data right rotate with carry flag data F127_DRCR The function rotates the value at output d via the carry flag to the right. The number of bits at output Description d to be rotated to the right is specified by the value assigned at input n. This shift can lie between 0 and 255 (only the lower value byte of n is effective).
Page 600
Bit-shift instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start changes from FALSE to TRUE, the function is carried out. In this example the constant (4) is assigned to the function at input n. You may, however, declare a variable in the POU header instead.
Page 601
Bit-shift instructions 32-bit data right rotate with carry flag data F128_DRCL The function rotates the value at output d via the carry flag to the left. The number of bits at output Description d to be rotated to the left is specified by the value assigned at input n. This shift can lie between 0 and 255 (only the lower value byte of n is effective).
Page 602
Bit-shift instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start changes from FALSE to TRUE, the function is carried out. In this example the constant (4) is assigned to the function at input n. You may, however, declare a variable in the POU header instead.
Page 605
Comparison instructions 16-bit data compare F60_CMP Compares the 16-bit data specified by s1 with one specified by s2 if the trigger EN is in the Description ON-state. The compare operation result is stored in special internal relays R9009, R900A to R900C.
Page 606
Comparison instructions Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: equal:= FALSE; greater_or_equal:= FALSE; start THEN F60_CMP(value, 2); R900B THEN equal := TRUE; END_IF; NOT(R9009) THEN greater_or_equal:= TRUE;...
Page 607
Comparison instructions 32-bit data compare F61_DCMP Compares the 32-bit data or 32-bit equivalent constant specified by s1 with one specified by s2 if Description the trigger EN is in the ON-state. The compare operation result is stored in special internal relays R9009, R900A to R900C.
Page 608
Comparison instructions Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: equal:= FALSE; greater_or_equal:= FALSE; start THEN F61_DCMP(value, 2); R900B THEN equal:= TRUE; END_IF; NOT(R9009) THEN greater_or_equal:= TRUE; END_IF;...
Page 609
Comparison instructions 16-bit data band compare F62_WIN Compares the 16-bit equivalent constant or 16-bit data specified by s1_In with the data band Description specified by s2_Min and s3_Max if the trigger EN is in the ON-state. This instruction checks that s1_In is in the data band between s2_Min (lower limit) and s3_Max (higher limit), larger than s3_Max, or smaller than s2_Min.
Page 610
Comparison instructions Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: start THEN F62_WIN( s1_In:= test_value, s2_Min:= lower_limit, s3_Max:= higher_limit); END_IF;...
Page 611
Comparison instructions 32-bit data band compare F63_DWIN Compares the 32-bit equivalent constant or 32-bit data specified by s1_In with the data band Description specified by s2_Min and s3_Max if the trigger EN is in the ON-state. This instruction checks that s1_In is in the data band between s2_Min (lower limit) and s3_Max (higher limit), larger than s3_Max, or smaller than s2_Min.
Page 612
Comparison instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start is set to TRUE, the function is carried out. inside_the_range:= FALSE; start THEN F63_DWIN( s1_In:= test_value, s2_Min:= lower_limit, s3_Max:= higher_limit);...
Page 613
Comparison instructions Block data compare F64_BCMP Compares the contents of data block specified by s2 with the contents of data block specified by s3 Description according to the contents specified by s1 if the trigger EN is in the ON-state. s1 specifications A = Starting byte position of data block specified by s3 ...
Page 614
Comparison instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 615
Comparison instructions Floating point data band compare F346_FWIN The function compares a data band whose upper and lower limits are specified at inputs s2_Min Description and s3_Max with a value that is entered at input s1_In. The result is returned as follows: Flags Comparison between s1, s2 and s3...
Page 616
Comparison instructions In this example, the input variable input_value is declared. However, you can write a constant directly at the input contact of the function instead. Body The constants -10.0 and 10.0 are assigned to the inputs s2_Min (lower limit) and s3_Max (upper limit).
Page 617
Comparison instructions 16-bit data revision detection F373_DTR The function detects changes in a value at input s by comparing it with its former value that is Description stored at output d. If the new input value at s does not coincide with the old value, the function assigns the new value to output d.
Page 618
Comparison instructions When programming with structured text, enter the following: start THEN F373_DTR(present_value, old_value); R9009 THEN changed_value:=TRUE; END_IF; END_IF;...
Page 619
Comparison instructions 32-bit data revision detection F374_DDTR The function detects changes in a value at input s by comparing it with its former value that is Description stored at output d. If the new input value at s does not coincide with the old value, the function assigns the new value to output d.
Page 620
Comparison instructions When programming with structured text, enter the following: start THEN F374_DDTR(present_value, old_value); R9009 THEN changed_value:=TRUE; END_IF; END_IF;...
Page 621
Comparison instructions 19.1 Further comparison instructions If you need information on one of the following comparison instructions, please refer to the corresponding standard operators in the online help: STD= AND= ORD= ST<> AN<> OR<> STD<> AND<> ORD<> ST> AN> OR> STD>...
Page 623
Conversion instructions HEX -> ASCII conversion F71_HEX2A Converts the data byte-wise from the 16-bit area specified by s1_Start to ASCII codes that express Description the equivalent hexadecimals if the trigger EN is in the TRUE-state. The number of bytes to be converted is specified by s2_Number.
Page 624
Conversion instructions Availability of F71_HEX2A (see page 1326) PLC types Data types Variable Data type Function ANY16 starting 16-bit area for hexadecimal number (source) s1_Start specifies number of source data bytes to be converted s2_Number ANY16 starting 16-bit area for storing ASCII code (destination) d_Start Operands Relay...
Page 625
Conversion instructions When programming with structured text, enter the following: start THEN F71_HEX2A( s1_Start:= HexInput[0], s2_Number:= BytesToConvert, d_Start=> ASCOutput[0]); END_IF;...
Page 626
Conversion instructions ASCII -> HEX conversion F72_A2HEX Converts the ASCII codes that express the hexadecimal characters starting from the 16-bit area Description specified by s1 to hexadecimal numbers if the trigger EN is in the ON-state. s2 specifies the number of ASCII (number of characters) to be converted. The converted result is stored in the area starting from the 16-bit area specified by d.
Page 627
Conversion instructions ASCII HEX code Hexadecimal number 16#30 16#31 16#32 16#33 16#34 16#35 16#36 16#37 16#38 16#39 16#41 16#42 16#43 16#44 16#45 16#46 This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger. Select [Insert P instruction] from the "Instructions"...
Page 628
Conversion instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start is set to TRUE, the function is carried out. In this example, the value for s2, i.e.
Page 629
Conversion instructions BCD -> ASCII conversion F73_BCD2A Converts the BCD code starting from the 16-bit area specified by s1 to the ASCII code that Description expresses the equivalent decimals according to the contents specified by s2 if the trigger EN is in the ON-state.
Page 630
Conversion instructions "Instructions" pane if you require a P instruction. To facilitate reuse, the instruction then appears under "Recently used" in the pop-up menu. Press <Ctrl>+<Shift>+<v> within the programming area to open the list of recently used elements. PLC types Availability of F73_BCD2A (see page 1326) Data types Variable...
Page 631
Conversion instructions When programming with structured text, enter the following: start THEN F73_BCD2A( s1_Start:= BCDCodeInput s2_Number:= direction_number d_Start=> ASCOutput[0] ); END_IF;...
Page 632
Conversion instructions ASCII -> BCD conversion F74_A2BCD Converts the ASCII codes that express the decimal characters starting from the 16-bit area Description specified by s1 to BCD if the trigger EN is in the ON-state. s2 specifies the number of source data bytes and the direction of converted code source data.
Page 633
Conversion instructions BCD character ASCII HEX code This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger. Select [Insert P instruction] from the "Instructions" pane if you require a P instruction. To facilitate reuse, the instruction then appears under "Recently used"...
Page 634
Conversion instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start is set to TRUE, the function is carried out. For the variable at s1, you define an ARRAY with a minimum of four word elements because 8 ASCII characters require 8 bytes of memory and the function cannot convert more than 8 bytes.
Page 635
Conversion instructions When programming with structured text, enter the following: start THEN F74_A2BCD( s1_Start:= ASCInput[0] , s2_Number:= 16#8 d_Start=> BCDOutput[0] ); END_IF;...
Page 636
Conversion instructions 16-bit BIN -> ASCII conversion F75_BIN2A Converts the 16-bit data specified by s1 to ASCII codes that express the equivalent decimal value. Description The converted result is stored in the area starting from the 16-bit area specified by d as specified by s2.
Page 637
Conversion instructions When a positive number is converted bit data 1234 F75_BIN2A instruction execution Converted d[2] d[1] d[0] result (Space) (Space) ASCII code Extra bytes Range specified by s2 (6 bytes) Decimal characters to express ASCII HEX code: Decimal ASCII HEX characters code SPACE...
Page 638
Conversion instructions Error flags IEC address %MX0.900.7 permanently the number of bytes specified by s2 R9007 exceeds the area specified by d. the data specified by s2 is recognized as "0". the converted result exceeds the area specified by d.
Page 639
Conversion instructions ASCII -> 16-bit BIN conversion F76_A2BIN Converts the ASCII codes that express the decimal digits, starting from the 16-bit area specified by Description s1 to 16-bit data as specified by s2. The converted result is stored in the area specified by d. s2 specifies the number of source data bytes to be converted using decimal number.
Page 640
Conversion instructions ASCII HEX Decimal code characters 16#20 SPACE 16#2B 16#2D 16#30 16#31 16#32 16#33 16#34 16#35 16#36 16#37 16#38 16#39 This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger. Select [Insert P instruction] from the "Instructions"...
Page 641
Conversion instructions Body When the variable start is set to TRUE, the function is carried out. The number of bytes to be converted is entered directly at the contact pin for s2. This programming example is based on the example for the conversion of a negative number on the main page of F76_A2BIN. When programming with structured text, enter the following: start THEN...
Page 642
Conversion instructions 32-bit BIN -> ASCII conversion F77_DBIN2A Converts the 32-bit data specified by s1 to ASCII code that expresses the equivalent decimals. The Description converted result is stored in the area starting from the 16-bit area specified by d as specified by s2. s2 specifies the number of bytes used to express the destination data using decimal.
Page 643
Conversion instructions This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger. Select [Insert P instruction] from the "Instructions" pane if you require a P instruction. To facilitate reuse, the instruction then appears under "Recently used"...
Page 644
Conversion instructions When programming with structured text, enter the following: start THEN F77_DBIN2A( s1:= DINT_input s2_Number:= d_Start=> ASCII_output[0] ); END_IF;...
Page 645
Conversion instructions ASCII -> 32 bit BIN conversion F78_DA2BIN Converts ASCII code that expresses the decimal digits, starting from the 16-bit area specified by s1 Description to 32-bit data as specified by s2. The converted result is stored in the area starting from the 32-bit area specified by d.
Page 646
Conversion instructions under "Recently used" in the pop-up menu. Press <Ctrl>+<Shift>+<v> within the programming area to open the list of recently used elements. Availability of F78_DA2BIN (see page 1326) PLC types Data types Variable Data type Function WORD starting 16-bit area for ASCII code (source) specifies number of source data bytes to be converted ANY32 area for 32-bit data storage (destination)
Page 647
Conversion instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 648
Conversion instructions 16-bit BIN -> 4-digit BCD conversion F80_BCD Converts the 16-bit binary data specified by s to the BCD code that expresses 4-digit decimals if Description the trigger EN is in the ON-state. The converted data is stored in d. The binary data that can be converted to BCD code are in the range of 0 (0 hex) to 9999 (270F hex).
Page 649
Conversion instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 650
Conversion instructions 4-digit BCD -> 16-bit BIN conversion F81_BIN Converts the BCD code that expresses 4-digit decimals specified by s to 16-bit binary data if the Description trigger EN is in the ON-state. The converted result is stored in the area specified by d. Source [s]: 16#15 (BCD) Bit position ·...
Page 651
Conversion instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 652
Conversion instructions 32-bit BIN -> 8-digit BCD conversion F82_DBCD Converts the 32-bit binary data specified by s to the BCD code that expresses 8-digit decimals if Description the trigger EN is in the ON-state. The converted data is stored in d. The binary data that can be converted to BCD code are in the range of 0 (0 hex) to 99,999,999 (5F5E0FF hex).
Page 653
Conversion instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 654
Conversion instructions 8-digit BCD -> 32-bit BIN conversion F83_DBIN Converts the BCD code that expresses 8-digit decimals specified by s to 32-bit binary data if the Description trigger EN is in the ON-state. The converted result is stored in the area specified by d. Source [s]: 16#72811730 (BCD) ·...
Page 655
Conversion instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 656
Conversion instructions 16-bit data sign extension, INT -> DINT F89_EXT 16-bit data is converted to 32-bit data without signs and values being changed. F89 copies the sign Description bit of the 16-bit data specified in s to all the bits of the higher 16-bit area (extended 16-bit area) in If the sign bit (bit position 15) of the 16-bit data specified by s is 0, all higher 16 bits in the variable assigned to d will be 0.
Page 657
Conversion instructions Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: start THEN F89_EXT(Var_16bit, Var_32bit); END_IF;...
Page 658
Conversion instructions Decode hexadecimal -> bit state F90_DECO Decodes the contents of 16-bit data specified by s according to the contents of n if the trigger EN is Description in the ON-state. The decoded result is stored in the area starting with the 16-bit area specified by n specifies the starting bit position and the number of bits to be decoded using hexadecimal data: ...
Page 659
Conversion instructions Operands Relay Register Constant dec. or hex. s, n In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 660
Conversion instructions 16-bit data 7-segment decode F91_SEGT Converts the 16-bit equivalent constant or 16-bit data specified by s to 4-digit data for 7-segment Description indication if the trigger EN is in the ON-state. The converted data is stored in the area starting with the 16-bit area specified by d.
Page 661
Conversion instructions Encode bit state -> hexadecimal F92_ENCO Encodes the contents of data specified by s according to the contents of n if the trigger EN is in the Description ON-state. The encoded result is stored in the 16-bit area specified by d starting with the specified bit position.
Page 662
Conversion instructions In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 663
Conversion instructions 12 Character -> ASCII transfer F95_ASC Converts the character constants specified by s to hexadecimal ASCII code. The hexadecimal Description code is stored in 6 words starting from the 16-bit area specified by d. Character constants A B C 1 2 3 0 D E F Data register d[5] d[4]...
Page 664
Conversion instructions ASCII Hex-Code Most significant digit ASCII HEX code SP AC E ” & ’ < – > In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 665
Conversion instructions When programming with structured text, enter the following: Enable THEN F95_ASC( s:= 'ABC1230 DEF' d_Start=> ASCII_Output[0] ); END_IF;...
Page 666
Conversion instructions 16-bit data -> 16-bit Gray code F235_GRY The function converts a value at input s to a gray code value. The result of the conversion is Description returned at output d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 667
Conversion instructions 32-bit data -> 32-bit Gray code F236_DGRY The function converts a value at input s to a gray code value. The result of the conversion is Description returned at output d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 668
Conversion instructions 16-bit Gray code -> 16-bit binary data F237_GBIN The function converts a gray-code value at input s to binary data. The result of the conversion is Description returned at output d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 669
Conversion instructions 32-bit Gray code -> 32-bit binary data F238_DGBIN The function converts a gray-code value at input s to binary data. The result of the conversion is Description returned at output d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 670
Conversion instructions Bit line to bit column conversion F240_COLM The function creates a bit column out of a value given at input s that is returned within an ARRAY Description at output d. The position of the column in the ARRAY is specified at input n. The value assigned at n can be between 0 and 15.
Page 671
Conversion instructions Operands Relay Register Constant dec. or hex. s, n Error flags IEC address %MX0.900.7 permanently the bit position specified at input n is not R9007 between 0 and 15 %MX0.900.8 for an instant R9008 the conversion operation results in an overflow of the address area at output d.
Page 672
Conversion instructions Bit column to bit line conversion F241_LINE The function converts a bit column out of an ARRAY at input s and returns it at output d. The Description position at which the conversion takes place is specified at input n. The value assigned at input n should be between 0 and 15.
Page 673
Conversion instructions Operands Relay Register Constant dec. or hex. Error flags IEC address %MX0.900.7 permanently the bit position specified at input n is R9007 not between 0 and 15 %MX0.900.8 for an instant an overflow of the address area at R9008 input s occurs.
Page 674
Conversion instructions Binary -> ASCII conversion F250_BTOA Converts 16-bit/32-bit binary data stored in the area specified by s2_BinaryData to ASCII code. Description The conversion method is specified by n_ConversionMethod according to the four control characters of s1_Control. The converted result is stored in the area specified by d_AsciiData. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 675
Conversion instructions Error flags IEC address %MX0.900.7 permanently there is an error in the control string R9007 specified by s1_Control. normal direction (+) is specified in s1_Control when the format is decimal. the number of ASCII characters per converted unit specified by %MX0.900.8 for an instant...
Page 676
Conversion instructions About the number of ASCII characters (8-bit) per converted unit When converting 16-bit binary units to hexadecimal ASCII data: Range: 16#1 to 16#4. When a range of less than 16#4 is set, the specified number of characters from the lower bytes are stored.
Page 677
Conversion instructions In this example, the same POU header is used for all programming languages. Example POU header All input and output variables used for programming this function have been declared in the POU header. Body When bExecute is set to TRUE, the instruction is carried out. It converts two 16-bit units to 2 x 4 decimal ASCII data.
Page 678
Conversion instructions ASCII -> Binary conversion F251_ATOB Converts ASCII code stored in the area specified by s2_AsciiData to 16-bit/32-bit binary data. The Description conversion method is specified by n_ConversionMethod according to the four control characters of s1_Control. The converted result is stored in the area specified by d_BinaryData. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 679
Conversion instructions Operands Relay Register Constant s1_Control s2_AsciiData dec or hex n_Conversion Method d_BinaryData Error flags IEC address %MX0.900.7 permanently there is an error in the control string R9007 specified by s1_Control. normal direction (+) is specified in s1_Control when the format is decimal.
Page 680
Conversion instructions Conversion examples for ASCII data '0123456789ABCDEF' Binary data n_Conver s1_Cont ASCII Comment sion data Data Offs. in Hex. value method type 16-bit word units H+16 16#404 0123 INT, 16#2301 Normal direction 4567 WORD 4 x 4 ASCII characters 89AB 16#6745 CDEF...
Page 681
Conversion instructions In this example, the same POU header is used for all programming languages. Example POU header All input and output variables used for programming this function have been declared in the POU header. Body When bExecute is set to TRUE, the instruction is carried out. It converts 2 x 4 decimal ASCII characters to binary data.
Page 682
Conversion instructions When programming with structured text, enter the following: DF(bExecute) THEN F251_ATOB(s1_Control := 'D-16', s2_AsciiData := iAscii1, n_ConversionMethod := 16#214, d_BinaryData => iArray2); END_IF;...
Page 683
Conversion instructions ASCII data check F252_ACHK Checks whether the ASCII codes stored in the area specified by s2_AsciiData can be converted Description correctly using the conversion method specified in by n_ConversionMethod and the 4 control characters specified by s1_Control. If the results are correct, the special internal relay (R900B) turns on. ...
Page 684
Conversion instructions In this example, the same POU header is used for all programming languages. Example POU header All input and output variables used for programming this function have been declared in the POU header. Body When bExecute is set to TRUE, the instruction checks whether the data connected at s2_AsciiData can be converted when the control string is 'D-16' and the conversion method 16#214.
Page 685
Conversion instructions 16-Bit Integer Data to Floating Point Data Conversion F325_FLT Converts the 16-bit integer data with sign specified by s to real number data. The converted data is Description stored in d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 686
Conversion instructions 32-Bit Integer Data to Floating Point Data Conversion F326_DFLT Converts the 32-bit integer data with sign specified by s to real number data. The converted data is Description stored in d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 688
Conversion instructions Floating point data -> 16-bit integer data (the largest integer not F327_INT exceeding the floating point data) The function converts a floating point data at input s in the range -32767.99 to 32767.99 into Description integer data (including +/- sign). The result of the function is returned at output d. The converted integer value at output d is always less than or equal to the floating point value at input s: ...
Page 689
Conversion instructions POU header All input and output variables used for programming this function have been declared in the POU header. In this example, the input variable input_value is declared. However, you can write a constant directly at the input contact of the function instead. Body When the variable start is set to TRUE, the function is carried out.
Page 690
Conversion instructions Floating point data -> 32-bit integer data (the largest integer not F328_DINT exceeding the floating point data) The function converts a floating point data at input s in the range -2147483000 to 214783000 into Description integer data (including +/- sign). The result of the function is returned at output d. The converted integer value at output d is always less than or equal to the floating point value at input s: ...
Page 691
Conversion instructions POU header All input and output variables used for programming this function have been declared in the POU header. In this example, the input variable input_value is declared. However, you can write a constant directly at the input contact of the function instead. Body When the variable start is set to TRUE, the function is carried out.
Page 692
Conversion instructions Rounding the first decimal point down F333_FINT The function rounds down the decimal part of the real number data and returns it at output d. Description The converted whole-number value at output d is always less than or equal to the floating-point value at input s: ...
Page 693
Conversion instructions POU header All input and output variables used for programming this function have been declared in the POU header. In this example, the input variable input_value is declared. However, you can write a constant directly at the input contact of the function instead. Body The value 1234.888 is assigned to the variable input_value.
Page 694
Conversion instructions Rounding the first decimal point off F334_FRINT The function rounds off the decimal part of the real number data and returns it at output d. Description If the first post-decimal digit is between 0..4, the pre-decimal value is rounded down. If the first post-decimal digit is between 5..9, the pre-decimal value is rounded up.
Page 695
Conversion instructions When programming with structured text, enter the following: start THEN F334_FRINT(input_value, output_value); END_IF;...
Page 696
Conversion instructions Floating point data sign changes (negative/positive conversion) F335_FSIGN The function changes the sign of the floating point value at input s and returns the result at output Description This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 697
Conversion instructions When programming with structured text, enter the following: input_value:=333.444; start THEN F335_FSIGN(input_value, output_value); END_IF;...
Page 698
Conversion instructions Conversion of angle units (Degrees -> Radians) F337_RAD The function converts the value of an angle entered at input s from degrees to radians and returns Description the result at output d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 699
Conversion instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 700
Conversion instructions Conversion of angle units (Radians -> Degrees) F338_DEG The function converts the value of an angle entered at input s from radians to degrees and returns Description the result at output d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 701
Conversion instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Counter instructions Down Counter CT_FB Counters realized with the CT_FB function block are down counters. The count area SV (set value) Description is 1 to 32767. For the CT_FB function block declare the following: Count count contact each time a rising edge is detected at Count, the value 1 is subtracted from the elapsed value EV until the value 0 is reached Reset reset contact...
Page 704
Counter instructions In order to work correctly, the CT_FB function block needs to be reset each time before it is used. The number of available counters is limited and depends on the settings in the system registers 5 and 6. The compiler assigns a NUM* address to every counter instance.
Page 705
Counter instructions Body This example uses variables. You may also use constants for the input variables. Each rising edge detected at count_contact the value 1 is subtracted from the elapsed value EV. Signal_output is set to TRUE if the elapsed value EV becomes zero.
Counter instructions Counter Decrements a preset counter. The function has the following parameters: Count, Reset, Num*, Description SV, and C. Their functions are listed in the Data types table below. 1. When the Reset input is on, the elapsed value is reset to 0. 2.
Page 707
Counter instructions Details about points of Down Counter CT: Type Number of points Nos. that can be used 100–143 FP-e 100–143 FP0 C10, C14, C16 100–139 Non-hold type 140–143 Hold type 100–143 FP0 C32 100–127 Non-hold type 128–143 Hold type 3000–3071 FP2SH/FP10SH 200–255...
Page 708
Counter instructions When programming with structured text, enter the following: Counter100:=CT( Count:= Count_input Reset:= Reset_input Num:= SV:= Setvalue (* Num*, 100 in this example, must be a constant *)
Counter instructions UP/DOWN counter F118_UDC DOWN counting if the trigger UpDirection is in the OFF state. UP counting if the trigger Description UpDirection is in the ON state. CountTrigger: Adds or subtracts one count at the rising edge of this trigger. Reset_Preset: The condition is reset when this signal is on.
Page 710
Counter instructions A rising edge at the input Count_Trigger activates the counter. The boolean variable at the input UpDirection sets the direction of the counter (TRUE = up, FALSE =down). TRUE at the input Reset_Preset resets the counter to the starting value. When programming with structured text, enter the following: output_value:=F118_UDC( UpDirection:= up, Count_Trigger:= count, Reset_Preset:= reset, s_PresetValue:= set_value);...
The slave answers automatically to the commands received from the master, so no program is necessary on the slave. The Modbus protocol supports both ASCII mode and RTU binary mode. However, the PLCs of the FP Series only support the RTU binary mode.
Page 714
Data transfer via communication ports Data is automatically received in the receive buffer defined in the system registers. For detailed information, see Receiving Data from External Devices (see page 747). communication ports Data is automatically received in the MCU unit. The data received can be moved to the CPU receive buffer using the instruction F161_MRCV (see page 755).
Data transfer via communication ports 22.2 Setting the communication parameters CPU: Setting the communication parameters for the COM ports via system registers (see page 714) During PROG mode: via DIP switches (see page 715) (for FP10SH only) F159_MTRN (switch communication mode (see page During RUN time: 717) with 16#8000)
Data transfer via communication ports Communication mode Select a communication mode. The factory setting for the communication mode is "MEWTOCOL-COM Master/Slave". Station number The station number must be set for MEWTOCOL-COM Master/Slave, Modbus RTU, and for PLC Link. MEWTOCOL-COM and Modbus RTU: The station number can be set within a range of 1 to 99. PLC Link: The station number can be set within a range of 1 to 16.
Page 717
Data transfer via communication ports End code: The setting must match the external device connected to the communication port. Use the upper row of operation mode switches: Upper DIP switches Lower DIP switches Operation mode switches (upper row) Settings Functions MODEM control Disabled Enabled...
Data transfer via communication ports 22.2.1.3 Setting in RUN Mode with SYS instructions (FP-Sigma, FP-X) Please refer to the description of SYS1, communication condition setting (see page 980) and to the description of SYS2 (see page 993). 22.2.1.4 Changing the communication mode in RUN mode The communication mode of the CPU's communication ports can be changed during RUN mode.
Page 719
Data transfer via communication ports Switch communication mode between 'Program controlled' and SetCommunication 'MEWTOCOL-COM' Mode Sets the communication mode to the mode indicated by the value applied at Description bSetProgramControlled. If this value is TRUE then the communication mode is set to Program controlled mode (see page 712), if it is FALSE it is set to "MEWTOCOL-COM (see page 712) Slave [Computer Link]".
Page 720
Data transfer via communication ports DIP switch settings COM 1 COM 2 Port Switch No. Spare Operation mode PLC link Program controlled communication MEWTOCOL-COM Slave 115200bit/s Baud rate 19200bit/s 9600bit/s Memory switch NOTE The factory setting for all DIP switches is ON. Setting the MCU's COM Ports in PROG Mode via the MCU Dialog Please refer to the description of the MCU parameter settings in the online help.
Page 721
Data transfer via communication ports under "Recently used" in the pop-up menu. Press <Ctrl>+<Shift>+<v> within the programming area to open the list of recently used elements. Configuration of communication parameters: 1. UnitNumber (station 1 to 99) 2. BaudrateValue (0 to 10) *2 *2.
Page 722
Data transfer via communication ports Operands Relay Register Constant s_Para dec. or hex. d_Port Error flags IEC address %MX0.900.7 permanently R9007 the MCU unit does not exist in the specified slot %MX0.900.8 for an instant R9008...
Page 723
Data transfer via communication ports Setting the MCU's communication ports during RUN mode via the output (Y) flags 16 I/Os for Y are allocated. I/O numbers are determined depending on the installation location and the I/O allocations of the other units. Output signal Name Description (0: OFF, 1: ON)
Page 724
Data transfer via communication ports Changing operation modes (see page 717) (switching between program controlled communication and MEWTOCOL-COM Slave) using F159_MTRN. Turning on the PLC power supply or changing from PROG to RUN mode if the MCU settings have been made via software.
Data transfer via communication ports 22.3 Getting the communication mode You can check during RUN mode which communication mode has been set on the PLC. The following communication modes can be determined: PLC Link (see page 724), program controlled communication (see page 725), and MEWTOCOL-COM Master / Slave (see page 726).
Data transfer via communication ports IsPlcLink Evaluation of "PLC Link" flag for all ports This instruction returns the value of the "PLC Link" flag. The "PLC Link" flag is TRUE if the Description communication port of the PLC has been set to PLC Link communication mode. Symbol: Example 22.3.2 Checking for program controlled mode...
Data transfer via communication ports IsProgramControlled Evaluates the "program controlled" flag This instruction returns the value of the "program controlled" flag. The "program controlled" flag is Description TRUE if the communication port of the PLC has been set to program controlled communication mode.
Data transfer via communication ports xx = slot number (hexadecimal) Getting the MCU's Communication Parameters In this section: F161_MRD_PARA (see page 728) F161_MRD_STATUS (see page 730) Getting in RUN Mode via the Input (X) Flags (see page 732)
Page 729
Data transfer via communication ports Getting the communication modes in RUN mode from MCU's COM port F161_MRD_PARA Communication parameters in the predefined DUT MCU_PARA_DUT are received from a port of a Description Multi-Communication Unit in a certain slot. settings Example This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 730
Data transfer via communication ports Storage value Baud rate 1200 2400 4800 9600 19200 38400 57600 115K 230K 3. CharacterBitsValue (0=7 bits, 1=8 bits) 4. ParityValue (0=no parity, 1=parity 0, 2=odd, 3=even) 5. StopBitLengthValue (0=1 bit, 1=2 bits) 6. RS_CS_IsValid (0=disable, 1=enable) 7.
Data transfer via communication ports Getting the statuses in RUN mode from MCU's COM port F161_MRD_STATUS Status data is read from the specified COM port of a Multi-Communication Unit. Description The DUT MCU_STATUS_DUT is predefined in the FP Library. settings Example This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 732
Data transfer via communication ports (16#0000=deinitialized, 16#0100=now initializing, 16#0200=initialization completed, 16#02FF=initialization failed.) Data types Variable Data type Function ANY16 Specification of slot number (high byte) and port number s_Port (low byte) of the MCU to which the data is transmitted. 16#xx01: COM1 on MCU in slot 16#xx 16#xx02: COM2 on MCU in slot 16#xx MCU_STATUS_DUT...
Data transfer via communication ports 22.3.3.1 Getting the communication modes and statuses via the input (X) flags from the MCU's COM ports in RUN mode 16 I/Os for X are allocated. I/O numbers are determined depending on the installation location and the I/O allocations of the other units.
Data transfer via communication ports 22.4 Data transfer in program controlled mode For all PLC types and all COM ports (including the COM ports of the Multi-Communication Unit) the following instructions are available: Tool instructions: SendCharacters (see page 737) SendCharactersAndClearString (see page 739) ReceiveData (see page 750) ReceiveCharacters (see page 752)
Page 735
Data transfer via communication ports 1. Setting the communication parameters (see) 2. Generating the data in the send buffer To generate the data in the send buffer, define a variable in the program and copy the data to the send buffer using a transfer instruction, e.g.
Page 736
Data transfer via communication ports POU Header and LD Body ST Body When the variable bSend is set to TRUE, the function F10_BKMV copies the characters of the string sSendData to the buffer awSendBuffer beginning at awSendBuffer[1]. The first two words of a string contain the string header information (maximum number of characters and the current number of characters).
Page 737
Data transfer via communication ports EXAMPLE Transmit the characters "ABCDEFGH" to an external device connected to COM port 1. For start code and end code the default settings "No-STX" and "CR" are selected. Offset ( C R ) Transmission data “Transmission done”...
Page 738
Data transfer via communication ports NOTE For details on the operation of the "reception done" flag, the "transmission done" flag, and the communication error flag, see page 757. For details on the format of the data in the send buffer and in the receive buffer, please see "Format of send and receive data"...
Data transfer via communication ports Send characters to CPU or MCU port SendCharacters This instruction first fills the send buffer applied at the VAR_INOUT variable SendBuffer with the Description relevant characters of the variable at sString according to the required data format for sending data "Sending data to external devices"...
Page 740
Data transfer via communication ports Error flags IEC address %MX0.900.7 permanently the MCU unit does not exist in the R9007 specified slot %MX0.900.8 for an instant R9008 16#8000 is specified in MEWTOCOL-COM Master/Slave mode In this example the function has been programmed in ladder diagram (LD) and structured text (ST). Example POU header All input and output variables used for programming this function have been declared in the POU...
Page 741
Data transfer via communication ports Send characters and clesr string SendCharactersAnd ClearString This instruction directly executes the send data instruction F159_MTRN (see page 741) on the Description applied string without requiring an additional send buffer. In contrast to the instruction SendCharacters (see page 737), the string variable applied at sString is cleared after execution.
Page 742
Data transfer via communication ports SendCharactersAndClearString(Port := 1, bSuppressEndCode := bSuppressEndCode, sString := sSendData);...
Data transfer via communication ports Serial data communication to CPU or MCU port F159_MTRN This instruction is used to send data when an external device (computer, measuring instrument, Description bar code reader, etc.) has been connected to the specified RS232C port. If applied to the CPU's COM port, it also clears the receive buffer (see page 746), resets the "reception done flag"...
Page 744
Data transfer via communication ports Availability of F159_MTRN (see page 1321) PLC types Data types Variable Data Function type Send buffer s_Start Bytes to send: n_Number Positive value: the end code is added in transmission. Negative value: the end code is not added in transmission. ...
Page 745
Data transfer via communication ports In this example the characters of the string sSendData are transmitted. Example POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable bSend is set to TRUE, the function F10_BKMV copies the characters of the string sSendData to the buffer awSendBuffer beginning at awSendBuffer[1].
Data transfer via communication ports When programming with structured text, enter the following: (DF(bSend)) then (* Copy all characters of the SendString to the SendBuffer from position 1 *) F10_BKMV(s1_Start Adr_Of_VarOffs(Var := sSendData, Offs := 2), s2_End := AdrLast_Of_Var(sSendData), d_Start =>...
Page 747
Data transfer via communication ports EXAMPLE Send 4 bytes of data without adding an end code: POU Header LD Body ST Body Preparing the system for the reception of further data Communication port of the CPU In order to receive the next data, reset the receive buffer. This is done automatically when sending the next data with F159_MTRN: ...
Data transfer via communication ports You can only execute F159_MTRN with the number of bytes equal to zero for the COM ports of a CPU; otherwise an operation error will occur. All input and output variables which are required for programming the function are declared in the Header and POU header.
Page 749
Data transfer via communication ports Incoming data is stored in the receive buffer. Start and end codes are not stored in the receive buffer. The storage area for the data received starts with the second word of the receive buffer (offset 1).
Page 750
Data transfer via communication ports EXAMPLE Receive a string of 8 bytes containing the characters "ABCDEFGH" via COM port 1. The characters are stored in ASCII HEX code without start and end codes. Beginning of reception Reception continued . . . V .
Page 751
Data transfer via communication ports POU Header and LD Body ST Body Data can be received when the "reception done" flag is FALSE. The "reception done" flag is evaluated by the system variable sys_bIsComPort1ReceptionDone. When the reception of the data is complete (the end code has been received), the "reception done"...
Data transfer via communication ports Receive data from CPU or MCU port ReceiveData This instruction copies the received data of the port specified by the variable at Port into the data Description applied at aBuffer. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Page 753
Data transfer via communication ports When programming with structured text, enter the following: (bReadReceiveData) then aiReceiveBuffer:=ReceiveData(1); end_if;...
Data transfer via communication ports Receive characters from CPU or MCU port ReceiveCharacters This instructions receives characters from a variable port number Port and stores the string in the Description variable sString. To add an enable input and enable output to the instruction, select [With EN/ENO] from the "Instructions"...
Data transfer via communication ports Reset the receive buffer ClearReceiveBuffer This instruction resets the receive buffer to be ready for the next data at the port number Port. Description The "reception done" flag turns to FALSE. see see page 1318 PLC types Data types Variable...
Page 756
Data transfer via communication ports (DF(bClearReceiveBuffer)) then ClearReceiveBuffer(1); end_if;...
Data transfer via communication ports Read serial data from the MCU's COM port F161_MRCV Use this instruction to copy the data received in the MCU from the external device to the specified Description receive buffer in the CPU. The receive buffer is defined by d1_Start and d2_End. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Data transfer via communication ports Data types Variable Data type Function Specification of slot number (high byte) and port number (low byte) s_Port of the MCU to which the data is transmitted. 16#xx01: COM1 on MCU in slot 16#xx ANY16 16#xx02: COM2 on MCU in slot 16#xx Starting address of the receive buffer d1_Start...
Page 759
Data transfer via communication ports "Reception done" flag When the end code is received, the "reception done" flag turns to TRUE. Reception of any further data is prohibited. F159_MTRN (see page 741) turns the "reception done" flag to FALSE. The "reception done" flag can be evaluated using the IsReceptionDone (see page 760) function. Or use the system variable sys_bIsComPort1ReceptionDone, sys_bIsComPort2ReceptionDone, or sys_bIsToolPortReceptionDone, depending on the port.
Page 760
Data transfer via communication ports "Transmission done" flag When the specified number of bytes has been sent, the "transmission done" flag turns to TRUE. New data may be sent or received. F159_MTRN (see page 741) turns the "transmission done" flag to FALSE. While F159_MTRN is executed, no data can be received.
Page 761
Data transfer via communication ports sys_bIsToolPortCommunicationError, depending on the port. FP0: Port Port Special Function name System variable name name number internal status relay R9037 IsCommunicationError sys_bIsComPort1CommunicationError TRUE (see page 764) FP0R: Port Port Special Function name System variable name name number internal...
Page 762
Data transfer via communication ports IsReceptionDone Evaluation of "reception done" flag for all ports This function returns the value of the "reception done" flag. The "reception done" flag is TRUE if Description the end code has been received at the assigned communication port of the PLC. See also: IsReceptionDoneByTimeOut (see page 761) Data types Input variable...
Page 763
Data transfer via communication ports IsReceptionDone Evaluation of "reception done" condition by time-out for all ports ByTimeout Depending on the PLC type and the input parameter Port, this function evaluates the "reception Description done" condition if no end code is expected in the data stream, e.g when transferring binary data. The output IsDone is set to TRUE if the receive buffer is not empty and no more characters are received before the time-out specified at TimeOutForCPU.
Page 764
Data transfer via communication ports IsReceptionDone1(Port := iPort, TimeOutForCPU := T#20ms, NoOfBytesReceived := g_awReceiveBuffer[0], IsDone => bIsRecDone1);...
Page 765
Data transfer via communication ports IsTransmissionDone Evaluation of "transmission done" flag for all ports This function returns the value of the "transmission done" flag. The "transmission done" flag (see Description page 757) is TRUE if the specified number of bytes has been sent from the assigned communication port of the PLC.
Page 766
Data transfer via communication ports IsCommunicationError Evaluation of communication error flag for all ports This instruction returns the value of the communication error flag. The communication error flag is Description TRUE if an error has occurred at the specified port during serial communication. Symbol: Example...
Page 767
Data transfer via communication ports 22.5 Data transfer in master/slave mode (MEWTOCOL/Modbus RTU) General Programming Information for F145 and F146 It is not possible to execute multiple F145_WRITE_DATA (see page 766) and F146_READ_DATA instructions for the same communication port simultaneously. The program should be set up so that these instructions are executed when the SEND/RECV execution enabled flag (R9044: COM1/R904A: COM2) is ON.
Page 768
Data transfer via communication ports Write Data to Slave F145_WRITE_DATA Use this instruction to write data from a master to a slave via the serial port (COM1 or COM2) using Description MEWTOCOL or Modbus RTU protocol (see communication mode (see page 712)), as defined in the system register settings (see page 1273) of port used.
Page 769
Data transfer via communication ports Error flags IEC address %MX0.900.7 permanently port 0 (global transmission) gets no R9007 response from COM1 or COM2. %MX0.900.8 permanently R9008 slave data or master data exceeds the available address range. the communication mode (see page 712) is not set to MEWTOCOL-COM Master/Slave or Modbus RTU Master/Slave.
Page 770
Data transfer via communication ports When programming with structured text, enter the following: bBool1 := sys_bPulse1s; (bWrite1 sys_bIsComPort1F145F146NotActive) then F145_WRITE_DATA(Port := SYS_COM1_PORT, SlaveAddress := 2, MasterData := bBool1, SlaveData => Slave2_g_bR15); bRead1 := true; bWrite1 := false; end_if;...
Page 771
Data transfer via communication ports Write Data to Slave with Type and Offset F145_WRITE_DATA_ TYPE_OFFS Use this instruction to write data from a master to a slave via the serial port (COM1 or COM2) using Description MEWTOCOL or Modbus RTU protocol (see communication mode (see page 712)), as defined in the system register settings (see page 1273) of port used.
Page 772
Data transfer via communication ports s1_ControlData Lower word Higher word 0 fixed 0 fixed COM port Unit No. Bit unit Bit No. of Slave Bit No. of Master transmission (16#1 or 16#2) (16#00 to 16#63) (16#0 to 16#F) (16#0 to 16#F) (0 to 99) To generate function code 05, bit unit transmission (16#8) must be specified.
Page 773
Data transfer via communication ports In this example the function has been programmed in ladder diagram (LD) and structured text (ST). Example POU header All input and output variables used for programming this function have been declared in the POU header.
Page 774
Data transfer via communication ports Read Data from Slave F146_READ_DATA Use this instruction to request data from a slave via the serial port (COM1 or COM2) using Description MEWTOCOL or Modbus RTU protocol (see communication mode (see page 712)), as defined in the system register settings (see page 1273) of port used.
Page 775
Data transfer via communication ports In this example the function has been programmed in ladder diagram (LD) and structured text (ST). Example In the global variable list you define variables that can be accessed by all POUs in the project. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 776
Data transfer via communication ports Read Data from Slave with Type and Offset F146_READ_DATA_ TYPE_OFFS Use this instruction to request data from a slave via the serial port (COM1 or COM2) using Description MEWTOCOL or Modbus RTU protocol (see communication mode (see page 712)), as defined in the system register settings (see page 1273) of port used.
Page 777
Data transfer via communication ports s1_ControlData Lower word Higher word 0 fixed Bit No. of Master Unit No. Bit unit Bit No. of Slave COM port (16#0 to 16#F) (16#00 to 16#63) transmission (16#0 to 16#F) (16#1 or 16#2) (0 to 99) To generate function code 01, bit unit transmission (16#8) must be specified.
Page 778
Data transfer via communication ports In this example the function has been programmed in ladder diagram (LD) and structured text (ST). Example POU header All input and output variables used for programming this function have been declared in the POU header.
Page 779
SYS_MODBUS_15_F 0–9998 multiple of 16 000001–009999 ORCE_COILS SYS_MODBUS_16_P 0–32764 400001–432765 RESET_REGISTERS Modbus specifications for Panasonic PLCs: Reference numbers Address area of Panasonic PLCs From 000001 From Y0 From 002049 From R0 From 100001 From X0 From 400001 From DT0...
Page 780
From 302001 From LD0 For reference number and address area ranges supported by the Panasonic PLCs, please refer to the User's Manual of the PLC. If the reference number is outside the supported range, an error is returned. PLC types...
Page 781
From WL0 From 302001 From LD0 For reference number and address area ranges supported by the Panasonic PLCs, please refer to the User's Manual of the PLC. If the reference number is outside the supported range, an error is returned.
Page 782
Data transfer via communication ports Availability of F145F146_MODBUS_MASTER (see page 1321) PLC types: Data types Variable Data Function type Specifies the slave's COM port (1 or 2) via system variable: Port SYS_COM1_PORT, SYS_COM2_PORT Address of the remote station (0–255). SlaveAddress SYS_MODBUS_01_READ_COIL FunctionCode* SYS_MODBUS_02_READ_INPUT...
Page 783
Data transfer via communication ports for all ports via a general function Is145F146NotActive This instruction returns the value of the "F145F146 Not Active" flag of the PLC's serial Description communication interface. Example This flag varies depending on the PLC type: Port Port name Flag...
Page 784
Data transfer via communication ports Returns the value of the "F145F146 Error" flag IsF145F146Error This instruction returns the value of the "F145F146 Error" flag of the PLC's serial communication Description interface. Example This flag varies depending on the PLC type: Port Port name Flag...
Page 787
Data transfer via network 23.1 Data transfer via MEWNET link In this section: - F145_SEND (see page 787) - F146_RECV (see page 789)
Page 788
Data transfer via network Data send (MEWNET link) F145_SEND Sends data to another station through link modules in the network. Description This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger. Select [Insert P instruction] from the "Instructions"...
Page 789
Data transfer via network Data types Variable Data type Function DWORD 32-bit area for storing control data starting 16-bit area for storing source data (data area at the source station) type of destination operands for storing data in the destination station. Be sure to select the area by setting the address 0 (e.g.
Page 790
Data transfer via network Data receive (MEWNET link) F146_RECV Receives data from another station through link units in the network. Description This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger. Select [Insert P instruction] from the "Instructions"...
Page 791
Data transfer via network Data types Variable Data type Function DWORD 32-bit area for storing control data type of source operands for storing data in the destination station. Be sure to select the area by setting the address 0 (e.g. DT0 or WR0, ...) (source data area at another station) starting 16-bit area address for the source operand specified ANY16 in s2 (source data area at another station)
Page 792
Data transfer via network 23.2 Data transfer via shared memory of a MEWNET-F-Slave station In this section: - F152_RMRD (see page 792) - F153_RMWT (see page 795)
Page 793
Data transfer via network Data read from the slave station F152_RMRD Reads data from the specified intelligent unit of the MEWNET-F Slave station. Description s1 stores the control data for the configuration of the Master and Slave units in the network. n words are read beginning from the shared memory address number in the intelligent unit specified by s2.
Page 794
Data transfer via network Operands Relay Register Constant dec. or hex. s2, n Error flags IEC address %MX0.900.7 permanently the control data s1 exceeds the limit of R9007 specified range %MX0.900.8 for an instant R9008 no MEWNET-F master unit is found ...
Page 795
Data transfer via network In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. Five words of data stored at address 0 to 4 in the shared memory of the intelligent unit of the slave station are read and the read data stored in ARRAY WordsRead of the master station "CPU"...
Page 796
Data transfer via network Data write into the slave station F153_RMWT Writes data into the specified intelligent unit of the MEWNET-F slave station. Description s1 stores the control data for the configuration of the Master and Slave units in the network. n words, beginning at the address in the CPU specified by s2, are written to the intelligent unit of the Slave unit beginning at the shared memory address number specified by d.
Page 797
Data transfer via network Operands Relay Register Constant dec. or hex. n, d Error flags IEC address %MX0.900.7 permanently the control data s1 exceeds the limit of R9007 specified range %MX0.900.8 for an instant R9008 no MEWNET-F master unit is found ...
Page 799
Data transfer via network 23.3 Data exchange with flexible network In this section: - FNS_InitConfigDataTable (see page 798) - FNS_InitConfigNameTable (see page 798)
Page 800
Data transfer via network Function FNS_InitConfigDataTable Description The FNS_InitConfigDataTable function creates a ConfigDataTable from the variable ProcessDataTable, which can be a single-element data type or a mulit-element data type. This ConfigDataTable is necessary to configure the FP-FNS block using the function block FNS_ProfibusDP, FNS_DeviceNet, FNS_CANopen and FNS_ProfinetIO.
Page 801
Data transfer via network The following syntax table shows how to declare 16-bit, 32-bit and 64-bit variables and arrays ProcessData thereof when using them as ProcessDataTable input for the FNS_InitConfigDataTable function. Table Input Data type Size of Input Comment 16-bit INT, WORD 32-bit DINT, WORD, REAL, TIME...
Page 802
Data transfer via network When programming with structured text, enter the following: sys_bIsFirstScan then ConfigData:=FNS_InitConfigDataTable(ProcessData); end_if;...
Page 803
Data transfer via network Function FNS_InitConfigNameTable Description This function creates a ConfigNameTable from the variable ProcessDataTable, which can be a single-element data type or a mulit-element data type. Make sure that the size of the variable ConfigNameTable corresponds to the structure of the ProcessDataTable, e.g. if the ProcessDataTable consists of three entries, then the ConfigNameTable variable should be an "Array[0..2] of WORD"...
Page 804
Data transfer via network The following syntax table shows how to declare 16-bit, 32-bit and 64-bit variables and arrays ProcessData thereof when using them as ProcessDataTable input. Table Input Data type Size of Input Comment 16-bit INT, WORD 32-bit DINT, WORD, REAL, TIME 64-bit 2-dimensional array;...
Page 806
Chapter 24 Data transfer within the PLC...
Page 807
Data transfer within the PLC 16-bit data move F0_MV The 16-bit data or 16-bit equivalent constant specified by s is copied to the 16-bit area specified by Description d, if the trigger EN is in the ON-state. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 808
Data transfer within the PLC POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: start THEN F0_MV(input_value, output_value);...
Page 809
Data transfer within the PLC 32-bit data move F1_DMV The 32-bit data or 32-bit equivalent constant specified by s is copied to the 32-bit area specified by Description d, if the trigger EN is in the ON-state. Instead of using this FP instruction, we recommend using the related IEC instruction MOVE (see page 59).
Page 810
Data transfer within the PLC In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 811
Data transfer within the PLC 16-bit data inversion and move F2_MVN The 16-bit data or 16-bit equivalent constant specified by s is inverted and transferred to the 16-bit Description area specified by d if the trigger EN is in the ON-state. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 812
Data transfer within the PLC When programming with structured text, enter the following: start THEN F2_MVN(input_value, output_value); END_IF;...
Page 813
Data transfer within the PLC 32-bit data inversion and move F3_DMVN The 32-bit data or 32-bit equivalent constant specified by s is inverted and transferred to the 32-bit Description area specified by d if the trigger EN is in the ON-state. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 814
Data transfer within the PLC POU header All input and output variables used for programming this function have been declared in the POU header. Body When the variable start is set to TRUE, the function is carried out. When programming with structured text, enter the following: start THEN F3_DMVN(input_value, output_value);...
Page 815
Data transfer within the PLC Reading of the Numbers of the First WX and the First WY of the F4_GETS Specified Slot The head word No. of the specified slot is read. Description This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 816
Data transfer within the PLC Error flags IEC address %MX0.900.7 permanently the specified address using the R9007 index modifier exceeds a limit. %MX0.900.8 for an instant a number other than 0 to 31 is R9008 specified for the slot number.
Page 817
Data transfer within the PLC Two 16-bit data move F7_MV2 The two 16-bit data or two 16-bit equivalent constants specified by s1 and s2 are copied to the Description 32-bit area specified by d when the trigger turns ON. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 818
Data transfer within the PLC When programming with structured text, enter the following: start THEN F7_MV2(input_value1, input_value2, output_value); END_IF;...
Page 819
Data transfer within the PLC Two 32-bit data move F8_DMV2 The function copies two 32-bit data areas specified at inputs s1 and s2 to a 32-bit ARRAY with two Description elements at output d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 820
Data transfer within the PLC When programming with structured text, enter the following: start THEN F8_DMV2(input_value_1, input_value_2, output_value); END_IF;...
Page 821
Data transfer within the PLC Block move F10_BKMV The data block specified by the 16-bit starting area specified by s1_Start and the 16-bit ending Description area specified by s2_End are copied to the block starting from the 16-bit area specified by d_Start if the trigger EN is in the ON-state.
Page 822
Data transfer within the PLC Operands Relay Register Constant s1_Start, s2_End d_Start In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 823
Data transfer within the PLC Block move by number F10_BKMV_NUMBER The data block specified by the 16-bit starting area specified by s1_Start and the number of Description WORDs specified by s2_Number are copied to the block starting from the 16-bit area specified by d_Start if the trigger EN is in the ON-state.
Page 824
Data transfer within the PLC Block move to an offset from source F10_BKMV_OFFSET Description This instruction is a modification of the F10_BKMV (see page 819) generated by the compiler. The data block specified by the 16-bit starting area specified by s1_Start and 16-bit ending area specified by s2_End are copied to the block starting from the 16-bit area specified by the offset d_Offset from s1_Start if the trigger EN is in the ON-state.
Page 825
Data transfer within the PLC Block move by number to an offset from source F10_BKMV_NUMBER _OFFSET Description This instruction is a modification of the F10_BKMV (see page 819) generated by the compiler. The data block specified by the 16-bit starting area specified by s1_Start and the number of WORDs specified by s2_Number are copied to the block starting from the 16-bit area specified by the offset d_Offset from s1_Start if the trigger EN is in the ON-state.
Page 826
Data transfer within the PLC Block copy F11_COPY The 16-bit equivalent constant or 16-bit area specified by s is copied to all 16-bit areas of the block Description specified by d1_Start and d2_End if the trigger EN is in the ON-state. The operands d1_Start and d2_End should be: ...
Page 827
Data transfer within the PLC In this example the function has been programmed in ladder diagram (LD) and structured text Example (ST).The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 828
Data transfer within the PLC EEPROM read from memory F12_EPRD Using this instruction data will be copied from EEPROM/ Flash-ROM to the destination area (DT). Description The copy function is carried out with blocks only. Thus you can not copy single words. The block size and the number of blocks is shown in the table "PLC specific information".
Page 829
Data transfer within the PLC PLC specific PLC type FP0 2,7k FP0 5k C32 FP0 10k FP-Sigma, information C10/C14/C16 T32CP FP-X, FP0R and FP-e EEPROM EEPROM EEPROM Flash-ROM 64 words 64 words 64 words 2048 words Block size (64x16bit) (64x16bit) (64x16bit) (1 block) 0 to 9...
Page 830
Data transfer within the PLC IC card extended memory read F12_ICRD The data for the number of words specified by s2_Number are read from the address in the IC Description card extended memory area specified by s1_Start and written to the area specified by d_Start. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 831
Data transfer within the PLC When programming with structured text, enter the following: DF(R901C) THEN Var_Real Var_Real + 22.33; END_IF; (* Write a REAL value to the IC Card *) DF(Write_To_ICCard) THEN F13_ICWT( s1_Start:= Adr_Of_Var( Var_Real s2_Number:= INT_TO_DINT( Size_Of_Var( Var_Real ) ), d_Start:= ICCardStartAdr END_IF;...
Page 832
Data transfer within the PLC IC card extended memory write F13_ICWT The data for the number of words specified by s2_Number are read from the address specified by Description s1_Start and written to the extended memory area in the IC card specified by d_Start. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 833
Data transfer within the PLC When programming with structured text, enter the following: DF(R901C) THEN Var_Real Var_Real + 22.33; END_IF; (* Write a REAL value to the IC Card *) DF(Write_To_ICCard) THEN F13_ICWT( s1_Start:= Adr_Of_Var( Var_Real s2_Number:= INT_TO_DINT( Size_Of_Var( Var_Real ) ), d_Start:= ICCardStartAdr END_IF;...
Page 834
Data transfer within the PLC Program Read from IC card F14_PGRD When the execution criterion of F/P14_PGRD is turned ON, the execution proceeds until the END. Description The program subsequently switches to the program specified by s. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 835
Data transfer within the PLC EEPROM write to memory P13_EPWT Using this instruction data will be copied from the data area (DT) to the EEPROM/ Flash-ROM. Description The EEPROM memory is not the same as the hold area. The hold area stores data in real time. Whenever the power shuts down, the hold data is stored in the EEPROM memory.
Page 836
Data transfer within the PLC PLC specific PLC type FP0 2,7k FP0 5k C32 FP0 10k FP-Sigma, information C10/C14/C16 T32CP FP-X, FP0R and FP-e EEPROM EEPROM EEPROM Flash-ROM 64 words 64 words 64 words 2048 words Block size (64x16bit) (64x16bit) (64x16bit) (1 block) 0 to 9...
Page 837
Data transfer within the PLC 16-bit data exchange F15_XCH The contents in the 16-bit areas specified by d1 and d2 are exchanged if the trigger EN is in the Description ON-state. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 838
Data transfer within the PLC 32-bit data exchange F16_DXCH Two 32-bit data specified by d1 and d2 are exchanged if the trigger EN is in the ON-state. Description 31 . . 28 27 . . 24 23 . . 20 19 . .16 15 .
Page 839
Data transfer within the PLC When programming with structured text, enter the following: start THEN F16_DXCH(value_1, value_2); END_IF;...
Page 840
Data transfer within the PLC Higher/lower byte in 16-bit data exchange F17_SWAP The higher byte (higher 8-bits) and lower bytes (lower 8-bits) of a 16-bit area specified by d are Description exchanged if the trigger EN is in the ON-state. 1 byte means 8 bit. 12 10 DT770 lower byte (8-bit)
Page 841
Data transfer within the PLC When programming with structured text, enter the following: start THEN F17_SWAP(swap_value); END_IF;...
Page 842
Data transfer within the PLC 16-bit blocked data exchange F18_BXCH The function exchanges one 16-bit data block for another. The beginning of the first data block is Description specified at output d1_Start and its end at output d2_End. Output d3_Start specifies the beginning of the second data block.
Page 843
Data transfer within the PLC In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 844
Data transfer within the PLC Partial I/O update F143_IORF Updates the inputs or outputs specified by the value of d1_Start (starting word address) and the Description value of d2_End (ending word address) immediately after the trigger EN is in the ON-state even in the program execution stage.
Page 845
Data transfer within the PLC Data types Variable Data type Function starting word address d1_Start ANY16 ending word address d2_End The same type of operand should be specified for d1_Start and d2_End. Operands Relay Register Constant dec. or hex. d1_Start dec.
Page 846
Data transfer within the PLC Parallel printout F147_PR Outputs the ASCII codes for 12 characters stored in the 6-word area specified by s via the word Description external output relay specified by d if the trigger EN is in the ON-state. If a printer is connected to the output specified by d, a character corresponding to the output ASCII code is printed.
Page 847
Data transfer within the PLC Connection example Printer Transistor output type (centronics interface) (output: 9 points or more) DATA1 DATA2 DATA3 DATA4 DATA5 DATA6 DATA7 DATA8 STROBE In this example the function is programmed in ladder diagram (LD). The same POU header is used Example for all programming languages.
Page 848
Data transfer within the PLC Body When programming with structured text, enter the following: DF(start) OR PrintOutFlag THEN F147_PR( Adr_Of_VarOffs( PrintOutString, 2), Printer); END_IF;...
Page 849
Data transfer within the PLC Data read from intelligent units F150_READ Reads data from the shared memory in an intelligent module. Description This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger. Select [Insert P instruction] from the "Instructions"...
Page 850
Data transfer within the PLC Data types Variable Data type Function Specifies the bank/slot number in the shared memory of the intelligent module ANY16 Specifies the starting address in the shared memory of the intelligent module (source data address) Specifies the number of words to be read ANY16 Starting address in the CPU for storing data read (destination address)
Page 851
Data transfer within the PLC Body Reads 4 words of data stored in the addresses starting from 19, specified in AddrDataToRead, of the intelligent unit's shared memory (located in slot 3). Then it stores them in the array DestAddrCPU, when Start turns on. (Slot No.) Intelligent unit DestAddCPU[0]...
Page 852
Data transfer within the PLC Write into memory of intelligent units F151_WRT Writes data into the shared memory of an intelligent unit. Description This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger. Select [Insert P instruction] from the "Instructions"...
Page 853
Data transfer within the PLC Data types Variable Data type Function Specifies the bank/slot number in the shared memory of the intelligent module ANY16 Starting address for data in the shared memory of the CPU Specifies the number of words to be written to the shared memory ANY16 Specifies the starting address in the intelligent unit for storing...
Page 854
Data transfer within the PLC When programming with structured text, enter the following: start THEN F151_WRT( s1_BankSlot:= SlotNo, s2_Start:= CPUDataToWrt[0], n_Number:= NoWordsToWrite, d_Start:= DestinationAddr); END_IF;...
Page 855
Data transfer within the PLC Three 16-bit data move F190_MV3 Description The function copies three 16-bit data values at inputs s1, s2 and s3 to an ARRAY with three elements that is returned at output d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 856
Data transfer within the PLC When programming with structured text, enter the following: start THEN F190_MV3(word_1, word_2, word_3, data_field); END_IF;...
Page 857
Data transfer within the PLC Three 32-bit data move F191_DMV3 The function copies three 32-bit data values at inputs s1, s2 and s3 to an ARRAY with three Description elements that is returned at output d. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 858
Data transfer within the PLC When programming with structured text, enter the following: start THEN F191_DMV3(word_1, word_2, word_3, data_field); END_IF;...
Page 859
Data transfer within the PLC Floating Point Data Move F309_FMV The floating point data (32 bits) specified by s is copied to the 32-bit area specified by d when the Description trigger turns on. The range of real number data which can be set is as follows: ...
Page 860
Data transfer within the PLC 24.1 Data transfer to and from special data registers FPWIN Pro offers three possibilities to read from or write to special relays/special data registers. 1. Via system variables (recommended from version 5.1 onwards) For each special data register and relay a system variable exists according to the following syntax: sys_ _system variable BOOL...
Page 861
Data transfer within the PLC 24.2 Transferring data to and from file register banks 1 or 2 In this section: ReadDataFromFileRegisterBank (see page 861) WriteDataToFileRegisterBank (see page 863)
Page 862
Data transfer within the PLC Read Data from File Register Bank 1 or 2 ReadDataFromFile RegisterBank This instruction reads the number of words specified by DataNumberOfWords from File Register Description Bank 1 or 2, as specified by BankNumber beginning with BankOffset, and writes it to DataStartAddress.
Page 863
Data transfer within the PLC When programming with structured text, enter the following: (DF(bGetData)) then ReadDataFromFileRegisterBank(BankNumber := 2, BankOffset := 1000, DataNumberOfWords := Size_Of_Var(awProcessDataToGet), DataStartAddress => Adr_Of_Var(awProcessDataToGet)); end_if;...
Page 864
Data transfer within the PLC Write Data to File Register Bank 1 or 2 WriteDataToFile RegisterBank This instruction reads the number of words specified by DataNumberOfWords from Description DataStartAddress and writes it to the File Register Bank 1 or 2 as specified by BankNumber beginning with BankOffset.
Page 865
Data transfer within the PLC Body If bStoreData changes from FALSE to TRUE, the entire data unit variable awProcessDataToStore (a DUT containing 11 elements) is filled with the data from File Register Bank 2 BankOffset 1000. When programming with structured text, enter the following: (DF(bStoreData)) then WriteDataToFileRegisterBank(BankNumber...
Page 867
Date and time instructions h:min:s -> s conversion F138_TIMEBCD_TO _SECBCD Converts the hours, minutes, and seconds data stored in the 32-bit area specified by s_TIMEBCD Description to seconds data if the trigger EN is in the ON-state. The converted seconds data is stored in the 32-bit area specified by d_SECBCD. All hours, minutes, and seconds data to convert and the converted seconds data is BCD.
Page 868
Date and time instructions s -> h:min:s conversion F139_SECBCD_TO _TIMEBCD Converts the second data stored in the 32-bit area specified by s to hours, minutes, and seconds Description data if the trigger EN is in the ON-state. The converted hours, minutes, and seconds data is stored in the 32-bit area specified by d. The seconds prior to conversion and the hours, minutes, and seconds after conversion are all BCD data.
Page 869
Date and time instructions Time addition F157_ADD_DTBCD _TIMEBCD The date/clock data (3 words) specified by s1_DTBCD and the time data (2 words) specified by Description s2_TIMEBCD are added together if the trigger EN is in the ON-state. The result is stored in the area (3 words, same format as s1_DTBCD) specified by d_DTBCD.
Page 870
Date and time instructions Data types Variable Data type Function DTBCD augend, time and date, values in BCD format s1_DTBCD DWORD addend, 32-bit area for storing time data in BCD format s2_TIMEBCD DTBCD sum in BCD format d_DTBCD Operands Relay Register Const.
Page 871
Date and time instructions Time subtraction F158_SUB_DTBCD _TIMEBCD Subtracts time data (2 words) specified by s2_TIMEBCD from the date/clock data (3 words) Description specified by s1_DTBCD if the trigger EN is in the ON-state. The result is stored in the area (3 words, same format than s1_DTBCD) specified by d_DTBCD.
Page 872
Date and time instructions Operands Relay Register Const. s1_DTBCD s2_TIMEBCD dec. or d_DTBCD hex.
Page 873
Date and time instructions Time Data Conversion into Seconds F230_DTBCD_TO_ This function converts time data (date and time) into the number of seconds. It calculates the time Description span between the specified time date and 01/01/2001 at 00:00 hours. The time data is specified in the DUT "DTBCD".
Page 874
Date and time instructions Conversion of Seconds into Time Data F231_SEC_TO_DTBCD This function converts a specified number of seconds into date and time. The time data is Description calculated from 01/01/2001 at 00:00 hours. For a conversion from time data into seconds, please refer to F230_DTBCD_TO_SEC (see page 871).
Page 875
Date and time instructions Read the Real-Time Clock GET_RTC_DTBCD Use this PLC independent instruction to read the real-time clock data from the PLC. When the Description instruction is carried out, the values from the special data registers DT90054 to DT90056 (DT9054 to DT9056) are transferred to the data unit type DTBCD.
Page 876
Date and time instructions Set the Real-Time Clock SET_RTC_DTBCD Use this PLC independent instruction to write date and time data in BCD format (DTBCD) to the Description real-time clock. When the variable SetNewDtBcd is set to TRUE, the values from the data unit type DTBCD are transferred to the special data registers DT90054 to DT90056 (DT9054 to DT9056) and the value 16#8000 is written to the special data register DT90058 (DT9058) to set the real-time clock of the PLC.
Page 879
Selection Instructions 16-bit data upper and lower limit control F285_LIMT The function compares the input value at input s3_In with a lower and an upper limit. The lower Description limit is specified at input s1_Min, and the upper limit at input s2_Max. The result of the function is returned at output d as follows.
Page 880
Selection Instructions Operands Relay Register Constant dec. or hex. s1_Min, s2_Max, s3_In Error flags IEC address %MX0.900.7 permanently R9007 the value at s1_Min > s2_Max %MX0.900.8 for an instant R9008 %MX0.900.11 permanently the result of processing is between the R900B upper and lower limits.
Page 881
Selection Instructions 32-bit data upper and lower limit control F286_DLIMT The function compares the input value at input s3_In with a lower and an upper limit. The lower Description limit is specified at input s1_Min, and the upper limit at input s2_Max. The result of the function is returned at output d as follows: If the input value at s3_In <...
Page 882
Selection Instructions Operands Relay Register Constant DWX DWY DWR dec. or hex. s1_Min, s2_Max, s3_In DWY DWR Error flags IEC address %MX0.900.7 permanently R9007 the value at s1_Min > s2_Max %MX0.900.8 for an instant R9008 %MX0.900.11 permanently the result of processing is between the R900B upper and lower limits.
Page 885
Edge detection instructions Rising edge differential DF is a rising edge differential instruction. The DF instruction executes and turns ON output o for a Description singular scan duration if the trigger i changes from an OFF to an ON state. Availability of DF (see page 1319) PLC types Be careful when programming with commands that effect the order in which a...
Page 886
Edge detection instructions Falling edge differential The DFN instruction executes and turns ON output o for a single scan duration if the trigger i Description changes from an ON to an OFF state. Availability of DFN (see page 1319) PLC types Be careful when programming with commands that effect the order in which a program is carried out, e.g.
Page 887
Edge detection instructions Rising edge differential (initial execution type) When a rising edge of the input signal (input i) is detected, this function changes the status of the Description output signal (output o) to TRUE for the duration of the scan. Input signal Ouput signal One scan...
Page 888
Edge detection instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. POU header In the POU header, all input and output variables are declared that are used for programming this function.
Page 889
Edge detection instructions Alternative out The function inverts the output condition (output o) each time the rising edge of the input signal Description (input i) is detected. When the mode is changed from PROG to RUN or the power is turned on in RUN mode while the input signal is TRUE, a rising edge will not be detected for the first scan.
Page 891
Tool instructions For users programming for different PLC types of the FP series or users who are tired of setting control code bits and looking up available channel numbers, the tool instructions offer new and comfortable features. These include information functions for evaluating status flags and settings, control functions for configuring high-speed counters and pulse outputs, PLC-independent functions and DUTs, as well as variable channel numbers.
Page 892
High-speed counter instructions 28.2 Writing the high-speed counter control code The special data register where the high-speed counter and pulse output control code are stored can be accessed with the system variable sys_wHscOrPulseControlCode. (The system variable sys_wHscOrPulseControlCode corresponds to special data register DT90052.) Operations performed by the high-speed counter control code ...
Page 893
High-speed counter instructions Description for FP0, FP-e: Bits 0–15 of the control code are allocated in groups of four, each group containing the settings for one channel. The bit setting in each group is represented by a hex number (e.g. 0000 0000 1001 0000 = 16#90).
Page 894
High-speed counter instructions Body The reset is performed in step 1, and 0 is entered just after that in step 2 to start counting. A reset alone does not start counting. Software reset for channel 1 POU header All input and output variables used for programming this function have been declared in the POU header.
Page 895
High-speed counter instructions 28.3 High-speed counter: writing and reading the elapsed value The elapsed value is stored as a double word in the special data registers. Access the special data registers using the system variable sys_diHscChannelxElapsedValue (where x=channel number). System variables for memory areas used: ...
Page 896
High-speed counter instructions Cam control F165_HighSpeedCounter_Cam This instruction performs cam control according to the parameters in the specified DUT with a Description maximum of 31 target values for the high-speed counter. An interrupt program can be executed whenever the elapsed value matches one of the target values. Create your own DUT using the following DUT as a sample: F165_HighSpeedCounter_Cam_8_Values_DUT The following parameters can be specified in the DUT:...
Page 897
High-speed counter instructions A maximum of 31 target values can be specified. The target values must be arranged in ascending order. No value may be used twice. When the instruction starts, all output relays are FALSE, except for output relay 0, which turns to TRUE, provided that the elapsed value is smaller than target value 1.
Page 898
High-speed counter instructions Incremental and decremental counting with maximum target value control: 14000 10000 8000 4000 2000 Elapsed value of high-speed counter 14000 Maximum target value Execution condition 10000 Target value 4 High-speed counter control flag 8000 Target value 3 Output relay 0-4 4000 Target value 2...
Page 899
High-speed counter instructions Interrupt operation The interrupt program will be executed when the elapsed value matches the target value. Any interrupt that has been entered into the Tasks list is automatically enabled. A special interrupt program number is assigned to each channel number. Channel Interrupt program General programming information...
Page 900
High-speed counter instructions Operands Relay Register Constant iHscChannel* Error flags IEC address %MX0.900.7 permanently channel number or values of the data table are outside the R9007 permissible range %MX0.900.8 for an instant R9008 high-speed counter has not been set in the system registers ...
Page 901
High-speed counter instructions When programming with structured text, enter the following: (sys_bIsFirstScan) THEN sys_diHscChannel0ElapsedValue:=0; END_IF; DF(bStartCam) THEN F165_HighSpeedCounter_Cam(iHscChannel := 0, s_dutDataTable := dut_F165_CAM_Example1, dutBitOutputs => WR0_bits_F165_CAM_Examples); END_IF; Example 2: Without maximum target value control In this example the function has been programmed in ladder diagram (LD) and structured text (ST). Example 2 The DUT F165_HighSpeedCounter_Cam_8_Values_DUT is predefined in the FP Library and can be used as a sample.
Page 902
High-speed counter instructions Target value match ON (high-speed counter) F166_HighSpeed Counter_Set If the elapsed value of the high-speed counter matches the target value, an interrupt process Description immediately turns the specified output to TRUE. See also: Hsc_TargetValueMatch_Set (see page 1168) Characteristics of target value match ON control 10000 10000...
Page 904
High-speed counter instructions Data types Variable Data type Function DINT High-speed counter channel: n_diHscChannel : 0–3 FP-X R: 0–11 FP-X T: 0–7 FP0: 0–3 FP-e: 0–3 FP0R: 0–5 DINT specify a 32-bit data value for the target value within the following range: s_diTargetValue FP0, FP-e: -838808–+8388607 ...
Page 905
High-speed counter instructions When programming with structured text, enter the following: DF(start) THEN F166_HighSpeedCounter_Set(n_diHscChannel := 0, s_diTargetValue := 10, => out_0); END_IF; Assign a number to the input variable (e.g. Monitor Monitor Header, click the variable, enter the value, press <Enter>), or replace the input variables with numbers.
Page 906
High-speed counter instructions Target value match OFF (high-speed counter) F167_HighSpeed Counter_Reset If the elapsed value of the high-speed counter matches the target value, an interrupt process Description immediately turns the specified output to FALSE. See also: Hsc_TargetValueMatch_Reset (see page 1166) Characteristics of target value match OFF control -200 -200...
Page 908
High-speed counter instructions Data types Variable Data type Function DINT High-speed counter channel: n_diHscChannel : 0–3 FP-X R: 0–11 FP-X T: 0–7 FP0: 0–3 FP-e: 0–3 FP0R: 0–5 DINT specify a 32-bit data value for the target value within the following range: s_diTargetValue FP0, FP-e: -838808–+8388607 ...
Page 909
High-speed counter instructions When programming with structured text, enter the following: DF(start) THEN F167_HighSpeedCounter_Reset(n_diHscChannel := 0, s_diTargetValue := -200, => out_0); END_IF; Assign a number to the input variable (e.g. Monitor Monitor Header, click the variable, enter the value, press <Enter>), or replace the input variables with numbers.
Page 910
High-speed counter instructions Input pulse measurement F178_HighSpeed Counter_Measure This instruction measures the number of input pulses in a specified counting period and the pulse Description period. Characteristics of input pulse measurement For input pulse measurement, the channel number, the counting period (1ms–5s) and the number of counting periods (1–5) must be specified.
Page 911
High-speed counter instructions PLC types Availability of F178_HighSpeedCounter_Measure (see page 1322) Data types Variable Data Function type High-speed counter channel: 0–5 s1_iHscChannel Counting period [ms]: s2_NumberOfPulses_iPeriodTime_m 1–5000 (1ms–5s). Number of counting periods: 1–5 s1_NumberOfPulses_iNumberOfPeri Unit of pulse period measurement s1_PulsePeriod_iMeasurementMetho 0: Pulse period is not measured ...
Page 912
High-speed counter instructions In this example the function has been programmed in ladder diagram (LD) and structured text (ST). Example The same POU header is used for all programming languages. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 915
Timer instructions Timer for 1ms intervals (0 to 32.767s) TM_1ms_FB This timer for 0.001s units works as an ON-delay timer. If the start contact of the function block is Description in the ON state, the preset time SV (set value) is started. When this time has elapsed, the timer contact T turns ON.
Page 916
Timer instructions Data types Variable Data type Function BOOL start contact start INT, WORD set value BOOL timer contact INT, WORD elapsed value Operands Relay Register Constant start SV, EV In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 917
Timer instructions When programming with structured text, enter the following: Alarm_Control( start:= Start_Contact SV:= 1000, T=> Alarm_Relay_2 EV=> Alarm_Control.EV (*The ON-delay time is 1000ms*) Alarm_Relay_1:= Alarm_Control.EV <= & Alarm_Control.EV <> 0; (*Alarm_Relay_1 is set to TRUE after 500ms*) (*Alarm_Relay_1 is set to TRUE after 500ms*)
Page 918
Timer instructions Timer for 10ms intervals (0 to 327.67s) TM_10ms_FB This timer for 0.01s units works as an ON-delay timer. If the start contact of the function block is in Description the ON state, the preset time SV (set value) is started. When this time has elapsed, the timer contact T turns ON.
Page 919
Timer instructions Data types Variable Data type Function BOOL start contact start INT, WORD set value BOOL timer contact INT, WORD elapsed value Operands Relay Register Constant start SV, EV In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 920
Timer instructions When programming with structured text, enter the following: Alarm_Control( start:= Start_Contact SV:= 1000, T=> Alarm_Relay_2 EV=> Alarm_Control.EV (*The ON-delay time is 10s*) Alarm_Relay_1:= Alarm_Control.EV <= & Alarm_Control.EV <> 0; (*Alarm_Relay_1 is set to TRUE after 5s*) (*Alarm_Relay_1 is set to TRUE after 5s*)
Page 921
Timer instructions Timer for 100ms intervals (0 to 3276.7s) TM_100ms_FB This timer for 0.1s units works as an ON-delay timer. If the start contact of the function block is in Description the ON state, the preset time SV (set value) is started. When this time has elapsed, the timer contact T turns ON.
Page 922
Timer instructions Data types Variable Data type Function BOOL start contact start INT, WORD set value BOOL timer contact INT, WORD elapsed value Operands Relay Register Constant start SV, EV In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 923
Timer instructions When programming with structured text, enter the following: Alarm_Control( start:= Start_Contact SV:= 100, T=> Alarm_Relay_2 EV=> Alarm_Control.EV (*The ON-delay time is 10s*) Alarm_Relay_1:= Alarm_Control.EV <= & Alarm_Control.EV <> (*Alarm_Relay_1 is set to TRUE after 5s*) (*Alarm_Relay_1 is set to TRUE after 5s*)
Page 924
Timer instructions Timer for 1s intervals (0 to 32767s) TM_1s_FB This timer for 1s units works as an ON-delay timer. If the start contact of the function block is in the Description ON state, the preset time SV (set value) is started. When this time has elapsed, the timer contact T turns ON.
Page 925
Timer instructions Data types Variable Data type Function BOOL start contact start INT, WORD set value BOOL timer contact INT, WORD elapsed value Operands Relay Register Constant start SV, EV In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 926
Timer instructions When programming with structured text, enter the following: Alarm_Control( start:= Start_Contact SV:= 10, T=> Alarm_Relay_2 EV=> Alarm_Control.EV (*The ON-delay time is 10s*) Alarm_Relay_1:= Alarm_Control.EV <= 5 & Alarm_Control.EV <> 0; (*Alarm_Relay_1 is set to TRUE after 5s*) (*Alarm_Relay_1 is set to TRUE after 5s*)
Page 927
Timer instructions Timer for 1ms intervals (0 to 32.767s) TM_1ms The TM_1ms instruction sets the ON-delay timer for 0.001s units (0 to 32.767s). Description Instead of using this FP instruction, we recommend using the related IEC instruction tmTM_1ms_FB (see page 913). Please refer also to Advantages of the IEC instructions in the online help.
Page 928
Timer instructions Operands Relay Register Constant start dec. or hex. Num* dec. or hex. It is not possible to use this function in a function block POU. For correct results, timer functions and timer function blocks must be executed exactly one time in each scan. Thus it is not allowed to use timer function or timer function blocks in interrupt programs or in loops.
Page 929
Timer instructions Timer for 10ms intervals (0 to 327.67s) TM_10ms The TM_10ms instruction sets the ON-delay timer for 0.01 s units (0 to 327.67s). Description Instead of using this FP instruction, we recommend using the related IEC instruction TM_10ms_FB (see page 916). Please refer also to Advantages of the IEC instructions in the online help.
Page 930
Timer instructions Operands Relay Register Constant start dec. or hex. Num* dec. or hex. It is not possible to use this function in a function block POU. For correct results, timer functions and timer function blocks must be executed exactly one time in each scan. Thus it is not allowed to use timer function or timer function blocks in interrupt programs or in loops.
Page 931
Timer instructions Timer for 100ms intervals (0 to 3276.7s) TM_100ms The TM_100ms instruction sets the ON-delay timer for 0.1s units (0 to 3276.7s). Description Instead of using this FP instruction, we recommend using the related IEC instruction TM_100ms_FB (see page 919). Please refer also to Advantages of the IEC instructions in the online help.
Page 932
Timer instructions Operands Relay Register Constant start dec. or hex. Num* dec. or hex. It is not possible to use this function in a function block POU. For correct results, timer functions and timer function blocks must be executed exactly one time in each scan. Thus it is not allowed to use timer function or timer function blocks in interrupt programs or in loops.
Page 933
Timer instructions Timer for 1s intervals (0 to 32767s) TM_1s The TM_1s instruction sets the ON-delay timer for 1s units (0 to 32767s). Description Instead of using this FP instruction, we recommend using the related IEC instruction TM_1s_FB (see page 922). Please refer also to Advantages of the IEC instructions in the online help.
Page 934
Timer instructions Operands Relay Register Constant start dec. or hex. Num* dec. or hex. It is not possible to use this function in a function block POU. For correct results, timer functions and timer function blocks must be executed exactly one time in each scan. Thus it is not allowed to use timer function or timer function blocks in interrupt programs or in loops.
Page 935
Timer instructions Timer 16-bit F137_STMR The auxiliary timer instruction F137_STMR is a down type timer. The formula of the timer-set time Description is 0.01 sec. * set value s (time can be set from 0.01 to 327.67 sec.). If you use the special internal relay R900D as the timer contact, be sure to program it at the address immediately after the instruction.
Page 936
Timer instructions Timer 32-bit F183_DSTM The F183 instruction activates an upward counting 32-bit timer which works on-delayed. The Description smallest counting unit is 0.01s. During execution of F183 (start = TRUE), elapsing time is added to the elapsed value d. The timer output will be enabled when the elapsed value d equals the set value s.
Page 938
Chapter 30 Process control instructions...
Page 939
Process control instructions 30.1 Explanation of the operation of the PID instuctions parameter F355_PID (Kp, Ti, Td, Ts) output quantity Control output analogue section input calculation value (MV) value (SP) measurement value (PV) POU body The above POU body represents the standard control loop. The control input is determined by the user (e.g. desired room temperature of 22°C).
Page 940
Process control instructions An integral part produces an output quantity that corresponds to the time integral and input quantity (area of the input quantity). The integral time thus evaluates the output quantity MVi. The integral part can be a quantity scale of a tank that is filled by a volume flow, for example. Because of the slow reaction time of the integral part, it has a larger maximum overshot than the P component, but no constant standard tolerance.
Page 941
Process control instructions A PID controller is a combination of a P component, an I component and a D component. When the parameters Kp, Ti and Td are optimally adjusted, a PID controller can quickly control and maintain a quantity at a predetermined set value.
Page 942
Process control instructions Reverse operation I-PD Control = 16#X002 Forward operation I-PD Control = 16#X003 PID processing instructions: PID_FB_DUT (see page 953) PID_FB (see page 951) F355_PID_DUT (see page 941)
Page 943
Process control instructions PID processing instruction F355_PID_DUT The PID processing instruction is used to regulate a process (e.g. a heater) given a measured Description value (e.g. temperature) and a predetermined output value (e.g. 20°C). The function calculates a PID algorithm whose parameters are determined in a data table in the form of an ARRAY with 30 elements that is entered at input s.
Page 944
Process control instructions Error flags IEC address %MX0.900.7 permanently the parameter settings are outside the R9007 permissible range %MX0.900.8 for an instant R9008 In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.
Page 945
Process control instructions Body The standard function MOVE copies the value 16#8000 to the member Control of the DUT PidParameters when the variable EnableAutoTuning turns from FALSE to TRUE (i.e. activates the control mode auto-tuning in the function F355_PID_DUT). The variables Set_Value_SP and Process_Value_PV are assigned to the members SP and PV of the DUT PidParameters.
Page 946
Process control instructions F356_PID_PWM PID processing with optional PWM output PID processing is performed to keep the process value PV as close as possible to the set point Description value SP. In contrast to F355_PID_DUT (see page 941), this instruction enables a PWM output (on-off output).
Page 947
Process control instructions PLC types Availability of F356_PID_PWM (see page 1325) The period (cycle) of the PWM output is the sampling time Ts (the frequency of the PWM output is 1/Ts) and the duty is the manipulated value MV in 0.01% units, e.g.
Page 948
Process control instructions In this example, the same POU header is used for all programming languages. Example In the global variable list, all values of global inputs and outputs are declared that are used for programming this function. POU header All input and output variables used for programming this function have been declared in the POU header.
Page 949
Process control instructions When programming with structured text, enter the following: (* Auto Tuning: *) DF(bStartAutoTuning) then ControlData.b0_AT_Request:=TRUE; end_if; y_bPwmOutput:=F356_PID_PWM( := bRunPidControl, Control := ControlData, ParametersHold := ParametersHold, ParametersNonHold := ParametersNonHold, ProcessValue := x_iTemperatureInput); F356_Control_DUT This data type, a DUT with overlapping elements (see page 53), is predefined in the FP Library and is used by the function F356_PID_PWM (see page 945).
Page 950
Process control instructions F356_Parameters_Hold_DUT This data type is predefined in the FP Library and is used by the function F356_PID_PWM (see page 945). This DUT specifies the control parameter (4 words). We recommend allocating the area used by this data type to the hold-type operation memory.
Page 951
Process control instructions Sets the sampling time for updating the 100 (1s) 1–3000 (0.01–30s) measured input values. Unit = 0.01s Also sets the PWM output period. ControlMode Inverse PI-D control, e.g. heating 0–3 Forward PI-D control, e.g. cooling Inverse I-PD control, e.g. heating Forward I-PD control, e.g.
Page 952
Process control instructions Auto-tuning bias value If a bias value has been set, auto-tuning will be performed with a temporary set point value SP’. In reverse operation, SP' is the difference of the set point value SP and the auto-tuning bias value. The auto-tuning bias value can be used to control excessive temperature rise during auto-tuning.
Page 953
Process control instructions PID processing instruction PID_FB This implementation allows you to set the parameters of F355_PID directly using arguments: Description Data types Input variables (VAR_INPUT): Variable Data type Function Automatic BOOL FALSE: Manual setting of MV possible TRUE: Automatic PID controlled MV Forward FALSE: Inverse control (heating) TRUE: Forward control (cooling)
Page 954
Process control instructions In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help. In the global variable list all global input and output values are declared that are used to program the function.
Page 955
Process control instructions PID processing instruction PID_FB_DUT This implementation allows you to access the F355_PID instruction via the structure PID_DUT. Description This structure defined in System Libraries / FP Library / DUTs contains the following parameters (for details, please refer to the DUT PID_DUT): Data types Input variables (VAR_INPUT): Variable...
Page 956
Process control instructions When programming with structured text, enter the following: PID_Parameter.SP := Set_Value_SP; PID_Parameter.PV := Process_Value_PV; PID_Control( Automatic:= TRUE, PidDut:= PID_Parameter); Output_Value_MV := PID_Parameter.MV;...
Page 957
Process control instructions Scales INTEGER data SCALE_INT This instruction scales an INTEGER value between a lower and an upper limit to an INTEGER Description output value. Use WITHIN_LIMITS (see page 111) to check if the input value is within the specified limits.
Page 958
Process control instructions When programming with structured text, enter the following: (bScale) then SCALE_INT(iInput := iInput, iInputLowerLimit := 50, iInputUpperLimit := 1000, iOutputLowerLimit := 40, iOutputUpperLimit := 2000, iOutput => iOutput); end_if;...
Page 959
Process control instructions Scale INTEGER data into unsigned INTEGER data SCALE_INT_UINT This instruction scales an INTEGER value between a lower and an upper limit to an unsigned Description INTEGER output value. Use WITHIN_LIMITS (see page 111) to check if the input value is within the specified limits.
Page 960
Process control instructions When programming with structured text, enter the following: (bScale) then SCALE_INT_UINT(iInput := iInput, iInputLowerLimit := -50, iInputUpperLimit := 1000, uiOutputLowerLimit := 0, uiOutputUpperLimit := 2000, uiOutput => uiOutput); end_if;...
Page 961
Process control instructions Scale REAL data SCALE_REAL This instruction scales a REAL value between a lower and an upper limit to a REAL output value. Description Use WITHIN_LIMITS (see page 111) to check if the input value is within the specified limits. See also: ...
Page 962
Process control instructions When programming with structured text, enter the following: (bScale) then SCALE_REAL(rInput := rInput, rInputLowerLimit := 245.25, rInputUpperLimit := 123456.56, rOutputLowerLimit := 147.25, rOutputUpperLimit := 258369.25, rOutput => rOutput); end_if;...
Page 963
Process control instructions Scale UINT data SCALE_UINT This instruction scales an unsigned INTEGER value between a lower and an upper limit to an Description unsigned INTEGER output value. Use WITHIN_LIMITS (see page 111) to check if the input value is within the specified limits. See also: ...
Page 964
Process control instructions When programming with structured text, enter the following: (bScale) then SCALE_UINT(uiInput := uiInput, uiInputLowerLimit := 123, uiInputUpperLimit := 45678, uiOutputLowerLimit := 321, uiOutputUpperLimit := 65535, uiOutput => uiOutput); end_if;...
Page 965
Process control instructions Scales UINT input data to INT output data SCALE_UINT_INT This instruction scales an unsigned INTEGER value between a lower and an upper limit to an Description INTEGER output value. Use WITHIN_LIMITS (see page 111) to check if the input value is within the specified limits.
Page 967
Process control instructions Smooth INT signals SmoothSignal_INT This instructions uses a 1st order delay time tT1 to smooth the INTEGER input value at iIN. Description see page 1330 PLC types Data types Input variable Data type Function Input signal TIME Time constant of the 1st order low-pass filter Input/output variable dutMemory...
Page 968
Process control instructions Smooth REAL signals SmoothSignal_REAL This instructions uses a 1st order delay time tT1 to smooth the REAL input value at iIN. Description see page 1331 PLC types Data types Input variable Data type Function REAL Input signal TIME Time constant of the 1st order low-pass filter Input/output variable...
Page 969
Process control instructions Smooth UINT signals SmoothSignal_UINT This instructions uses a 1st order delay time tT1 to smooth the unsigned INTEGER input value at Description iIN. see page 1331 PLC types Data types Input variable Data type Function UINT Input signal uiIn TIME Time constant of the 1st order low-pass filter...
Page 971
FP-e display instructions Screen display instruction F180_SCR This instruction sets up the screen display in the normal mode (N) and switch mode (S) of the FP-e Description unit. Availability of F180_SCR (see page 1335) PLC types Data types Variable Data type Function ANY16 Specifies "s1"...
Page 972
FP-e display instructions Configuring the Display of the FP-e F180_SCR_DUT This instruction allows you to configure the screen display of the FP-e for N mode (normal mode) Description and S mode (switch mode). Using a convenient dialog, the control code for the screen display is configured. Procedure 1.
Page 973
FP-e display instructions Error flags IEC Address %MX0.900.7 permanently when the area defined by index modifiers R9007 is greater than the area allowed %MX0.900.8 temporarily R9008 the value for s1 or s2 is invalid You cannot enter the special data register “DT9***” for the lower display area.
Page 974
FP-e display instructions DisplayMode0 DisplayMode1 DisplayControlData0 DisplayControlData1 For detailed information please refer to the technical manual of the FP-e (file ARCT1F369E.PDF on your installation CD of Control FPWIN Pro).
Page 975
FP-e display instructions When programming with structured text, enter the following: (Enable0) THEN F180_SCR_DUT(ScreenSelection:=DisplayMode0, ScreenControl:=DisplayCtrlData0, DataUpperSection:=ElapsedValue0, DataLowerSection:=SetValue0); F181_DSP (DisplayMode0); END_IF; (Enable1) THEN F180_SCR_DUT(ScreenSelection:=DisplayMode1, ScreenControl:=DisplayCtrlData1, DataUpperSection:=ElapsedValue1, DataLowerSection:=SetValue1); F181_DSP (DisplayMode1); END_IF;...
Page 976
FP-e display instructions Screen change instruction F181_DSP The FP-e display mode is changed to the one specified using s1. Description Availability of F181_DSP (see page 1322) PLC types Data types Variable Data type Function ANY16 Display mode and No. (0 to 7 can be specified). Operands Relay Register...
Page 977
FP-e display instructions POU header All input and output variables used for programming this function have been declared in the POU header. Body According to the variable Enable0 to Enable7 that is set to TRUE, the function is executed and the FP-e is switched to the corresponding mode and the corresponding screen.
Page 978
FP-e display instructions When programming with structured text, enter the following: DF(bEnable0) THEN (* N mode, 1st screen *) F181_DSP(s1:=0); END_IF; DF(bEnable1) THEN (* N mode, 2nd screen *) F181_DSP(s1:=1); END_IF; DF(bEnable2) THEN (* S mode, 1st screen *) F181_DSP(s1:=2); END_IF;...
Page 980
Chapter 32 System register instructions...
Page 981
System register instructions Change PLC system setting SYS1 Description The description for SYS1 is divided into the following sections: Communication condition setting (see page 980) Password setting (see page 984) Interrupt setting (see page 986) PLC link time setting (see page 988) Change high-speed counter operation mode (see page 989) ...
Page 982
System register instructions 1. Communication format (Shared by the Tool, COM 1 and COM 2 ports) Keyword setting TOOL, B7PNS1 Port used TOOL: Tool port COM1: COM1 port COM2: COM2 port Character bit B7: 7bits B8: 8bits Parity PE: Even PN: None PO: Odd Stop bit...
Page 983
System register instructions Example: SYS1 'COM1No,D9999' indicates DT9999 SYS1 'COM1No,D0000' indicates DT0 A calculation error occurs if any value except 1–99 is assigned to the DT memory. 4. Header and Terminator (Shared by the COM 1 and COM 2 ports) COM1 , Port used COM1: COM1 port...
Page 984
System register instructions 5. RS (Request to Send) control (COM 1 port only) RTS 1 COM1 , Port used COM1: COM1 port RS control for the 1-channel RS232C type communication cassette RTS1: Disables communication (Sets the RS terminal to “on”) RTS0: Enables communication (Sets the RS terminal to “off”) Precautions during programming...
Page 985
System register instructions Error flags IEC address R9007 %MX0.900.7 permanently any character other than a keyword is specified no comma is between the first and second keywords small letters of the alphabet are used to specify the keyword (except for numbers used to specify unit no.) ...
Page 986
System register instructions Password Setting This changes the password specified by the controller, based on the contents specified by the character constant. This changes the password specified by the controller to the contents specified by the second keyword. The first and second keywords are separated by a comma. Keyword setting for 4-digit hexadecimal password PASS,ABCD PASS:...
Page 987
System register instructions Body When ChangePassword turns on, the controller password is changed to "ABCD". The values entered at s* will be right aligned automatically by the compiler. Interrupt Setting This sets the interrupt input based on the contents specified by the character constant. This sets the input specified by the first keyword as the interrupt input, and changes the input conditions to the contents specified by the second keyword.
Page 988
System register instructions Precautions during programming Executing this instruction does not rewrite the contents of the system ROM in the control unit. As a result, turning the power supply off and then on again rewrites the contents of the system registers specified by the tool software. ...
Page 989
System register instructions PLC Link Time Setting This sets the system setting time when a PLC link is used, based on the contents specified by the character constant. The conditions specified by the first keyword are set as the time specified by the second keyword. The first and second keywords are separated by a comma.
Page 990
System register instructions default value is 400 ms.) Precautions when setting the error detection time for the transmission assurance relay This should be specified such that the value is at least twice that of the largest transmission cycle time of all the PLCs that are linked. ...
Page 991
System register instructions Keyword setting SYS1 HSC1,UP High-speed counter setting n: 0 to 9, A, B with FP-X C14R, C30/60R HSCn n: 0 to 7 with FP-X C14T, C30/60T n: 0, 1, 2, 3 with FPΣ UP: Addition input setting DOWN: Subtraction input setting Precautions during programming ...
Page 992
System register instructions When programming with structured text, enter the following: DF(bCountUp) Then SYS1('HSC0,UP'); SYS1('HSCB,UP'); End_If; DF(bCountDown) Then SYS1('HSC0,DOWN'); SYS1('HSC7,DOWN'); End_If; RS485 Response Time Control This changes the communication conditions based on the RS485 of the COM port or Tool port, in response to the contents specified by the character constant.
Page 993
System register instructions When a commercial RS232C/RS485 converter is being used to carry out communication between Usage Example a personal computer and the FP-, this instruction is used to return the PLC response after switching of the enable signal has been completed on the converter side. Commercial RS232C/RS485 converter Command...
Page 994
System register instructions Error flags IEC address any character other than a keyword is specified no comma is between the first and second keywords R9007 %MX0.900.7 permanently small letters of the alphabet are used to R9008 %MX0.900.8 for an instant specify the keyword ...
Page 995
System register instructions Change System Register Settings for PC Link Area SYS2 While the PLC is in RUN mode, SYS2 changes the settings for the specified system registers. Description s_Start contains the new values for those system registers defined between d_Start* and d_End*. You can change the values in system registers 40 - 47 (with the FP0R, FP-...
Page 996
System register instructions In this example the function SYS2 is programmed in ladder diagram (LD). Example A Data Unit Type (DUT) can be composed of several data types. A DUT is first defined in the DUT pool and then processed like the standard data types (BOOL, INT, etc.) in the list of global variables or the POU header.
Page 999
Special instructions Carry-flag set F140_STC Special internal relay R9009 (carry-flag) goes ON if the trigger EN is in the ON-state. This Description instruction can be used to control data using carry-flag R9009 (e.g. F122_RCR (see page 589) and F123_RCL (see page 591) instructions). This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 1000
Special instructions Carry-flag reset F141_CLC Special internal relay R9009 (carry-flag) goes OFF if the trigger EN is in the ON-state. This Description instruction can be used to control data using carry-flag R9009 (e.g. F122_RCR (see page 589) and F123_RCL (see page 591) instructions). This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 1001
Special instructions Watchdog timer update F142_WDT The scan ‘check watchdog timer’ is preset with the constant specified by s* if the trigger EN is in Description the ON-state. The value specified by s* is 1 to 255 and the preset time becomes 2.5 ms * s* (637.5 ms).
Page 1002
Special instructions Self-diagnostic error set/reset F148_ERR The error no. specified by n* is copied into the system variable sys_iSelfDiagnosticErrorCode that Description reads the corresponding special data register. Setting n*=0, all error numbers greater than 43 are cleared and the error LED turns off. At the same time, the self-diagnostic error-flag R9000 is set and ERROR LED on the CPU is turned The contents of the error flag R9000 and the error no.
Page 1003
Special instructions When programming with structured text, enter the following: start THEN (* Sets the self-diagnostic error 100 *) (* The ERROR/ALARM LED of the PLC is on, and operation stops. *) F148_ERR(100); END_IF; 1002...
Page 1004
Special instructions Message display F149_MSG This instruction is used for displaying the message on the FP Programmer II screen. After Description executing the F149_MSG instruction, you can see the message specified by s on the FP Programmer II screen. When the F149_MSG instruction is executed, the message-flag R9026 is set and the message specified by s is set in special data registers DT9030 to DT9035 (DT90030 to DT90035 for FP0 T32CP, FP2/2SH, FP10/10S/10SH).
Page 1005
Special instructions Transfer sampling data F155_SMPL This instruction transfers the sampling data specified by the sampling trace editor into the sampling Description memory. F155_SMPL can only be used with the sampling mode "per Scan". This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 1006
Special instructions Set sampling trigger F156_STRG This instruction sets the sampling trigger that stopps the sampling after the delay specified by the Description sampling trace parameters. F156_STRG can be used with both sampling modes, "per Scan" and "per Time Interval". This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 1008
Chapter 34 Program execution control instructions...
Page 1009
Program execution control instructions Master control relay Executes the program between the master control relay MC and master control relay end MCE Description (see page 1008) instructions of the same number Num* only if the trigger EN is in the ON-state When the predetermined trigger EN is in the OFF state, the program between the master control relay MC and master control relay end MCE instructions is not executed.
Page 1010
Program execution control instructions Master control relay end Executes the program between the master control relay MC (see page 1007) and master control Description relay end MCE instructions of the same number Num* only if the trigger EN is in the ON-state. When the predetermined trigger EN is in the OFF state, the program between the master control relay MC and master control relay end MCE instructions is not executed.
Page 1011
Program execution control instructions Jump to label The JP (Jump to Label) instruction skips to the Label (LBL (see page 1013)) function that has the Description same number Num* as the JP function when the predetermined trigger EN is in the ON-state. The JP function will skip all instructions between a JP and an LBL of the same number.
Page 1012
Program execution control instructions Indirect jump to label F19_SJP Jumps to the label LBL (see page 1013) s with the same number as the data stored in the area Description specified by s if the trigger EN is in the ON-state. This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which is only executed at the rising edge of the EN trigger.
Page 1013
Program execution control instructions When programming with structured text, enter the following: (* if Start is true Counter will be incremented by 1, else by 2 *) Start THEN F19_SJP(_label); END_IF; Counter:=Counter+1; LBL(1); Counter:=Counter+1; 1012...
Page 1014
Program execution control instructions Loop to label LOOP LOOP (Loop to Label) instruction skips to the LBL (see page 1013) instruction with the same Description number Num* as the LOOP instruction and repeats execution of what follows until the data of a specified operand becomes "0".
Page 1015
Program execution control instructions Label for the JP- and LOOP-instruction The LBL (Label for the JP and LOOP) instruction skips to the LBL instruction with the same Description number Num* as the JUMP (see page 1009) instruction if the predetermined trigger EN is in the ON-state.
Page 1016
Program execution control instructions When programming with structured text, enter the following: (* if Start is true Counter will be incremented by 1, else by 2 *) Start THEN JP(1); END_IF; Counter:=Counter+1; LBL(1); Counter:=Counter+1; 1015...
Page 1017
Program execution control instructions Break The BRK (Breakpoint) instruction stops the execution at the address of this instruction during the Description test run mode if the trigger EN is in the ON-state. Once this instruction is executed, the program halts. To continue the program, the mode in the test run (continuous run / step run) should be selected.
Page 1018
Program execution control instructions Interrupt Control ICTL The ICTL instruction sets all interrupts to enable or disable. Each time the ICTL instruction is Description executed, it is possible to set parameters like the type and validity of interrupt programs. Settings can be specified by s1_Control and s2_Condition.
Page 1019
Program execution control instructions Availability of ICTL (see page 1327) PLC types Data types Variable Data type Function Interrupt control data setting ANY16 Interrupt condition setting Operands Relay Register Constant dec. or hex. s1, s2 In this example, the same POU header is used for all programming languages. For an example Example using IL (instruction list), please refer to the online help.