What is Structured Text

Structured text, abbreviated as ST or STX, is one of the five languages supported by the IEC 61131-3 standard, designed for programmable logic controllers (PLCs). It is a high level language that is block structured and syntactically resembles Pascal, on which it is based. All of the languages share IEC61131 Common Elements. The variables and function calls are defined by the common elements so different languages within the IEC 61131-3 standard can be used in the same program. Complex statements and nested instructions are supported.

At first it may seem better to use a graphical programming language for PLC programming but there are pros and cons in each case. Like me, I have come to PLC from higher level programming language such as C/C++, so this fits to me better. Same general compilation process is used here.
We shall use Visual Studio for program development and download to PLC or simulator.

Memory Management

Library contains a number of functions which provide direct access to memory areas in the PLC runtime system of the PLC Controller. Default editor includes the library by default.

 

The fact that these functions allow direct access to the physical memory of the PLC. Misuse of such functions can result in a system crash, or in access to forbidden memory areas. So we need to be careful when we are using these function.

 

MEMCMP Compares the values of variables in two memory areas

 

MEMCPY Copies the values of variables from one memory area to another

 

MEMSET Sets the variables in a memory area to a particular value

Memcpy example

//Declaration

PROGRAM MAIN

VAR

org : DINT :=12;

dest : DINT :=13;

another : DINT := 14;

myTimer : TON;

startTimer : BOOL := FALSE;

END_VAR

//Body

 

myTimer(IN:= startTimer, PT:=T#1S);

 

MEMCPY(ADR(dest), ADR(org),4);

MEMCPY(ADR(another), ADR(dest),4);

 

IF myTimer.Q = TRUE THEN

myTimer(IN:= FALSE);

org:= org +1;

END_IF

 
How to add route for searching Beckhoff PLC

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

How to change AMS Net Id

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.