|
|
Topic: P345 |
Structured Text Function List |
|
The sections below detail the built-in functions and function blocks available in Productivity Suite Structured Text editor.
Note: Function blocks are similar to ladder instructions.
There are eight categories of functions and function blocks:
Note: In the sections below, the INTEGER parameter type can refer to any of the following data types:
• Integer, 8 Bit Unsigned
• Integer, 16 Bit
• Integer, 16 Bit Unsigned
• Integer, 32 Bit
• Float, 32 Bit
• Integer, 16 Bit BCD
• Integer, 32 Bit BCD
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | BOOLEAN | Required | Watched input |
Returns TRUE if a falling edge is detected on the input.
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | BOOLEAN | Required | Input signal |
Returns TRUE if a rising edge is detected on the input.
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Number between -1 and 1 |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Number between -1 and 1 |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value1 | INTEGER | Required | First integer |
| value2 | INTEGER | Required | Second integer |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Number between -1 and 1 |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Number between -1 and 1 |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Any number |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Any number |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value1 | INTEGER | Required | Value #1 |
| value2 | INTEGER | Required | Value #2 |
| value3..16 | INTEGER | Optional | Additional values (up to 16 total) |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| Parameter | Type | Required | Description |
|---|---|---|---|
| degrees | INTEGER | Required | Angle in degrees |
| Parameter | Type | Required | Description |
|---|---|---|---|
| radians | INTEGER | Required | Angle in radians |
| Parameter | Type | Required | Description |
|---|---|---|---|
| radians | INTEGER | Required | Angle in radians |
The constant value 2.71828182… (Euler's number e). No parameters required.
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value1 | INTEGER | Required | Value #1 |
| value2 | INTEGER | Required | Value #2 |
| value3..16 | INTEGER | Optional | Additional values (up to 16 total) |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value1 | INTEGER | Required | Value #1 |
| value2 | INTEGER | Required | Value #2 |
| value3..16 | INTEGER | Optional | Additional values (up to 16 total) |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value1 | INTEGER | Required | Value #1 |
| value2 | INTEGER | Required | Value #2 |
| value3..16 | INTEGER | Optional | Additional values (up to 16 total) |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| decimal_points | INTEGER | Required | Decimal points to round to |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| decimal_points | INTEGER | Required | Decimal points to round to |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| decimal_points | INTEGER | Required | Decimal points to round to |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value1 | INTEGER | Required | First integer |
| value2 | INTEGER | Required | Second integer |
The constant value 3.14159265… No parameters required.
| Parameter | Type | Required | Description |
|---|---|---|---|
| degrees | INTEGER | Required | Angle in degrees |
No parameters required.
| Parameter | Type | Required | Description |
|---|---|---|---|
| value1 | INTEGER | Required | Value #1 |
| value2 | INTEGER | Required | Value #2 |
| value3..16 | INTEGER | Optional | Additional values (up to 16 total) |
| Parameter | Type | Required | Description |
|---|---|---|---|
| degrees | INTEGER | Required | Angle in degrees |
| Parameter | Type | Required | Description |
|---|---|---|---|
| radians | INTEGER | Required | Angle in radians |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
Note: Square root of a negative number will evaluate as zero (0)
| Parameter | Type | Required | Description |
|---|---|---|---|
| degrees | INTEGER | Required | Number not n*180 + 90 |
| Parameter | Type | Required | Description |
|---|---|---|---|
| radians | INTEGER | Required | Number not n*PI + PI/2 |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | INTEGER | Required | Input number |
| Parameter | Type | Required | Description |
|---|---|---|---|
| value1 | INTEGER | Required | First integer |
| value2 | INTEGER | Required | Second integer |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INTEGER | Required | Number to be converted |
| string_length | INTEGER | Required | Length of output string |
| decimal_points | INTEGER | Required | Constant, number of decimal points |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string1 | STRING | Required | String #1 |
| string2 | STRING | Required | String #2 |
| string_length | INTEGER | Required | Number of characters to compare |
Returns TRUE if contents are equal.
| Parameter | Type | Required | Description |
|---|---|---|---|
| string1 | STRING | Required | String #1 |
| string2 | STRING | Required | String #2 |
| string3..16 | STRING | Optional | Additional strings (up to 16 total) |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | 1D INTEGER ARRAY | Required | Integer array |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | STRING | Required | Input string |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | STRING | Required | String to be converted |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | STRING | Required | Input string |
| L | INTEGER | Required | Number of characters to delete |
| N | INTEGER | Required | Beginning position |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string1 | STRING | Required | String to be searched |
| string2 | STRING | Required | String to be found |
Returns position of the found string, or 0 if not found.
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | STRING | Required | String to be searched |
| value | INTEGER | Required | Hex value to find (range 0 to 0xFFFF) |
| start | INTEGER | Required | Position in string to start search |
| end | INTEGER | Required | Position in string to end search |
| instance | INTEGER | Required | Which instance of value to find |
Returns position of the found hex value, or 0 if not found.
| Parameter | Type | Required | Description |
|---|---|---|---|
| string1 | STRING | Required | String to be inserted into |
| string2 | STRING | Required | Inserting string |
| N | INTEGER | Required | Starting position |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | STRING | Required | Input string |
| N | INTEGER | Required | Number of leftmost characters |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | STRING | Required | Input string |
| L | INTEGER | Required | Length of string |
| P | INTEGER | Required | Starting position |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string1 | STRING | Required | String to be replaced in |
| string2 | STRING | Required | Replacing string |
| L | INTEGER | Required | Number of characters to replace |
| N | INTEGER | Required | Beginning position |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | STRING | Required | Input string |
| N | INTEGER | Required | Number of rightmost characters |
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | STRING | Required | Input string |
| Parameter | Type | Required | Description |
|---|---|---|---|
| min | INTEGER | Required | Minimum value |
| input | INTEGER | Required | Input value |
| max | INTEGER | Required | Maximum value |
| Parameter | Type | Required | Description |
|---|---|---|---|
| flag | BOOLEAN | Required | Selection flag |
| input_1 | INTEGER | Required | Value returned when flag is TRUE |
| input_2 | INTEGER | Required | Value returned when flag is FALSE |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input_1 | INTEGER | Required | Input value #1 |
| select_1 | BOOLEAN | Required | Selection flag #1 |
| input_2..8 | INTEGER | Optional | Input value #2 through #8 |
| select_2..8 | BOOLEAN | Optional | Selection flag #2 through #8 |
Accepts up to 8 input/select pairs. Only inputs with their corresponding select flag set to TRUE are included in the sum.
| Parameter | Type | Required | Description |
|---|---|---|---|
| source_array | NUM_ARRAY | Required | Source array |
| destination_array | NUM_ARRAY | Required | Destination array |
| src_start_col | INTEGER | Required | Source starting column index |
| src_end_col | INTEGER | Required | Source ending column index |
| dest_start_col | INTEGER | Required | Destination starting column index |
| src_start_row | INTEGER | Optional | Source starting row index |
| src_end_row | INTEGER | Optional | Source ending row index |
| dest_start_row | INTEGER | Optional | Destination starting row index |
| overflow | BOOLEAN | Optional | Flag enabled when index is out of bounds |
Only numerical (integer and float) arrays are supported.
| Parameter | Type | Required | Description |
|---|---|---|---|
| source_array | ANY_ARRAY | Required | Source array |
| destination_array | ANY_ARRAY | Required | Destination array |
| src_start_col | INTEGER | Required | Source starting column index |
| src_end_col | INTEGER | Required | Source ending column index |
| dest_start_col | INTEGER | Required | Destination starting column index |
| src_start_row | INTEGER | Optional | Source starting row index |
| src_end_row | INTEGER | Optional | Source ending row index |
| dest_start_row | INTEGER | Optional | Destination starting row index |
| overflow | BOOLEAN | Optional | Flag enabled when index is out of bounds |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INTEGER | Required | Value to fill the array with |
| array | NUM_ARRAY | Required | Array to be filled |
| start_col | INTEGER | Required | Starting column index |
| end_col | INTEGER | Required | Ending column index |
| start_row | INTEGER | Optional | Starting row index |
| end_row | INTEGER | Optional | Ending row index |
| overflow | BOOLEAN | Optional | Flag enabled when index is out of bounds |
| Parameter | Type | Required | Description |
|---|---|---|---|
| source_array | BOOL_1D_ARRAY | Required | Source Boolean array |
| destination_array | INT_1D_ARRAY | Required | Destination integer array |
| src_start_col | INTEGER | Required | Source starting column index |
| src_end_col | INTEGER | Required | Source ending column index |
| dest_start_col | INTEGER | Required | Destination starting column index |
| overflow | BOOLEAN | Optional | Flag enabled when index is out of bounds |
Same parameter structure as PBA. Source: 8-bit Integer array, Destination: 32-bit Integer array.
Same parameter structure as PBA. Source: 8-bit Integer array, Destination: 16-bit Integer array.
Same parameter structure as PBA. Source: 16-bit or 32-bit Integer array, Destination: 32-bit Integer array.
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | ARRAY_1D | Required | One dimensional array |
| start_col | INTEGER | Required | Starting column index |
| end_col | INTEGER | Required | Ending column index |
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | ARRAY_1D | Required | One dimensional array |
| start_col | INTEGER | Required | Starting column index |
| end_col | INTEGER | Required | Ending column index |
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | ARRAY_1D | Required | One dimensional array |
| start_col | INTEGER | Required | Starting column index |
| end_col | INTEGER | Required | Ending column index |
| inflow | INTEGER | Optional | Value to fill the vacated element |
| outflow | INTEGER | Required | Element value shifted out |
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | ARRAY_1D | Required | One dimensional array |
| start_col | INTEGER | Required | Starting column index |
| end_col | INTEGER | Required | Ending column index |
| inflow | INTEGER | Optional | Value to fill the vacated element |
| outflow | INTEGER | Required | Element value shifted out |
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | NUM_ARRAY | Required | Array with elements to be calculated |
| start_col | INTEGER | Required | Starting column index |
| end_col | INTEGER | Required | Ending column index |
| start_row | INTEGER | Optional | Starting row index |
| end_row | INTEGER | Optional | Ending row index |
| ignore_less | INTEGER | Optional | Value below which elements are ignored |
| ignore_greater | INTEGER | Optional | Value above which elements are ignored |
| overflow | BOOLEAN | Optional | Flag enabled when an index is out of bounds |
Same parameter structure as STAMD.
Same parameter structure as STAMD.
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | NUM_ARRAY | Required | Array with elements to be searched |
| start_col | INTEGER | Required | Starting column index |
| end_col | INTEGER | Required | Ending column index |
| greater_than | INTEGER | Required | Value above which elements are counted |
| start_row | INTEGER | Optional | Starting row index |
| end_row | INTEGER | Optional | Ending row index |
| ignore_less | INTEGER | Optional | Value below which elements are ignored |
| ignore_greater | INTEGER | Optional | Value above which elements are ignored |
| overflow | BOOLEAN | Optional | Flag enabled when an index is out of bounds |
| Parameter | Type | Required | Description |
|---|---|---|---|
| array | NUM_ARRAY | Required | Array with elements to be searched |
| start_col | INTEGER | Required | Starting column index |
| end_col | INTEGER | Required | Ending column index |
| less_than | INTEGER | Required | Value below which elements are counted |
| start_row | INTEGER | Optional | Starting row index |
| end_row | INTEGER | Optional | Ending row index |
| ignore_less | INTEGER | Optional | Value below which elements are ignored |
| ignore_greater | INTEGER | Optional | Value above which elements are ignored |
| overflow | BOOLEAN | Optional | Flag enabled when an index is out of bounds |
Same parameter structure as STAMD.
Same parameter structure as STAMD.
Same parameter structure as STAMD.
| Parameter | Type | Required | Description |
|---|---|---|---|
| source_array | INT_1D_ARRAY | Required | Source integer array |
| destination_array | BOOL_1D_ARRAY | Required | Destination Boolean array |
| src_start_col | INTEGER | Required | Source starting column index |
| src_end_col | INTEGER | Required | Source ending column index |
| dest_start_col | INTEGER | Required | Destination starting column index |
| overflow | BOOLEAN | Optional | Flag enabled when index is out of bounds |
Source: 8-bit Integer array, Destination: Boolean array.
Same parameter structure as UPBA. Source: 32-bit Integer array, Destination: 8-bit Integer array.
Same parameter structure as UPBA. Source: 32-bit Integer array, Destination: 16-bit Integer array.
Same parameter structure as UPBA. Source: 16-bit Integer array, Destination: 8-bit Integer array.
First parameter 'type' is a constant: 0 = gray code, 1 = binary. Followed by the corresponding number of Boolean bit inputs.
| Variant | Bits | Pulses |
|---|---|---|
| ABSE32 | 5 | 32 |
| ABSE64 | 6 | 64 |
| ABSE128 | 7 | 128 |
| ABSE180 | 8 | 180 |
| ABSE256 | 8 | 256 |
| ABSE360 | 9 | 360 |
| ABSE512 | 9 | 512 |
| ABSE720 | 10 | 720 |
| ABSE1024 | 10 | 1024 |
| ABSE2048 | 11 | 2048 |
| ABSE4096 | 12 | 4096 |
| Parameter | Type | Required | Description |
|---|---|---|---|
| source | INTEGER | Required | Source data (constant or tag) |
| destination | INTEGER | Required | Destination tag |
Only integers and floats are supported.
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | BOOLEAN | Required | A Boolean value |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INTEGER | Required | An integer value |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input1..4 | INTEGER | Optional | 8 bit integer values (up to 4) |
Note: input1 is the LSB and input4 is the MSB.
Accepts up to 32 optional BOOLEAN parameters (bit1 through bit32).
| Parameter | Type | Required | Description |
|---|---|---|---|
| input1 | INTEGER | Optional | An integer value (8 bit) |
| input2 | INTEGER | Optional | An integer value (8 bit) |
Note:input1 is the LSB and input2 is the MSB.
| Parameter | Type | Required | Description |
|---|---|---|---|
| input1 | INT16_32 | Optional | A 16 or 32 bit integer value |
| input2 | INT16_32 | Optional | A 16 or 32 bit integer value |
Note:input1 is the LSB and input2 is the MSB.
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INTEGER | Required | A float value |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INTEGER | Required | Input value |
| bits | INTEGER | Required | Number of bits to rotate |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INTEGER | Required | Input value |
| bits | INTEGER | Required | Number of bits to rotate |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INTEGER | Required | Input value |
| bits | INTEGER | Required | Number of bits to shift |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INTEGER | Required | Input value |
| bits | INTEGER | Required | Number of bits to shift |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INT32 | Required | A 16 or 32 bit 2's complement value |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INT32 | Required | A 16 or 32 bit sign plus magnitude value |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INTEGER | Required | Input value to unpack |
| bit1..32 | BOOLEAN | Optional | Output bit variables (up to 32) |
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INT32 | Required | A 32 bit integer value |
| output1..4 | INT8 | Optional | 8 bit integer outputs (up to 4) |
Note:output1 is the LSB and output2 is the MSB.
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INT32 | Required | A 32 bit integer value |
| output1 | INT16 | Optional | 16 bit integer output #1 |
| output2 | INT16 | Optional | 16 bit integer output #2 |
Note: output1 is the LSB and output4 is the MSB.
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | INT16 | Required | A 16 bit integer value |
| output1 | INT8 | Optional | 8 bit integer output #1 |
| output2 | INT8 | Optional | 8 bit integer output #2 |
Note: output1 is the LSB and output2 is the MSB.
Note: Standard function blocks use formal parameter syntax. The function block name must be replaced by a tag declared as the corresponding System Structure type (e.g., tag name myCounter of System Structure data type CTU).
| Parameter | Type | Required | Description |
|---|---|---|---|
| CD | BOOLEAN | Required | Count down input |
| LD | BOOLEAN | Required | Load input (set CV to PV) |
| PV | INTEGER | Required | Preset value |
Declare as tag of System Structure data type CTD. Access members: .Q (output), .CV (current value).
Behavior:
| Parameter | Type | Required | Description |
|---|---|---|---|
| CU | BOOLEAN | Required | Count up input |
| R | BOOLEAN | Required | Reset input |
| PV | INTEGER | Required | Preset value |
Declare as tag of System Structure data type CTU. Access members: .Q (output), .CV (current value).
Behavior:
| Parameter | Type | Required | Description |
|---|---|---|---|
| CU | BOOLEAN | Required | Count up input |
| CD | BOOLEAN | Required | Count down input |
| R | BOOLEAN | Required | Reset input |
| LD | BOOLEAN | Required | Load input (set CV to PV) |
| PV | INTEGER | Required | Preset value |
Declare as tag of System Structure data type CTUD. Access members: .QU (up output), .QD (down output), .CV (current value).
| Parameter | Type | Required | Description |
|---|---|---|---|
| S | BOOLEAN | Required | Set input |
| R1 | BOOLEAN | Required | Reset input |
Declare as tag of System Structure data type RS. Access member: .Q1 (output).
| Parameter | Type | Required | Description |
|---|---|---|---|
| S1 | BOOLEAN | Required | Set input |
| R | BOOLEAN | Required | Reset input |
Declare as tag of System Structure data type SR. Access member: .Q1 (output).
| Parameter | Type | Required | Description |
|---|---|---|---|
| IN | BOOLEAN | Required | Timer enable |
| PT | INTEGER | Required | Preset time in milliseconds or time literal |
Declare as tag of System Structure data type TOF. Access members: .Q (output), .ET (elapsed time).
| Parameter | Type | Required | Description |
|---|---|---|---|
| IN | BOOLEAN | Required | Timer enable |
| PT | INTEGER | Required | Preset time in milliseconds or time literal |
Declare as tag of System Structure data type TON. Access members: .Q (output), .ET (elapsed time).
| Parameter | Type | Required | Description |
|---|---|---|---|
| IN | BOOLEAN | Required | Timer enable |
| PT | INTEGER | Required | Preset time in milliseconds or time literal |
Declare as tag of System Structure data type TP. Generates a pulse of duration PT when triggered. Access members: .Q (output), .ET (elapsed time).
Note: Advanced function blocks use a dialog window to configure the function block and can only be configured and edited via the dialog window.
Invokes a task configured as "Run When Called" from the current program context.
Note: This function can only be configured using the dialog. You cannot manually add the function parameters in the editor.
The dialog is accessible via the right-click context menu Edit Instruction option or via the Shift + Space keyboard shortcut.
Creates and executes a User-Defined Instruction. Parameters depend on the specific UDI definition.
Note: This function can only be configured using the dialog. You cannot manually add the function parameters in the editor.
The dialog is accessible via the right-click context menu Edit Instruction option or via the Shift + Space keyboard shortcut.