The timer doesn't work when it is triggured

Hi everyone, I am a newbie in PLC programming.

This is my code written in ST
--------------------------------------
PROGRAM MAIN
VAR
Motor :BOOL;
Start :BOOL;

Delay :TON;

button :R_TRIG;

END_VAR
--------------------------------------
button(CLK:= Start);
Delay(IN := button.Q, PT := T#5S, Q => Motor);
--------------------------------------

The idea is simple. After 5 seconds the button is pressed, the motor will work.

But, the program doesn't work as expected. I don't understand why

nOCNcnr.jpg


Could you help me out please?

Thanks so much.
 
Not sure of the platform, but -

If Start is TRUE but the next line shows In FALSE it may be the syntax of Button in the 2 lines

First line = button(CLK... on the second = button.Q, maybe it is looking at a different value.
 
TON timers usually require the signal to be high... not be a pulse.



Perhaps if you have a pulse in the button you latch a bit that will keep the timer counting?
 
Welcome to forum


It is lot of easier start with ladder or function blocks programming than ST.


On program is couple issues.


TP (Timer pulse) makes pulse to ouput as soon there rising edge on input. it won't delay output. (pulse 5s now)



you have rising edge detection of button. Q is on "1" only one program cycle, so you can't see it on animation view.


What you need now, is TON timer



So you probaly have now 5s pulse on timer output as soon as you pressed button




p.s Forgot, there is TON timer configured on program, looked first that there is TP 🙃


You only need to configure button without R_trig
 
Not sure of the platform, but -

If Start is TRUE but the next line shows In FALSE it may be the syntax of Button in the 2 lines

First line = button(CLK... on the second = button.Q, maybe it is looking at a different value.


There is R_trig on button configured
Codesys 🔨
 
But, the program doesn't work as expected.
[...]
Could you help me out please?

The source of the timer IN (run?) bit is a one-shot that is True/1 for exactly and only one scan, so the timer resets on the next scan.

TL;DR

button is an R_TRIG i.e. a rising edge trigger (one-shot), so button.Q will be True/1 for one scan and then reset to False/0 on the second, next scan.

I don't know what brand of PLC you are using, but I think that for most brands, Delay:TON will reset when its Delay.IN, which is one-shot output button.Q, resets on that second scan after the one-shot fires.

A TON reset means the timer will
  • stop running
  • set Q to False/0
  • reset ET to zero.

In most cases that second scan, when the one-shot output button.Q goes False/0, will occur before the 5s timer expires.

When button.Q goes False/0, the timer will reset and never reach its 5s PT value.

Do you know the solution? Is this a homework problem?
 
Well, I am trying to learn a PLC program, so I have created many simple problems like turning ON/OFF a lamp, blinking a lamp, or something like that... so there is no real PLC unit involved here.

A platform is Codesys.

My own current problem is: After 5 seconds (or any second) the button is pressed, the motor will work (or turn ON). As simple as that :)

In most cases that second scan, when the one-shot output button.Q goes False/0, will occur before the 5s timer expires.

When button.Q goes False/0, the timer will reset and never reach its 5s PT value.
Maybe you are right.
I still don't have a solution yet :D
 
thinking that on config you need this line

button : Bool;

(same way than you have for motor)


then on st


delay (in =button, PT = t#5s, Q => motor);


And check that you haven't used same timer multiple times on program.
 
oh man, it works :D
thanks man


Yeah, you had one shot trigger there


TON timer input was on only one program scan (which is something around 1-20ms maybe for default on your PLC configuration)
So your timer started to count, but on online you won't see it as it is so fast.

If you would have TP timer whit one shot, then it would have gived 5s pulse. (and also even with button: bool configuration)

(y)
 
TON timer input was on only one program scan (which is something around 1-20ms maybe for default on your PLC configuration)
So your timer started to count, but on online you won't see it as it is so fast.

oh yeah, man, you are right. Sometimes I see the system running pretty fast, so I could not catch each step :D
 

Similar Topics

Hi, I want to register the time of operation of a valve. I'm using timers to simulate a one second pulse, but the output doesn't activate. I...
3
Replies
2,952
Views
In Mitsubishi's PLCs, there is no off-delay timer. If you need one in your program, how do you get one ? :)
16
Replies
15,684
Views
Hi all, I am developing a controller in Easy e4 using Structured Text, which reads a temperature, triggers an output then waits for a given number...
4
Replies
353
Views
I'm writing a program in Studio 5000 for a 5069-L320ERM with a number of servos and pneumatics being run from a typical auto sequence routine. The...
9
Replies
524
Views
I am working with a Studio 5000 Logix Designer® application version 36.00, and need a 2 min reset for my totalizer. Is there a way I can use the...
5
Replies
372
Views
Top