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
0
votes
2 answers

Codesys IF statement error with bit operation

The compiler gives an error for the following program. I can't solve it. This is the Codesys system writing it in ST language. I want to operate a solenoid valve using bit operation. CanRx := can_getDatabox (CAN_2, 10, ADR(CanRx_data),…
0
votes
4 answers

Array as Type for Interface Property CoDeSys

I am attempting to implement the Observer design pattern in CoDeSys using structured text. I'm encountering an error where I can't call the ., [], nor [..] on an interface property. Is it possible to have an interface property that is an array? The…
Michael LeVan
  • 528
  • 2
  • 8
  • 21
0
votes
1 answer

Store variable value in each PLC cycle

Is it possible to store a variable value in each PLC cycle? I need the first 10 values each time to perform some calculations. I am using the OpenPCS platform and ST for programming.
0
votes
1 answer

Countdown timer in PLC - Structured Text

Being new in PLC programming, I am struggling with the programming of countdown timer in PLC. I want to add a countdown timer for 90 days that will be reset to again 90 days once the button on HMI is pressed. The countdown time should be shown on…
0
votes
3 answers

Is it possible to indirectly index an array in structured text (IEC 61131-3 standard)

I have an array of a structure: myStructure[0..100] I would like to index that structure by name. It works by giving each index a name: P101_AI := 9 P102_AI := 10 P103_AI := 11 P104_AI := 12 So indexing a member in the structure:…
tomatoeshift
  • 465
  • 7
  • 23
0
votes
1 answer

Execute Linux System Command from CoDeSys Runtime

I am attempting to resolve a bug where the memory on my PLC is not synced on an operating system level. When power is cycled to the PLC a file I have "on disk" doesn't save when the PLC boots up again. I have found that running the linux sync…
Michael LeVan
  • 528
  • 2
  • 8
  • 21
0
votes
2 answers

How to get ASCII code of char in Codesys?

I need to get a byte code of char in Codesys (using ST language). Is there a way to do it? For example, in c++ it is quiet straightforward: int c = 'h';
Perotto
  • 194
  • 1
  • 14
0
votes
0 answers

Is there any tool or way to obfuscate structured text?

I am looking for a tool to obfuscate structured text code written for PLC. both paid or opensource. i cannot find anything in google. Please help.
Ravi Sharma
  • 116
  • 1
  • 7
0
votes
2 answers

Strange file output when using Concat in CodeSys

I'm using the CAA-File library in CodeSyS to write data to a text file. When I write a string to the file it works fine, but if I combine 2 strings with CONCAT, I get a strange file output with random characters (see below). Does anyone know how to…
Wout Rombouts
  • 1,479
  • 2
  • 9
  • 15
0
votes
1 answer

CoDeSys Visualization Dropdown Menu Custom Values in modelTextList

Using CoDeSys, I have a drop down list for a visualization that uses an enumeration of values for the options in the list. The enumeration comes from a separate library and for my particular application I would like to use only a subset of the…
Michael LeVan
  • 528
  • 2
  • 8
  • 21
0
votes
2 answers

Initialize Array of Custom Types in Structured Text Syntax

In my project I have a type like: TYPE myDataStruct : STRUCT A : UINT; B : WORD; C : REAL; D : Custom_Obj; END_STRUCT END_TYPE And I need to keep an array of this type for persistent memory. I can't just use VAR RETAIN because this…
Michael LeVan
  • 528
  • 2
  • 8
  • 21
0
votes
1 answer

Split IEC 61131-3 DINT into two INT variables (PLC structured text)

I want to publish a DINT variable (dintTest) over MODBUS on a PLC to read it with Matlab Instrument Control Toolbox. Turns out, Matlab can read Modbus variables but only INT16. So i want to split the DINT variable into two INT variables in IEC. I…
Biomusli
  • 13
  • 6
0
votes
2 answers

Syntax for Getting Ouput Variable in Structured Text

I'm trying to use a library defined function (CCaux for Cross Control Products) with the following interface: FUNCTION Lightsensor_GetIlluminance : eErr (* return error status. 0 ERR_SUCCESS, otherwise error code.*) VAR_OUTPUT value:…
Michael LeVan
  • 528
  • 2
  • 8
  • 21
0
votes
3 answers

PLC programming: Conversion to datatype of same size and back changes actual value

A function block gives me a number of datatype REAL. The Real must be converted to DWORD. On the used platform the datatypes have the following sizes: REAL: 32 bits (4 bytes) DWORD: 32 bits (4 bytes) So, what I think is that if just the bit…
user2190492
  • 1,174
  • 2
  • 9
  • 37
0
votes
1 answer

Define multiple variables in a condition in ST

I am currently programming/simulating a small plant in CODESYS. I have several outputs (that correspond to engines) that I need to test several times, so I want to create a condition that incorporates this test so I dont need to write the entire…
L8call
  • 87
  • 1
  • 1
  • 6