PLC#The Basic Of ST Language

This is a Memo that while I using ST Language to code the PLC Program.  I am very interested in C, JAVA ..Etc, and I tried to self-learning for these.but there was no chance to practice these stuff… So I Always Forget it :)!!

What is ST Language?

Reference to the Manual…

SThe ST language is one of the languages supported by IEC 61131-3, the international standard that defines the description methods for logic. ST language is a text programming language with a grammatical structure similar to C language. ST language is suitable for programming some complicated processing that cannot be easily described using ladder diagram. ST language supports control syntaxes, operational expressions, function blocks (FBs), and functions (FUNs). Therefore, the following description can be made.

Statement

In the Below program, there is a sample to show the basic statement.

[php]
/*This is a ST Example.
Now I am using Mitsubishi PLC to explain it.
*/
D10:=100;//the value in side D10 =100
M10:=TRUE;
[/php]

ーComment

/*This is a comment*/
//This is a comment too!

ーAssignment statement

:= The assignment statement assigns the result of the right side expression to the label or device of the left side.The result of the right side expression and the data type of the left side need to be the same data type.

ー;

A statement must end with “;” (semicolon).Spaces, tabs, and line feeds can be inserted anywhere between an operator and data.

[php]
M1:=FALSE;//OK!
M1 := FALSE;//OK!
M1 := //OK!
FALSE;
[/php]

文の終端は,必ず「;」(セミコロン)を付けます。
スペース,タブ,改行は,演算子やデータの間に挿入でもOKです。

AND、OR、LD…

Here is the basic logic of AND,OR,LD and Timer operations in Ladder

Program

[php]
Y0:=X0;//Line0
Y1:=NOT X0//Line2
Y2:=X0 AND NOT X1//Line4
Y3:=X0 OR X1//Line7
Y4:=X0 OR NOT X1//Line10
OUT_T(X0,TC0,100);//Line13
OUT(TS0,Y010);//Lin18
OUT(TS0,Y014);//Lin18
[/php]

Please take a look on the timer using.In the Line 13, Line18 you can see Devices TC0,TS0 and I would like to say that they are all the same things of Timer0.In Mitsubishi, there is some rules on the timer while you are using;
-TS -if you would like to use the timer as a contact.
-TC -if you would like to use the timer as a coil.
-TN -if you would like to use the actual values of the timer.

Conditional statement

IF…ELSIF

It is just a basic statement that if Condition A is true then execute the statement that below it and unit END_IF.

[php]
IF X0 THEN
Y0:=TRUE;
ELSIF X1 THEN
Y1:=TRUE;
ELSIF X2 THEN
Y2:=TRUE;
END_IF;
[/php]

ーIf X0 is ON. Y0 changes to ON.
ーIf X0 is OFF and then X1 is ON, Y1 changes to ON.
ーIF X0 is OFF and then X1 is off and then X2 is ON, Y2 changes to ON.
*Please pay attention that if you Set the output yo true, it will keep to ON until you reset it.

CASE

When the statement that has the integer selection value that matches with the value of the integer expression (conditional expression) is executed, and if no integer selection value matches with the expression value, the statement that follows the ELSE statement is executed. The CASE statement is used to execute a conditional statement based on a single integer value or an integer value as the result.

[php]
CASE D10 OF
1 : D20.0:=1;
2 : D20.1:=1;
3 : D20.2:=1;
ELSE
D20:=0
END_CASE;
[/php]

In the Above program, the result will depends on the Result of D10.
IF D10=1,D20.0 is ON.
IF D10=2,D20.1 is ON.
IF D10=3,D20.2 is ON.
IF D10 is No Equal to 1,2, or 3, D20 will reset to Zero.

Operator

*,/,+,-,<,>,= Etc..

[php]
D10:=D10*D20+D21/D22
IF D10 &amp;gt; D23 THEN
M10:=TRUE;
END_IF;
[/php]

Label and Devices

At the end of this post, i would like to explain some details of Label and Devices.

Data Type

While there is no data type defined as the the devices, using to the arithmetic operations, it should be 16bit signed words.But also you can define it:

ーD10:U  UNSigned 16bit words
ーD10:UD UNSigned 32bit words
ーD10:E Float data

Label

There are Global Labels and Local Labels.
ーGlobal labels are labels that can be shared by programs in a project. Global labels can be used in all the programs in a project.
ーLocal labels are labels that can be used in each POU only. Local labels that are not included in POUs cannot be used. When setting a local label, set the label name, class, and data type.

OK, See you next time and now i need to get a beer..

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする