Questions tagged [st]

Structured Text is a high level text based programming language for PLCs. DO NOT USE this tag for questions regarding products from ST Microelectronics! For questions about the simple terminal (st) for X, use [x-st].

Structured Text is a high level text based programming language for PLCs based on Pascal. It is one of the five IEC 61131-3 programming languages.

Tag usage:

  • Make sure that your question specifies which PLC model you are using.
  • Always use this tag together with or your question will not draw attention from the right kind of people who can answer it.
  • DO NOT USE this tag for questions regarding products from ST Microelectronics! Instead use the relevant product tags such as for example or .
  • Do not use this tag for questions about the simple terminal (st) for X, use instead.
107 questions
5
votes
6 answers

Timers in PLC - Structured Text

How do timers work in PLC Structured Text (ST)? How do we declare them? I've been studying a standard of PLC (IEC 61131-3), and they do not speak about timers in ST. I know the great majority of PLC programmers do them in ladder logic, but in this…
Yoanribeiro
  • 135
  • 1
  • 1
  • 10
4
votes
4 answers

What is the benefit of defining enumerators as a DUT?

The main goal of defining enumerators is to assign a variable to some numbers and their equal strings as I understand. We can define var a as an enum everywhere in the initializing section of our Program or Function Block like…
asys
  • 667
  • 5
  • 20
4
votes
3 answers

How to assign an initialized array to an array of arrays in TwinCAT

I'm trying to assign two initialized arrays evenNumbers and oddNumbers to an array of arrays integers: PROGRAM ArrayInit VAR evenNumbers : ARRAY[1..3] OF INT := [2, 4, 6]; oddNumbers: ARRAY[1..3] OF INT := [1, 3, 5]; integers :…
Roald
  • 2,459
  • 16
  • 43
4
votes
2 answers

Which method is generally used to communicate between programs in Structured Text

I am maintaining a project for a PLC written in ST. To implement a new feature I need to let cyclic program A know when an event happened in cyclic program B. How is this generally done in ST? Do I simply use global variables or is there a different…
martinhans
  • 1,133
  • 8
  • 18
3
votes
3 answers

How can link BIT2 type to a variable?

In most input cards of Beckhoff, there are two variables, Limit 1 and limit 2. They have a BIT2 datatype, size of 0.2 bytes, which means they have two bits, as shown in the following figure for Limit 1: Bit0: Value smaller/equal Limit 1 Bit1: Value…
asys
  • 667
  • 5
  • 20
3
votes
1 answer

In TwinCAT, is there a way to get the real time (isolated) CPU usage from outside of the PLC code?

The CPU usage of non-RT cores is available in MDP (either over ADS or UA), but I'm unable to find any way to get the CPU usage of isolated cores from user land (i.e. Windows). I feel like there should be an easy way to read this since TcXaeShell is…
Jay
  • 33
  • 4
3
votes
1 answer

How can warm start a method in TwinCAT?

One of the features of the method based on the definition of Beckoff site is that: All data of a method are temporary and are only valid while the method is executed (stack variables). This means that TwinCAT re-initializes all variables and…
asys
  • 667
  • 5
  • 20
3
votes
1 answer

How can I get current time from PLC (Beckhoff)

I am trying to get the current time from the PLC (Beckhoff-cx5130). I have tried "GETSYSTEMTIME", but I am not getting any output. I also tried "NT_GetTime" "TIMESTRUCT" and "T_FILETIME" but showing some compiling error (Could be a library…
ali nawaz
  • 93
  • 1
  • 7
3
votes
5 answers

Pausing Timers In Structured Text

I need to be able to pause a timer and retain it's ET value when the timer is no longer being asked to run. The timer times when the input from a proximity switch is not present, but I only want it to time when the pump that forwards on the material…
LBPLC
  • 1,570
  • 3
  • 27
  • 51
2
votes
0 answers

Program Beckhoff PLC in VS Code

Since Beckhoffs TwinCAT3 Shell is missing basic function that are considered standard in other IDEs im trying to switch to VS Code to do the job. There is an extension that enables syntax highlighting for ST (Structured Text) which is great. But im…
HL-EM
  • 21
  • 2
2
votes
1 answer

How to assign the value to be returned by a method?

I have a method which I want to be returning a value. The declaration is clear to me. But how do I assign the value to be returned inside the method implementation? I can only think of creating an output variable and use that to propagate the value…
Felix
  • 1,066
  • 1
  • 5
  • 22
2
votes
1 answer

S71200 LSQL-Microsoft, Datatype changed, after copying Function Block - How do I fix this?

I am integrating SQL-Connection to one or our existing Siemens S7-1200 PLCs right now. After copying a Function Block from a working project, one of the data types has changed and is causing trouble now. Original: Copied FB: Does anybody know, how…
nico25
  • 73
  • 6
2
votes
1 answer

How to trigger a Function_Block

Hello to all TwinCAT developers, I am currently developing function blocks with TwinCAT. I'm trying to find a "standard" way to interact with the outside of the block. The Beckhoff examples always have a bExec signal to start a state machine on the…
Aurel
  • 45
  • 3
2
votes
3 answers

How can define enumerator in Methods?

There is a problem when u define an enum in a method. I was trying to do this: VAR enumA:(A,B,C); END_VAR and there is the compiler reaction when I used this in TwinCAT3 Shell (TcXaeShell). any help would be appreciated.
asys
  • 667
  • 5
  • 20
2
votes
1 answer

Multi-variable assignment to an array in TwinCAT

How can assign a new variable to an array in TwinCAT? in TwinCAT you can initialize all your array's argument directly for example for array a we can use: a : ARRAY [1..3] OF INT := [3(0)]; or a : ARRAY [1..3] OF INT := [0,0,0]; but if you want…
asys
  • 667
  • 5
  • 20
1
2 3 4 5 6 7 8