Adding a TON with TwinCAT

Join Date
May 2010
Location
Indianapolis
Posts
4
I just took over aproject and need to add a timer using twincat software, but do not have much experience with it. I know how to map in inputs and outputs, but dont know how to add a timer. need to get equipment back online to night hopefully -- any help is much appreciated.
 
In the sample project supplied with TwinCat (TwinCat\Samples\FirstSteps) there are examples of the use of TON

tcton.jpg
 
I was able to simulate and run TON using Structured Text. I have activated "T.IN", however deactivating "T.IN", I noticed that "T.Q" remains activated. When I set "T.Q:=FALSE", the program shows error message. How can I turn this "T.Q" OFF?

Example program:

dev_down := NOT dev_up;
IF start THEN
t1(IN:=TRUE , PT:=t#1s , Q=>, ET=> );
IF t1.Q THEN
dev_up:=TRUE;
t1.IN:=FALSE;
END_IF
END_IF

Thank you very much,
Andrei K.



In the sample project supplied with TwinCat (TwinCat\Samples\FirstSteps) there are examples of the use of TON
 
You must always make the call of ton. Now if start is not true you wont call the ton.

Code:
dev_down := NOT dev_up;
IF start THEN
      t1(IN:=TRUE , PT:=t#1s , Q=>, ET=> ); //this one will execute the ton, if start is not true, it wont execute, also when call is made u assign true to in so it will always be true when call is made.
  IF t1.Q THEN
    dev_up:=TRUE;
    [COLOR=Red]t1.IN:=FALSE;[/COLOR]
  END_IF
END_IF
 
Last edited:
Good day,

Thank you very much. I was able to put up a decent ST program just today and this will be the beginning of more complex programs to make. Here is my improved simple "TON" program:
dev_down := NOT dev_up;

IF NOT start THEN
t1(IN:=FALSE , PT:= , Q=> , ET=> );
t2(IN:=FALSE , PT:=, Q=> , ET=> );
dev_up:=FALSE;
END_IF
IF start AND NOT t2.IN THEN
t1(IN:=TRUE , PT:=t#1s , Q=>dev_up , ET=> );
END_IF
IF start AND dev_up THEN
t1(IN:=FALSE , PT:= , Q=> , ET=> );
t2(IN:=TRUE , PT:=t#1s, Q=> , ET=> );
IF t2.Q THEN
t2(IN:=FALSE , PT:=, Q=> , ET=> );
dev_up:=FALSE;
END_IF
END_IF



You must always make the call of ton. Now if start is not true you wont call the ton.

Code:
dev_down := NOT dev_up;
IF start THEN
      t1(IN:=TRUE , PT:=t#1s , Q=>, ET=> ); //this one will execute the ton, if start is not true, it wont execute, also when call is made u assign true to in so it will always be true when call is made.
  IF t1.Q THEN
    dev_up:=TRUE;
    [COLOR=Red]t1.IN:=FALSE;[/COLOR]
  END_IF
END_IF
 
You should call the timer exactly once in one program scan.

Example:

Code:
IF (StartCondition)
    THEN
    t1.in := true;
ELSE
    t1.in := false;
END_IF; //this could also be written "t1.in := StartCondition;"

t1(IN:= , PT:=t#1s , Q=> , ET=> ); //execute timer

IF (t1.q)
    THEN
    //do stuff
END_IF;

Basically, modify input parameters, then execute timer, then read output parameters.
 
Now that's way much convenient. Thank you very much as my ST programming has really improved in a few day span. Here is my revised program:

dev_down := NOT dev_up;
t1(IN:= , PT:=t#1s , Q=> , ET=> );
t2(IN:= , PT:=t#1s , Q=> , ET=> );
IF NOT start THEN
t1.IN:=0;
t2.IN:=0;
dev_up:=0;
END_IF
IF start AND NOT t2.IN THEN
t1.IN:=1;
IF t1.Q THEN
dev_up:=1;
END_IF
END_IF
IF start AND dev_up THEN
t1.IN:=0;
t2.IN:=1;
IF t2.Q THEN
t2.IN:=0;
dev_up:=0;
END_IF
END_IF


You should call the timer exactly once in one program scan.

Example:

Code:
IF (StartCondition)
    THEN
    t1.in := true;
ELSE
    t1.in := false;
END_IF; //this could also be written "t1.in := StartCondition;"

t1(IN:= , PT:=t#1s , Q=> , ET=> ); //execute timer

IF (t1.q)
    THEN
    //do stuff
END_IF;
Basically, modify input parameters, then execute timer, then read output parameters.
 
Hi guys,
I am working on TWINCAT v3 and I am trying to call a TON timer inside a function block.
I observed that even though the values of the variables are passed on to the timer function, the timer does not actually start. I tried implementing the same in the main program which calls the function block and here the TON timer works as expected.
I think there is a difference in the execution of code in the function blocks and the programs. Can you please suggest some solution or show me the right way to approach this problem .
Thanks in advance.
 
The function block must be active to run a timer (any timer)

the timer (TON) must be declared on top are three ??? fill in a name, and in the declaration of variables (VAR, on top of program)) you will put same name like name:TON;
as this thread is 3 years old, please start new one. put twincat in subject, and i will find you
 

Similar Topics

How can I add the "Go To..." function to the RSLogix 5000's Standard Toolbar?
Replies
9
Views
3,553
Does anyone know the best way to add a horn to a start button that stays on for 10 sec then shuts off and the motor starts.
Replies
15
Views
7,068
Does anyone know the bet way to add a horn to a start button that stays on for 10 sec then shuts off and the motor starts.
Replies
1
Views
3,193
Hello, I have a pair of redundant 1756-L71 controllers rev 24. These controllers currently have produced and consumed tag interfaces to 3 other...
Replies
2
Views
91
I'm adding an IAI Gateway with 2 axes connected to it. To an ethernet network on my PLC. So, I think the math is correct on the Input and Output...
Replies
0
Views
66
Back
Top Bottom