What Is Structured Text and Why Use It

Structured Text, usually shortened to ST, is a language for writing programmable logic controller (PLC) control instructions as text. You write statements that read values, make decisions, and calculate the values the controller should write.

You may already have seen the same control ideas in Ladder. Ladder expresses a decision with graphical contacts, branches, coils, and instruction blocks; Structured Text expresses it with names, operators, and statements.

What you will learn

  • Recognize Structured Text as another way to write a PLC program.

  • Read one simple statement and connect it to an input and output.

  • Explain where text is useful and how the program repeats while the controller runs.

See one working instruction

A sensor detects whether a part is present. Its value is named PROX_SENSOR, and it is TRUE while a part is detected. The output PILOT_LIGHT commands a lamp to show the same state.

The complete instruction is:

PILOT_LIGHT := PROX_SENSOR;

Read it as “put the current sensor value into the pilot-light command.” The names are variables, also called tags. Here they hold TRUE or FALSE.

Turn the sensor switch on and off in this working example. Watch the light and the tag values; you do not need to edit the program.

The symbol := assigns a value, and the semicolon ends the statement. Later lessons explain the syntax and data types in detail. For now, connect that one line with the physical job it does.

The controller keeps running the program

In this example, the controller repeatedly reads the input, executes the statement, and updates the output. When the sensor changes, a later scan writes the new state to the lamp command. The program keeps doing that while it runs.

Use Pause, change the sensor, and select Step one scan to see one update. Use Run to let the scans repeat. Writing the instruction as text still leaves you responsible for the same input, logic, and output behavior.

Why use text?

Text is useful when you want to write a calculation, choose between several conditions, or perform similar work on several values. It lets you name intermediate results and describe a control rule in a compact sequence of statements.

JobWhat Structured Text lets you express
Convert a measurementWrite the arithmetic that turns an input reading into engineering units.
Choose an actionTest a condition and select the appropriate statements.
Follow machine stepsDescribe what happens in each operating state.
Work with several readingsApply a calculation or check to a collection of values.

Ladder remains useful for following contact logic and tracing a graphical circuit. The choice depends on the job, the controller's tools, and what the people maintaining the program can read clearly. The same machine can use both languages where the platform supports it.

Your first goal

You do not need to memorize a page of code to begin. Start by asking what does this line read, what does it decide or calculate, and what does it write? Those questions work for both a short assignment and a larger control program.

In the example, identify the input, the assignment, and the output. Then continue to Variables, Data Types, and Assignment, where you will give values names and choose what each can hold.

Enable JavaScript to run the embedded simulator and complete the interactive exercises.