松下PLC 高级语言编程

Structured Text Language Structured Text Editor

Structured Text is a text based language and allows you to write complex programs and control structures using an optimized programming language.

+It is available for all PLCs.

+Requires no more resources compared to editors such as LD or IL.

Contrast to other languages

What is structured text

?You need to understand the following definitions: ?Construct:

Depending on the function, a construct may require one or more lines if iValue >4000then

iValue :=0;end_if;if iValue >4000then iValue :=0;end_if ;?Operand:

Any valid Matsushita operand ?Operator:

Logical and / or relational operator ?Comments:

Use comments for code documentation

TON1( IN:=Start1,PT:=T#300ms ,Q=> End1,EV=> EV_1);if TON1.Q then ....;end_if;

Calling FBs Y:=SIN(x);Y:=LIMIT(MN:=0,IN:=X,MX:=100);

Calling functions a :=87;b :=b+1;c :=SIN(x);

Assignment

Example

Description

Boolean OR

OR

Boolean exclusive OR XOR

Boolean AND &, AND Equal

Less than or Greater than =<>Comparison

>,<,>=,<=Addition Subtraction +-Raise to a power Multiplication Division

Modulo (remainder)***/

MOD Negation Complement -NOT Description Operator Operators

X:=A+B-C*SQRT(D);

Y0 := X0 AND X1 OR X2 AND NOT X3;

Example

Description CASE a OF 0:b:=0;1,2:

b:=1;100..110: b:=2;3,4,10..20:b:=3;ELSE b:=4;

END_CASE ;

Multiple selection

IF a >= 0AND a <= 10THEN

val1 := 10.3;ELSIF b > 100THEN

bFlag :=TRUE;ELSE

val1 := 0;END_IF ;Conditional

Nested IF..THEN

Single value List of values List and range of values Range of values Default values

Loop instruction

FOR i:=0 TO100 DO

FOR

SUM:=SUM + a[i]

END_FOR;

i:=0;

WHILE

WHILE i<=100AND a[i]<100DO

i:=i+10;

END_WHILE;

i:=0;

REPEAT

REPEAT

i:=i+10;

UNTIL i> 100OR a[i] >= 100

END_REPEAT;

Non-conditional exit

FOR i:=0 TO 100 DO

SUM:=SUM + a[i](* …*)

IF a[i]>=100 THEN

EXIT ;END_IF;(* …*)END_FOR;

FOR

RETURN;

Jump End

EXIT ;Quit loop Example

3. Develop a Function TwoPointControl

?3 inputs (Input ,

controlPoint ,hysteresis )

?1 output (bResult ) VAR_IN_OUT

2. Develop a function block FlashingLight

?3 inputs (enable, time_on, time_off)?1 output (timer state)4. Develop a program CalcInterpol

]

[]1[]

[]1[])

[(][i Px i Px i Py i Py i Px x i Py y ?+?+?+=1. Develop a function N_of_3

?3 inputs (In0, In1, In2)?_1_of_3 if 1 input is true ?_2_of_3 if 2 inputs are true ?_3_of_3if all 3 inputs are true ?N_of_3 if at least 1 input is true

N_of_3

FlashingLight

TwoPointControl

CalcInterpol

Syntax Coloring and Color Settings

Background Color

Auto Tab Generation

Find Matching Keyword

Line Numbers in the Status Bar

相关主题
相关文档
最新文档