The Home of PLC    
Home | PLC Fundamental | Siemens PLC | A-B PLC | Mitsubishi PLC | Omron PLC | Panasonic PLC | PLC Articles
  Current Position:Home>PLC Program>Content
A Structured Text Example Program in PLC
Source: Author: Date: 2008-09-28  

If you know how to program in any high level language, such as Basic or C, you will be comfortable with Structured Text (ST) programming. ST programming is part of the IEC 61131 standard. An example program is shown in See A Structured Text Example Program. The program is called main and is defined between the statements PROGRAM and END_PROGRAM. Every program begins with statements the define the variables. In this case the variable i is defined to be an integer. The program follows the variable declarations. This program counts from 0 to 10 with a loop. When the example program starts the value of integer memory i will be set to zero. The REPEAT and END_REPEAT statements define the loop. The UNTIL statement defines when the loop must end. A line is present to increment the value of i for each loop.

PROGRAM main
var
   i:INT;
END_VAR
i:=0;
REPEAT
     i:=i+1;
     UNTIL i>=10;
END_REPEAT;
END_PROGRAM

A Structured Text Example Program

One important difference between ST and traditional programming languages is the nature of program flow control. A ST program will be run from beginning to end many times each second. A traditional program should not reach the end until it is completely finished. In the previous example the loop could lead to a program that (with some modification) might go into an infinate loop. If this were to happen during a control application the controller would stop responding, the process might become dangerous, and the controller watchdog timer would force a fault.

ST has been designed to work with the other PLC programming languages. For example, a ladder logic program can call a structured text subroutine. At the time of writing, Allen Bradley offers limited support for ST programming, but they will expand their support in the future.


 
[Add to Favorit] [Refer to] [Comment(0Item)] Back to Top Print Close this Window  
Username:New UserPassword: Anonymous
Contents: Less than 250 words. Please follow the applicable rules and laws.
  Latest Comment:
  Popular Articles
·Traffic Lights PLC Control -St
·An Example of using ladder dia
·One-shots in plc programs
·PLC Ladder logic functions
·PLC ladder diagram programming
·DC Inputs in PLCs
·PLC Programming
·Basic Instructions in PLC prog
·Ladder Logic of PLCs
·Ladder diagram of add instruct
·Draw a state diagram for a mic
·Transistor Outputs of PLCs
  Related Articles
·Introduction of Sequential Fun
·Basic Elements in SFCs of PLC
·SFC for Control of Two Doors w
·Example of SFC for Controlling
·Example of SFC Implemented in
·SFC Renumbered
·Sample Ladder Logic for a Grap
·Ladder logic for transitions a
·A comparison of methods in dif
·A Simple Comparison PLC Progra
·Inverting Inputs and Outputs o
·A Simple Function Block