Questions tagged [iec61131-3]

IEC 61131-3 specifies a family of programming languages for PLCs.

IEC 61131-3 specifies a family of programming langues for programmable logic controllers (PLCs). It describes both textual and graphical languages.

  • Instruction List (IL): textual, assembly-like
  • Structured Text (ST): textual, Pascal-like
  • Ladder Diagram (LD): graphical
  • Function Block Diagram (FBD): graphical

References:

68 questions
2
votes
4 answers

How to declare data type ENUM in Yaskawa MotionWorks IEC 3?

I'm trying to add my own enum in MotionWorks. After creation of new data type the only available types are ARRAY,STRING,STRUCT. Writing the following code: TYPE SimulationType: ( Passing := 0, Random := 1, Failing := 2 ) INT :=…
Ilya Dan
  • 301
  • 1
  • 8
2
votes
0 answers

Is there an LLVM backend for IL code according to IEC61131-3?

Does anybody know about a LLVM backend which outputs IL (instruction list, also known as AWL) according to IEC 61131-3? Background: I have an algorithm written in C and want to run it on an industrial PLC, which unfortunatelly is not capable to…
alx
  • 31
  • 2
2
votes
2 answers

What is the default size of a STRING in IEC61131-3

I inherited a PLC program written in IEC 61131-3 structured text. I just noticed that it has a mixture of STRING variables, and a few STRING(15) variables. It suggests that IEC61131-3 declares its strings with a pre-defined length (does it?) and…
omatai
  • 3,448
  • 5
  • 47
  • 74
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…
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

In IEC61131-3, what are the semantics of the assignment operator for variables of Function Block type?

In IEC 61131-3 implementations (e.g. CoDeSys, TwinCAT, Unity), what actually happens when you use the assignment operator on variables of Function Block type? I've looked at the TwinCAT and CoDeSys docs without finding any kind of clear description;…
Hydrargyrum
  • 3,378
  • 4
  • 27
  • 41
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

Performing a Shift Register operation on an array in TwinCAT3 using SHL/SHR

I am very new to PLC programming. Can anyone help with explaining how I can perform a SHR/SHL operation on an array of INT of lets say 10 elements using TwinCAT3. They way I thought I would do this is by moving the shift register one place so that…
pro_to_be
  • 11
  • 3
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
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
2 answers

In Codesys, how to define pre-processors parameters?

I need create certain amount of struct type pairs which will be further used as const parameters and has essentially the same set of values, but scaled in half, something like this (given a n constant): TYPE ADDR_1 : STRUCT …
aluis.rcastro
  • 46
  • 1
  • 7
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
1
vote
1 answer

SFC Steps in IEC 61131-3 Programming

So I have a problem where in my SFC it jumps to an inital step but the commands written in the step would not register. At the end of the SFC a step inputs 5 into A_Status(INT). The very next transition checks if the value of A_Status is 5. No…
1
vote
1 answer

Are there IEC 61131 / IEC 61499 PLC function blocks that use OPA UA to transport data?

I have a machine learning and advanced control application in Python (TensorFlow + Gekko) that I need to integrate with a Programmable Logic Controller (PLC) that provides the data acquisition and final element control. Can I use a rack-mounted…
TexasEngineer
  • 684
  • 6
  • 15
1
vote
1 answer

What are the semantics of input variables passed by reference?

Beckhoff's TwinCat-3, as well as Codesys 3 it's based on, adds references as an extension to IEC-61131-3 languages. I'm wondering what is the exact grammar and semantics of this non-standard addition (that's the problem with them: nobody bothers…
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313