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
0
votes
1 answer

how to access VAR_IN_OUT variable when FB cannot be extended?

I have been trying to gain access to the AXIS_REF_SM3 i.e. Axis of SM3_Basic.MC_MoveAbsolute in order to return the wDriveId of the axis. Since Axis is declared as a VAR_IN_OUT variable, I am unable to access it outside of the FB using the .Axis…
void
  • 7
  • 3
0
votes
0 answers

About __POUNAME() behavior

I have written a custom logger and wanted to add the name of POUs as the pszComponent for easier debugging. I wrote a custom FB_init which accepts as input the name of the POU as a string and encountered puzzling behavior (to me at least). Could…
void
  • 7
  • 3
0
votes
3 answers

How do you group variables in Structured Text?

How do you group variables in Structured Text? Say I have n global variables for lamps: lamp1 lamp2 lamp3 ... // and so on Then I have a button, and pressing it should set all variables to TRUE: IF buttonPressed Then lamp1 := TRUE; lamp2…
Kai Lee
  • 3
  • 2
0
votes
2 answers

How to cast enum to uint in structured text

I have a structured text program running in codesys 3.5, in which I want to set the mode of some motor to several values. In order to have good encapsulated code I defined the following struct: {attribute 'strict'} TYPE PD4_modes : ( no_mode :=…
U_flow
  • 475
  • 5
  • 18
0
votes
2 answers

How to save value of integer variable in TwinCat3?

I have a program in TwinCat where 5 integer variables are being updated every 10 seconds to represent the state of 5 pumps. I want to save these values that are being generated into either a textfile or CSV file that I can later extract from the…
Stunts1897
  • 55
  • 4
0
votes
2 answers

True only when going from High to Low

I’m trying to think a generalized way to program something that is True( does some logic) only when a bit goes from high to low. The programming language doesn’t matter but I prefer JAVA or Structured Text. Any help would be appreciated.
0
votes
2 answers

Why can't I pass output variable as a parameter to function block constructor in IEC61131-3 structured text (TwinCAT3)?

I have a function block A that has one variable output (defined in the FUNCTION_BLOCK A method) and this FB_init method: METHOD FB_init : BOOL VAR_INPUT bInitRetains : BOOL; // if TRUE, the retain variables are initialized (warm start /…
Jakub Szlaur
  • 1,852
  • 10
  • 39
0
votes
4 answers

How to pass variable type as an argument to an function in IEC61131-3 structured text (TwinCAT3)?

This is what I would like to have (this is a constructor for FB object): METHOD FB_init : BOOL VAR_INPUT bInitRetains : BOOL; bInCopyCode : BOOL; //My variables: typeOfVariable : TYPE; // This obviously doesn't…
Jakub Szlaur
  • 1,852
  • 10
  • 39
0
votes
1 answer

How to link CSS element in TwinCat 3 HMI, to parameter

I used status indicator web component in my HMI HTMLhost in twincat. I created HTMLhost and added to script these lines:
0
votes
1 answer

Change a value from A to B in a certain time

I want it to take a certain time for a value to change between value A to value B. It works this way, but I am limited by a BYTE (255) which makes the scale bad if I want to use larger numbers. And I cant figure out how. I therefore want help to…
cha28
  • 41
  • 6
0
votes
1 answer

Version Control with Structured Text files (*.ST, *.POE,*.bak)

I would like to do version control with my structured text project (I use infoteam openpcs) for industrial applications. The problem is that each time I modify an *.ST file, I get changes also in *.POE and *.bak corresponding files. Is there any…
bardulia
  • 145
  • 11
0
votes
2 answers

Concatenate variable

I need to concatenate a string and an integer and a string into a variable - in this case an input. The inputs are named as following: DI_Section1_Valve AT %I*: BOOL; DI_Section2_Valve AT %I*: BOOL; DI_Section3_Valve AT %I*: BOOL; Now, I want to…
Thoft
  • 15
  • 5
0
votes
4 answers

TwinCAT Systemtime-Timestruct to milliseconds since epoch

I need to convert the timestruct I get from Beckhoffs function block "FB_LocalSystemTime" to milliseconds since epoch to receive the local computer time in milliseconds. Unfortunately I can't find a function to convert this timestruct. Any help is…
timosmd
  • 159
  • 11
0
votes
2 answers

How to dynamically create fb instances during runtime on a plc?

I'm new to PLC programming and we need to create a library for a project. We need dynamically created function block instances during the runtime. There is a concept described on the codesys…
Jkirchho
  • 3
  • 1
0
votes
1 answer

C style function in structured text?

Our company has bought our first of many Beckhoff PLCs and I am currently developing a state machine. What I typically do in C is using a switch case in which every case calls a function, the state function of that particular state. This state…
1 2 3
8 9