Download presentation
Presentation is loading. Please wait.
1
WindLDR - Script
2
HG and FT1A Differences HG Touch Screen FT1A Touch Display
FT1A Controller FT1A Touch Controller Functions Functions related to String and drawing are not supported BITS2BITS, BITS2WORD, WORD2BITS are added Temporary devices 16 32 Data type Word, Integer, Double, Long, Float, BCD4, BCD8 Word, Integer, Double, Long, Float Number of scripts 65535 255 How to use Global script, part SCRPT instruction/FB Programming WindO/I-NV WindLDR
3
Grammar Each line is ended with semi-colon ;
1 set of characters ended with semi-colon is called a statement. Each line (statement) is executed from the top to the bottom. Device is specified within square brackets
4
How Script Works - Basic
Equal Mark (=) specifies that data is copied from right hand side device to left hand side device. In this case, 1234 is stored to D100. For example, script is described as below, value in D70 is copied to D50. [D50] = [D70]; Multiple operators can be used in 1 line. In above case, values in D300, D400, and D500 are added and then divided by 3. Result is stored in D200. As a result, the average of 3 data registers is stored in D200. Note: Values of DRs on the right hand side of = are just referred and unchanged. Page 13-10
5
Constants Note: The range of constants varies depending on the selected data type. For example, data type I (Integer) is selected, the range is to Page 13-15
6
List of Operators Following operators are available to use. Page 13-35
7
Priority of Operators What is “Priority” of operators?
[D100] = * 5; The result of above statement is 23. Multiplication (*) is executed prior to Addition (+) because the priority of * is higher than the priority of +. If you want to change the priority, square brackets, which has the highest priority, can be used as follows: [D100] = (3 + 4) * 5; The result of above statement is 35. Use of square brackets is recommended to explicitly specify your intention.
8
Flow Control Statements
Flow control is “Branching” and “Looping”. The following statements are available to use in Script. Conditional branch: if, else, else if, switch - case Repeat: while Halt and exit: break, return The most simple form of the branching : if Example: if( [D30] > 500 ) { [D100] = [D100] + 1; } The condition within parenthesis is checked. If the condition is true, statements within the curly brackets are executed The statements within curly brackets are executed only when D30 is greater than 500. Page to 13-11
9
Flow Control Statements – Branching 1
Example: if – else if( [D30] > 500 ) { [D100] = [D100] + 1; } else [D100] = [D100] - 1; The statements within curly brackets are executed when D30 is greater than 500. The statements within curly brackets are executed when D30 is less than or equal to 500. Page to 13-11
10
Flow Control Statements – Branching 2
Example: if - else if – else if( [D30] > 500 ) { [D100] = [D100] + 1; } else if ( [D30] > 400 ) [D101] = [D101] + 1; else if ( [D30] > 300 ) [D102] = [D102] + 1; else [D103] = [D103] + 1; The statements within curly brackets are executed only when D30 is greater than 500. Note: If this condition is met, the following else if clauses are not executed. else if can be added as many as you want The statements within curly brackets are executed when D30 is greater than 400 and less than or equal to 500. The statements within curly brackets are executed when D30 is greater than 300 and less than or equal to 400. The statements within curly brackets are executed when D30 is less than or equal to 300. Page to 13-11
11
Flow Control Statements – Branching 3
Example: if clauses can be nested if ([D0102]) { if ([D0103]) [D0104] = 100; } else [D0104] = 200; When both D102 and D103 are greater than 0, 100 is stored in D104. When both D102 is greater than 0 but D103 is 0, 200 is stored in D104. Page to 13-11
12
Flow Control Statements – Looping 1
Example: while [D0100] = 10; [D0102] = 10; while (0 < [D0100]) { [D0102] = [D0102] + 1; [D0100] = [D0100] - 1; } The condition within parenthesis is checked. While the condition is true, statements within the curly brackets are repeatedly executed Those statements within curly brackets are repeatedly executed while D100 is greater than 0. Once D100 becomes 0, execution of while loop is ended. Page 13-17
13
Flow Control Statements – Looping 2
Caution: Infinite while loop You need to make sure that the condition will be false after the intended loop operations are executed. This condition is always met. The while loop never ends, resulting in watchdog timer error. Page 13-35
14
Flow Control Statements – Looping 3
Another way to end the loop: break If D103 is equal to D102, M0 is turned on and the while loop is ended with break statement. Once the execution reaches break; statement, the execution goes out of while loop. Page 13-18
15
Functions In addition to operators and flow control statements, special functions are provided: Bit function: SET, RST, REV Arithmetic Operation: MAX, MIN, EXP, LOGE, LOG10, POW, ROOT, SIN, COS, TAN, ASIN, ACOS, ATAN, RAD, DEG Data type conversion: BCD2BIN, BIN2BCD, FLOAT2BIN, BIN2FLOAT, DEC2ASCII, ASCII2DEC Data comparison and copy: MEMCMP, MEMCPY, BITS2BITS, BITS2WORD, WORD2BITS Offset: OFFSET Operations of the most functions are simple except OFFSET. Please refer to the user’s manual for details of each function. Page to 13-14
16
Functions – OFFSET 1 OFFSET is a powerful function used for indirect read & write and quite important when you use while loop. Page 13-34
17
Functions – OFFSET 2 Page 13-34
18
Functions – OFFSET 3 OFFSET with while loop
D10 thru D19 are copied to D100 thru D109. Page 13-18
19
Data Type You can select only 1 data type for each script.
Data type can be selected from Word, Integer, Double, Long, and Float Once data type is selected, all devices are handled as the selected data type. In above case, both D118 and D521 are handled as Float.
20
Temporary Devices During calculation, DR is used to store calculation result so that the calculation result can be used in another calculation. In Script, temporary device is provided for you to store such values. Benefit: you don’t have to prepare data registers used to pass values from 1 calculation to another calculation. Below is just an example: @1 = [D1] / 10 * 8 + [D1] % 10; @2 = [D2] / 10 * 8 + [D2] % 10; [D10] [D11] = / 2; Page & 13-19
21
Comments To make the script descriptive, you can add comments that are not executed. If you start a statement with // , the following text in the same line becomes comment. Comment data is not executed Comment data is also restored when the program is uploaded from PLC. Comment can be described in the same line with a statement.
22
How Script is Called (Ladder)
Use SOTU/SOTD if you want to execute script only once. When M11 is turned on, Script 4 is executed.
23
How Script is Called (FBD)
When Q1 is turned on, Script 4 is executed.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.