PREFACE
When I started as Assistant Professor (lecturer) at Dania Academy, Randers, Denmark, one of my first tasks was to find books for the students at the Automation Technology degree course.
It turned out to be particularly difficult to find relevant material related to programming in Structured Text (ST). Books with hundreds of pages would only contain a few pages about ST programming, and only at a very theoretical level.
My students enjoy learning ST programming from practical examples and methods. In January 2017, I began work to fill this gap by developing new teaching material under the working title of:
Get Started with Structured Text
Whilst using the material in my lectures, it has continuously been updated and extended. There has been high demand for the material among my students, and I have now turned it into a book for other interested readers to benefit from.
It is my hope that you will enjoy this book.
I would like to extend my gratitude to my students, fellow lecturers and colleagues for feedback and inspiration.
Comments, complaints, compliments and suggestions are welcome and appreciated.
Please, send them to
First edition issued June 2018
The 3rd edition has been updated and expanded with many of the suggestions and questions that readers and students have come up with, including the desire for many more illustrations and program examples.
Please enjoy!
Tom Mejer Antonsen
Randers, Denmark (June 2020)
2018 - 2020 Tom Mejer Antonsen
3. Edition, June 2020
All rights reserved. No part of this publication may be reproduced, shared, or transmitted, in any form or by any means, including electronic or mechanical methods, photocopying, recording or otherwise, without the prior permission of the publisher.
Illustrations and graphics: Tom Mejer Antonsen
Translated by: Katrine Bay Madsen
The original version (Danish) 1. Edition issued March 2018
Publisher: Books on Demand GmbH, Copenhagen, Denmark
Printed: Books on Demand GmbH, Norderstedt, Germany
ISBN: 978-87-4301-855-1
Table of contents
1 Introduction
This book gives an introduction to the programming language Structured Text (ST) which is used in Programmable Logic Controllers (PLC) and Programmable Automation Controllers (PAC).
The book can be used for all PLC types and PLC brands following the open international standard IEC 61131 part 3: programming languages.
In a Siemens PLC, the programming language is called Structured Control Language (SCL). SCL may differ slightly from programming in ST.
The book systematically describes basic programming, including advice and practical examples based on the authors extensive industrial experience.
Explanations to the PLC programming code with an emphasis on writing stable, robust, readable, structured and clean code are included in the book. The aim of the book is to enable the reader to write PLC code, which does not require a specific PLC type and can be reused across multiple types of PLCs.
It is recommended to read the entire book to gain an overview of its content, and then use the book as a reference moving forward.
The book was developed for the full-time Academy Profession (AP) Graduate in Automation Engineering course and the part-time AP Degree in Automation and Operation course at the Dania Academy, Randers, Denmark.
The book is based on the IEC 61131-3 standard. PLC suppliers and manufactures interpret the standard in different ways and not all follow the standard consistently. This means that some of the program examples in this book may not work properly in the PLC type you are using.
Unfortunately the author is not available for support in connection with programming code within this book.
1.1 Background for ST
ST is a high-level programming language similar to Pascal Programming. Pascal Programming was widely used from 1980 to approx. 2000 a period in which many companies started developing software for PC running on DOS (Disk Operating System), and later software running on Windows.
ST was developed and published by the International Electrotechnical Commission (IEC) in IEC 61131-3 International Standard in 1993. The standard consists of five PLC programming languages of which the Ladder Diagram (LD) language is the most well-known and commonly used. In addition to ST and LD, the other PLC programming languages include Function Block Diagram (FBD), Instruction List (IL) samt Sequential Function Chart (SFC).
Since about 2010 the usage of ST programming for PLCs has become widespread across Denmark, and many companies are now purely delivering PLCs programmed in ST. This means that the demand for ST programming capabilities across the industry has increased. This book is part of educating a workforce to fill this demand.
1.2 Prerequisites for learning ST programming
It is not necessary to know how to program in LD or the other PLC programming languages when learning ST programming. However, a certain level of knowledge of mathematics, mechanics, electronics, automation solutions and basic PLC is required to be able to learn ST programming.
Students with knowledge of a high-level programming language (e.g. VB, C++, C#, Python) will be able to learn ST relatively easy, due to the similarities in coding structures. The program execution inside a PLC is different compared to a traditional program or App running on a PC or a smartphone.
Like other text programming languages, the student can expect to be proficient in the language within three to five years.
1.3 Foundation of knowledge
The author has 25 years industrial experience with the specification, development and delivery of complex control systems and supervision systems. Of the 25 years, the author has 7 years experience with Pascal Programing and 12 years within automation solutions and systems involving PLC. This experience includes employment in four international companies and delivery of more than a thousand control system solutions in 20 different countries. This experience provides an important base for the content of this book
In recent years the author has been teaching PLC Systems at degree level in Denmark. The students have from 0 to 20 years of practical and/or vocational experience within PLC, automation and technological services. The internet, the standard DS/EN 61131-3 and a series of books on PLC programming have been utilized as inspiration for this book.
The material for this book was developed with feedback from lecturers and students attending the Academy Profession (AP) Graduate in Automation Engineering course and AP Degree in Automation and Operation course at the Dania Academy, Randers, Denmark. The content has been updated to answer the questions which the students typically ask during the course.
The author has a Bachelor of Science in Electrical Engineering (B.Sc.E.E.) from Aarhus University School of Engineering, Denmark.
1.4 Advantages of ST programming
ST is a flexible and universal programming language. As ST programming code is based on text and not graphics like LD, the code can easily be copied between different PLC types, and even be sent by e-mail.
The ST programming code is similar to text sentences, and work is executed in the same way as a word processor program such as Microsoft Word which makes it easier to work on. Consequently, the same working methods are applied when using a word processor program or a text editor.