Questions tagged [structured-text]

Structured text is one of the five languages supported by the IEC 61131-3 standard, designed for programmable logic controllers (PLCs).

From Wikipedia: Structured text 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.

126 questions
2
votes
1 answer

Is there a way to use Methods in Structured Text (ST) to program a PLC

So I am new to PLC programming and I come from a traditional Object Oriented programming background. I am used to programming languages having guides/references on how to use the languages but I cannot find any readily available online. I want to…
1
vote
1 answer

Writing array tag to INT in Structured Text in PLC Logic

I'm new to PLC logic and would like to know a more efficient way to change the following statement. A is INT, B is an array of INT. IF COUNT = 1 THEN A := B[0]; ELSIF COUNT = 2 THEN A := B[1]; ELSIF COUNT = 3 THEN A := B[2]; ELSIF COUNT = 4 THEN A…
1
vote
1 answer

How to use minimax alalgorithm without recursion?

I'm developing a program that people can play "tic tac toe" with a computer. I choose structured text as my develop language, but it doesn't have recursion, so I have to develop it without recursion. As the result, I decide to use the stack to…
1
vote
1 answer

General Protection Error after second 'New Downlaod' or 'Online Change'

I'm trying to build a composite pattern in Twincat 3.1. Everything seems to work fine on Activate Configuration and the first new download or online change. The second new download causes General Protection Error or BSOD, no matter how many objects…
1
vote
1 answer

How to access a nested structure using PyADS

I have two structures defined in TwinCAT3 like so: TYPE ADSUWDisplay : STRUCT sYarn : STRING; sNextYarn : STRING; lLength : REAL; iPosition : INT; sYarnSpec : STRING; iPackageCount : INT; iPackageTotalCount : INT; …
modra-alan
  • 11
  • 2
1
vote
1 answer

CONCAT two wstrings in codesys

I have the problem that the CONCAT(str1, str2) function does not take two wstrings and I have not found a concat function for wstring. So how should I do it? I cannot convert the input to string and then back to wstring as I then loose information…
SGKlee
  • 70
  • 6
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
1 answer

Issue in assigning priority to plc based motor

I want to assign a unique priority to each element in an array, but with the snippet below I'm getting the same priority m repeated for elements with the same working time values. How do I set a unique priority for each element? // assign priority…
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

How can one preview the source code of a library in CoDeSys 2.3

Is there any way to preview the source code of an imported library in CoDeSys 2.3? When I check the library *.lib file I can see it is not compiled nor obfuscated, but in the CoDeSys there is no option to get into it. I've been browsing the web for…
czerwin
  • 972
  • 8
  • 10
1
vote
3 answers

Is it possible to add static parameters to function blocks?

Is it possible to write function blocks with some static parameterization? Specifically, can I make a buffer with a static capacity, but such that different instances can have different capacities? Ideally, I'd imagine some constant parameters, like…
relatively_random
  • 4,505
  • 1
  • 26
  • 48
1
vote
3 answers

How can I use access specifiers on member variables in a function block in structured text? (Beckhoff, TwinCAT)

An important part of OOP is to use access specifiers to make member methods and variables inaccessible from outside of the object. When declaring a function block method is is easy to control the Access Specifier, but I have not found a way to…
Mikkel
  • 138
  • 7
1
vote
1 answer

Getting values from energy meter to Schneider PLC

I am trying to read the values from an energy meter, and convert them to REAL (32bit float). In this case I am reading phase 1 voltage. Each value is read across two registers. So I have received to WORDS of values 17268 (MSW) and 2456 (LSW)…
James
  • 13
  • 2
1
vote
1 answer

Can I declare a user defined function in structured text in studio 5000?

I am used to python syntax: def function(par1, par2) Body of function here Return result Does ST allow user defined functions like this? I am using studio 5000.
Kenny
  • 11
  • 2
1
vote
1 answer

Twincat 3 Using FB_MBReadRegs Modbus

I cant get FB_MBReadinputs to work in Twincat, when Factory IO is sending/receiving Input and Holding registers. First off here's my currently working snip of handling Modbus from Factory IO: VAR GAB_FactoryIO_Inputs AT %I* : ARRAY [0..15]…
1
2
3
8 9