Time Delay between two ST statements

musman

Member
Join Date
Nov 2014
Location
Munich
Posts
20
Hello all, I am writing a PLC POU (Function Block) in Structured Text (ST). I have two dimensional array in which I want to store the data but with some time delay. Let say, I want to fill the first row of array at t=0sec and next row at t=30 sec.


Since I have this array filling statement inside for loop, so how can I make the for loop to stop or do nothing for 30 sec and then fill the second row of array.

or Is there any other way to do it?
 
You don't want to wait in the loop for 30 seconds, I think.

You should exit the loop, continue the rest of your program and then hop back into the loop.
 
One way would be to get rid of the For-Next loop, and increment a word value "Rows" for each row of the array. After Row 1 is done, Add 1 to value "Rows". Then start the timer. When timer = 30 and Rows = 2, Store Row 2, Add 1 to "Rows", then repeat until "Rows" = Last Row.
 
You can't wait. If you want to wait 30 seconds between filling a row, you shouldn't be using a loop (you can still loop the columns). Instead, as Lancie1 has said, you should use a variable to track which row you are on and use a timer to trigger filling it and increment the row tracking variable.
 
isn't there a timer function that delays execution for the desired time without getting stuck in a loop? We have a delay transition or link type that delays for the desired amount of time but yields the CPU to other functions. When the timer times out the task's state is restored and processing continues.
 
Most platforms do have a way to suspend execution of a task; it doesn't pause it so much as stop running it altogether until it is turned back on. That would be a little overkill and hard to precisely control as far as when the task execution is terminated.
 
So you like a program (function block will be later) that runs every 30 seconds.
Make a POU and put in the task list a task that will run every 30 seconds.
In this POU is a counter that needs adding 1 for a row.
This POU calls a function block to fill the columns of the array.
function block getarow(rownumber)
for column 0 to ...
fill the array
end_for

Make the array global so you can use the results in another POU.
 
Most platforms do have a way to suspend execution of a task; it doesn't pause it so much as stop running it altogether until it is turned back on.
Yes but the effect is the same. The running task's state must be saved until it is restarted then the task's state is restored and the program started from where it left off. This is about what happens when a program is interrupted.

That would be a little overkill and hard to precisely control as far as when the task execution is terminated.
Polling is the easy thing to do but it wastes CPU cycles.

It is easy to control when the tasks execution is terminated. It is terminated when the delay() function is reached.

Shooter's plan will work. It should be cleaner BUT now there is a need to check to make sure another task is modifying indexes.
 
peter just use another VAR for when calling the array.

musman if array is full only make the index zero, it will auto overwrite old results.
 

Similar Topics

Hello. I have main PLC L73 with redundancy module, and 4 others controller as L71, L72 (S/R A,B, CSU A/B). They connected through control net...
Replies
3
Views
1,647
Hello, friends! I need your help. I have communication between four CPU 317-2PN/DP via CP 343-1 LEAN. There are PLC1,PLC2,PLC3,PLC0. Speed of data...
Replies
0
Views
1,810
I need to selectively activate an output based on the delay between 2 inputs. How would I do this in a SLC500?
Replies
5
Views
39,183
Build error occurs with TON ladder logic command. Time Input expected on block. Using Integer Tag under Control Local, and then hard number 19...
Replies
2
Views
754
I have an SLC 503 running a machine with a scanner and 1794 RIO. One of the functions is a register motor on a printing cylinder. The manual 3...
Replies
3
Views
1,273
Back
Top Bottom