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
4
votes
8 answers

C to IEC 61131-3 IL compiler

I have a requirement for porting some existing C code to a IEC 61131-3 compliant PLC. I have some options of splitting the code into discrete function blocks and weaving those blocks into a standard solution (Ladder, FB, Structured Text etc). But…
Peter M
  • 7,309
  • 3
  • 50
  • 91
4
votes
3 answers

How to assign an initialized array to an array of arrays in TwinCAT

I'm trying to assign two initialized arrays evenNumbers and oddNumbers to an array of arrays integers: PROGRAM ArrayInit VAR evenNumbers : ARRAY[1..3] OF INT := [2, 4, 6]; oddNumbers: ARRAY[1..3] OF INT := [1, 3, 5]; integers :…
Roald
  • 2,459
  • 16
  • 43
4
votes
1 answer

Twincat3: Can't connect to LabVIEW's Modbus TCP/IP server via Tc2_ModbusSrv library (on virtual PLC)

I am trying to create a simple Hello World Modbus TCP/IP program using Twincat3 and virtual PLC (PLC running locally on my computer). I have set up a LabVIEW Modbus TCP/IP master + slave program (both of which are working see screenshots below). I…
Jakub Szlaur
  • 1,852
  • 10
  • 39
4
votes
2 answers

How to write an ASCII value into a string in Structured Text for a PLC?

For a PLC program written in Structured Text I need a string which starts with the ASCII values 0x01 0x01 0x01 0x00 0x12. In Java I would do this with: String literal = "\x01\x01\x01\x0\x12"; How can I achieve the same in Structured Text for a PLC?
BetaRide
  • 16,207
  • 29
  • 99
  • 177
3
votes
1 answer

How can warm start a method in TwinCAT?

One of the features of the method based on the definition of Beckoff site is that: All data of a method are temporary and are only valid while the method is executed (stack variables). This means that TwinCAT re-initializes all variables and…
asys
  • 667
  • 5
  • 20
3
votes
2 answers

Instantiating of numerous function block in CODESYS (IEC61131)

I have made a function block using CODESYS to perform energy metering. The inputs of the function block is current and voltage and the output is energy. Now, we need to have 1000 instances of this function block to run the code for 1000 meter we…
aghd
  • 685
  • 2
  • 9
  • 20
3
votes
3 answers

how to create pointer to function in codesys v3

Can you give me an example of how can I declare a pointer to function in my library? And how can I pass a pointer to function to my external library?
Ksouri Wissem
  • 49
  • 1
  • 5
3
votes
5 answers

I need to concatenate several strings

I am new to stuctured text and I would like to know how to concatenate several string. The cleanest way possible. I this instance I only need to change one variable when creating the string. I have another where I need to do 2. That number will…
TheColonel26
  • 2,618
  • 7
  • 25
  • 50
2
votes
1 answer

Are there any cons to using TO_ conversion instead of _TO_?

TwinCAT and (I think so) every other IEC61131-3 language supports both conversion types _TO_ and TO_. I am wondering, is there any cons to using the latter, so TO_? For example, I have a calculation and we all know, that…
ziga
  • 159
  • 1
  • 6
2
votes
1 answer

Unexpected Functionality in Codesys REAL_TO_STRING

On an IFM CR1203: For most 3-decimal REAL values, REAL_TO_STRING outputs the expected value. For others, it outputs the expected value with '0001' at the end. Why is this happening, and what is a good workaround?
2
votes
0 answers

How does IO-Link handle compatibility between different sensor brands and models

I am starting to study the application of IO-Link Sensors in a machine, in this case I will apply several types, such as inductive, optical, flow and pressure, this technology will help me to standardize the types of connections... but well... Once…
dwpessoa
  • 440
  • 4
  • 15
2
votes
2 answers

TwinCAT Pointer to Pointer of undefined type?

I'm trying to build a function that sums a single dimension array of any type in TwinCAT. I'm relatively inexperienced with pointers so the answer may be obvious, but I could not find any solutions. I read through all these and they helped a…
Gene Parmesan
  • 211
  • 2
  • 8
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
2 answers

Programming for the SAE J1939 standard

I'm trying to find information on how to program an embedded mobile controller such as the ifm R 360. Where could I find specific information on the programming language used, the required development environment and any other useful…
JcMaco
  • 1,258
  • 3
  • 16
  • 31
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
1
2 3 4 5