General - Move/Set - MOV

Operation:

Assigns the value of P2 to P1.

Parameters:

 | Type | Description
P1 | I/E | The destination.
P2 | I/E/C/AE | The source.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Examples:

$U2 = 123.45 (F) /* Assign 123.45 to $U2 (and $U3) */

$U100.f = 1d (B) /* Turn on the specified bit */

W60 = ($U30 + W50 - 1000) / 2 (SD) /* Write the result of the arithmetic expression to W60. */

V0.0 = 2\M0 (B) /* Assign the bit value of M0 of link 2 to the bit V0.0 of link 1*/


Operation:

Logical NOT - Reverses P2 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E | The operand.

I: Internal Variable; E: External Variable

Example:

$U2.3 = !$U3.4 (B) /* If $U3.4 is 1 (On), $U2.3 is 0 (Off) */


Operation:

Copies the quoted ASCII character string P2 to P1. Note that the string is a null terminated string. If the length of the string is N then N+1 bytes will be copied to P1 and the last byte is 0.

Parameters:

 | Type | Description
P1 | I | The location to save the result.
P2 | A | The quoted ASCII character string.

I: Internal Variable; A: ASCII character string

Examples:

$U60 = "TEST" /* The null character (0) will be moved to the low byte of $U62 */

$U20 = "ABCDE" /* The null character (00h) will be moved to the high byte of $U22 */


General - Move/Set - WCHAR

Operation:

Copies the quoted UNICODE string P2 to P1. Note that the string is a null terminated string. If the length of the string is N then N+1 words will be copied to P1 and the last word is 0.

Parameters:

 | Type | Description
P1 | I | The location to save the result.
P2 | U | The quoted UNICODE string.

I: Internal Variable; U: UNICODE string

Examples:

$U100 = L"中文" /* $U100 is 4E2DH (‘中’), $U101 is 6587H (‘文’), $U102 is the null character (0) */

$U200 = L"abc" /* $U200 is 61H (‘a’), $U201 is 62H (‘b’), $U202 is 63H (‘c’), $U203 is the null character (0) */


Operation:

Copies P3 words of P2 to P1.

Parameters:

 | Type | Description
P1 | I/E | The starting location of the memory to receive the copy.
P2 | I/E | The starting location of the memory to be copied.
P3 | I/C | The number of words to be copied.

I: Internal Variable; E: External Variable; C: Constant

Examples:

$U100 = MOV($U200, 16) /* Copy the 16 words starting from $U200 to $U100 */

W60 = MOV($U200, $U2) /* Copy the word array starting from $U200 with the size specified in $U2 to W60.*/

$U10 = MOV(2/D100,10) /* Copy D100 ~ D109 of link 2 to $U10 ~ $U19.*/


Operation:

Sets P3 words of P1 to word value P2.

Parameters:

 | Type | Description
P1 | I/E | The starting location of the memory to be set.
P2 | I/C | The set value or the location that holds the set value.
P3 | I/C | The number of words to be set.

I: Internal Variable; E: External Variable; C: Constant

Examples:

$U100 = SETM(0, 16) /* Set the 16 words starting from $U100 to 0. */

W60 = SETM($U200, $U2) /* Set the words of the word array starting from W60 with the size specified in $U2 to the value of $U200.*/


Operation:

Copies a block of bits starting from P2 with a length of P3 to the bit block starting from P1.

Parameters:

 | Type | Description
P1 | I | The starting location of the bits to receive the copy.
P2 | I/E | The starting location of the bits to be copied.
P3 | C | The number of bits to be copied.

I: Internal Variable; E: External Variable; C: Constant

Examples:

$U100.0 = MOV_BITS($U200.0, 16)(B) /* Copy the 16 bits starting from $U200.0 to $U100.0. */

$U10.E = MOV_BITS(W60.1, 10) (B) /* Copy the 10 bits starting from W60.1 to $U10.E. */


Operation:

Copies P4 words of P3 to P1. The link number of P3 is determined by P2.

Parameters:

 | Type | Description
P1 | I/E | The starting location of the memory to receive the copy.
P2 | I/C | The link number of the memory to be copied.
P 3 | I/E | The starting location of the memory to be copied.
P 4 | I/C | The number of words to be copied.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U1 = 3

$U100 = MOV_VL($U1,40001,100) /* Copy 100 words from 3\40001 of a Modbus device to $U100 */


LINK_PAR

Operation:

Copies P4 words of P3 to P2. The link number of P2 is determined by P1..

Parameters:

 | Type | Description
P1 | I/C | The link number of the memory to receive the copy.
P2 | I/E | The starting location of the memory to receive the copy.
P3 | I/E | The starting location of the memory to be copied.
P4 | I/C | The number of words to be copied.

I: Internal Variable; E: External Variable; C: Constant

Examples:

$U1 = 3 (U)

SET_VL($U1, 40001, $U100,100 ) /* Copy 100 words from $U100 to 3\40001 of a Modbus device*/


Operation:

Copies the ASCII character string in P2 to P1. Note that the string is a null terminated string. If the length of the string is N then N+1 bytes will be copied to P1 and the last byte is 0.

Parameters:

 | Type | Description
P1 | I/E | The destination. The byte array that receives a copy of the ASCII character string in P2. The byte array must be large enough to hold the string and the null terminator.
P2 | I/E | The source, i.e. the byte array that contains the null-terminated string to be copied.

I: Internal Variable; E: External Variable

Examples:

2\MyStringTag = "abc"

$U200 = MOVE_STR(2\MyStringTag) /* The null character (0) will be moved to the high byte of $U201*/


Operation:

Copies the UNICODE string in P2 to P1. Note that the string is a null terminated string. If the length of the string is N then N+1 words will be copied to P1 and the last word is 0.

Parameters:

 | Type | Description
P1 | I/E | The destination. The word array that receives a copy of the UNICODE string in P2. The word array must be large enough to hold the UNICODE string and the null terminator.
P2 | I/E | The source, i.e. the word array that contains the null-terminated UNICODE string to be copied.

I: Internal Variable; E: External Variable

Examples:

2\MyStringTag = L"萬事如意"

1\R500 = MOVE_WSTR(2\MyStringTag) /* After the command MOVE_WSTR is executed, the WORD array 1\R500 contains the string “萬事如意”. */


Operation:

Bitwise Inclusive OR - Performs bitwise Inclusive OR operation of P2 and P3 and saves the results in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2, P3 | I/E/C | The operands

I: Internal Variable; E: External Variable; C: Constant

Example:

W60 = 1111000000001111b

$U100 = 0000111100001111b | W60 (U) /* The value of $U100 is 1111111100001111b */

B15 = $U1.2 | B14 (B) /* If either $U1.2 or B14 has a value of 1(On), B15 has the value 1(On). Otherwise, B15 has the value 0(Off)*/


Operation:

Bitwise AND - Performs bitwise AND operation of P2 and P3 and saves the results in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2, P3 | I/E/C | The operands

I: Internal Variable; E: External Variable; C: Constant

Example:

W60 = 1111000000001111b

$U100 = 0000111100001111b & W60 (U) /* The value of $U100 is 0000000000001111b */

B15 = $U1.2 & B14 (B) /* If both $U1.2 and B14 are 1(On), B15 is set to 1(On). Otherwise B15 is set to 0(Off) */


Operation:

Bitwise Exclusive OR - Performs bitwise Exclusive OR operation of P2 and P3 and saves the results in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2, P3 | I/E/C | The operands

I: Internal Variable; E: External Variable; C: Constant

Example:

W60 = 1111000000001111b

$U100 = 0000111100001111b ^ W60 (U) /* The value of $U100 is 1111111100000000b.*/

B15 = $U1.2 ^ B14 (B) /*If both $U1.2 and B14 are 1(On) or 0(Off), the B15 is set to 0(Off). Otherwise B15 is set to 1(On)*/


Operation:

Left shift - Shifts P2 to the left by P3 bits and saves the results in P1. The operation supports the logic shift only.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The value or the location that holds the value to be shifted.
P3 | I/E/C | The number of bits to be shifted.

I: Internal Variable; E: External Variable; C: Constant

Examples:

$U100 = $U101 << 8 (U)

W200 = W100 << $U10 (UD)


Operation:

Right shift - Shifts P2 to the right by P3 bits and saves the results in P1. The operation supports the logic shift only.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The value or the location that holds the value to be shifted.
P3 | I/E/C | The number of bits to be shifted.

I: Internal Variable; E: External Variable; C: Constant

Examples:

$U100 = $U101 >> 8 (U)

W200 = W100 >> $U10 (UD)


Operation:

Logical AND - Saves 1 in P1 if both P2 and P3 are 1, otherwise saves 0 in P1.

Parameters:

 | Type | Description
P1 | I/E | The bit to save the result.
P2, P3 | I/E/C | The operands.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U100.0 = $U101.0 && $U101.1 (B)


Operation:

Logical OR - Saves 1 in P1 if either or both P2 and P3 are 1, otherwise saves 0 in P1.

Parameters:

 | Type | Description
P1 | I/E | The bit to save the result.
P2, P3 | I/E/C | The operands.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U100.0 = $U101.0 || $U101.1 (B)


Operation:

Addition - Adds P2 and P3 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2, P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Examples:

$U100 = $U101 + $U102 (U)

W100 = 0.3*$U0 + 0.1*$U2 + 0.6*$U4 (F)


Operation:

Subtraction - Subtracts P3 from P2 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2, P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Examples:

$U100 = $U101 - $U102 (U)

W100 = 0.3*$U0 - 10.75 (F)


Operation:

Multiplication - Multiplies P2 by P3 and saves the product in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the product. If the product is overflow, the higher bits exceeding the limit will be truncated and the remaining bits will be stored in P1.
P2, P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Examples:

$U100 = $U102 * 0x192

W100 = ($U0 + $U2) * ($U4 + $U6) (F)


Operation:

Division - Divides P2 by P3 and saves the quotient in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2, P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Examples:

$U100 = $U101 / $U102 (U)

W100 = ($U0 + $U2) / ($U4 + $U6) (F)


Operation:

Modulus - Divides P2 by P3 and saves the remainder in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2, P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Examples:

$U100 = $U30 % 16(U)

W100 = $U200 % ($U402 + $U106) (SD)


Operation:

Sets P1 to the larger value of P2 and P3.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2, P3 | I/E/C | The operands.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U100 = MAX(100, 200) /* Set $U100 to 200 */


Operation:

Sets P1 to the smaller value of P2 and P3.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2, P3 | I/E/C | The operands.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U100 = MIN(100, 200) /* Set $U100 to 100 */


Operation:

Finds the maximum in an array starting from P2 with P3 elements and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The location to save the result.
P2 | I | The starting location of the array.
P3 | I/C | The size of the array.

I: Internal Variable; C: Constant

Examples:

$U100 = BMAX($U200, 16) (F) /* Find the maximum among 16 floating point numbers starting from $U200 and save the result in $U100 */


Operation:

Finds the minimum in an array starting from P2 with P3 elements and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The location to save the result.
P2 | I | The starting location of the array.
P3 | I/C | The size of the array.

I: Internal Variable; C: Constant

Example:

$U100 = BMIN($U200, 60) (F) /* Find the minimum among 60 floating point numbers starting from $U200 and save the result in $U100 */


Operation:

Calculates the sum of the value in an array starting from P2 with P3 elements and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The location to save the result.
P2 | I | The starting location of the array.
P3 | I/C | The size of the array.

I: Internal Variable; C: Constant

Example:

$U100 = SUM($U200, 16) (F) /* Calculate the sum of 16 floating point numbers starting from $U200 and save the result in $U100 */


Operation:

Calculates one element XOR (Bitwise Exclusive OR) sum of all the P3 elements in an array starting from P2 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The location to save the result.
P2 | I | The starting location of the array.
P3 | I/C | The size of the array.

I: Internal Variable; C: Constant

Example:

$U100 = XSUM($U200, 5) (UD) /* Perform XOR sum of 5 32-bit unsigned numbers starting from $U200 and save the result in $U100. Another expression of XOR sum is $U100 = $U200 ^ $U202 ^ $U204 ^ $U206 ^ $U208 (UD) */

$U100 =1001B
$U101 =1100 B
$U102 =0110B
$U120 =
XSUM($U100,3)
/* $U120=0011B

*/


Operation:

Swaps the low byte and high byte of every word in a word array starting from P1 with P2 words.

Parameters:

 | Type | Description
P1 | I | The starting location of the array.
P2 | I/C | The size of the array.

I: Internal Variable; C: Constant

Example:

$U120=1111111100000000B

$U121=1000000100000000B

SWAP($U120, 2) /* The value of $U120 will be 0000000011111111B, The value of $U121 will be 000000010000001B */


Operation

This command initializes the cyclical redundant check (CRC) calculations for CRC8 and CRC16 macro commands.

Parameters:

Type

Description

P1

I

The word block that contains the data to initialize CRC calculations. The following table describes the data arrangement in the word block.

Word No.

Parameter

0

CRC checksum size

Value | Size
8 | 8-bit checksum
16 | 16-bit checksum

1

Attributes of data

Bit | Attribute
0 | The data transmission order. 0: MSB-first 1: LSB-first
1-15 | Reserved bits. Must be 0.

2

Low word of CRC polynomial representation

For MSB-first code

Value | Polynomial | Name
0x07 | x8 + x2 + x + 1 | CRC-8-CCITT
0x31 | x8 + x5 + x4 + 1 | CRC-8-Dallas/Maxim
0xD5 | x8 + x7 + x6 + x4 + x2 + 1 | CRC-8
0x1D | x8 + x4 + x3 + x2 + 1 | CRC-8-SAE-J1850
0x9B | x8 + x7 + x4 + x3 + x + 1 | CRC-8-WCDMA
0x8005 | x16 + x15 + x2 + 1 | CRC-16
0x1021 | x16 + x12 + x5 + 1 | CRC-16-CCITT
0x8BB7 | x16 + x15 + x11 + x9 + x8 + x7 + x5 + x4 + x2 + x + 1 | CRC-16-T10-DIF
0x3D65 | x16 + x13 + x12 + x11 + x10 + x8 + x6 + x5 + x2 + 1 | CRC-16-DNP
0xD589 | x16 + x10 + x8 + x7 + x3 + 1 | CRC-16-DECT

For LSB-first code

Value | Polynomial | Name
0xE0 | x8 + x2 + x + 1 | CRC-8-CCITT
0x8C | x8 + x5 + x4 + 1 | CRC-8-Dallas/Maxim
0xAB | x8 + x7 + x6 + x4 + x2 + 1 | CRC-8
0xB8 | x8 + x4 + x3 + x2 + 1 | CRC-8-SAE-J1850
0xD9 | x8 + x7 + x4 + x3 + x + 1 | CRC-8-WCDMA
0xA001 | x16 + x15 + x2 + 1 | CRC-16
0x8408 | x16 + x12 + x5 + 1 | CRC-16-CCITT
0xEDD1 | x16 + x15 + x11 + x9 + x8 + x7 + x5 + x4 + x2 + x + 1 | CRC-16-T10-DIF
0xA8BC | x16 + x13 + x12 + x11 + x10 + x8 + x6 + x5 + x2 + 1 | CRC-16-DNP
0x91A0 | x16 + x10 + x8 + x7 + x3 + 1 | CRC-16-DECT

3

High word of CRC polynomial representation; This word is reserved for CRC-32.

4

Low word of initial CRC value

5

High word of initial CRC value; This word is reserved for CRC-32.

6

Low word of final XOR value

7

High word of final XOR value; This word is reserved for CRC-32.

I: Internal Variable

Example:

$U100 = 16 /* CRC-16 */

$U101 = 1 /* LSB-first code */

$U102 = 0xA001 /* CRC-16-ANSI*/

$U104 = 0xFFFF /* Initial CRC value */

$U106 = 0 /* No final XOR value */

INIT_CRC($U100) /* Initialize the CRC calculation for Modbus */


Operation

Calculates the 8-bit CRC checksum of the data stored in P2 with a size of P3 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The word to save the result. The high byte of the word will be zero. The calculation should be initialized by the command INIT_CRC before or the result is meaningless. No need to re-initialize the calculation if the same CRC method is still in use.
P2 | I | The word block that contains the data of which the checksum is to be calculated. Note that the calculation takes only the low bytes of the words in the block. The high bytes are ignored.
P3 | I/C | The size of the word block in the unit of word. It also specifies the number of bytes involved in the checksum calculation.

I: Internal Variable; C: Constant

Example:

$U100 = “ABCDEEFGH”

$U110 = B2W($U100, 9) /* Convert byte array to word array */

$U120 = CRC8($U100, 9) /* Store the 8-bit CRC checksum of the string “ABCDEFGH” in $U120 */


Operation

Calculates the 16-bit CRC checksum of the data stored in P2 with a size of P3 and saves the result in P1.

Parameters:

Type

Description

P1

I

The word block to save the result.

Word No. | Description
0 | The low byte of the checksum will be saved in the low byte of this word. The high byte of this word will be 0.
1 | The high byte of the checksum will be saved in the low byte of this word. The high byte of this word will be 0.

The calculation should be initialized by the command INIT_CRC before or the result is meaningless. No need to re-initialize the calculation if the same CRC method is still in use.

P2

I

The word block that contains the data of which the checksum is to be calculated. Note that the calculation takes only the low bytes of the words in the block. The high bytes are ignored.

P3

I/C

The size of the word block in the unit of word. It also specifies the number of bytes involved in the calculation.

I: Internal Variable; C: Constant

Example:

$U100 = “ABCDEEFGH”

$U110 = B2W($U100, 9) /* Convert byte array to word array */

$U120 = CRC16($U100, 9) /* Store the 16-bit CRC checksum of the string “ABCDEFGH” in $U120 and $U121 */


Operation:

Converts binary number P2 to a BCD number and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The binary number to be converted.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U100 = BCD(0x1234) (U) /* The value of $U100 will be 1234 */


Operation:

Converts BCD number P2 to a binary number and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The BCD number to be converted.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U100 = BIN(1234) (U) /* The value of $U100 will be 0x1234 */


Operation:

Converts 16-bit number P2 to a 32-bit number and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The 16-bit number to be converted.

I: Internal Variable; E: External Variable; C: Constant

Examples:

$U100 = DW(12345) /* The value of $U100 will be 12345 and the value of $U101 will be 0 */

$U200 = DW(-12345) (S) /* The value of $U200 will be -12345 and the value of $U201 will be 0xFFFF */


Operation:

Converts 32-bit number P2 to a 16-bit number and saves the result in P1. The truncation error may occur.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The 32-bit number to be converted.

I: Internal Variable; E: External Variable; C: Constant

Examples:

$U100 = W(0x12345678) /* The value of $U100 will be 0x5678 */

$U200 = W(-12345) (SD) /* The value of $U200 will be -12345 */


Operation:

Converts P3-byte array starting from P2 to a P3-word array and saves the result in P1. All the high bytes of the word array are set to 0.

Parameters:

 | Type | Description
P1 | I | The location (or the word array) to save the result.
P2 | I | The byte array to be converted.
P3 | I/C | The size of the byte array.

I: Internal Variable; C: Constant

Example:

$U200 = 0x45FA

$U201 = 0xEB29

$U100 = B2W($U200, 3) /* Convert 3 bytes starting from $U200 to 3 words starting from $U100, $U100 will be 0xFA, $U101 will be 0x45 and $U102 will be 0x29 */


Operation:

Converts a word array P2 with P3 elements to a byte array and saves the result in the byte array P1. The conversion discards the high byte of every element of the word array to form a byte array with the same number of elements. The array size can not exceed 256.

Parameters:

 | Type | Description
P1 | I | The location (or the byte array) to save the result.
P2 | I | The word array to be converted.
P2 | I/C | The size of the word array.

I: Internal Variable; C: Constant

Example:

$U200 = 0x45FA

$U201 = 0xEB29

$U202 = 0xC781

$U100 = W2B($U200, 3) /* Convert 3 words starting from $U200 to 3 bytes starting from $U100, $U100 will be 0x29FA and the low byte of $U101 will be 0x81*/


Operation:

Converts a 4-digit hex number in ASCII character form to a binary number and saves the result in P1. The character of the fourth digit is in the first word of the word array P2 and the characters of the other digits are in the following words in sequence.

Parameters:

 | Type | Description
P1 | I | The location to save the result.
P2 | I | The word array that contains the characters to be converted.

I: Internal Variable

Example:

$U20 = 49 // '1'

$U21 = 50 // '2'

$U22 = 69 // 'E'

$U23 = 70 // 'F'

$U100 = A2X($U20)
/* The value of $U100 will be 0x12ef
*/


Operation:

Converts 16-bit number P2 to a 4-digit hex number in ASCII character form and saves the result in word array P1. The character of the fourth digit is saved in the first word of P1 and the characters of the other digits are saved in the following words in sequence.

Parameters:

 | Type | Description
P1 | I | The location (or the word array) to save the result.
P2 | I/C | The number to be converted.

I: Internal Variable; C: Constant

Example:

$U10 = X2A(0x34AB) /*The 4 words starting from $U10 will be: 51('3'), 52('4'), 65('A'), 66('B') */


Operation:

Converts 16-bit number P2 to a floating point number and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The 16-bit number to be converted.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U200 = W2F($U10) (S)


Operation:

Converts 32-bit number P2 to a floating point number and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The 32-bit number to be converted.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U200 = D2F($U10) (SD)


Operation:

Converts floating point number P2 to a 16-bit number and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The floating point number to be converted.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U200 = F2W($U10) (F)


Operation:

Converts floating point number P2 to a 32-bit number and saves the result in P1.

Parameters:

 | Type | Description
P1 | I/E | The location to save the result.
P2 | I/E/C | The floating point number to be converted.

I: Internal Variable; E: External Variable; C: Constant

Example:

$U200 = F2D($U10) (F)


Operation:

Extracts bit P3 from P2 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The bit to save the result.
P2 | I | The location to extract the bit.
P3 | I/C | The number of the bit to be extracted.

I: Internal Variable; C: Constant

Example:

$U2.0 = EXTRACT_BIT($U10, 31) (UD) /* Extract bit 31 of the double word $U10 and save the result in $U2.0 */


Operation:

Executes the commands in the command block following this IF command when P2 is equal to P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this IF command when P2 is not equal to P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this IF command when P2 is greater than P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this IF command when P2 is greater than or equal to P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this IF command when P2 is less than P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this IF command when P2 is less than or equal to P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this IF command when the result of Bitwise AND between P2 and P3 is non-zero.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this IF command when the result of Bitwise AND between P2 and P3 is zero.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this IF command when the condition P2 is true (1/On).

Parameters:

 | Type | Description
P2 | I/E/CE | The condition.

I: Internal Bit; E: External Bit; CE: Comparison Expression


Operation:

Executes the commands in the command block following this IF command if the condition P2 is false (0/Off).

Parameters:

 | Type | Description
P2 | I/E/CE | The condition.

I: Internal Bit; E: External Bit; CE: Comparison Expression


Operation:

Executes the commands in the command block following this ELIF command when P2 is equal to P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this ELIF command when P2 is not equal to P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this ELIF command when P2 is greater than P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this ELIF command when P2 is greater than or equal to P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this ELIF command when P2 is less than P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this ELIF command when P2 is less than or equal to P3.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this ELIF command when the result of Bitwise AND between P2 and P3 is non-zero.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this ELIF command when the result of Bitwise AND between P2 and P3 is zero.

Parameters:

 | Type | Description
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression


Operation:

Executes the commands in the command block following this ELIF command if the condition P2 is true (1/On).

Parameters:

 | Type | Description
P2 | I/E/CE | The condition.

I: Internal Bit; E: External Bit; CE: Comparison Expression


Operation:

Executes the commands in the command block following this ELIF command when the condition P2 is false (0/Off).

Parameters:

 | Type | Description
P2 | I/E/CE | The condition.

I: Internal Bit; E: External Bit; CE: Comparison Expression


Operation:

This command specifies the begin of the default command block that will be executed if none of the conditions in the preceding IF and/or ELIF commands is true. This is not an executable command.

IF-Command Structures:

Commands and Structures | Description
IF <condition> … ENDIF | Runs the command block between IF and ENDIF when the condition is true, otherwise ignores the command block.
IF <condition> … ELSE … ENDIF | Runs the command block between IF and ELSE when the condition is true, otherwise runs the command block between ELSE and ENDIF.
IF <condition_1> … ELIF <condition_2> … ELIF <condition_3> . . . ELIF <condition_N> … ENDIF | Runs the command block between IF and the first ELIF and ignores all the following commands in the structure when condition 1 is true, otherwise examines condition 2. Runs the command block between the first ELIF and the second ELIF and ignores all the following commands in the structure when condition 2 is true, otherwise checks condition 3. Repeats the same operation until condition N is processed. If none of the conditions are true, no command block in this structure is run.
IF <condition_1> … ELIF <condition_2> … ELIF <condition_3> . . . ELIF <condition_N> … ELSE … ENDIF | Runs the command block between IF and the first ELIF and ignores all the following commands in the structure when condition 1 is true, otherwise examines condition 2. Runs the commands block between the first ELIF and the second ELIF and ignores all the following commands in the structure when condition 2 is true, otherwise checks condition 3. Repeats the same operation until condition N is processed. Runs the command block between ELSE and ENDIF if none of the conditions are true.

Note that t here can be up to 20 nested IF-command structures.


Operation:

This command specifies the end of a command block, which begins at the command following the matching IF, ELIF, or ELSE command. This is not an executable command.

IF-Command Structures:

Commands and Structures | Description
IF <condition> … ENDIF | Runs the command block between IF and ENDIF when the condition is true, otherwise ignores the command block.
IF <condition> … ELSE … ENDIF | Runs the command block between IF and ELSE when the condition is true, otherwise runs the command block between ELSE and ENDIF.
IF <condition_1> … ELIF <condition_2> … ELIF <condition_3> . . . ELIF <condition_N> … ENDIF | Runs the command block between IF and the first ELIF and ignores all the following commands in the structure when condition 1 is true, otherwise examines condition 2. Runs the command block between the first ELIF and the second ELIF and ignores all the following commands in the structure when condition 2 is true, otherwise checks condition 3. Repeats the same operation until condition N is processed. If none of the conditions are true, no command block in this structure is run.
IF <condition_1> … ELIF <condition_2> … ELIF <condition_3> . . . ELIF <condition_N> … ELSE … ENDIF | Runs the command block between IF and the first ELIF and ignores all the following commands in the structure when condition 1 is true, otherwise examines condition 2. Runs the commands block between the first ELIF and the second ELIF and ignores all the following commands in the structure when condition 2 is true, otherwise checks condition 3. Repeats the same operation until condition N is processed. Runs the command block between ELSE and ENDIF if none of the conditions are true.

Note that t here can be up to 20 nested IF-command structures.


Operation:

Unconditionally jumps to the program point specified by label P1.

Parameters:

 | Type | Description
P1 | CS | The label of the program point.

CS: Character string

Example:

IF $U10 == 0

JMP SKIP /* Skip the command "$U20 = $U10 / 2" */

ENDIF

$U20 = $U10 / 2

SKIP:

$U10 = 1


Operation:

This is not an executable command. The P1 is the label of the program point where it is positioned.

Parameters:

 | Type | Description
P1 | CS | The character string as the label of the program point. Remember to have the character ':' after the label.

CS: Character string

Example:

IF $U10 == 0

JMP SKIP /* Skip the command "$U20 = $U10 / 2" */

ENDIF

$U20 = $U10 / 2

SKIP:

$U10 = 1


Operation:

Jumps to the program point specified by label P1 when P2 is equal to P3.

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Jumps to the program point specified by label P1 when P2 is not equal to P3.

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Jumps to the program point specified by label P1 when P2 is greater than P3.

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Jumps to the program point specified by label P1 when P2 is greater than or equal to P3.

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Jumps to the program point specified by label P1 when P2 is less than P3.

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Jumps to the program point specified by label P1 when P2 is less than or equal to P3.

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Jumps to the program point specified by label P1 when the result of Bitwise AND between P2 and P3 is non-zero.

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Jumps to the program point specified by label P1 when the result of Bitwise AND between P2 and P3 is zero.

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Jumps to the program point specified by label P1 if the condition P2 is true (1/On).

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 | I/E/CE | The condition.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Jumps to the program point specified by label P1 if the condition P2 is false (0/Off).

Parameters:

 | Type | Description
P1 | CS | The label of the program point.
P2 | I/E/CE | The condition.

I: Internal Variable; E: External Variable; C: Constant; CS: Character string; AE: Arithmetic Expression


Operation:

Goes to sub-macro P1.

Parameters:

 | Type | Description
P1 | Sub-macro name | The sub-macro to be called.

Example:

CALL CommonFunction_01 /* Go to sub-macro named CommonFuncation_01 */


Operation:

Returns to the calling macro. This command can only be used in sub-macros.


Operation:

Runs the commands within the FOR loop by P2 times. A FOR loop is enclosed by a matching pair of FOR and NEXT commands. There can be up to 20 nested FOR loops.

Parameters:

 | Type | Description
P2 | I/C | Total times to run the FOR loop. Note: If P2 is an internal variable, the value of P2 will be decreased by 1 after each loop. If the value of P2 is 1, the loop will be executed before exiting.

I: Internal Variable; C: Constant;

Example:

FOR 10

$U100 = $U100 + 1 /* This command will be executed 10 times */

FOR 12

$U200 = $U200 + 1 /* This command will be executed 120 times */

NEXT

NEXT

$U1 = 10

FOR $U1

$U100 = $U100 + 1 /* This command will be executed 10 times. */

$U2 = 12

FOR $U2

$U200 = $U200 + 1 /* This command will be executed 120 times. */

NEXT

NEXT


Operation:

This command indicates the end of a FOR loop. It is not an executable command.

Example:

$U1 = 10

$U2 = 12

FOR $U1

$U100 = $U100 + 1 /* This command will be executed 10 times. */

$U4 = $U2

FOR $U4

$U200 = $U200 + 1 /* This command will be executed 120 times. */

NEXT

NEXT

$U1 = 10

$U2 = 12

FOR $U1

$U100 = $U100 + 1 /* This command will be executed 10 times. */

FOR $U2 /* The value of $U2 is decreased by 1 after each loop. If the value of $U2 is 1, run the loop and then exit the loop. */

$U200 = $U200 + 1 /* This command will be executed 21 times. */

NEXT

NEXT


Operation:

Stops the macro immediately. If the macro is a Cycle macro, it will be run again starting from the first command when the associated window is opened again. If the macro is Main macro, it will be run again starting from the first command when restarting the application.

This command can not be used in sub-macros.


Operation:

Indicates the end of macro and stops the macro in the current cycle. It can be put anywhere in a macro to stop the macro at any point. If the macro is a cyclic macro, such as the Main macro and the Cycle macros, it is stopped just in the current cycle and will be run again starting from the first command in the next cycle.

This command can not be used in sub-macros.


Operation:

Report the result P1 of examining the qualification of the current record for the current query and stop the macro.

Parameters:

 | Type | Description
P1 | I | The result of qualification. Value 1 represents qualified. Value 0 represents unqualified.

I: Internal Variable

Example:

QRET($U100) /* The current record is qualified in the query if $U100 is 1.*/


Operation:

Starts the timer P1 using the timer control block in P2.

Parameters:

Type

Description

P1

C

The ID of the timer. There are 8 timers available and the IDs are 0 to 7. Those models that are based on Windows, WinCE, and ARM11 CPU have extra 4 timers and the IDs are 8 to 11.

P2

I

The starting location of the memory block (or word array) that is used as a Timer Control Block for the timer. The structure of the Timer Control Block is shown below:

Word No.

Data Item

Description

0

Type of operation

0: One-shot; 1: Square-wave

1

Current timer value

The timer increases the value of this word by 1 every 100ms.

2

Timer limit

When the current timer value reaches the timer limit, the timer will perform one of the following operations according to the type of operation:

1) If the type of operation is One-shot (0), sets the time-up flag to 1, resets the current timer value to 0, and stops itself.

2) If the type of operation is Square-wave (1), toggles the time-up flag, resets the current timer value to 0, and continues the timing operation.

3 Time-up flag This word will be set to 0 or 1 when the current timer value is equal to the timer limit.

4

Number of bits

The number of bits to be rotated. The maximum is 32. The word is required only for operation type 3 (Square-wave with bits rotating).

For example, when the number of bits is 24, the rotation will work on bit 0 through bit 23 and keep bit 25 through bit 31 intact. Each rotation will shift bit 0 through bit 22 left and rotates bit 23 to bit 0.

5

Bits 0 to 15

The word contains bit 0 through bit 15 of the rotate operation. The word is required only for operation type 3.

6

Bits 16 to 31

The word contains bit 16 through bit 31 of the rotate operation. The word is required only for operation type 3 with more than 16 bits to be rotated.

The timer will use the associated Timer Control Block as its private memory, so do not use any words in the block for other purposes.

A Timer Control Block require s 4, 6, or 7 words.

I: Internal Variable; C: Constant

Example:

$U100 = 1 /* Type of operation is Square-wave. */

$U101 = 0 /* Initialize the current timer value to 0. */

$U102 = 5 /* Timer limit is 0.5 second (5*100ms). */

$U103 = 0 /* Initialize the time-up flag to 0. */

SET_T(3, $U100) /* Use timer #3 to generate a 1 Hz square wave on $U103.0 */


Operation:

Stops the timer P1.

Parameters:

 | Type | Description
P1 | C | The ID of the timer.

C: Constant

Example:

STOP_T(1) // Stop timer #1


Operation:

Waits for the time-up of timer P1. The macro command following this one will not be executed until the timer reaches its limit.

Parameters:

 | Type | Description
P1 | C | The ID of the timer.

C: Constant

Example:

$U100 = 0 /* Type of operation is One-shot. */

$U101 = 0 /* Initialize the current timer value to 0. */

$U102 = 5 /* Timer limit is 0.5 second (5*100ms). */

$U103 = 0 /* Initialize the time-up flag to 0. */

SET_T(7, $U100) /* Starts timer #7 as a 0.5 second timer */

WAIT_T(7) /* Wait 0.5 second */


Operation:

Accepts or ignores the character/command currently input by the associated keypad button. This command must be used only in a macro that is run by a keypad button. A keypad button runs the specified macro when it is pressed. You can use this command in a keypad button macro to accept or ignore the current input of that button.

Parameters:

 | Type | Description
P1 | I/C | The value or the location that holds the value to determine the acceptance of the keypad button input. If the value is 0, the input will be accepted; Otherwise the input will be ignored.

I: Internal Variable; C: Constant

Example:

KB_MCR(1)
/* Ignore the current input
*/


Operation:

Initialized the keypad display and buffer using the string P1.

Parameters:

 | Type | Description
P1 | I | The memory block (or byte array) that contains the null-terminated ASCII character string to be used to initialize the keypad display and buffer.

I: Internal Variable

Example:

$U100 = "initial text"

KPD_TEXT($U100) /* Initialize the keypad display and buffer using the string "initial text". */


Operation:

Outputs a string of character/command codes to the current keypad.

Parameters:

Type

Description

P1

I/C

The number of character/command codes to be output.

P2

I/C

The starting location of the word array that contains the codes to be output. Each word of the array contains one code. If only one code is to be output, you can specify the code directly with P2.

The valid character codes are from 32 to 127, which represent displayable ASCII characters.

The valid command codes are listed in the following table:
Command Code | Command
13 | Enter
24 | Clear
27 | Escape

I: Internal Variable; C: Constant

Example 1:

$U100 = 45 // '-'

$U101 = 49 // '1'

$U102 = 50 // '2'

$U103 = 51 // '3'

$U104 = 46 // '.'

$U105 = 52 // '4'

$U106 = 53 // '5'

$U107 = 13 // Enter

TO_KPD(8, $U100) /* Enter the number -123.45 automatically with the current keypad */

Example 1:

TO_KPD(1, 27) /* Cancel the current keypad */


Operation:

Saves the data of recipe block P2 to the flash ROM and saves the completion code in P1.

Parameters:

 | Type | Description
P1 | I | The word to receive the completion code. If the completion code is 0, the operation succeeded; Otherwise the operation failed.
P2 | I/C | The ID of the recipe block to be saved. The option "Need space in flash ROM to save backup" must be selected for the recipe block.

I: Internal Variable; C: Constant

Example:

$U10 = RB2ROM(3) /* Save recipe block #3 to the flash ROM */


Operation:

Restores the data of recipe block P2 from the flash ROM and saves the completion code in P1.

Parameters:

 | Type | Description
P1 | I | The word to receive the completion code. If the completion code is 0, the operation succeeded; Otherwise the operation failed.
P2 | I/C | The ID of the recipe block to be restored. The option "Need space in flash ROM to save backup" must be selected for the recipe block.

I: Internal Variable; C: Constant

Example:

$U10 = ROM2RB(3) /* Restore recipe block #3 from the flash ROM */


Operation:

Refreshes the recipe objects associated with the specified recipe block P1. The recipe objects include recipe selectors and recipe tables. You can use this command to update the display of associated objects after changing the data of a recipe block in a macro program.

Parameters:

 | Type | Description
P1 | I/C | The ID of the associated recipe block.

I: Internal Variable; C: Constant

Example:

REF_RCP_OBJ(3) /* Refresh the recipe objects associated with recipe block #3 */


Operation:

Enables communication link P1 or sub-link P2 of communication link P1 when P3 is 1. Disables the specified communication link or sub-link when P3 is 0.

Parameters:

 | Type | Description
P1 | I/C | The number of the communication link to be enabled or disabled.
P2 | I/C | The node address of the sub-link to be enabled or disabled. If the specified communication link has no sub-link, this parameter is ignored. If the specified communication link has sub-links and you want to enable or disable the link itself, set this parameter to 0.
P3 | I/C | To enable the specified communication link or sub-link, set this parameter to 1. To disable the specified communication link or sub-link, set this parameter to 0.

I: Internal Variable; C: Constant

Example:

ENABLE_LINK(1, 20, 0) /* Disable the sub-link, whose node address is 20, of communication link 1. */


Operation:

Gets the status of communication link P2 or the sub-link P3 of communication link P2 and saves the result in P1.

Parameters:

Type

Description

P1

I

The word to receive the status of the specified communication link or sub-link. The status is a 16-bit value. The following table lists the meaning of each status value.

Status Value | Meaning
0 | OK
1 | Overrun error
2 | Break error
3 | Parity error
4 | Framing error
5 | No response
6 | Unrecognized response
7 | Timeout
8 | Inactive CTS
9 | Checksum error
10 | Command rejected
11 | Invalid address
12 | Invalid range
13 | Invalid request
14 | Device busy
15 | Unknown error
16 | Link disabled
17 | Initialization failure
18 | Failed to send data
19 | Failed to receive data
20 | Failed to open connection
21 | Connection not ready
22 | Invalid sub-link
23 | Invalid COM port
24 | Error
255 | Condition uncertain
65535 | Failed to get status

P2

I/C

The number of the communication link.

P3

I/C

For a sub-link of a serial link, specify the node address of the sub-link. For a sub-link of an Ethernet link, specify the sub-link ID of the sub-link. If the specified communication link has no sub-link, this parameter is ignored.

I: Internal Variable; C: Constant

Examples:

$U100 = LINK_STS(2, 0) /* Get the status of communication link 2 and save it to $U100. */

$U12 = LINK_STS(1, 128) /* Get the status of the sub-link, whose node address is 128, of communication link 1 and save it to $U12. */


LINK_PAR

Operation:

Accesses the communication parameters of an Ethernet link or a sub-link of an Ethernet link.

Parameters:

Type

Description

P1

I/C

The operation of the access.

Operation | Value
Get parameters | 0
Set parameters | 1

P2

I/C

The number of the communication link. For example, the number of the first link is 1. Note that the link must be an Ethernet link or the operation will fail.

P3

I/C

The ID of the sub-link. If the specified communication link has no sub-link, this parameter is ignored.

P4

I

The starting location of the memory block that stores the parameters. The memory arrangement of the block is shown in the following table.

Word No.

Description

0

The communication delay. The unit is 1 millisecond.

1

The timeout time. The unit is 0.1 second.

2,3

The IP address. The four bytes of this double-word stores the 4 numbers of an IP address.

Byte | Content
High byte of word No. 3 | The 1st number
Low byte of word No. 3 | The 2nd number
High byte of word No. 2 | The 3rd number
Low byte of word No. 2 | The 4th number

[Example]

The following table shows how the IP address '192.168.1.100' is stored in the memory block when the memory block starts at $U100.

Byte | Content | Remark
HIgh byte of $U103 | C0H (192) | The word value of $U103 is C0A8H
Low byte of $U103 | A8H (168) |
High byte of $U102 | 01H (1) | The word value of $U102 is 0164H
Low byte of $U102 | 64H (100) |

[Note]

You can use a numeric entry object to display and enter an IP address. When configuring a numeric entry object to display an IP address, Select '32-Bit Unsigned Integer' as the Data Type and select 'IP Address' as the Display Type.

4

The IP port number.

5

Reserved

6

Reserved

7

Reserved

I: Internal Variable; C: Constant

Examples:

LINK_PAR(0, 1, 2, $U100) /* Get the communication parameters of sub-link 2 of communication link 1 and save it to the memory block starting at $U100. */

$U200 = 10 (U) /* Will be used to set the command delay to 10 ms */

$U201 = 1 (U) /* Will be used to set the timeout time to 0.1 second */

$U202 = C0A80164H (UD) /* Will be used to set the IP address to 192.168.1.100 */

$U204 = 2000 (U) /* Will be used to set the IP port to 2000 */

LINK_PAR(1, 2, 0, $U200) /* Set the communication parameters of link 2 using the data stored in the memory block starting at $U200. */


Operation:

Gets the data of the real time clock and saves the result in P1.

Parameters:

Type

Description

P1

I

The starting location of the memory block that is used as an RTC data block to receive the operation result. The structure of the RTC data block is shown below:

Data Item | Data Type/Size | Word No.
Second | 16-bit Unsigned Integer | 0
Minute | 16-bit Unsigned Integer | 1
Hour | 16-bit Unsigned Integer | 2
RTC adjustment | 16-bit Signed Integer | 3
Day | 16-bit Unsigned Integer | 4
Month | 16-bit Unsigned Integer | 5
Year | 16-bit Unsigned Integer | 6
Day of week | 16-bit Unsigned Integer | 7

Second: 0~59; Minute: 0~59; Hour: 0~23; RTC adjustment: -63~63; Day: 1~31; Month: 1~12; Year: 0(2000)~99(2099); Day of week: 0(Sunday)~6(Saturday)

An RTC data block requires 8 words.

I: Internal Variable

Example:

GET_RTC($U100) /* Get the data of the real time clock. The second will be in $U100 and the day-of-week will be in $U107. */


Operation:

Sets the real time clock using the data in P1.

Parameters:

 | Type | Description
P1 | I | The starting location of the memory block that is used as an RTC data block to contain the new settings for the real time clock. See the description of GET_RTC to know the structure of the RTC data block.

I: Internal Variable

Example:

$U100 = 0 // Second

$U101 = 30 // Minute

$U102 = 8 // Hour

$U103 = 0 // Adjustment

$U104 = 1 // Day

$U105 = 7 // July

$U106 = 10 // Year 2010

$U107 = 4 // Thursday

SET_RTC($U100) /* Set the real time clock to 8:30:00 July 1st 2010 Thursday */


Operation:

Requests system service P1 with the arguments P2 and P3. This command is reserved for system use.

Parameters:

 | Type | Description
P1 | I/C | The code of the system service.
P2, P3 | I/C | The arguments of the system service.

I: Internal Variable; C: Constant


Operation:

Switches the LCD backlight.

Parameters:

Type

Description

P1

I/C

Specifies the switch operation.

P1 | Operation
0 | Turns off the backlight.
1 | Turns on the backlight.

I: Internal Variable; C: Constant

Example:

SetBacklight(0) /* Turn off the backlight. */


Operation:

Sets the wait time of the screen saver.

Parameters:

 | Type | Description
P1 | I/C | The wait time. The time unit is minute. The screen saver is disabled when the wait time is 0.

I: Internal Variable; C: Constant

Example:

SetScreenSaver(20) /* Set the wait time of the screen saver to 20 minutes. */


Operation:

Sets the properties of the idle processing.

Parameters:

Type

Description

P1

I/C

Specifies the setting operation.

P1 | Operation
0 | Resets all properties to the original settings.
1 | Sets the idle time.
2 | Sets the idle screen.
3 | Sets the user level.

P2

I/C

Specifies the property of the designated operation.

P1 | P2
0 | 0
1 | The idle time. The time unit is minute. The idle processing is disabled when the idle time is 0.
2 | The idle screen number. The HMI will display the idle screen when it enters in the idle mode. Set P2 to 0 if no idle screen is to display.
3 | The user level that the HMI will change to when it enters in the idle mode. A valid user level is between 0 and 8. Set P2 to 255 if changing user level is not required.

I: Internal Variable; C: Constant

Example:

SetIdleProc(2, 10) /* Set the idle screen to screen No. 10. */


Utilities - System - GetID

Operation:

Gets P2 type of the identifier of the HMI unit and saves the result starting from P1.

Parameters:

Type

Description

P1

I

The starting location of the memory block to save the identifier.

Two kinds of data can be used as the identifier of an HMI unit, which are the product serial number and the MAC address of an Ethernet port. The required sizes of memory to save the two kinds of identifiers are different. The product serial number needs seven words because the serial number is a string with 14 characters. The MAC address needs six words because the address is composed of 6 numbers.

P2

I/C

The type of the identifier.

The following table describes the type codes and the supporting HMI models:

Type Code | Type of identifier | Supporting models
0 | Product serial number | T Series HMI
1 | MAC address of the first Ethernet port | T Series HMI; PC runtime
2 | MAC address of the second Ethernet port | PC runtime

I: Internal Variable; C: Constant

Example:

$U100 = GetID(0) /* Get the HMI’s serial number. The result is saved in $U100-$U106 */

$U110 = “07WT4DX1130118”

$U120 = STRNCMP($U100, $U110, 14) /* Set $U120 to 0 if the identifier is 07WT4DX1130118 */


Operation:

Sets the brightness of the LCD.

Parameters:

 | Type | Description
P1 | I/C | Specifies the brightness level. A valid level is between 0 and 15. Level 0 is the darkest and level 15 is the brightest.

I: Internal Variable; C: Constant


Operation:

Sets the adjustable range of the LCD brightness. The range is determined by two values: the darkest percentage (P1) and the brightest percentage (P2).

Parameters:

 | Type | Description
P1 | I/C | Specifies the darkest percentage which is the percentage of the least brightness that is allowed to set to the full brightness of the display. A valid value is between 0 and 99 and must be less than the brightest percentage.
P2 | I/C | Specifies the brightest percentage which is the percentage of the most brightness that is allowed to set to the full brightness of the display. A valid value is between 1 and 100 and must be greater than the darkest percentage.

I: Internal Variable; C: Constant

Example:

SetBriRange(10,85) /* The adjustable range is between 10% and 85% of the full brightness when the darkest percentage and the brightest percentage are 10 and 85 respectively. */


Operation:

Sets or gets the network related addresses. The command is available to RTOS based products only.

Parameters:

Type

Description

P1

I/C

The type of operation.

Operation Type | Code | Remark
Get Address | 0 |
Set Address | 1 | The command will close all the communication links of the application before setting the specified addresses and reset the option 'Panel Setup|GeneralGet An IP Address Automatically' to 'False'. The application needs be restarted to make the new addresses effective and make all the communication links work again.
Use DHCP | 2 | Sets the option 'Panel Setup|GeneralGet An IP Address Automatically' to 'True'. The application needs be restarted to make the option effective.
Stop Using DHCP | 3 | Resets the option 'Panel Setup|GeneralGet An IP Address Automatically' to 'False'. The application needs be restarted to make the change effective.

P2

I/C

Specifies which addresses are to be set when the operation type is Set Address. The following table lists the corresponding addresses of the parameter's bits

Bit No. | When the Bit Is On
0 | Set the IP address
1 | Set the subnet mask
2 | Set the gateway address
3 | Set the address of the primary DNS
4 | Set the address of the alternative DNS
5 | Set the name of the HMI unit
6~15 | Reserved

Set the parameter to 0 when the operation type is not Set Addresses.

P3

I

The starting location of the memory block that stores the addresses.

Word No. | Description
0~1 | IP address
2~3 | Subnet mask
4~5 | Gateway address
6~7 | Primary DNS address
8~9 | Alternative DNS address
10~17 | The 16-byte array stores the name of the HMI unit. The name is a null terminated ASCII string and can have up to 15 characters.

I: Internal Variable; C: Constant

Example:

$U100 = 0xC0A80120 (UD) /* The new IP address will be 192.168.1.32 */

$U102 = 0xFFFFFF00 (UD) /* The new subnet mask will be 255.255.255.0 */

$U104 = 0xC0A80101 (UD) /* The new gateway address will be 192.168.1.1 */

$U110 = "MyHMI" /* The new HMI name will be MyHMI */

NET_ADDR(1, 0x27, $U100) /* 1: Set Address */

/* 0x27: Select the addresses to modify: IP address, subnet mask, gateway address, name of the HMI unit */

/* $U100: Where the new addresses are stored */


Operation:

Terminates the application.

Parameter:

Type

Description

P1

I/C

Specifies the type of termination.

Code | Description
0 | Terminates the application unconditionally

I: Internal Variable; C: Constant

Example:

EXIT(0)


Operation:

Opens the window screen specified by P1. This command can only be used in a Cycle Macro.

Parameters:

 | Type | Description
P1 | I/C | The number of the window screen to be opened. This command will not open the specified screen if it is a normal screen or menu screen. The macro commands following this command will not be executed until the opened window screen is closed. Also, when a screen's Cycle macro is waiting for the closing of the window screen opened by this command, that screen can not be closed or switched by any means.

I: Internal Variable; C: Constant


Operation:

Closes the window screen and terminates the Cycle macro when it is executed. This command can only be used in a Cycle macro of a window screen.


Operation:

Sets the initial position of the specified window screen. The window screen will be shown at the specified position when it is opened.

Parameters:

 | Type | Description
P1 | I/C | The number of the window screen.
P2 | I/C | The X-coordinate of the initial position. If you want the window screen to be shown at the center of the display, set P2 to 65535.
P3 | I/C | The Y-coordinate of the initial position.

I: Internal Variable; C: Constant

Example:

InitWndPos(10, 120, 100) /* Set the initial position of the window screen No. 10 at (120, 100) */


Operation

Opens the screen specified by P1 at the designated position (P2, P3).

Parameters:

 | Type | Description
P1 | I | The number of the screen to be opened. The command can open any kind of screen. If the specified screen is a normal screen, the command closes the currently displayed normal screen before opening the specified screen. If the specified screen is a menu screen, the screen will be dragged down at the designated position. If the specified screen is nonexistent or already opened, the operation is cancelled.
P2 | I | The x-coordinate of the position where the upper-left corner of the screen is placed at. The parameter is ignored when the specified screen is a normal screen because a normal screen is always displayed at (0, 0). If the parameter makes the right part of the screen unseen, the command will move the screen left to make the whole screen visible. To center the screen on the display, set P2 to 65535 (0xffff).
P3 | I/C | The y-coordinate of the position where the upper-left corner of the screen is placed at. The parameter is ignored when the specified screen is a normal screen or the value of P2 is 65535 (0xffff). If the parameter makes the lower part of the screen unseen, the command will move the screen up to make the whole screen visible.

I: Internal Variable; C: Constant

Example:

OpenScreen(10, 0, 0) /* Open the normal screen numbered 10 */

OpenScreen(35, 120, 200) /* Open the window screen numbered 35 and place it at the position (120, 200) */

OpenScreen($U50, 65535, 0) /* Open the window screen specified by the internal word $U50 at the center of the display */


Operation

Closes the window screen or menu screen specified by P1.

Parameters:

 | Type | Description
P1 | I/C | The number of the window screen or menu screen to be closed.

I: Internal Variable; C: Constant

Example:

CloseScreen(27) /* Close the window screen numbered 27 */


Operation:

Performs the file operation specified by P2 and P3 using default filename and saves the completion code in P1.

Parameters:

Type

Description

P1

I

The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise the operation failed.

Note: This command can only be used in the following types of macros: Main Macro, Event Macro, Time Macro, and Cycle Macro.

P2, P3

I/C

P2 specifies the type of file operation. P3 specifies the ID of the data source. The following table describes how to set P2 and P3.

File Operation | P2 | P3
Save Logged Data (.txt) | 1 | Data logger ID (0~15)
Save Logged Data (.csv) | 14 | Data logger ID (0~15)
Save Logged Alarms (.txt) | 2 | 0
Save Logged Alarms (.csv) | 15 | 0
Save Alarm Counts (.txt) | 3 | 0
Save Alarm Counts (.csv) | 16 | 0
Save Recipe Data (.txt) | 4 | Recipe block ID (0~15)
Save Recipe Data (.csv) | 17
Save Recipe Data (.prd) | 5
Read Recipe Data (.csv) | 19
Read Recipe Data(.txt) | 20
Read Recipe Data(.prd) | 21
Print Screen to File (256-color .bmp) | 6 | Screen number (1~7999)
Print Screen to File (64K-color .bmp) | 7 | Screen number (1~7999)
Save Logged Operations (.txt) | 9 | 0
Save Logged Operations (.csv) | 18 | 0
Save Logged Data (.ldf) | 10 | Data logger ID (0~15)
Take Picture (.bmp) | 12 | USB camera ID (0~3)
Take Picture (.jpg) | 13 | USB camera ID (0~3)
Print Screen to File(.jpg) | 22 | Screen number (1-7999)
Take Picture for HMI units (.jpg) | 23 | Video Channel ID (1-2)

I: Internal Variable; C: Constant

Default Filename:

File Operation | Filename Format | Remark
Save Logged Data (.txt) | DL<ID>_<Date>_<Time>.txt | <ID>: Data logger ID
Save Logged Data (.csv) | DL<ID>_<Date>_<Time>.csv | <ID>: Data logger ID
Save Logged Alarms (.txt) | AL_<Date>_<Time>.txt |
Save Logged Alarms (.csv) | AL_<Date>_<Time>.csv |
Save Alarm Counts (.txt) | AC_<Date>_<Time>.txt |
Save Alarm Counts (.csv) | AC_<Date>_<Time>.csv |
Save Recipe Data (.txt) | RB<ID>.txt | <ID>: Recipe block ID
Save Recipe Data (.csv) | RB<ID>.csv
Save Recipe Data (.prd) | RB<ID>.dat
Read Recipe Data (.csv) | RB<ID>.csv
Read Recipe Data(.txt) | RB<ID>.txt
Read Recipe Data(.prd) | RB<ID>.dat
Print Screen to File (256-color .bmp) | S<ID>_<Date>_<Time>.bmp | <ID>: Screen number
Print Screen to File (64K-color .bmp) | S<ID>_<Date>_<Time>.bmp | <ID>: Screen number
Save Logged Operations (.txt) | OL_<Date>_<Time>.txt |
Save Logged Operations (.csv) | OL_<Date>_<Time>.csv |
Save Logged Data (.ldf) | DL<ID>_<Date>_<Time>.ldf | <ID>: Data logger ID
Take Picture (.bmp) | CAM<ID>_<Date>_<Time>.bmp | <ID>:USB camera ID
Take Picture (.jpg) | CAM<ID>_<Date>_<Time>.jpg | <ID>:USB camera ID
Print Screen to File(.jpg) | S<ID>_<Date>_<Time>.jpg | <ID>: Screen number
Take Picture for HMI units (.jpg) | V<ID>_<Date>_<Time>.jpg | <ID>: Video Channel ID

Note:

<Date>: The date when saving the data.

<Time>: The time when saving the data.

You can select the formats of <Date> and <Time> on the Custom page in the General Setup dialog box.

You can select not to show the progress bar when the macro command is executed. To hide the progress bar, use the normal operation code plus 100. For example, to save the logged data to a CSV file without showing the progress bar, use the code 114 (100+14) instead of 14.


Operation:

Performs the file operation specified by P2 and P3 using filename P4 and saves the completion code in P1.

Parameters:

Type

Description

P1

I

The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise the operation failed.

Note: This command can only be used in the following types of macros: Main Macro, Event Macro, Time Macro, and Cycle Macro.

P2, P3

I/C

P2 specifies the type of file operation. P3 specifies the ID of the data source. The following table describes how to set P2 and P3.

File Operation | P2 |  | P3
Save Logged Data (.csv/.txt) | 31 |  | Data logger ID (0~15)
Save Logged Alarms (.txt) | 32 |  | 0
Save Alarm Counts (.txt) | 33 |  | 0
Save Recipe Data (.csv/.txt) | 34 |  | Recipe block ID (0~15)
Save Recipe Data (.prd) | 35 |  | Recipe block ID (0~15)
Print Screen to File (256-color .bmp) | 36 |  | Screen number (1~7999)
Print Screen to File (64K-color .bmp) | 37 |  | Screen number (1~7999)
Save Logged Operations (.txt) | 39 |  | 0
Save Logged Data (.ldf) | 40 |  | Data logger ID (0~15)
Take Picture (.bmp) | 42 |  | USB camera ID (0~3)
Take Picture (.jpg) | 43 |  | USB camera ID (0~3)
Print Screen to File (.jpg) | 52 |  | Screen number (1-7999)
Take Picture for HMI units (.jpg) | 53 |  | Video channel ID (1-2)
Append Logged Data (in CSV/TXT format) | 231 |  | Data logger ID (0~15)
Append Logged Alarms | 232 |  | 0
Append Logged Operations | 239 |  | 0
Load Logged Data (in CSV/TXT format) | Code | ID of the file buffer that the loaded data will be stored | Data logger ID (0~15)
 | 1000 | 0
 | 1001 | 1
 | 1002 | 2
 | ... | ...
 | 1015 | 15

Note: You can select not to show the progress bar when the macro command is executed. To hide the progress bar, use the normal operation code plus 100. For example, to save the logged data to a CSV file without showing the progress bar, use the code 131 (100+31) instead of 31.

P4

I

The byte array that contains the specified filename or full pathname. The name must be a valid Windows pathname with ASCII characters only. The character string must be null terminated and each character occupies one byte. The maximum length of the string is 127. All the folders stated in the full pathname must already exist or the file operation will fail.

I: Internal Variable; C: Constant


Operation:

Creates a directory using the name specified by P2. The completion code will be saved in P1.

Parameters:

 | Type | Description
P1 | I | The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise the operation failed.
P 2 | I | The byte array that contains the name of the new directory. The name must be a valid directory name with or without pathname and has only ASCII characters in it.

I: Internal Variable


Operation:

Creates or opens a file.

Parameters:

Type

Description

P1

I

The starting location of the memory block that is used as a File Information Block to receive the operation result. The structure of the File Information Block is shown below:

Data Item | Data Type/Size | Word No.
File handle | 32-bit Unsigned Integer | 0 and 1
File size | 32 bit Unsigned Integer | 2 and 3
Filename | Byte array with 81 elements | 4 through 44

The file handle is zero if the operation failed.

The file size is zero for a newly created file.

The filename is a null-terminated character string. The maximum allowable size is 80. It is set when the file is successfully opened.

A File Information Block requires 45 words.

P2

I

The byte array that contains the filename or the full pathname of the file to be opened. The name is a null-terminated string and has only ASCII characters in it.

P 3

I/C

Specifies the purpose of opening the file.

Purpose | Value
Read | 0
Write | 1
Append | 3
Read CSV File | 5

I: Internal Variable; C: Constant

Example:

$U10 = “test.txt”

$U100 = OPEN_FILE($U10, 0) /* Open the file “test.txt” for the read operation. The double word $U100 will contain the file handle. The double word $U102 will contain the file size. The byte array $U104 will contain the filename. */


Operation:

Reads P4 bytes from file P2 to buffer P3 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The word to receive the number of bytes that were actually read. If the operation failed, the number is 65535 (0xFFFF).
P2 | I | The file handle of the file to be read.
P 3 | I | The memory block to receive the data read from the file.
P 4 | I/C | Number of bytes to be read from the file. The maximum you can specify is 32767(0x7FFF).

I: Internal Variable; C: Constant

Example:

$U200 = READ_FILE($U100,$U150,20) /* Read 20 bytes from the file specified by the file handle in $U100 and saves the data in the memory block starting from $U150. */


Operation:

Writes P4 bytes of data in P3 to file P2 and saves the completion code in P1.

Parameters:

 | Type | Description
P1 | I | The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; Otherwise the operation failed.
P2 | I | The file handle of the file.
P 3 | I | The memory block (or byte array) that stores the data to be written to the file.
P 4 | I/C | Number of bytes to be written to the file.

I: Internal Variable; C: Constant

Example:

$U200=WRITE_FILE($U100,$U150,30) /* Write 30 bytes of data stored in the memory block starting from $U150 to the file specified by the file handle in $U100. */


Operation:

Closes an opened file P2 and saves the completion code in P1.

Parameters:

 | Type | Description
P1 | I | The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; Otherwise the operation failed.
P2 | I | The file handle of the file to be closed.

I: Internal Variable

Example:

$U200=CLOSE_FILE($U100) /* Close the file specified by the file handle in $U100. */


Operation:

Deletes a file named P2 and saves the completion code in P1.

Parameters:

 | Type | Description
P1 | I | The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; Otherwise the operation failed.
P2 | I | The byte array that contains the filename or the full pathname of the file to be deleted. The name is a null-terminated string and has only ASCII characters in it.

I: Internal Variable

Example:

$U10 = “test.txt”

$U200 = DELETE_FILE($U10) /* Delete the file “test.txt” */


Operation:

Deletes the files that are older than a specified number of days in a folder. Note: You can use the command only in a Main macro, Event macro, Time macro, or Cycle macro.

Parameters:

Type

Description

P1

I

The word parameter receives the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise, the operation failed.

P2

I/C

The parameter specifies the execution options:

1. If the target files are any files or a certain type of files (Bit 3~0)

2. If the sub-folders are included (Bit 4)

3. If the progress bar shows (Bit 5)

The following table lists the valid parameter values and the corresponding options.

Value | Type of Target Files | Include Sub-folders | Show Progress Bar
0 | csv | No | Yes
16 | csv | Yes | Yes
32 | csv | No | No
48 | csv | Yes | No
1 | txt | No | Yes
17 | txt | Yes | Yes
33 | txt | No | No
49 | txt | Yes | No
2 | ldf | No | Yes
18 | ldf | Yes | Yes
34 | ldf | No | No
50 | ldf | Yes | No
3 | jpg | No | Yes
19 | jpg | Yes | Yes
35 | jpg | No | No
51 | jpg | Yes | No
15 | * (Any file) | No | Yes
31 | * (Any file) | Yes | Yes
47 | * (Any file) | No | No
63 | * (Any file) | Yes | No

P3

I

The parameter is the starting address of a byte array that specifies the pathname of the folder of the target files. The pathname is a null-terminated ASCII character string and can have up to 48 characters.

P4

I/C

Specifies the number of days. For example, to delete files that are older than 30 days, set the parameter to 30.

I: Internal Variable; C: Constant

Example:

$U100 = "c:\" /* The target files are under the root directory of drive C */

$U200 = DEL_OLD_FILES(48, $U100, 10) /* Delete all the CSV files in drive C that are older than 10 days */

/* Do not show the progress bar */

/* Save the completion code in $U200. */


Operation:

Renames file P2 with new name P3 and saves the completion code in P1.

Parameters:

 | Type | Description
P1 | I | The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; Otherwise the operation failed.
P2 | I | The byte array that contains the filename or the full pathname of the file to be renamed. The name is a null-terminated string and has only ASCII characters in it.
P 3 | I | The byte array that contains the new filename. The name is a null-terminated string and has only ASCII characters in it.

I: Internal Variable

Example:

$U10 = “test.txt”

$U50 = “new.txt”

$U200 = RENAME_FILE($U10, $U50) /* Rename the file “test.txt” to “new.txt”. */


Operation:

Copies the file P2 to a new file P3 and saves the completion code in P1.

Parameters:

Type

Description

P1

I

The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; Otherwise the operation failed.

Note: This command can only be used in the following types of macros: Main Macro, Event Macro, Time Macro, and Cycle Macro.

P2

I

The byte array that contains the filename or the full pathname of the file to be copied. The name is a null-terminated string and has only ASCII characters in it.

P3

I

The byte array that contains the filename or the full pathname of the new file. The name is a null-terminated string and has only ASCII characters in it.

I: Internal Variable

Example:

$U10 = “c:\abc.txt”

$U50 = “d:\new.txt”

$U200 = COPY_FILE($U10, $U50) /* Copy the file “c:\abc.txt” to the new file “d:\new.txt”. */


Operation:

Gets the information of volume P2 and saves the result in P3. The completion code is saved in P1.

Parameters:

Type

Description

P1

I

The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; Otherwise the operation failed.

P 2

I/C

The drive ID.

ID | Drive
0 | Current drive
3 | Drive C
4 | Drive D
5 | Drive E

P3

I

The starting location of the memory block that is used as a Volume Information Block to receive the operation result. The structure of the Volume Information Block is shown below:

Data Item | Data Type/Size | Word No.
Volume name | Byte array with 32 elements | 0 through 15
Volume size | 32-bit Unsigned Integer | 16 and 17
Free size | 32-bit Unsigned Integer | 18 and 19
Drive ID | 16-bit Unsigned Integer | 20

The volume name is a null-terminated character string. The maximum allowable size is 31 characters.

Both the unit of volume size and the unit of free size are 1024 bytes.

A Volume Information Block requires 21 words.

I: Internal Variable; C: Constant

Example:

$U100 = GET_VOL_INFO(0, $U0) /* Get the volume information of the current drive. The volume name will be stored in $U0 through $U15. The size of the drive will be stored in $U16 and $U17. The free size of the drive will be stored in $U18 and $U19. The ID of the current drive will be stored in $U20. */


Operation:

The command READ_CSV reads the data in the field of row P3 and column P4 of the CSV file P2 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The word location to receive the value of the specified field. The data type selected for this command should be the same as the data type of the specified field, or the operation may fail. If the operation fails for any reason, no value will be written to P1. To know if the operation failed or not, check the word $S522. When the value of $S522 is non-zero, the operation failed.
P2 | I | The file handle of the file to be read. The file must be a CSV file and is opened with the purpose of Read CSV File. The delimiter must be TAB.
P 3 | I/C | The row number of the field to be read. The row counts from 0.
P 4 | I/C | The column number of the field to be read. The column counts from 0.

I: Internal Variable; C: Constant

Example:

$U10 = "test.csv"

$U100 = OPEN_FILE($U10,5) /* Open the file "test.csv" for the READ CSV FILE operation. */

$U200 = READ_CSV($U100,2,3) (F) /* Read the floating point number in the field of row 2 and column 3 and save the result in $U200 and $U201. */


Operation:

The command READ_CSV_STR reads the string in the field of row P3 and column P4 of the CSV file P2 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The byte array to receive the string in the specified field. The maximal string length that this command can handle is 128. If the operation fails for any reason, no value will be written to P1. To know if the operation failed or not, check the word $S522. When the value of $S522 is non-zero, the operation failed.
P2 | I | The file handle of the file to be read. The file must be a CSV file and is opened with the purpose of Read CSV File. The delimiter must be TAB.
P 3 | I/C | The row number of the field to be read. The row counts from 0.
P 4 | I/C | The column number of the field to be read. The column counts from 0.

I: Internal Variable; C: Constant

Example:

$U10 = "test.csv"

$U100 = OPEN_FILE($U10,5) /* Open the file "test.csv" for the READ CSV FILE operation. */

$U200 = READ_CSV_STR($U100,2,4) /* Read the string in the field of row 2 and column 4 and save the result in the byte array starting at $U200. */


Operation:

Finds the files with the specified extension name in a folder and save the names of the found files in the designated name buffer. The command can also get the names of the subfolders of a folder.

Parameters:

Type

Description

P1

I

The word is to receive the completion code of the operation.

Completion Code | Description
0 | The operation was successful
1 | The operation was successful. However, some names were not saved to the name buffer because those names were too long.
2 | The operation was successful. However, some names were not saved to the name buffer because the name buffer is full.
3 | The operation was successful. However, some names were not saved to the name buffer because those names were too long or the name buffer was full.
65535 | The operation failed

P2

I

The first word of the memory block that specifies the details of the operation.

Word No.

Description

0

Specifies the type of the operation.

Operation Code | Description
0 | Get filenames from a disk
1 | Get folder names from a disk
2 (Note 1) | Get filenames from the external FTP server (Note 2)
3 (Note 1) | Get folder names from the external FTP server (Note 2)

Note 1: The operations are available to X series products only.

Note 2: You can use a function button to specify the external FTP server. The function can be selected from the 'File' catogory.

1

Specifies the maximal number of names the name buffer can hold. We name the parameter MaxCounts.

2

Specifies the maximal length that the name buffer can hold for a name. We name the parameter MaxLength. Every name is a null-terminated ASCII character string. If a name is longer than MaxLength, it will not be saved to the name buffer.

The size of the name buffer can be calculated by the following formula:

MaxCounts x ((MaxLength + 2)/2) word (Note: Integer calculation must be used when using the formula)

3~26

The 48-byte array specifies the pathname of the folder to get the desired names. The pathname is a null-terminated ASCII character. The length of the string can be up to 47.

The following are examples of valid folder pathnames for disk operation:

"C:\aaa"

"c:\aaa\bbb"

"D:\"

"e:\Folder1\Subfolder1"

The following are examples of valid folder pathnames for FTP operation:

"\"

"\xx\yy"

27~28

The byte array stores a null-terminated ASCII character string that specifies the extension name of the interested files. The length of the character string can be up to 3. Specify one-character string "*" if all the files are interested. Specify a zero-length string "" if the interested files have no extension name.

The following are examples of valid extension names:

"csv"

"TXT"

"*"

""

P3

I

The parameter is a 16-bit unsigned integer that receives the count of the filenames or folder names saved in the name buffer.

P4

I

The parameter is the first word of the memory block that is used as the name buffer.

For example, if P4 is $U1000, MaxCounts is 30, and MaxLength is 47, then:

1. The buffer size is 30 x ((47+2)/2) = 720 words.

2. The buffer uses internal words $U1000~$U1719.

3. The character string of the first name starts at $U1000, the second starts at $U1024, the Nth starts at $U[24*N+1000].

I: Internal Variable; C: Constant

Example:

/* $U100~$U128 are used to specify the details of the operation */

$U100 = 2 /* Find the desired files from the external FTP server */

$U101 = 100 /* The name buffer can save up to 100 filenames */

$U102 = 64 /* The filenames can be up to 64 characters */

$U103 = "\ForHMI" /* The pathname to find files */

$U127 = "csv" /* Find .CSV files */

//

$U200 = GET_FILE_LIST($U100, $U202, $U300) /* Get the names of the CSV files from the folder "\ForHMI" of the external FTP server */

/* Save the completion code in $U200 */

/* The operation details are specified in $U100~$U128 */

/* Save the count of the filenames in the name buffer in $U202 */

/* The name buffer starts at $U300 */

/* The size of the name buffer is 100*(64+2)/2, which is 3300 words */


Operation:

Performs the database operation specified by P2 and P3 and saves the completion code in P1.

Parameters:

Type

Description

P1

I

The word to receive the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise the operation failed.

Note: This command can only be used in the following types of macros: Main Macro, Event Macro, Time Macro, and Cycle Macro.

P2, P3

I/C

P2 specifies the type of file operation. P3 specifies the ID of the data source. The following table describes how to set P2 and P3.

File Operation | P2 | P3
Save Logged Data | 14 | Data logger ID (0~15)
Save Logged Alarms | 15 | 0
Save Recipe Data | 17 | Recipe block ID (0~15)
Read Recipe Data | 19
Save Logged Operations | 18
 |  | 0

I: Internal Variable; C: Constant


Operation:

Saves the data of size P3 in the memory block P2 to the data logger P1.

Parameters:

 | Type | Description
P1 | I/C | The ID of the data logger. There are 16 data loggers at most and the IDs are 0 to 15.
P2 | I | The internal memory block that saves the converted sample data.
P3 | I/C | The size of the data to be logged.

I: Internal Variable; C: Constant

Example:

$U103 = 100 /* Set the size of the logged data to 100. */

SAVE2LB(3, $U100, $U103) /* Save 100 words from $U100 to data logger 3 */


Operation:

Redraw the historic objects' display that are associated with the data logger P1 with the reason P2.

Parameters:

Type

Description

P1

I/C

The ID of the data logger. There are 16 data loggers at most and the IDs are 0 to 15.

P2

I/C

The reason.

Value | Description
0 | After the data of the specified data logger is changing.
1 | If the data for the historic objects' is from the specified data logger.
2 | If the data for the historic objects' is from the specified file buffer.

I: Internal Variable; C: Constant

Example:

$U100 = 1 /* Set the data logger ID to 1*/

REF_H_OBJ($U100, 0) /* When the data of data logger 1 is changed, redraw all the historic objects' display that associated with data logger 1 */


Operation:

Clears the logging buffer of the data logger P1.

Parameters:

 | Type | Description
P1 | I/C | The ID of the data logger. There are 16 data loggers at most and the IDs are 0 to 15.

I: Internal Variable; C: Constant

Example:

CLR_LB(1) /* Clear the logged buffer of data logger 1 */


Operation:

Copies the collected data of a data logger to a file buffer. You can specify a filtration method to copy the qualified data only. The command will update the display of the screen objects associated with the file buffer after copying the data.

Parameters:

Type

Description

P1

I

The 16-bit word is to receive the completion code of the operation.

Completion Code | Description
0 | The operation was successful
8001 | Invalid data logger ID
8002 | Invalid file buffer ID
8003 | Insufficient memory
8004 | Non-existent data logger
8006 | Invalid filter type
8007 | The file buffer has been assigned to another data logger
8008 | The file buffer does not contain logged data
8011 | Invalid starting time
8012 | Invalid starting date
8013 | Invalid ending time
8014 | Invalid ending date
8015 | The starting time is later than the ending time

P2

I/C

Specifies the identifier of the data logger that you want to copy its data.

P3

I/C

Specifies the identifier of the file buffer that you want to save the copied data. The valid file identifier is between 0 and 15.

P4

I

The parameter is the first word of a memory block that defines the filtration method for the copy operation.

Word No.

Description

0

The word specifies the filtration type.

Filtration Code | Description
0 | No filtration. The command will copy all the data.
1 | The command will copy the records that are within the date and time range specified by the words 1 to 12 of the memory block.
2 | The command will copy the records that are within the date range specified by the words 1 to 6 of the memory block.

1

The year of the starting date. The valid number is between 2000 and 2099.

2

The month of the starting date. The valid number is between 1 and 12.

3

The day of the starting date. The valid number is between 1 and 31.

4

The year of the ending date. The valid number is between 2000 and 2099.

5

The month of the ending date. The valid number is between 1 and 12.

6

The day of the ending date. The valid number is between 1 and 31.

7

The hour of the starting time. The valid number is between 0 and 23.

8

The minute of the starting time. The valid number is between 0 and 59.

9

The second of the starting time. The valid number is between 0 and 59.

10

The hour of the ending time. The valid number is between 0 and 23.

11

The minute of the ending time. The valid number is between 0 and 59.

12

The second of the ending time. The valid number is between 0 and 59.

I: Internal Variable; C: Constant

Example:

/* $U100~$U112 are used to define the filtration for the copy operation */

$U100 = 1 /* Copy the records within the specified date and time range */

$U101 = 2014 /* The starting date is 2014/12/1 */

$U102 = 12

$U103 = 1

$U104 = 2015 /* The ending date is 2015/3/31 */

$U105 = 3

$U106 = 31

$U107 = 0 /* The starting time is 00:00:00 */

$U108 = 0

$U109 = 0

$U110 = 23 /* The ending time is 23:59:59 */

$U111 = 59

$U112 = 59

//

$U200 = LB_2_FB(10, 2, $U100) /* Copy the data of data logger #10 to file buffer #2 */

/* Save the completion code in $U200 */

/* The filtration is defined in $U100 */


Operation:

Performs a statistical calculation on a data item of the historic data in the specified file buffer. The historic data must be collected by one of the application's data logger. The data type of the target data must be of 16/32 signed integer, 16/32 unsigned integer, or 32-bit floating number.

Parameters:

Type

Description

P1

I

Receives the completion code of the operation.

Completion Code | Description
0 | The operation was successful
8002 | Invalid file buffer ID
8003 | Insufficient memory
8005 | Invalid data item sequence number
8008 | The file buffer does not contain logged data
8009 | The file buffer is empty
8010 | The file buffer is undefined
8016 | Invalid calculation code
8017 | Invalid data type
8018 | The operation failed

P2

I/C

The parameter is a 16-bit unsigned integer that specifies the identifier of the file buffer. The valid identifier is between 0 and 15.

P3

I

The parameter is the first word of the word array that specifies the type of the calculation and the target data item.

The following table shows the data arrangement of the word array.

Word No.

Description

0

Specifies the type of the calculation. The following table lists the available calculations and their codes.

Calculation | Code | Description
COUNT | 0 | Get the number of records of the historic data.
MAX | 1 | Find the largest value of the target data.
MIN | 2 | Find the smallest value of the target data.
AVERAGE | 3 | Calculate the average of the target data.
MEDIAN | 4 | Calculate the median (the middle value) of the target data.
SUM | 5 | Calculate the sum of the target data.

1

Specifies the sequence number of the target data item in the logged data record. Specify value K when the data item is the Kth data item in the record. The sequence number starts from 1.

P4

I

Receives the calculation result.

Calculation | Result
COUNT | 32-bit unsigned integer
MAX, MIN, AVERAGE, MEDIAN | Same as the target data type
SUM | The result of 16/32-bit signed integer data is a 32-bit signed integer. The result of 16/32-bit unsigned integer data is a 32-bit unsigned integer. The result of 32-bit floating point data is a 32-bit floating point number.

I: Internal Variable; C: Constant

Example:

/* $U100 and $U101 define the statistical calculation */

$U100 = 1 /* Find the largest value */

$U101 = 1 /* The target data item is the first data item of the logged data record */

//

$U200 = PROC_FB_DATA(2, $U100, $U202) /* Find the largest value of the first data item of the logged data in file buffer #2 */

/* Save the completion code in $U200 */

/* Save the calculation result in $U202 when the target data size is 16-bit */

/* Save the calculation result in $U202 and $U203 when the target data size is 32-bit */


Operation:

Sets bit P1 to 1 if P2 is equal to P3, otherwise sets P1 to 0.

Parameters:

 | Type | Description
P1 | I/E | The bit location to save the result.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Example:

$U3.3 = ($U10 + $U20) == 25.75 (F)


Operation:

Sets bit P1 to 1 if P2 is not equal to P3, otherwise sets P1 to 0.

Parameters:

 | Type | Description
P1 | I/E | The bit location to save the result.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Example:

$U3.3 = ($U10 + $U20) != -700 (S)


Operation:

Sets bit P1 to 1 if P2 is greater than P3, otherwise sets P1 to 0.

Parameters:

 | Type | Description
P1 | I/E | The bit location to save the result.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Example:

$U3.3 = ($U10 + $U20) > $U30 (UD)


Operation:

Sets bit P1 to 1 if P2 is greater than or equal to P3, otherwise sets P1 to 0.

Parameters:

 | Type | Description
P1 | I/E | The bit location to save the result.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Example:

$U3.3 = ($U10 + $U20) >= 25.75 (F)


Operation:

Sets bit P1 to 1 if P2 is less than P3, otherwise sets P1 to 0.

Parameters:

 | Type | Description
P1 | I/E | The bit location to save the result.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Example:

$U3.3 = ($U10 + $U20) < 25.75 (F)


Operation:

Sets bit P1 to 1 if P2 is less than or equal to P3, otherwise sets P1 to 0.

Parameters:

 | Type | Description
P1 | I/E | The bit location to save the result.
P2 , P3 | I/E/C/AE | The operands.

I: Internal Variable; E: External Variable; C: Constant; AE: Arithmetic Expression

Example:

$U3.3 = ($U10 + $U20) <= 25.75 (F)


Operation:

Copies the string in P2 to P1.

Parameters:

 | Type | Description
P1 | I | The byte array that receives a copy of the string in P2. The byte array must be large enough to hold the string and the null terminator.
P2 | I | The source, i.e. the byte array that contains the null-terminated string to be copied.

I: Internal Variable

Example:

1

$U10 = “ABCDE”

STRCPY($U20, $U10)

After the command STRCPY is executed, the byte array $U20 contains the string “ABCDE” and the memory content is like the following:

Word | Low Byte | High Byte
$U20 | 'A' | 'B'
$U21 | 'C' | 'D'
$U22 | 'E' | 0

2

$U10 = “12”

STRCPY($U20, $U10)

After the command STRCPY is executed, the byte array $U20 contains the string “12” and the memory content is like the following:

Word | Low Byte | High Byte
$U20 | '1' | '2'
$U21 | 0 | Undefined


Operation:

Appends string in P2 to string in P1.

Parameters:

 | Type | Description
P1 | I | The byte array that contains a null-terminated string to which the command appends P2. The byte array must be large enough to hold both strings and the null terminator.
P2 | I | The byte array that contains a null-terminated string to be appended to the string in P1.

I: Internal Variable

Examples:

1 | $U10 = “ABC” $U20 = “12345” STRCAT($U10, $U20) /* After this command is executed, the byte array $U10 contains “ABC12345” */
2 | $U100 = “C:\MyFolder\” $U130 = “Test” $U140 = “.txt“ STRCAT($U100, $U130) STRCAT($U100, $U140) /* After this command is executed, the byte array $U100 contains “C:\MyFolder\Test.txt” */


Operation:

Gets the length of string P2 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The word to receive the result.
P2 | I | The byte array that stores the null-terminated string.

I: Internal Variable

Example:

$U10 = “ABC”

$U20 = STRLEN($U10) /* After this command is executed, the value of $U20 is 3. */


Operation:

Compares strings P2 and P3 lexicographically and saves a value indicating their relationship in P1.

Parameters:

Type

Description

P1

I

The value of comparison result.

Value | Description
0 | P2 and P3 are identical.
1 | P2 is greater than P3.
0xFFFF | P2 is less than P3.

P2 , P3

I

The byte array that contains a null-terminated string to compare.

I: Internal Variable

Examples:

1 | $U10 = “ABC” $U20 = “abc” $U30 = STRCMP($U10, $U20) /* After this command is executed, $U30 is 0xFFFF*/
2 | $U10 = “XYZ” $U20 = “ABC” $U30 = STRCMP($U10, $U20) /* After this command is executed, $U30 is 1*/
3 | $U10 = “ABC” $U20 = “ABC” $U30 = STRCMP($U10, $U20) /* After this command is executed, $U30 is 0*/


Operation:

Compares lowercase version of strings P2 and P3 lexicographically and saves a value indicating their relationship in P1.

Parameters:

Type

Description

P1

I

The value of comparison result.

Value | Description
0 | P2 and P3 are identical.
1 | P2 is greater than P3.
0xFFFF | P2 is less than P3.

P2 , P3

I

The byte array that contains a null-terminated string to compare.

I: Internal Variable

Examples:

1 | $U10 = “ABC” $U20 = “abc” $U30 = STRICMP($U10, $U20) /* After this command is executed, $U30 is 0*/
2 | $U10 = “XYZ” $U20 = “ABC” $U30 = STRICMP($U10, $U20) /* After this command is executed, $U30 is 1*/
3 | $U10 = “ABC” $U20 = “XYZ” $U30 = STRICMP($U10, $U20) /* After this command is executed, $U30 is 0xFFFF*/


Operation:

Lexicographically compares, at most, the first P4 characters in strings P2 and P3 and saves a value indicating the relationship between the substrings in P1.

Parameters:

Type

Description

P1

I

The value of comparison result.
Value | Description
0 | P2's substring and P3's substring are identical.
1 | P2's substring is greater than P3's substring .
0xFFFF | P2's substring is less than P3's substring .

Note: The comparison ends if a terminating null character is reached in either string before P4 characters are compared. If the strings are equal when a terminating null character is reached in either string before P4 characters are compared, the shorter string is less.

The characters from 91 to 96 in the ASCII table ('[', '\', ']', '^', '_', and '`') will evaluate as less than any alphabetic character.

P2 , P3

I

The byte array that contains a null-terminated string to compare.

P4

I/C

The number of characters to compare.

I: Internal Variable; C: Constant

Examples:

1 | $U10 = “XYZ” $U20 = “XYZAB” $U30 = STRNCMP($U10, $U20,4) /* After this command is executed, $U30 is 0xFFFF*/
2 | $U10 = “ABZ” $U20 = “ABC” $U30 = STRNCMP($U10, $U20,2) /* After this command is executed, $U30 is 0*/
3 | $U10 = “AXC” $U20 = “ABC” $U30 = STRNCMP($U10, $U20,3) /* After this command is executed, $U30 is 1*/


Operation:

Finds the first occurrence of a character P3 in a string P2 and saves a search result in value indicating the position of the found character in P1.

Parameters:

 | Type | Description
P1 | I | The value of search result. If the character P3 is not found in P2, the result value is 0xFFFF.Otherwise, the result value is the index to the first occurrence of character P3 in a string P2.
P2 | I | The byte array that contains a null-terminated source string.
P3 | I/C | The byte that contains a character code to be located.

I: Internal Variable; C: Constant

Examples:

$U10 = “The quick brown dog jumps over the lazy fox.”

$U20 = 0x72 /* The ASCII code of character 'r' */

$U30 = STRCHR($U10, $U20) /* After this command is executed, $U30 is 11*/


Operation:

Gets the value from the source specified by P2 and P3, converts it to an ASCII string with the length specified by P4, and saves the result in P1.

Parameters:

Type

Description

P1

I

The byte array that stores the result.

P2

I/C

The source of the value to be converted.

P2 Value | Source | Remark
0~63 | $SL0~$SL63 | The value is one of the data items of the record selected in a historic data display. The P3 specifies the sequence number of the data item. The sequence numbers start from 0.
1000 | P3 | The P3 specifies the value or the address that holds the value. The data type of the value is the data type you select for the macro command.

P3

I/C

Specifies the data item, the value, or the address that holds the value to be converted.

P4

I/C

The parameter is used only when the value source is P3. It specifies the exact number of characters that the result should have. If the number of digits of the value is less than the parameter, the result is padded on the left with zeros. If the number of digits of the value exceeds the parameter, the higher digits are truncated. If the parameter is 0, there is no limitation on the length of the result.

I: Internal Variable; C: Constant

Example 1:

$U120 = 123

$U100 = NUM2A(1000, $U120, 0) /* After this command is executed, the byte array $U100 contains "123".*/

Example 2:

$U120 = 1234567 (UD)

$U100 = NUM2A(1000, $U120, 10) (UD) /* After this command is executed, the byte array $U100 contains "0001234567".*/

Example 3:

$U120 = 1234567 (UD)

$U100 = NUM2A(1000, $U120, 5) (UD) /* After this command is executed, the byte array $U100 contains "34567".*/


Operation:

Gets the time from source specified by P2, converts it to an ASCII string using the format specified by P3, and saves the result in P1.

Parameters:

Type

Description

P1

I

The byte array that stores the result.

P2

I/C

The source of the date.

P2 Value | Source | Remark
0~63 | $SL0~$SL63 | The time of the record selected in a historic data display
1000 | System | The current date

P3

I/C

Specifies the desired conversion format.

P3 Value | Format | Remark
1000 | hhmmss | hh: hour(00~23);mm: minute(00~59);ss: second(00~59)
1001 | hhmm |
0 | hh:mm |
1 | hh:mm:ss |
2 | mm:ss |
3 | hh:mm PM |
4 | hh:mm:ss PM |

I: Internal Variable; C: Constant

Examples:

$U10 = T2A(1000, 1000) /* Assume that the current system time is 12:30:59. After this command is executed, the byte array $U10 contains"123059".*/


Operation:

Gets the date from the source specified by P2, converts it to an ASCII string using the format specified by P3, and saves the result in P1.

Parameters:

Type

Description

P1

I

The byte array that stores the result.

P2

I/C

The source of the date.

P2 Value | Source | Remark
0~63 | $SL0~$SL63 | The date of the record selected in a historic data display
1000 | System | The current date

P3

I/C

Specifies the desired conversion format.

P3 Value | Format | Remark
1000 | YYMMDD | YY: year (00~99); MM: month(01~12); DD: day(01~31)
1001 | YYMM |
1002 | YYMMMDD | MMM: month(JAN~DEC)
1003 | YYMMM |
0 | DD/MM/YY |
1 | MM/DD/YY |
2 | YY/MM/DD |
3 | DD.MM.YY |
4 | MM.DD.YY |
5 | YY.MM.DD |
6 | DD-MM-YY |
7 | MM-DD-YY |
8 | YY-MM-DD |
23 | DD-MMM-YY |
24 | MMM-DD-YY |
25 | YY-MMM-DD |
26 | YYYY/MM/DD | YYYY: year (2000~2099)
27 | YYYY-MM-DD |

I: Internal Variable; C: Constant

Examples:

$U10 = D2A(1000, 1000) /* Assume that the current system date is December 7, 2008. After this command is executed, the byte array $U10 contains “081207”. */
 $U20 = D2A(1000, 1003) /* Assume that the current system date is December 31, 2008. After this command is executed, the byte array $U20 contains “08DEC”. */


Operation:

Converts the current system time and date to a string using the format specified by P2 and saves the result in P1.

Parameters:

Type

Description

P1

I

The byte array that stores the result.

P2

I/C

Specifies the desired conversion format.

Format | P2 Value | Remark
YYMMDD_hhmmss | 0 | YY: year (00~99); MM: month(01~12); DD: day(01~31) hh: hour(00~23); mm: minute(00~59) ; ss: second(00~59)
YYMMMDD_hhmmss | 1 | YY, DD, hh, mm, ss: same as above MMM: month(JAN~DEC)
YYMMDD_hhmm | 2 | YY, DD, hh, mm: same as above; MM: month(01~12)
YYMMMDD_hhmm | 3 | YY, DD, hh, mm: same as above; MMM: month(JAN~DEC)

I: Internal Variable; C: Constant

Examples:

$U10 = TD2STR(0) /* Assume that the current system date is December 7, 2008 and the current system time is 15:18:30. After this command is executed, the byte array $U10 contains “081207_151830". */

$U20 = TD2STR(3) /* Assume that the current system date is December 31, 2008 and the current system time is 13:30:00. After this command is executed, the byte array $U20 contains “08DEC31_1330”. */


Operation:

Converts the integer number in P2 to a string and saves the result in P1. The string is generated according to the format specified by P3.

Parameters:

 | Type | Description
P1 | I | The byte array that stores the result. The result is a null terminated string.
P2 | I/C | The integer number or the location that holds the integer number to be converted.
P3 | I/C | Specifies where to insert a decimal point in the string. A decimal point is inserted to the left of the nth digit when P3 is n. The least significant digit is the first digit. No decimal point is inserted when P3 is 0.

I: Internal Variable; C: Constant

Examples:

1 | $U120 = 123 $U100 = I2A($U120, 0) /* After this command is executed, the byte array $U100 contains “123”. */
2 | $U120 = 1234567 (UD) $U100 = I2A($U120, 2) (UD) /* After this command is executed, the byte array $U100 contains “12345.67”. */
3 | $U120 = -12345 (S) $U100 = I2A($U120, 1) (UD) /* After this command is executed, the byte array $U100 contains “-1234.5”. */


Operation:

Converts the string P2 to an integer value and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The location that stores the result. The result is 0 when there is any conversion error.
P2 | I | The byte array that holds the string to be converted.
P3 | I/C | Specifies the length of the string. It is allowed to specify 0 for P3. When P3 is 0, the string must be a null terminated string.
P4 | I/C | Specifies how many fractional digits in the string are to be converted.

I: Internal Variable; C: Constant

Examples:

1 | $U120 = “123” $U100 = A2I($U120, 0, 0) /* After this command is executed, the value in word $U100 is 123. */
2 | $U120 = “1234567” $U100 = A2I($U120, 6, 0) (UD) /* After this command is executed, the value in double word $U100 is 123456. */
3 | $U120 = “-123.45” $U100 = A2I($U120, 0, 2) (S) /* After this command is executed, the value in word $U100 is -12345. */


Operation:

Converts the floating point number in P2 to a string and saves the result in P1. The string is generated according to the format specified by P3.

Parameters:

 | Type | Description
P1 | I | The byte array that stores the result. The result is a null terminated string.
P2 | I/C | The floating point number or the location that holds the floating point number to be converted.
P3 | I/C | Specifies the number of fractional digits the string can have.

I: Internal Variable; C: Constant

Examples:

1 | $U120 = 123.45 (F) $U100 = F2A($U120, 2) /* After this command is executed, the byte array $U100 contains “123.45”. */
2 | $U120 = 567.89 (F) $U100 = F2A($U120, 1) (UD) /* After this command is executed, the byte array $U100 contains “567.8”. */
3 | $U120 = -1234 (S) $U100 = F2A($U120, 1) (UD) /* After this command is executed, the byte array $U100 contains “-1234.0”. */


Operation:

Converts the string P2 to a floating point number and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The location that stores the result. The result is 0 when there is any conversion error.
P2 | I | The byte array that holds the string to be converted.
P3 | I/C | Specifies the length of the string. It is allowed to specify 0 for P3. When P3 is 0, the string must be a null terminated string.

I: Internal Variable; C: Constant

Examples:

1 | $U120 = “123.4” $U100 = A2F($U120, 0) /*The value of the floating point number in double word $U100 is 123.4. */
2 | $U120 = “1234567” $U100 = A2F($U120, 6) (UD) /* The value of the floating point number in double word $U100 is 123456. */
3 | $U120 = “-123.45” $U100 = A2F($U120, 0) (S) /* The value of the floating point number in double word $U100 is -123.45. */


Utilities - System - GetID

Operation:

Gets the bar code input from the bar code reader connected to the specified USB port.

Parameters:

 | Type | Description
P1 | I | The starting location of the byte array to store the bar code. The bar code is stored in the byte array as a null-terminated character string. The length of a bar code can be up to 1024 characters. Make sure the byte array has sufficient space for your application. If there is no bar code input, the first 2 bytes of the byte array are set to 0. There is only one bar code input buffer in the system, so if a bar code is not fetched in time, it could be overwritten by a new bar code input. The bar code in the buffer will be erased immediately after it is fetched, so the command can get the bar code of one input only once. The most effective way to get a bar code is to use the macro command in an Event macro and the Event macro is triggered by the system bit BarCodeInputViaUsb. When there is a bar code input, the system bit triggers the Event macro once. This guarantees that a bar code input will always be fetched and processed. Note: Only T series models support this command.
P2 | I/C | The number of the USB port that connects to the bar code reader. For T series models, you can only specify 1.

I: Internal Variable; C: Constant

Example:

$U100 = GET_BAR_CODE(1) /* Get the bar code scanned by the bar code reader connected to the USB port 1 */


Operation:

Converts the GB code string in P3 to an UNICODE string in P2 and saves the number of characters in P1.

¡¡

Parameters:

¡¡ | Type | Description
P1 | I | The number of characters.
P2 | I | Destination. The word array that stores the null-terminated UNICODE or word string.
P3 | I | Source. The byte array that holds the null-terminated GB code string to be converted.

I: Internal Variable;

¡¡

Examples:

$U20 = "ABC"

$U30 = GB2U($U10, $U20) /* After this command is executed, the value of $U30 is 4, and $U10 = 0x41, $U11 = 0x42, $U12 = 0x43 */


Operation:

Converts the UNICODE string in P3 to a GB code string in P2 and saves the number of characters in P1.

¡¡

Parameters:

¡¡ | Type | Description
P1 | I | The number of characters.
P2 | I | Destination. The byte array that holds the null-terminated GB code string after converted.
P3 | I | Source. The word array that stores the null-terminated UNICODE or word string.

I: Internal Variable;

¡¡

Examples:

$U20 = 0x41 // "A"

$U21 = 0x42 // "B"

$U22 = 0x43 // "C"

$U23 = 0

$U30 = U2GB($U10, $U20) /* After this command is executed, the value of $U30 is 3, and $U10 = 0x4241, $U11 = 0x43 */


Operation:

Converts the Big5 code string in P3 to an UNICODE string in P2 and saves the number of characters in P1.

¡¡

Parameters:

¡¡ | Type | Description
P1 | I | The number of characters.
P2 | I | Destination. The word array that stores the null-terminated UNICODE or word string.
P3 | I | Source. The byte array that holds the null-terminated Big5 code string to be converted.

I: Internal Variable;

¡¡

Examples:

$U20 = "ABC"

$U30 = BIG52U($U10, $U20) /* After this command is executed, the value of $U30 is 4, and $U10 = 0x41, $U11 = 0x42, $U12 = 0x43 */


Operation:

Converts the UNICODE string in P3 to a Big5 code string in P2 and saves the number of characters in P1.

¡¡

Parameters:

¡¡ | Type | Description
P1 | I | The number of characters.
P2 | I | Destination. The byte array that holds the null-terminated Big5 code string after converted.
P3 | I | Source. The word array that stores the null-terminated UNICODE or word string.

I: Internal Variable;

¡¡

Examples:

$U20 = 0x41 // "A"

$U21 = 0x42 // "B"

$U22 = 0x43 // "C"

$U23 = 0

$U30 = U2BIG5($U10, $U20) /* After this command is executed, the value of $U30 is 3, and $U10 = 0x4241, $U11 = 0x43 */


Operation:

Gets the length of UNICODE or word string P2 and saves the result in P1.

Parameters:

 | Type | Description
P1 | I | The number of characters.
P2 | I | The word array that stores the null-terminated UNICODE or word string.

I: Internal Variable

Example:

$U10 = 0x41 // "A"

$U11 = 0x42 // "B"

$U12 = 0x43 // "C"

$U13 = 0

$U20 = WCSLEN($U10) /* After this command is executed, the value of $U20 is 3 */


Operation:

Writes formatted data to a string P3 by given encoding in P4, given format based on Text Format ID P2 in Text Format Table and returns the number of characters to P1.

Parameters:

Type

Description

P1

I

T he number of characters. T he null terminator is not included.

P2

I/C

Text Format ID in Text Format Table.

P3

I

The array that receives the string. The array must be large enough to hold the string and the null terminator.

P4

I/C

The string encoding to use。

Word | Description
0 | Using Unicode as a string encoding。The string is a null terminated string. If the length of the string is N then N+1 words will be the word array length and the last word is 0.
1 | Using UTF-8 as a string encoding。The string is a null terminated string. If the length of the string is N then N+1 bytes will be the byte array length and the last byte is 0.

I: Internal Variable; C: Constant

Example:

$U100 = Format(1000, $U120, 0)


Operation:

Runs the executable P1 which is on the same PC. This command is available for PanelExpress only.

Parameters:

 | Type | Description
P1 | I/A | The name of the executable to be run.

I: Internal Variable; A: ASCII Character String

Examples:

RUN "ABC.exe" /* Run the program ABC */

$U10 = "XYZ.bat"

RUN $U10 /* Run the batch file XYZ */


Operation:

Runs the executable P2 which is on the same PC and saves the result in P1. Note that the macro command following this one will not be executed until the program is closed. This command is available for PanelExpress only.

Parameters:

 | Type | Description
P1 | I | The word to receive the result.
P2 | I/A | The name of the executable to be run.

I: Internal Variable; A: ASCII Character String

Example:

$U10 = RUNW "ABC.exe" /* Run the program ABC and use $U10 to get the result. */

IF $U10 == 0 /* If the result is 0 then run the batch file XYZ */

$U20 = "XYZ.bat"

$U11 = RUNW $U20 /* Run the batch file XYZ */

ENDIF


Operation:

Runs the executable that is specified by the start information block P1. The executable must be on the same PC as the software. This command is available for PanelExpress only.

Parameters:

Type

Description

P1

I

The starting location of the memory block (or word array) that is used as a Start Information Block for the executable. The structure of the Start Information Block is shown below:

Word No.

Data Item

Description

0

Operation Flag

This value can be a combination of the following:

Bit No. | Description
0 | Has Arguments.
1 | Changes the position.
2 | Changes the size.
3 | Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
4 | Runs once.
5 | Hides the window and activates another window.
6 | Auto close.
Others | Reserved

Note: If the value is 0, the executable runs in its default settings. By default, displays and activates the window, and the executable will be run every time the macro command is executed.

1~130

File Name

The 260-byte array specifies the file name of the executable to be run. The file name is a null-terminated ASCII character. The length of the string can be up to 259.

131~260

Arguments String

The 260-byte array specifies the set of command-line arguments to be used when starting the executable. The argument is a null-terminated ASCII character. The length of the string can be up to 259. This field is used when bit 0 of the operation flag is 1.

261

X

The new position of the left side of the executable window, in screen coordinates. This field is used when bit 1 of the operation flag is 1.

262

Y

The new position of the top of the executable window, in screen coordinates. This field is used when bit 1 of the operation flag is 1.

263

Width

The new width of the executable window, in pixels. This field is used when bit 2 of the operation flag is 1.

264

Height

The new height of the executable window, in pixels. This field is used when bit 2 of the operation flag is 1.

I: Internal Variable

Examples:

$U0.0 = 0 (B) /* No arguments */

$U0.1 = 1 (B) /* Moves to new position */

$U0.2 = 1 (B) /* Changes size */

$U0.3 = 1 (B) /* Places the window on the topmost */

$U1 = "Notepad.exe" /* Executable name */

$U261 = 50 /* Sets the left side to 50 . */

$U262 = 20 /* Sets the top to 20. */

$U263 = 400 /* Sets width to 400. */

$U264 = 500 /* Sets height to 500. */

RUNP $U0 /* Run executable named "Notepad.exe" with new size 400x500 at (50,20) in screen coordinates. The executable will be shown above all other windows. */


Operation:

Runs the executable that is specified by the start information block P2 and saves the result in P1. The executable must be on the same PC as the software. Note that the macro command following this one will not be executed until the program is closed. This command is available for PanelExpress only.

Parameters:

Type

Description

P1

I

The word to receive the result.

P2

I

The starting location of the memory block (or word array) that is used as a Start Information Block for the executable. The structure of the Start Information Block is shown below:

Word No.

Data Item

Description

0

Operation Flag

This value can be a combination of the following:

Bit No. | Description
0 | Has Arguments.
1 | Changes the position.
2 | Changes the size.
3 | Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
4 | Runs once.
5 | Hides the window and activates another window.
6 | Auto close.
Others | Reserved

Note: If the value is 0, the executable runs in its default settings. By default, displays and activates the window, and the executable will be run every time the macro command is executed.

1~130

File Name

The 260-byte array specifies the file name of the executable to be run. The file name is a null-terminated ASCII character. The length of the string can be up to 259.

131~260

Arguments String

The 260-byte array specifies the set of command-line arguments to be used when starting the executable. The argument is a null-terminated ASCII character. The length of the string can be up to 259. This field is used when bit 0 of the operation flag is 1.

261

X

The new position of the left side of the executable window, in screen coordinates. This field is used when bit 1 of the operation flag is 1.

262

Y

The new position of the top of the executable window, in screen coordinates. This field is used when bit 1 of the operation flag is 1.

263

Width

The new width of the executable window, in pixels. This field is used when bit 2 of the operation flag is 1.

264

Height

The new height of the executable window, in pixels. This field is used when bit 2 of the operation flag is 1.

I: Internal Variable;

Example:

$U0.0 = 0 (B) /* No arguments */

$U0.1 = 1 (B) /* Moves to new position */

$U0.2 = 1 (B) /* Changes size */

$U0.3 = 1 (B) /* Places the window on the topmost */

$U1 = "TEXT.exe" /* Executable name */

$U261 = 50 /* Sets the left side to 50 . */

$U262 = 20 /* Sets the top to 20. */

$U263 = 400 /* Sets width to 400. */

$U264 = 500 /* Sets height to 500. */

$U1000 = RUNPW $U0/* Run executable named "TEST.exe" with new size 400x500 at (50,20) in screen coordinates. The executable will be shown above all other windows and its running result will be saved in $U1000. */

IF $U1000 == 1 /* If the result in $U1000 is 1 then setting "OK" to $U2000 */

$U2000 = "OK"

ENDIF


Operation:

Sends P3 bytes of data stored in byte array P2 to the printer and saves the completion code in P1.

Parameters:

Type

Description

P1

I

The word to receive the completion code of the operation. The following table describes the meanings of the completion codes.

Code | Description
0 | Succeeded
1 | Printer not ready
3 | System error
4 | Printer busy
7 | No printer specified

P2

I

The starting location of the byte array that stores the data to be sent to the printer.

P3

I/C

The length in byte of the data to be sent to the printer.

I: Internal Variable; C: Constant

Examples:

$U10 = "This is a test."

$U20 = PRINT($U10, 15) /* Send the string “This is a test.” to the printer. */

$U10 = 10

$U20 = PRINT($U10, 1) /* Send the line-feed character to the printer */

$U10 = 12

$U20 = PRINT($U10, 1) /* Send the form-feed character to the printer */

$U10 = 0x401b /* ESC, '@' */

$U20 = PRINT($U10, 2) /* Initialize the EPSON printer */


Operation:

Prints the screen specified by P2 and saves the completion code in P1.

Parameters:

Type

Description

P1

I

The word to receive the completion code of the operation. The following table describes the meanings of the completion codes.

Code | Description
0 | Succeeded
1 | Printer not ready
2 | Invalid screen number
3 | System error
4 | Printer busy
5 | System busy
6 | Improper use of this command (See Note)
7 | No printer specified

Note: This command can only be used in the following types of macros: Main Macro, Event Macro, Time Macro, and Cycle Macro.

P2

I/C

The number of the screen to be printed. You can specify the printed area in the Screen Properties dialog box.

P3

I/C

Reserved for future use. Must be 0.

I: Internal Variable; C: Constant

Example:

$U0 = PRINT_SCREEN(28, 0) /* Print screen #28*/


Operation:

The BLANK command blanks the print buffer P1, i.e. makes the print buffer P1 contain only blank characters.

Parameters:

 | Type | Description
P1 | I | The print buffer to be blanked. The print buffer is a byte array. You should always blank a print buffer before printing strings to it.
P2 | I/C | The size of the print buffer. The unit is byte (one-byte character). For example, if the size of a print buffer is 40, it has 20 words and can contain up to 40 one-byte characters.

I: Internal Variable; C: Constant

Example:

BLANK($U100, 80) /* Blank the print buffer starting at $U100 with a length of 40 words. */


Operation:

The P2B command prints the null-terminated string P1 to the print buffer P2 at the specified byte position P3.

Parameters:

 | Type | Description
P1 | I | The byte array that holds the string to be printed.
P2 | I | The byte array that is used as a print buffer to accept the string P1.
P3 | I/C | The byte position in the print buffer to put the string. The byte position counts from 0. For example, to print a string at the beginning of the print buffer, set P3 to 0.

I: Internal Variable; C: Constant

Example:

BLANK($U100, 20) /* Blank the print buffer. */

$U10 = “Weight:”

P2B($U100, $U10, 0) /* Print the string “Weight:” at the position of byte 0 of the print buffer. */

$U10 = I2A(1234, 2) /* The byte array $U10 will hold the string “12.34” after this command is executed. */

P2B($U100, $U10, 8) /* Print the string “12.34” at the position of byte 8 of the print buffer. */

$U10 = “kg”

P2B($U100, $U10, 14) /* Print the string “kg” at the position of byte 14 of the print buffer. */

PRINT($U100, 20 ) /* Print string “Weight: 12.34 kg” in the print buffer to the real printer. */


Operation:

The P2B_R command prints the null-terminated string P1 to the print buffer P2. The string is right aligned with the byte position P3.

Parameters:

Type

Description

P1

I

The byte array that holds the string to be printed.

P2

I

The byte array that is used as a print buffer to accept the string P1.

P3

I/C

The byte position in the print buffer that the last characters of the string is placed. The byte position counts from 0.

For example, to print a string with 6 characters at the beginning of the print buffer, set P3 to 5 as the last character of the string should be placed at the position of byte 5.

I: Internal Variable; C: Constant

Example:

BLANK($U100, 20) /* Blank the print buffer. */

$U10 = “Weight:”

P2B_R($U100, $U10, 6) /* Print the string “Weight:” to the print buffer and align the string right with the position of byte 6. */

$U10 = I2A(1234, 2) /* The byte array $U10 will hold the string “12.34” after this command is executed. */

P2B_R($U100, $U10, 12) /* Print the string “12.34” to the print buffer and align the string right with the position of byte 12. */

$U10 = “kg”

P2B_R($U100, $U10, 15) /* Print the string “kg” to the print buffer and align the string right with the position of byte 15. */

PRINT($U100, 20 ) /* Print string “Weight: 12.34 kg” in the print buffer to the real printer. */


Operation:

This command plays the sound P1.

Parameters:

 | Type | Description
P1 | I/C | The identifier of the sound to be played. Note: The sounds and their identifiers are defined in the sound table of the panel application.
P2 | I/C | The number of times you want the sound to be played. If you want the specified sound to be played just once, set P2 to 1.
P3 | I/C | The break time between two consecutive plays. The time unit is 100 ms (0.1 second). If you do not want any break between two plays, set P3 to 0.

I: Internal Variable; C: Constant

Example:

SOUND(10, 5, 3) /* Play the sound #10 5 times with a break of 0.3 second between two consecutive plays. */


Operation:

This command stops playing the current sound.

Example:

STOP_SOUND /* Stop playing the current sound.*/


Operation

This command clears the operation logging.

Example:

CLR_OP_LOG /* Clear operation logging.*/


Operation:

Calculates the arccosine of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result in the range 0 to π. If the value of P2 is less than -1 or greater than 1, the result will be an indefinite by default.
P2 | I/C | The value between -1 to 1 whose arccosine is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 0 (F) /* Assign 0 to $U100 (and $U101)*/

$U200 = ACOS($U100) (F) /* Write the result 1.570796 of arccosine of 0 to $U200 (and $U201)*/


Operation:

Calculates the arcsine of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result in the range -π/2 to π/2. If the value of P2 is less than -1 or greater than 1, the result will be an indefinite by default.
P2 | I/C | The value between -1 to 1 whose arcsine is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = -0.5 (F) /* Assign -0.5 to $U100 (and $U101)*/

$U200 = ASIN($U100) (F) /* Write the result -0.523599 of arcsine of -0.5 to $U200 (and $U201)*/


Operation:

Calculates the arctangent of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result in the range -π/2 to π/2. If the value of P2 is 0, the result will be 0.
P2 | I/C | The value whose arctangent is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 236.89 (F) /* Assign 236.89 to $U100 (and $U101)*/

$U200 = ATAN($U100) (F) /* Write the result 1.566575 of arctangent of 236.89 to $U200 (and $U201)*/


Operation:

Calculates the arctangent of the value of P2 / P3 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result in the range -π to π. If the value of P2 and P3 both are 0, the result will be 0.
P2 | I/C | The value whose arctangent is to be calculated.
P3 | I/C | The value whose arctangent is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 60 (F) /* Assign 236.89 to $U100 (and $U101)*/

$U102 = 3 (F) /* Assign 236.89 to $U100 (and $U101)*/

$U200 = ATAN($U100,$U102) (F) /* Write the result 1.520838 of arctangent of 60/3 to $U200 (and $U201)*/


Operation:

Calculates the cosine of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result in the range -1 to 1.
P2 | I/C | The angle in radians whose cosine is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 1.570796 (F) /* Assign 1.570796 to $U100 (and $U101)*/

$U200 = COS($U100) (F) /* Write the result 0 of cosine of 1.570796 to $U200 (and $U201)*/


Operation:

Calculates the sine of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result in the range -1 to 1.
P2 | I/C | The angle in radians whose sine is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 1.570796 (F) /* Assign 1.570796 (2/π) to $U100 (and $U101)*/

$U200 = SIN($U100) (F) /* Write the result 1 of sine of 1.570796 to $U200 (and $U201)*/


Operation:

Calculates the tangent of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result.
P2 | I/C | The angle in radians whose tangent is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 0.785398 (F) /* Assign 0.785398 to $U100 (and $U101)*/

$U200 = TAN($U100) (F) /* Write the result 1 of tangent of 0.785398 to $U200 (and $U201)*/


Operation:

Calculates the exponential of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result.
P2 | I/C | The floating point parameter whose exponential is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 2.302585 (F) /* Assign 2.302585 to $U100 (and $U101)*/

$U200 = EXP($U100) (F) /* Write the result 10 of exponential of 2.302585 to $U200 (and $U201)*/


Operation:

Calculates the natural (base-e) logarithms of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result.
P2 | I/C | The floating point parameter whose logarithm is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 9000 (F) /* Assign 9000 to $U100 (and $U101)*/

$U200 = LOG($U100) (F) /* Write the result 9.104980 of logarithms of 9000 to $U200 (and $U201)*/


Operation:

Calculates the common (base-10) logarithms of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result.
P2 | I/C | The floating point parameter whose logarithm is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 9000 (F) /* Assign 9000 to $U100 (and $U101)*/

$U200 = LOG10($U100) (F) /* Write the result 3.954242 of logarithms of 9000 to $U200 (and $U201)*/


Operation:

Calculates P2 raised to the power of P3 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result.
P2 | I/C | The base value.
P 3 | I/C | The exponent value.

I: Internal Variable; C: Constant

Example:

$U100 = 2 (F) /* Assign 2 to $U100 (and $U101)*/

$U102 = 3 (F) /* Assign 3 to $U102 (and $U101)*/

$U200 = POW($U100,$U102) (F) /* Write the result 8(2 to the power of 3 is 8) to $U200 (and $U201)*/


Operation:

Calculates the square root of the value of P2 and saves the result to P1.

Parameters:

 | Type | Description
P1 | I | The result.
P2 | I/C | The nonnegative floating point value whose square root is to be calculated.

I: Internal Variable; C: Constant

Example:

$U100 = 45.35 (F) /* Assign 45.35 to $U100 (and $U101)*/

$U200 = SQRT($U100) (F) /* Write the result 6.73 of square root of 45.35 to $U200 (and $U201)*/


Operation:

Receives the data of recipe block P2 from HMI Server and saves the completion code in P1. P3 stores the percentage of completion. This command can only be used in a Main Macro, Cycle Macro and Time Macro。

Parameters:

 | Type | Description
P1 | I | The word parameter receives the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise, the operation failed.
P2 | I/C | The ID of the recipe block to be received.
P3 | I | The percentage of completion.

I: Internal Variable; C: Constant;

Examples:

$U20 = GET_RCP_BLK(1, $U40) /* The ID of the recipe block to be received is 1. The percentage of completion will be stored in $U40 . The result code of the execution will be save in $U20 */


Operation:

Sends the recipe block P2 in HMI client to HMI Server. P3 stores the percentage of completion. P1 saves the completion code. This command can only be used in a Main Macro, Cycle Macro and Time Macro。

Parameters:

 | Type | Description
P1 | I | The word parameter receives the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise, the operation failed.
P2 | I/C | The ID of the recipe block to be sent.
P3 | I | The percentage of completion.

I: Internal Variable; C: Constant;

Example:

$U20 = SET_RCP_BLK(1, $U40) /* The ID of the recipe block to be sent is 1. The percentage of completion will be stored in $U40 . The result code of the execution will be save in $U20 */


Operation:

Publishes MQTT message by UNICODE topic P2 and UNICODE message P3. P4 specifies the service type. P1 receives the result。

Parameters:

Type

Size

Description

P1

I

W

The word parameter receives the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise, the operation failed.

P2

I

WA

Specifies the null-terminated UNICODE topic.

P3

I

WA

Specifies the null-terminated UNICODE message.

P4

I/C

W

Specifies the service type. The following tables list the service type.

Bit 1 | Bit 0 | Quality of Service
0 | 0 | A message is delivered at most once。
0 | 1 | A message is delivered at least once。

Bit 2 | Retain Messages
0 | No
1 | Yes

Bit 15~3 | Description
Reserved | Must be 0

I: Internal Variable; C: Constant; W: 16-bit Word; WA: 16-bit Word Array

Example 1:

$U20 = L"John/Test001"

$U40 = L"Hello!"

$U60 = MqttP($U20, $U40, 0) /* 。*/


Operation:

Publishes MQTT message by topic ID P2 and UNICODE string P3. P4 specifies the service type. P1 receives the result。

Parameters:

Type

Size

Description

P1

I

W

The word parameter receives the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise, the operation failed.

P2

I

WA

Specifies the topic ID。

P3

I

WA

Specifies the null-terminated UNICODE message.

P4

I/C

W

Specifies the service type. The following tables list the service type.

Bit 1 | Bit 0 | Quality of Service
0 | 0 | A message is delivered at most once。
0 | 1 | A message is delivered at least once。

Bit 2 | Retain Messages
0 | No
1 | Yes

Bit 15~3 | Description
Reserved | Must be 0

I: Internal Variable; C: Constant; W: 16-bit Word; WA: 16-bit Word Array

Example 1:

$U40 = L"Hello!"

$U10 = MqttP_IS( 1, $U40, 0)


Operation:

Publishes MQTT message by topic ID P2 and text format ID P3. P4 specifies the service type. P1 receives the result。

Parameters:

Type

Size

Description

P1

I

W

The word parameter receives the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise, the operation failed.

P2

I

WA

Specifies the topic ID。

P3

I

WA

Specifies the text format ID in text format table.

P4

I/C

W

Specifies the service type. The following tables list the service type.

Bit 1 | Bit 0 | Quality of Service
0 | 0 | A message is delivered at most once。
0 | 1 | A message is delivered at least once。

Bit 2 | Retain Messages
0 | No
1 | Yes

Bit 15~3 | Description
Reserved | Must be 0

I: Internal Variable; C: Constant; W: 16-bit Word; WA: 16-bit Word Array

Example 1:

$U10 = MqttP_IF( 1, 15, 0)


Operation:

Gets the earliest MQTT message in the system buffer. P2 receives the topic of the message. P3 receives the message. P4 receives the length of the topic. P1 receives the length of the message.

The received MQTT message will be cached in the system buffer. When the macro is executed, the earliest message will be removed from the system buffer and saves to the user specified buffer. So the message can be taken once only.

Parameters:

 | Type | Size | Description
P1 | I | W | Receives the length of the message. If the length is 0, the length of the message is 0 or no message is received.
P2 | I | WA | Receives the topic of the message. The word array must be large enough to hold the UNICODE string and the null terminator.
P3 | I | WA | Receives the message. The word array must be large enough to hold the UNICODE string and the null terminator.
P4 | I/C | W | Receives the length of the topic. The null-terminator is not included and each character occupys two bytes.

I: Internal Variable; C: Constant; W: 16-bit Word; WA: 16-bit Word Array

Example 1:

$U10 = MqttGet( $U20, $U120, $U11) /* Get the earliest MQTT message in the system buffer. $U10 - receives the length of the message $U20 - receives the topic of the message $U120 - receives the message $U11 - receives the length of the topic*/


Operation:

Checks a MQTT topic P2 and saves the topic ID in P1. The topic length specifies in P3.

Parameters:

 | Type | Size | Description
P1 | I | W | The word parameter receives the completion code of the operation. If the completion code is 0, the topic is unknown; otherwise, the value is topic ID。
P2 | I | WA | The word array that holds the UNICODE topic string to be converted.
P3 | I | W | Specifies the length of the string.
P4 | I/C | W | Reserved for future use. Must be 0.

I: Internal Variable; C: Constant; W: 16-bit Word; WA: 16-bit Word Array

Example 1:

0\msgLen = MqttGet( (0\topic[0], 0\msg[0], 0\topicLen) /**/

0\topicId = MqttChkTopic( (0\topic[0], 0\topicLen, 1)


Operation:

Parses MQTT message P3 by given text format ID P2 and saves the values in UNICODE string to specified internal variable. The message length specifies in P4 and the completion code of the operation saves in P1.

Parameters:

 | Type | Size | Description
P1 | I | W | The word parameter receives the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise, the operation failed.
P2 | C | W | Text format ID in Text format Table
P3 | I | WA | The word array that holds the UNICODE string to be converted.
P4 | I/C | W | Specifies the length of the string.

I: Internal Variable; C: Constant; W: 16-bit Word; WA: 16-bit Word Array

Example 1:

0\msgLen = MqttGet( 0\topic[0], 0\msg[0], 0\topicLen) /**/

0\topicId = MqttChkTopic( (0\topic[0], 0\topicLen, 1)

if 0\topicId == 1 // The topic ID is 1
0\result = MqttProcMsg(6, 0\msg[0], 0\msgLen) /* Process the message according to the text format #6 */
if 0\result == 0 // OK
endif
endif


Operation:

Sends short message to predefined cell phone through IDCS server and saves the result in P1. Specifies the type of short message in P2 and format ID in P3.

Parameters:

 | Type | Size | Description
P1 | I | W | The word parameter receives the completion code of the operation. If the completion code is 0, the operation succeeded; otherwise, the operation failed.
P2 | I/C | W | The type of short message. 0: Alarm; 1: Warning; 2: Message
P3 | I | W | Text Format ID in Text Format Table.

I: Internal Variable; C: Constant; W: 16-bit Word;

Examples:

$U10 = SendSM(1, 15)


Operation:

Draws a circle on the drawing pad object with the parameters saved in the memory block P1 . This command is available for Drawing Macro of Drawing Pad object only.

Parameters:

Type

Description

P 1

I

The starting location of the word memory block (or word array) that stores the drawing parameters. A Parameter Block for circle drawing requires 6 words. The structure is shown below:

Word No. | Mnemonic | Description
0 | X | The X coordinate of the center of the circle.
1 | Y | The Y coordinate of the center of the circle.
2 | r | The radius of the circle.
3 | options | The drawing options. Bit 0: Outline the circle with the outline color if the bit is 1. Bit 1: Fill the circle with the fill color if the bit is 1.
4 | fColor | The fill color.
5 | oColor | The outline color.

Note: All the coordinates are related to the object.

I: Internal Variable

Color Values:

Color | Value | Color | Value
Black | 0x0000 | White | 0xFFFF
Blue | 0x0010 | Light Blue | 0x001F
Green | 0x0400 | Light Green | 0x07E0
Cyan | 0x0410 | Light Cyan | 0x07FF
Red | 0x8000 | Light Red | 0xF800
Magenta | 0x8010 | Light Magenta | 0xF81F
Brown | 0x8400 | Yellow | 0xFFE0
Dark Gray | 0x8410 | Gray | 0xC618

Example:

$U100 = 80 /* X */

$U101 = 128 /* Y */

$U102 = 60 /* r */

$U103 = 3 /* Outline and fill the circle. */

$U104 = 0x0400 /* Fill the circle with green. */

$U105 = 0x0000 /* Outline the circle with black. */

Circle($U100) /* Draw a circle on the drawing pad with the settings in the memory block from $U100 .*/


Operation:

Draws an ellipse on the drawing pad object with the parameters saved in the memory block P1 . This command is available for Drawing Macro of Drawing Pad object only.

Parameters:

Type

Description

P 1

I

The starting location of the word memory block (or word array) that stores the drawing parameters. A Parameter Block for ellipse drawing requires 7 words. The structure is shown below:

Word No. | Mnemonic | Description
0 | X1 | The X coordinate of the upper-left position of the bounding rectangle of the ellipse.
1 | Y1 | The Y coordinate of the upper-left position of the bounding rectangle of the ellipse.
2 | X2 | The X coordinate of the lower-right position of the bounding rectangle of the ellipse.
3 | Y2 | The Y coordinate of the lower-right position of the bounding rectangle of the ellipse.
4 | options | The drawing options. Bit 0: Outline the ellipse with the outline color if the bit is 1. Bit 1: Fill the ellipse with the fill color if the bit is 1.
5 | fColor | The fill color.
6 | oColor | The outline color.

Note: All the coordinates are related to the object.

I: Internal Variable

Color Values:

Color | Value | Color | Value
Black | 0x0000 | White | 0xFFFF
Blue | 0x0010 | Light Blue | 0x001F
Green | 0x0400 | Light Green | 0x07E0
Cyan | 0x0410 | Light Cyan | 0x07FF
Red | 0x8000 | Light Red | 0xF800
Magenta | 0x8010 | Light Magenta | 0xF81F
Brown | 0x8400 | Yellow | 0xFFE0
Dark Gray | 0x8410 | Gray | 0xC618

Example:

$U100 = 160 /* X1 */

$U101 = 100 /* Y1 */

$U102 = 297 /* X2 */

$U103 = 153 /* Y2 */

$U104 = 1 /* Outline the ellipse only. */

$U106 = 0x8010 /* Outline the ellipse with magenta. */

Ellipse($U100) /* Draw a ellipse on the drawing pad with the settings in the memory block from $U100 .*/


Operation:

Draws a line on the drawing pad object with the parameters saved in the memory block P1 . This command is available for Drawing Macro of Drawing Pad object only.

Parameters:

Type

Description

P 1

I

The starting location of the word memory block (or word array) that stores the drawing parameters. A Parameter Block for line drawing requires 6 words. The structure is shown below:

Word No. | Mnemonic | Description
0 | X1 | The X coordinate of the starting position of the line.
1 | Y1 | The Y coordinate of the starting position of the line.
2 | X2 | The X coordinate of the ending position of the line.
3 | Y2 | The Y coordinate of the ending position of the line.
4 | c olor | The color of the line.
5 | t hickness | The thickness of the line. There are 4 valid thickness: 1, 3, 5, and 7.

Note: All the coordinates are related to the object.

I: Internal Variable

Color Values:

Color | Value | Color | Value
Black | 0x0000 | White | 0xFFFF
Blue | 0x0010 | Light Blue | 0x001F
Green | 0x0400 | Light Green | 0x07E0
Cyan | 0x0410 | Light Cyan | 0x07FF
Red | 0x8000 | Light Red | 0xF800
Magenta | 0x8010 | Light Magenta | 0xF81F
Brown | 0x8400 | Yellow | 0xFFE0
Dark Gray | 0x8410 | Gray | 0xC618

Example:

$U100 = 144 /* X1 */

$U101 = 24 /* Y1 */

$U102 = 204 /* X2 */

$U103 = 84 /* Y2 */

$U104 = 0x0010 /* Set the color of the line to blue. */

$U105 = 1 /* Set the thickness of the line to 1 pixel. */

Line($U100) /* Draw a line on the drawing pad with the settings in the memory block from $U100 .*/


Operation:

Draws an one-pixel point on the drawing pad object with the parameters saved in the memory block P1 . This command is available for Drawing Macro of Drawing Pad object only.

Parameters:

Type

Description

P 1

I

The starting location of the word memory block (or word array) that stores the drawing parameters. A Parameter Block for point drawing requires 3 words. The structure is shown below:

Word No. | Mnemonic | Description
0 | X | The X coordinate of the point.
1 | Y | The Y coordinate of the point.
2 | Color | The color of the point.

Note: All the coordinates are related to the object.

I: Internal Variable

Color Values:

Color | Value | Color | Value
Black | 0x0000 | White | 0xFFFF
Blue | 0x0010 | Light Blue | 0x001F
Green | 0x0400 | Light Green | 0x07E0
Cyan | 0x0410 | Light Cyan | 0x07FF
Red | 0x8000 | Light Red | 0xF800
Magenta | 0x8010 | Light Magenta | 0xF81F
Brown | 0x8400 | Yellow | 0xFFE0
Dark Gray | 0x8410 | Gray | 0xC618

Example:

$U100 = 216 /* X */

$U101 = 40 /* Y */

$U105 = 0xF800 /* Set the color of the point to light red. */

Point($U100) /* Draw a point on the drawing pad with the settings in the memory block from $U100 .*/


Operation:

Draws a polygon on the drawing pad object with the parameters saved in the memory block P1 . This command is available for Drawing Macro of Drawing Pad object only.

Parameters:

Type

Description

P 1

I

The starting location of the word memory block (or word array) that stores the drawing parameters. The structure is shown below:

Word No. | Mnemonic | Description
0 | nsides | Specifies how many sides the polygon has. Assume there are N sides in this description.
1 | options | The drawing options. Bit 0: Outline the polygon with the outline color if the bit is 1. Bit 1: Fill the polygon with the fill color if the bit is 1.
2 | fColor | The fill color.
3 | oColor | The outline color.
4 | thickness | The thickness of the outline. There are 4 valid thickness: 1, 3, 5, and 7.
5 | X1 | The X coordinate of the first corner of the polygon.
6 | Y1 | The Y coordinate of the first corner of the polygon.
... | ... | ...
2*N+3 | Xn | The X coordinate of the last corner of the polygon.
2*N+4 | Yn | The Y coordinate of the last corner of the polygon.

Note: All the coordinates are related to the object.

I: Internal Variable

Color Values:

Color | Value | Color | Value
Black | 0x0000 | White | 0xFFFF
Blue | 0x0010 | Light Blue | 0x001F
Green | 0x0400 | Light Green | 0x07E0
Cyan | 0x0410 | Light Cyan | 0x07FF
Red | 0x8000 | Light Red | 0xF800
Magenta | 0x8010 | Light Magenta | 0xF81F
Brown | 0x8400 | Yellow | 0xFFE0
Dark Gray | 0x8410 | Gray | 0xC618

Example:

$U100 = 5 /* The polygon has 5 sides */

$U101 = 3 /* Outline and fill the polygon. */

$U102 = 0xFFFF /* Fill the polygon with white. */

$U103 = 0x001F /* Outline the polygon with light blue. */

$U104 = 5 /* Set the thickness of the outline to 5. */

$U105 = 113 /* X1 */

$U106 = 225 /* Y1 */

$U107 = 162 /* X2 */

$U108 = 278 /* Y2 */

$U109 = 93 /* X3 */

$U110 = 276 /* Y3 */

$U111 = 56 /* X4 */

$U112 = 220 /* Y4 */

$U113 = 82 /* X5 */

$U114 = 216 /* Y5 */

Polygon($U100) /* Draw a polygon on the drawing pad with the settings in the memory block from $U100 .*/


Operation:

Draws a polyline on the drawing pad object with the parameters saved in the memory block P1 . This command is available for Drawing Macro of Drawing Pad object only.

Parameters:

Type

Description

P 1

I

The starting location of the word memory block (or word array) that stores the drawing parameters. The structure is shown below:

Word No. | Mnemonic | Description
0 | nPoints | Specifies how many end points the polyline has. Assume there are N end points in this description.
3 | color | The color of the polyline.
4 | thickness | The thickness of the polyline. There are 4 valid thickness: 1, 3, 5, and 7.
5 | X1 | The X coordinate of the first end point of the polyline .
6 | Y1 | The Y coordinate of the first end point of the polyline .
... | ... | ...
2*N+1 | Xn | The X coordinate of the last end point of the polyline .
2*N+2 | Yn | The Y coordinate of the last end point of the polyline .

Note: All the coordinates are related to the object.

I: Internal Variable

Color Values:

Color | Value | Color | Value
Black | 0x0000 | White | 0xFFFF
Blue | 0x0010 | Light Blue | 0x001F
Green | 0x0400 | Light Green | 0x07E0
Cyan | 0x0410 | Light Cyan | 0x07FF
Red | 0x8000 | Light Red | 0xF800
Magenta | 0x8010 | Light Magenta | 0xF81F
Brown | 0x8400 | Yellow | 0xFFE0
Dark Gray | 0x8410 | Gray | 0xC618

Example:

$U100 = 4 /* The polyline has 4 points */

$U101 = 0x8400 /* Set the color of the polyline to brown. */

$U102 = 5 /* Set the thickness of the outline to 5. */

$U103 = 220 /* X1 */

$U104 = 200 /* Y1 */

$U105 = 224 /* X2 */

$U106 = 264 /* Y2 */

$U107 = 268 /* X3 */

$U108 = 216 /* Y3 */

$U109 = 308 /* X4 */

$U110 = 289 /* Y4 */

Polyline($U100) /* Draw a polyline on the drawing pad with the settings in the memory block from $U100 .*/


Operation:

Draws a rectangle on the drawing pad object with the parameters saved in the memory block P1 . This command is available for Drawing Macro of Drawing Pad object only.

Parameters:

Type

Description

P 1

I

The starting location of the word memory block (or word array) that stores the drawing parameters. A Parameter Block for rectangle drawing requires 8 words. The structure is shown below:

Word No. | Mnemonic | Description
0 | X1 | The X coordinate of the upper-left position of the rectangle.
1 | Y1 | The Y coordinate of the upper-left position of the rectangle.
2 | X2 | The X coordinate of the lower-right position of the rectangle.
3 | Y2 | The Y coordinate of the lower-right position of the rectangle.
4 | options | The drawing options. Bit 0: Outline the rectangle with the outline color if the bit is 1. Bit 1: Fill the rectangle with the fill color if the bit is 1.
5 | fColor | The fill color.
6 | oColor | The outline color.
7 | thickness | The thickness of the outline. There are 4 valid thickness: 1, 3, 5, and 7.

Note: All the coordinates are related to the object.

I: Internal Variable

Color Values:

Color | Value | Color | Value
Black | 0x0000 | White | 0xFFFF
Blue | 0x0010 | Light Blue | 0x001F
Green | 0x0400 | Light Green | 0x07E0
Cyan | 0x0410 | Light Cyan | 0x07FF
Red | 0x8000 | Light Red | 0xF800
Magenta | 0x8010 | Light Magenta | 0xF81F
Brown | 0x8400 | Yellow | 0xFFE0
Dark Gray | 0x8410 | Gray | 0xC618

Example:

$U100 = 24 /* X1 */

$U101 = 20 /* Y1 */

$U102 = 118 /* X2 */

$U103 = 58 /* Y2 */

$U104 = 3 /* Outline and fill the rectangle. */

$U105 = 0xFFE0 /* Fill the rectangle with yellow. */

$U106 = 0x8000 /* Outline the rectangle with red. */

$U107 = 3 /* Set the thickness of the outline to 3. */

Rectangle($U100) /* Draw a rectangle on the drawing pad with the settings in the memory block from $U100 .*/