timer excution in ST code in Mervis

Hi,
I have a question regarding the implementation of a timer in ST code in Mervis.
I have written the below code to set B := 10 after 10s since A becomes bigger than 5 and stays bigger than 5.
However, it does not work properly. It sometimes set B := 10 after more than 15s since A>5.
I appreciate any help.

VAR
A,B: bool;
MyTON: TON;
END_VAR

IF A>5 THEN MyTON(IN := not MyTON.Q, PT := T#10s);
END_IF;
IF A>5 AND MyTON.Q THEN B := 10;
END_IF;
 
Hi,
I have a question regarding the implementation of a timer in ST code in Mervis.
I have written the below code to set B := 10 after 10s since A becomes bigger than 5 and stays bigger than 5.
However, it does not work properly. It sometimes set B := 10 after more than 15s since A>5.
I appreciate any help.

VAR
A,B: bool;
MyTON: TON;
END_VAR

IF A>5 THEN MyTON(IN := not MyTON.Q, PT := T#10s);
END_IF;
IF A>5 AND MyTON.Q THEN B := 10;
END_IF;
HI

According to Unipi/Mervis forum users ET( elapsed time ) output should be used in the program

Here is 2 examples:
https://help.codesys.com/webapp/ton;product=codesys;version=3.5.11.0


ControlsGuy25
 
Top