The timer doesn't work when it is triggured

michonezol

Member
Join Date
Feb 2020
Location
Netherlands
Posts
5
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.
 
Last edited:
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
 
Last edited:
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
 
Thanks for the great responses so far. Where can I go to find the absolute basics? Bit vs byte for an example? Or even microprocessing etc?
 

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...
Replies
3
Views
1,762
In Mitsubishi's PLCs, there is no off-delay timer. If you need one in your program, how do you get one ? :)
Replies
16
Views
13,311
I have some logic that I have written within a 5380 series controller that tracks the time an event is started, while the event is running an RTO...
Replies
2
Views
91
Hi all, I have a simple question that I have overcomplicated and gotten stuck on. I have a variable, we can call it "light" that I need to stay...
Replies
4
Views
310
Question to anyone with ideas about my thoughts on upgrading a very vintage timer, which is being used to switch between 2 5hp domestic water...
Replies
14
Views
435
Back
Top Bottom