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
1
vote
4 answers

Beckhoff-PLC: Declaring an array as remanent inside a Function Block

this is my first question on StackOverlfow, so feel free to give me feedback on the problem :) I'm new to working with controllers from Beckhoff and I'm trying to program a program block for communicating machine data to the PC. To store the data of…
Paul
  • 23
  • 4
1
vote
1 answer

Can you display messages in the Codesys message window during runtime? If so how?

My Problem: I have been creating projects using Codesys for the past 6 months or so and while I have learned a lot about the programming environment I have yet to discover a way to display custom messages during runtime to the console message…
Nicholas
  • 112
  • 12
1
vote
1 answer

TwinCAT - How to check contents of a directory from Beckhoff PLC

I am trying to perform file management within the PLC. Currently, NT_StartProcess works as follows, but I will not have any feedback after the process has been spawned. Is there a way to check the contents of a directory from the PLC? Is there any…
nah_ny
  • 37
  • 1
  • 8
1
vote
2 answers

FB_FileOpen stays busy, Statemachine not working - TwinCat3

i am trying to get into the beckhoff/twincat universe, therefore is was following along with some twincat tutorials. While programming a simple event-logger I encountered the following problem: After executing FB_FileOpen, it´s bBusy variable stays…
nico25
  • 73
  • 6
1
vote
1 answer

Declare values of array of structures in POU using PLC ST

I have structure declared like this: TYPE board: STRUCT number: INT; color: DWORD; END_STRUCT END_TYPE And i want to declare array of these structures with starting values in POU. I do it like this: Program PLC_PRG VAR arr1: ARRAY[1..61]…
koliber
  • 23
  • 4
1
vote
1 answer

How to convert byte array into various LREAL(double) values in TwinCAT3

I'm right now trying to convert my original python socket reading code into structure text in TwinCAT3. The following is the original python code that unpacks the read_data = socket.recv(1116) data into different things: def ur_read(read_data): …
Harry
  • 15
  • 5
1
vote
2 answers

How can you configure a Beckhoff program to work with a variable amount of physical IO blocks?

At work we are building an airline machine. It is a machine which holds bicycle frames and it has several stations. Depending on how much stations there are, the amount of physical IO blocks on the ethercat bus may differ. This may differ per…
bask185
  • 377
  • 1
  • 3
  • 12
1
vote
2 answers

How to make TwinCAT3 in Visual studio could be use word text select highlighted like "Word Highlight With Margin"

I am installed the Word Highlight With Margin , but it looks like not works with TwinCAT 3 text editor (ST) , any other way I can achieve that ?
robinshion
  • 33
  • 1
  • 7
1
vote
1 answer

TwinCAT 3: Global Method call without instantiating function block in VAR-Definitions?

I want to use a global method to debounce digital inputs by passing the IO and the desired debounce time to the method and using the returnvalue to set the Bool-Variable. The Method itself is working but I need to instantiate the function block for…
momo0815
  • 11
  • 2
1
vote
0 answers

How to stream data from Firebase REST API to Beckhoffs's PLC using SSE (TwinCAT3)?

I can normally read data from Firebase Realtime Database via REST API through .GET requests. And the same applies for writing data with .PUT requests. But in the Firebase Realtime Database REST API documentation it is specified that you can also set…
Jakub Szlaur
  • 1,852
  • 10
  • 39
1
vote
1 answer

Is the whole function block really stored in RETAIN memory?

In the CodeSys manual we can read that: "If you declare a local variable in a function block as RETAIN, CODESYS stores the complete instance of this function block in the Retain range (all data of the function block); however, only the declared…
Dawid Rutkowski
  • 2,658
  • 1
  • 29
  • 36
1
vote
1 answer

Change Size of Array in PLC

is it possible to change the size of an array in an TwinCAT-PLC using ADS, in this case pyads? VAR CONSTANT min_a : INT := 1; max_a : INT := 234; END_VAR VAR array_1: ARRAY[min_a..max_a] OF INT; END_VAR And then i wanted to change…
Amy15Fee
  • 35
  • 5
1
vote
2 answers

How to call function every Nth seconds in IEC61131-3 structured text (TwinCAT3)?

What I want to do in the code? I want to create a function block that is made up out of 4 methods: start, stop, run, calculate. Start method will call a run method that has an while loop that periodically calls calculate method. The while loop…
Jakub Szlaur
  • 1,852
  • 10
  • 39
1
vote
1 answer

ST PLC programming: Detecting a rising edge and remembering its value

I’ve started working in PLC structured text programming recently. Excuse me for the noobie question but how can I retain a rising edge detectors value? I am thinking of an RS flip flop of some kind. I am using codesys v2.3 and there is a function…
Adro
  • 13
  • 1
  • 3
1
vote
2 answers

What is the best way to clear an entire structure in Structured text

This is how I have it now TYPE MyType: STRUCT name: STRING[20]; input: INT; output: INT; END_STRUCT END_TYPE PROGRAM PLC_PRG: VAR struct: MyType; struct_NULL: MyType; error: BOOL; END_VAR IF…
tomatoeshift
  • 465
  • 7
  • 23