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

find the nth value in a value in structured text

I have experience of VB and c# but not ST. Im trying to find the value of the nth digit in a value. ie 654321 the nth value when n = 3 should return 4. Is it possible to do this in ST?
Simon Wait
  • 65
  • 1
  • 4
0
votes
1 answer

FB_FileClose is only the first time busy

I'm working with TwinCAT 3 and ST to save data from a socket connection. The sockets work and parts of the saving too, but not all of it. The first array I try to save works fine. But if i want to save another one, it fails. The FB_FileClose doesn't…
leontkp
  • 50
  • 5
0
votes
1 answer

Symbolic adressing of array elements

I have an array of objects, lets say MyArray[1..x] of Object. When programming I want to have a more "readable" way of addressing each object. Instead of saying MyArray[1] := ...etc. I would like to say MyReadableName :=... I've looked into…
krakers
  • 111
  • 10
0
votes
2 answers

PLC Pulsating timer

I'm trying to create alternating outputs on my PLC (Mistubishi Melsec Q00UJCPU) in structured text. out1 and out2 - are outputs. IN1 - input. Here's the code IF IN1=TRUE THEN; timer1(IN:= TRUE, PT:=T#0s , Q:=timer1.Q); END_IF; IF timer1.Q…
Roman Selin
  • 109
  • 1
  • 16
0
votes
1 answer

Implement a Read_I_Point FB in TwinCAT 2 BeckHoff PLC

What I want to do is to create a FB to read the signal of input point when it is given a TAG NAME. For example, if the tag name is "I_motor_sensor", so "I_motor_sensor" is send to Read_I_Point FB, then the FB will give the current status back. So…
Sunh Hao
  • 3
  • 2
0
votes
1 answer

Structured text(ST) programming PLC, debugging

everyone. I have a question. So I am using OpenPCS and ST language. When I am compelled my program, the system did not detect any error, but I see that the program working not correct. Is it possible somehow to use "print" as in "python" or…
user23441
  • 33
  • 9
0
votes
1 answer

Saving different sets of values of variables with a changing structure

I have several sets of values (factory setting, user setting...) for a structure of variables and these values are saved in a binary file. So when I want to apply certain setting I just load the specific file containing desired values and these…
0
votes
1 answer

Is it possible to specify PLC execution on a certain 'n' Scan Cycle in Structured Text?

I am currently working on coding a PLC to execute certain commands in which I would like to be performed at specific scan cycles. Is there a way I could code a program in Structured Text to where I can flag statements to only execute at an 'n' scan…
0
votes
1 answer

How can a MQTT/HTTP Client function block in Structured Text(IEC 61131-3) be created?

I would like to insert documents into MongoDB(where the server is present) using Structured Text programming which collects the data from PLC. Since there is no driver available, how I can create a HTTP client function block and connect to the…
Arjun
  • 9
  • 1
  • 7
0
votes
3 answers

How to check analog values to see if they have varied more than 1V in the last 5 min?

I have an AB PLC where I am trying to read analog values to see if the values vary more than 1V in 5 minutes? I have 10 sets of values I need to read. What would the easiest way to implement this? I can think of creating arrays to save the values…
user2840240
  • 87
  • 1
  • 1
  • 5
0
votes
1 answer

How do you let define the delay time for a timer in ST?

I'm trying to write a program in ST to let the user define the Bakelength time (in hours) for a TON timer. I have this currently but when I compile the code, the program throws up an 'illegal constant' error. How would I change this syntax? Any help…
user2840240
  • 87
  • 1
  • 1
  • 5
0
votes
2 answers

Structured Text : Function and Function block (Pros and Cons)

I am coming from computer science background and used to traditional IT programming. I have relatively little experience with structured text. In my current project I am extensively using many function block. I am aware that this involves some…
soulemane moumie
  • 1,005
  • 1
  • 14
  • 26
0
votes
2 answers

How to work with real time in custom function block on ST in Codesys 3.5

I am trying to accomplish very simple task, but it looks like I cannot figure our how. My task is daily schedule. output Q1 have to be HIGH every day from 1:00 to 2:00. I could not find function block that would help me. I decided to create my…
Sergey Romanov
  • 2,949
  • 4
  • 23
  • 38
0
votes
2 answers

explanation about NT_GetTime in twincat/beckhoff plc

Can I have explanation about this function block and its parameters (timeout: what is it for, busy: when it will be true and false)?
Ahmad Z. Tibi
  • 419
  • 2
  • 8
  • 19
-1
votes
4 answers

I'm looking for a more concise way to compare a variable to a range of numbers in Structure Text (ST)

I am trying to find a more concise way to compare a variable to a range of numbers. Currently I do: IF int_variable=67 or int_variable=68 or int_variable=69 then... Is there a way to write something like: IF int_variable=67 through 69 then Thanks in…