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

How to determine the maximum nth occurrence of an event at a given duration?

How can it be determined that the time interval of the nth event of an event is not more than a certain period of time? For example, an event can occur up to ‍5 ti‍mes every 10 minutes. In STL we can use this VAR counter:CTU; timer:TON; …
asys
  • 667
  • 5
  • 20
2
votes
1 answer

Difference Between Call of function block in IEC61131-3

What the difference between assigning a parameter with dot and put as an array to a function block? here is a simple code as an example. Timer1(IN:=TRUE,PT:=T#2S); IF Timer1.Q THEN i:=i+1; …
asys
  • 667
  • 5
  • 20
2
votes
2 answers

In structured text: is it possible to write to a multi dimensional array with a single line in the cyclic code?

The following works fine: PROGRAM PLC_PRG: VAR MyArray : ARRAY[0..1,0..5]OF USINT := [1,2,3,4,5,6,7,8,9,10,11,12]; i : INT; j : INT; END_VAR // change to random values FOR i:=0 TO 1 DO FOR j:=0 TO 5…
tomatoeshift
  • 465
  • 7
  • 23
2
votes
1 answer

Executing g-code from file within a ST-program in the software Automation Studio from B&R

I have a 3-axis system, which resembles the CNC-axis, and a PowerPanel from B&R. Now I plan to execute the g-code, which I read from a file, which is fe located in the Downloads folder. This will be done with fbs from B&R Automation Studio. I got…
Andreas
  • 89
  • 1
  • 11
2
votes
3 answers

Using generic type in Struct & Function Block

I would like to create a type-generic STRUCT and a paired Function Block that accept and return variables of a generic type (assumed ANY_NUM). This is desired to condense many existing STRUCT and FB pairs in the same format using generic number…
Graeme Rock
  • 601
  • 5
  • 21
2
votes
2 answers

PLC-ST: How to initialize a structure in declaration?

According to the PLCOpen, IEC-61131 standard, is it possible to initialize a structure in the declaration? I'm thinking of something along the lines of this C++ question.
clabacchio
  • 1,047
  • 1
  • 17
  • 28
2
votes
2 answers

ST(structure text) transfer data from hex to decimal

I need to transfer data from hex to decimal. Data I get as a string. Can someone help with this? Is it possible with ST make it? Thanks.
user23441
  • 33
  • 9
2
votes
0 answers

Read/Write in Array of Structure stock in a persistant variable

I'm working on codesys (ST) to create a storekeeper programm. I have a persistant variable which is a strucure name ST_STORAGE, here it definition : TYPE ST_STORAGE : STRUCT xInitialized :BOOL; // Indicate if the storage have been already…
2
votes
1 answer

SyncStart with Codisys without PLCOPEN Part 4

I need to Approximate A SyncStart/SyncStop Function in Codesys using PLCOPEN. I don't have access to Part 4 that contains the Synchronized motion stuff. Any ideas on how to start down the right path this in ST would be Awesome.
2
votes
2 answers

Is mixing types allowed in ST (Structured Text)

I wonder if it is allowed by the standard (IEC 1131-3) to mix different data types in an expression. Example VAR A : BOOL; B : INT; (* ... *) IF (B AND C) THEN ... END_IF
AndersK
  • 35,813
  • 6
  • 60
  • 86
1
vote
1 answer

How to loop through instances of different classes

I use TwinCAT to code a robot with many joints, each of which has some unique features. Some joints have absolute encoders, while someones need to be initialized in a specific way, etc. I used a joint base class(function block), containing common…
secs ss
  • 11
  • 1
1
vote
1 answer

Reference to hardware I/O in Twincat

First time user and non english speaker here. Please be kind. I'm trying to write a FB that control a pump which as a sensor on the motor axis to monitor its movement. I've written the code so that during init of the FB I can reference to the…
1
vote
0 answers

TwinCAT3 ST language - save file from PLC computer to PC using TwinCAT IDE

Is it possible to use function blocks like FB_WRITEFILE FB_READFILE to read/save data between CX8190 and casual PC with TwinCAT installed? I tried to get Local Computer address and set this as an argument in function block fb_FileOpen(sNetId…
Mirek
  • 13
  • 3
1
vote
1 answer

TwinCAT OPC UA: Setting individual Publish-Rate using Direct Access

I have configured a Twincat OPC UA server and need a fast cyclic data exchange of some variables (~400 bytes) with 1000Hz. If I set the publishing rate for all variables in the xml to 1ms, the CPU is 100% busy and the communication does not work. Is…
Paul
  • 23
  • 4
1
vote
1 answer

check if a specific hardware input is linked to a plc variable in Twincat 3.1

i am trying to check if a specific input from a hardware device is linked to my plc application on Twincat 3.1, in my example below i would like to check if "Terminal Overtemperature" is linked to a variable in the plc application side at runtime. I…
DonMiguelSanchez
  • 376
  • 3
  • 15