Section 15.4.5 · Chapter 15: Using Macros
Calculation
■ MAX
| Format | P1 = MAX(P2,P3) | Data Type | U/S/UD/SD/F |
|---|---|---|---|
| Function | Sets P1 to the larger value of P2 and P3. | ||
| P1 (I/E) | The location to save the result. | ||
| P2,P3(I/E/C) | The operands. | ||
| Example 1 | $U100 = MAX(100, 200) /* Set $U100 to 200 */ | ||
■ MIN
| Format | P1 = MIN(P2,P3) | Data Type | U/S/UD/SD/F |
|---|---|---|---|
| Function | Sets P1 to the smaller value of P2 and P3. | ||
| P1 (I/E) | The location to save the result. | ||
| P2,P3(I/E/C) | The operands. | ||
| Example 1 | $U100 = MIN(100, 200) /* Set $U100 to 100 */ | ||
■ BMAX
| Format | P1 = BMAX(P2,P3) | Data Type | U/S/UD/SD/F |
|---|---|---|---|
| Function | Finds the maximum in an array starting from P2 with P3 elements and saves the result in P1. | ||
| P1 (I) | The location to save the result. | ||
| P2 (I) | The starting location of the array. | ||
| P3 (I/C) | The size of the array. | ||
| Example 1 | $U100 = BMAX($U200, 16) (F) /* Find the maximum among 16 floating point numbers starting from $U200 and save the result in $U100 */ | ||
■ BMIN
| Format | P1 = BMIN(P2,P3) | Data Type | U/S/UD/SD/F |
|---|---|---|---|
| Function | Finds the minimum in an array starting from P2 with P3 elements and saves the result in P1. | ||
| P1 (I) | The location to save the result. | ||
| P2 (I) | The starting location of the array. | ||
| P3 (I/C) | The size of the array. | ||
| Example 1 | $U100 = BMIN($U200, 60) (F) /* Find the minimum among 60 floating point numbers starting from $U200 and save the result in $U100 */ | ||
■ SUM
| Format | P1 = SUM(P2,P3) | Data Type | U/S/UD/SD/F |
|---|---|---|---|
| Function | Calculates the sum of the value in an array starting from P2 with P3 elements and saves the result in P1. | ||
| P1 (I) | The location to save the result. | ||
| P2 (I) | The starting location of the array. | ||
| P3 (I/C) | The size of the array. | ||
| Example 1 | $U100 = SUM($U200, 16) (F) /* Calculate the sum of 16 floating point numbers starting from $U200 and save the result in $U100 */ | ||
■ XSUM
| Format | P1 = XSUM(P2,P3) | Data Type | U/UD |
|---|---|---|---|
| Function | 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. | ||
| P1 (I) | The location to save the result. | ||
| P2 (I) | The starting location of the array. | ||
| P3 (I/C) | The size of the array. | ||
| Example 1 |
$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 = 1100B $U102 = 0110B $U120 = XSUM($U100,3) /* $U120=0011B */ |
||
■ SWAP
| Format | SWAP(P1,P2) | Data Type | U |
|---|---|---|---|
| Function | Swaps the low byte and high byte of every word in a word array starting from P1 with P2 words. | ||
| P1 (I) | The starting location of the array. | ||
| P2 (I/C) | The size of the array. | ||
| Example 1 |
$U120=1111111100000000B $U121=1000000100000000B SWAP($U120, 2) /* The value of $U120 will be 0000000011111111B, The value of $U121 will be 000000010000001B */ |
||
■ INIT_CRC
| Format | INIT_CRC(P1) | Data Type | U | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Function | This command initializes the cyclical redundant check (CRC) calculations for CRC8 and CRC16 macro commands. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| P1 (I) |
The word block that contains the data to initialize CRC
calculations. The following table describes the data
arrangement in the word block.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Example 1 |
$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 */ |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
■ CRC8
| Format | P1 = CRC8(P2,P3) | Data Type | U |
|---|---|---|---|
| Function | Calculates the 8-bit CRC checksum of the data stored in P2 with a size of P3 and saves the result in P1. | ||
| 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. | ||
| Example 1 |
$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 */ |
||
■ CRC16
| Format | P1 = CRC16(P2,P3) | Data Type | U | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Function | Calculates the 16-bit CRC checksum of the data stored in P2 with a size of P3 and saves the result in P1. | ||||||||
| P1 (I) |
The word block to save the result.
|
||||||||
| 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. | ||||||||
| Example 1 |
$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 */ |
||||||||
Need PM Designer itself?
V4 for current PK, PT, ITV and PM panels, V2 for older models. Free, sent by email.
Source.Section 15.4.5 of the PM Designer Software User Manual, Edition 2.0, © Cermate Technologies Inc. (www.cermate.com, service@cermate.com). Reproduced online, with the manual's own figures, by TSL Automation Solutions, authorised Cermate distributor, for users of Cermate HMI panels. PM Designer and PanelMaster are trademarks of Cermate Technologies Inc.
Text and figures are the manufacturer's and may describe features your panel or software version does not have. For a plain-language introduction read the PM Designer guide; for help with a specific panel contact TSL Automation.