Basics of Structured Text ST Programming | Examples & Applications

preview_player
Показать описание

▶ You can read the full post here

⌚Timestamps:
00:00 - Intro
00:24 - IEC-61131 programming languages
00:47 - Structured text advantages and disadvantages
03:02 - Basic rules of structured text syntax
04:09 - Structured text operators
04:26 - Structured text examples

=============================

As one of the IEC-61131 PLC programming languages, Structured Text or just ST is based on and resembles traditional programming languages like Python or Java.

Rather than being visual or graphics-based like ladder logic or Function Block Diagram, Structured Text is just that, text!

Like all programming languages, Structured Text has advantages and disadvantages, and there are also reasons you as a programmer might choose to use Structured Text in your next PLC programming project.

Since Structured Text is similar to traditional High-Level programming languages, it can be fairly easy for many people who may not have a background in PLC programming but have experience in traditional coding to learn and develop PLC projects.

In most cases, you can also develop your Structured Text PLC programming project without using the PLC programming software. Since it is text-based, you can write your project in a simple text file and copy and paste it into your PLC project when you are ready.

This also makes editing your project easier when you are debugging. While this feature of Structured Text is useful, remember that without your programming software like TIA Portal or RSLogix, you cannot compile and debug your program.

Most PLC manufacturers support different programming languages in their PLC’s and this is because there are many different reasons that a programmer will choose a particular programming language.

These reasons can be as simple as a client request for a specific programming language all the way to the size of the programming project.

Since Structured Text is by definition, text-based, it means that it does not have the memory-intensive graphical interface which can allow for a smaller processor memory and therefore a reduced cost.

This makes Structured Text an ideal candidate for larger PLC programs where controller memory is at a premium.

Some other times you might want to use Structured Text are when you are deploying the same PLC program over and over, such as in a packaged machine that is sent to a customer for a turn-key start-up.

In these cases, your PLC program file can be stored offline in a text file or word document and can be easily sent as an email attachment for someone to download into the PLC and deploy.

The syntax of Structured Text follows some basic rules:

- First, all statements in Structured Text will end with a semicolon.
- A routine will close out with an End_If statement.
- Spaces and tabs are not required, but a good programmer will still use them for readability.
- Structured Text is not case sensitive, but if you are assigning a variable, known as a tag or a symbol such as “control valve 1”, then using camelCase ControlValve1 is a good practice to get into.

Another very common and useful syntax of Structured Text is the use of a comment. As a beginning programmer, the use of comments is essential to creating code that can be read later on.

To add a comment in Structured Text you will start with a left parenthesis followed by an asterisk. To close your comment, you will then add another asterisk followed by a right parenthesis.

Structured Text also uses operators to manipulate data. Some examples of operators are the logical operators such as AND, OR, and NOT. A logical operator is used to compare Boolean data and create logic from it.

=============================

=============================

Missed our most recent videos? Watch them here:

=============================

To stay up to date with our last videos, make sure to subscribe to this YouTube channel:

=============================

=============================

#RealPars #PLCprogramming #StructuredText
Рекомендации по теме
Комментарии
Автор

Signed up for your courses. I am chemical engineer and have experience in designing and operating experimental, pilot and industrial equipment. But I have experience in desining equipment based only on relay logic.
Now I design much more complicated experimental equipment and I definitely need PLC programming skills.
Thank you, RealPars!

deniskalugin
Автор

Another benefit is version control. Version control via git is easier to manage with text than gxworks project files. You can see the exact program changes each time. I have bkms to overcome this but it is a real issue for a lot of people. The exact changes are not often document between revisions and it sucks

Fgcbear
Автор

Best of both worlds is that can make abstractions with FB and FUNC using ST and then use those inside Ladder Logic. This way the code can be understandable by the operator without having to know what is happening behind those FB.

PurushNahiMahaPurush
Автор

Nice video! Btw at 4:45 I think you should have said "if the control valve is *NOT* closed" since you had the closed status equal to false :)

FirstnameLastname-fnik
Автор

Thank you for great teaching...please include pointer and area register in the series

vatsalthaker
Автор

Thanks RealPars for another fantastic video yet again.

bitebonumbere
Автор

Structured Text, for those who can't let Pascal die... :)

Still, it's another useful tool in the toolbox.

MrWaalkman
Автор

Does realpars have a STL course, from basic to advanced?

mashudumawela
Автор

Thanks for a video which I always thought of tough one.. Thanks again guys.

ejazasif
Автор

Sir, could you please upload more videos about structured text programing...
I want to learn structured text programing. Your explanation is very good to understanding..

mrponnambalam
Автор

I don't know much about PLC programming, but I saw some ladder logic and function block logic made programs, and I thought they were really primitive in what they can do compared to C++. Now with structured texts available, I think that PLCs will be able to do way more than just reading sensors' data and activate actuators, or apply some sort of predefined controls. With this, maybe we can apply some machine learning algorithms, as now we can declare variables and do arithmetics, conditions and loops.

What would be wonderful later on if PLC companies release compilers that work independently from the entire programming software, something like gcc that can run and compile C\C++ programs without having to install the big fat useless Microsoft Visual Studio.

abbddos
Автор

Thank you again for that interesting information

IngDzib
Автор

Also, we can omit the second condition and write simple ELSE cause it is a complete negation of the first condition (IF Valve_Closed = false AND Valve_Opened = true).

alex_nevskiy_
Автор

please can you make explicit videos for a full course on structure text. thanks so much for the explanation.

johnudure
Автор

There are quite a few of issues here. I don't know, if it is different in the States, but variables should be written in a specific manner.

If a variable is a boolean then it should be 'bControlValve1_Closed' and not '#ControlValve1_Closed'.
Writing ' = true' is unnecessary in most cases and often just makes the code less readable.
It is also a good rule, if you have an 'OR' condition to do parenthesis, e.g.' ( bControlValve1_Closed OR NOT bControlValve1_open ) '. Helps to spot where it begins and ends.
End_if does not need semicolon ( ; ).
The comment should be simple and straight forward, and not ramble on about what, where and how, keep it simple. (* Start pump if control valve is open *) is sufficient. You don't need to explain every detail, if the code is very cut and dry. You will see it faster than you read and understand a "complex" sentence.
But the major issue here is that an if statement should ALWAYS have the 'ELSE' specified.

I would write this code as:

(* Start pump if control valve is open *)
IF ( bControlValve1_Open AND NOT bControlValve1_Closed ) THEN
bStartPump := TRUE;
ELSE
bStartPump := FALSE;
END_IF

Keep it simple and clear.

pekka
Автор

Sir great video.... I don't understand ladderlogic. Please post tank level control analog structured text program video

indubhargav
Автор

Yes sir
Thanks a lot
A very important a very much needed topic is given in this video
But how can we learn from realpars sir
Plz 🙏🙏🙏🙏 reply me back urgently required pls

kocengineering
Автор

Hi RealPars! Thank you for another great video. I found them very useful and informative.

deniskalugin
Автор

Thank you for your videos. I just want to ask if what computer should I need to learn to master this STRUCTURED Text programming. I want to learn this because my Next work is not using Ladder programming anymore. They use FBD and STRUCTURED Text in SIEMENS and FUJI PLC.
I want to learn it more before I start working there since my current company only used LADDER PROGRAMMING which is easy for me.

joshuajavier
Автор

Thanks for you support, Pls could you give instructions for Honeywell DCS system

laithjawad