Think Automation and beyond… FT1A Script Programming.

Slides:



Advertisements
Similar presentations
Escape Sequences \n newline \t tab \b backspace \r carriage return
Advertisements

2.1 Program Construction In Java
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Control Structures Any mechanism that departs from straight-line execution: –Selection: if-statements –Multiway-selection: case statements –Unbounded iteration:
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
IM 215 Operators, Conditions and Loops. Review Nature of Javascript How to include Javascript on a page Declaring and assigning variables Commenting code.
True or false A variable of type char can hold the value 301. ( F )
10-Jun-15 Just Enough Java. Variables A variable is a “box” that holds data Every variable has a name Examples: name, age, address, isMarried Variables.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
Chapter 6 - Repetition. Introduction u Many applications require certain operations to be carried out more than once. Such situations require repetition.
ספטמבר 04Copyright Meir Kalech1 C programming Language Chapter 2: Control Flow.
Rules of Integers. Positive numbers are numbers that are above zero. Negative numbers are numbers below zero.
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Variables 1.
Python  By: Ben Blake, Andrew Dzambo, Paul Flanagan.
4. Python - Basic Operators
Programmable Logic Controllers
CONTROL STATEMENTS IF-ELSE, SWITCH- CASE Introduction to Computer Science I - COMP 1005, 1405 Instructor : Behnam Hajian
2440: 211 Interactive Web Programming Expressions & Operators.
Control Structures – Selection Chapter 4 2 Chapter Topics  Control Structures  Relational Operators  Logical (Boolean) Operators  Logical Expressions.
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Input, Output, and Processing
1 Conditions Logical Expressions Selection Control Structures Chapter 5.
Flow of Control Part 1: Selection
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Operators Precedence - Operators with the highest precedence will be executed first. Page 54 of the book and Appendix B list C's operator precedence. Parenthesis.
Chapter 12 Variables and Operators. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Basic C Elements.
A summary of TOY. 4 Main Components Data Processor Control Processor Memory Input/Output Device.
Chapter 6 Mathematical Operations. 6.1 Mathematical Expressions In mathematics this expression is valid 0 = -4y + 5 It is invalid in programming Left.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Digital Image Processing Lecture 6: Introduction to M- function Programming.
Repetition Statements (Loops) The do while Loop The last iteration structure in C++ is the do while loop. A do while loop repeats a statement or.
Programming Fundamentals. The setw Manipulator setw changes the field width of output. The setw manipulator causes the number (or string) that follows.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Decision Statements, Short- Circuit Evaluation, Errors.
Controlling Program Flow with Decision Structures.
Chapter 6: Looping. Objectives Learn about the loop structure Create while loops Use shortcut arithmetic operators Create for loops Create do…while loops.
C Language 1 Program Looping. C Language2 Topics Program looping Program looping Relational operators / expressions Relational operators / expressions.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
1 Flow of Control Chapter 5. 2 Objectives You will be able to: Use the Java "if" statement to control flow of control within your program.  Use the Java.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Learning Javascript From Mr Saem
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
‘C’ Programming Khalid Jamal.
Chapter 12 Variables and Operators
Assignment statement:
C Short Overview Lembit Jürimägi.
Introduction to MATLAB
Control Structures – Selection
Chapter 12 Variables and Operators
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
Arrays, For loop While loop Do while loop
Chapter 11 © 2011, The McGraw-Hill Companies, Inc.
Selection CIS 40 – Introduction to Programming in Python
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
3 Control Statements:.
Repetition Control Structure
C Programming Getting started Variables Basic C operators Conditionals
2.6 The if/else Selection Structure
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
WindLDR - Script.
Chapter 3: Selection Structures: Making Decisions
Control System Applications (2)
Presentation transcript:

Think Automation and beyond… FT1A Script Programming

Think Automation and beyond… 2 Areas to use Script  How Device is defined in Display Function  Internal PLC device [#Dxxxx] where # signified internal PLC  Internal HMI device [LDRxxxx]  External Host (PLC) device [0:Dxxxx] where 0 is defined as station number  How Device is defined in Control Function  Device is defined as [Dxxxx]  In FT1A Touch, Scripts can be utilized in both Control (Ladder) and Display areas  The difference is how Device address inside the [ ] brackets are defined  For the rest of this PPT, we’ll mainly focus on Script in Display function and internal PLC device

Think Automation and beyond… Program Syntax Each line of code needs to be ended with a semicolon “ ; ” 1 set of characters ended with semicolon is called a statement Each statement is executed from top to bottom. Device is specified within square brackets […]

Think Automation and beyond… Available Operators Order of Operation OperatorDescription High( ) Commands inside parenthesis get executed first ! ~ - Reverse the logic, Reverse logic each bit, negative * / % Multiply, Divide, Remainder + - Addition, Subtraction > Shift bit left, Shift bit right & And ^ Calculates the exclusive logical sum of each bit | Calculates the logical sum (OR) of each bit >= Compare greater, equal or less, less, equal greater == != Compare equal to, Compare Not equal to && Calculates the logical product || Calculates the logical sum Low= Copy

Think Automation and beyond… Constants  Constants can be expressed in Decimal or Hexadecimal Decimal Numbers can be expressed in the following form: (negative value) (floating point value) Hexadecimal Numbers can be expressed in the following form: 0x12AB (“0” zero and letter “x” at the beginning of the value) 12ABh (“h” at the end of the value)

Think Automation and beyond… How Script Works - Basic Equal sign (=) specifies that data is copied from right-hand to left-hand side device. In this case, 1234 is stored to D100. Another example, [D50] = [D70]; value in D70 is copied to D50. Multiple operators can be used in 1 statement. In this example, values stored in D300, D400, and D500 are added and then divided by 3. Result is stored in D200.

Think Automation and beyond… Flow Control Statements  Flow control is also called “Branching” or “Looping”  The following statements can be used:  Conditional Branch  If, Else, Else If, Switch-case  Repeat  While  Halt and Exit  Break, Return

Think Automation and beyond… Branching – Example 1 if ([#D30] > 500) { [#D100] = [#D100] +1; } The statements within curly brackets are executed only when D30 is greater than 500. In this case, D100 is increment by 1 at every Scan time. The condition within parenthesis is checked. If the condition is true, statements within the curly brackets are executed  IF statement

Think Automation and beyond… Branching – Example 2  IF - ELSE statement 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.

Think Automation and beyond… Branching – Example 3  IF - ELSE IF – ELSE statement if ([#D30] > 500) { [#D100] = [#D100] +1; } else if ([#D30] > 400) { [#D101] = [#D101] +1; } else if ([#D30] > 300) { [#D102] = [#D102] +1; } else { [#D103] = [#D103] +1; } ELSE IF can be used as many time 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 less than or equal to 300. 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 only when D30 is greater than 500. Note: If this condition is met, the following else if clauses are NOT executed.

Think Automation and beyond… Branching – Example 4  Nested IF statement if ([#D102]) { if ([#D103]) { [#D104] = 100; } else { [#D104] = 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.

Think Automation and beyond… Looping – Example 1  WHILE statement [#D100] = 10; [#D102] = 10; while ([#D100] > 0) { [#D102] = [#D102] + 1; [#D100] = [#D100] - 1; } Those statements within curly brackets are repeatedly executed while D100 is greater than 0. Once D100 becomes 0, execution of while loop is terminated. The condition within parenthesis is checked. While the condition is true, statements within the curly brackets are repeatedly executed

Think Automation and beyond… Looping – Caution [#D100] = 10; while (0 != [#D100]) { [#D200] = [#D200] + 1; } This condition is always true and while loop never ends, resulting in watchdog timeout error.  Caution – Infinite Loop You need to make sure that the condition will be false after the intended loop operations are executed.

Think Automation and beyond… Looping – Example 2 [#D100] = 0; [#D102] = 3; [#D103] = 5; while ([#D100] == 0) { [#D102] = [#D102] + 1; if ([#D103] == [#D102] ) { SET ([#M0000]); break; }  Loop with Break Once the execution reaches break; statement, the execution goes out of while loop. If D103 is equal to D102, M0 is turned on and the while loop is ended with break statement.

Think Automation and beyond… Other Functions TypeCommand BITSET, RST, REV ARITHMETICMAX, 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 & COPY MEMCMP, MEMCPY, BITS2BITS, BITS2WORD, WORD2BITS OFFSET

Think Automation and beyond… Offset – Example 1  OFFSET is a powerful function used for indirect read & write. It’s quite important when you use while loop. [#D0300] = OFFSET ([#D0010], [#D0020]); When the value stored in D20 is 8, the value in D18 (D10 + 8), is read and stored in D300.

Think Automation and beyond… Offset – Example 2  Indirect Write OFFSET ([#D0010], [#D0020]) = 1234; When the value stored in D20 is 3, a constant 1234 is moved to D13 (D10 + 3).

Think Automation and beyond… Offset – Example 3  Indirect Write and Read using While statement // Transfer D10 through D19 to D100 through D109 // Initialize offset value [#D0000] = 0; // Loop 10 times while ([#D0000] < 10) { // Transfer 1 word by indirect assignment OFFSET ([#D0100], [#D0000]) = OFFSET ([#D0010], [#D0000]); // Increment indirect value [#D0000] = [#D0000] + 1; }

Think Automation and beyond… Data Type 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.  Data Type Limitation: only 1 data type for each script

Think Automation and beyond… Temporary Device In Script, temporary memory is provided for storing temporary data. Benefit: you don’t have to use data registers to pass values from 1 calculation to another. Below is just an = [#D1] / 10 * 8 + [#D1] % = [#D2] / 10 * 8 + [#D2] % 10; [#D10] [#D11] = / 2;

Think Automation and beyond… Comments All comments start with // Comment data is not executed Comment data is also restored when program is uploaded from PLC. Comment can be described in the same line with a statement.  To make the script descriptive, you can add comments which will not get executed

Think Automation and beyond… How Script is Executed Display Function  Script in Display area is available in Script Command and Global script  Script Command executes in accordance with trigger conditions and only in the screens where it is placed.  Multiple scripts can be set for each screen  Global script is executed regardless of which screen is being displayed  Only 1 script can be set for the project

Think Automation and beyond… How Script is Executed Display Function  Global Script 1.Under Configuration tab, select Global Script and check Use Global Script 2.Click and create your script in Script Manager 3.Click Trigger Condition tab and select trigger type 1 2 3

Think Automation and beyond… How Script is Executed Display Function  Command Script 1.Under Home tab, click Commands  Script Command and click on the screen 2.Click and create your script in Script Manager 3.Click Trigger Condition tab and select trigger device 1 3 2

Think Automation and beyond… How Script is Executed Control Function When M11 is turned on, Script 4 is executed. Use SOTU/SOTD if you want to execute script only once.

Think Automation and beyond… Script Comparison HG Touch Screen FT1A Touch Display FT1A Controller FT1A Touch Controller Temporary devices16 Data typeWord, Integer, Double, Long, Float, BCD4, BCD8 Word, Integer, Double, Long, Float Number of scripts65, How to useGlobal script, Script Command SCRPT instruction/Function Block ProgrammingWindO/I-NV2 and WindO/I-NV3 WindLDR