![]() |
||
|
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
| ||
New Here? Please read this important info!!!
|
|
#1 |
|
Member
![]() Join Date: May 2010
Location: Indianapolis
Posts: 4
|
Adding a TON with TwinCAT
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.
|
|
|
|
#2 |
|
Supporting Member
![]() Join Date: Nov 2006
Location: UK
Posts: 4,562
|
In the sample project supplied with TwinCat (TwinCat\Samples\FirstSteps) there are examples of the use of TON
|
|
|
|
#3 |
|
Member
![]() Join Date: Mar 2009
Location: Makati City
Posts: 69
|
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. |
|
|
|
#4 |
|
Member
![]() Join Date: May 2008
Location: Finland
Posts: 1,295
|
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;
t1.IN:=FALSE;
END_IF
END_IF
Last edited by TurpoUrpo; December 17th, 2010 at 09:26 AM. |
|
|
|
#5 | |
|
Member
![]() Join Date: Mar 2009
Location: Makati City
Posts: 69
|
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 Quote:
|
|
|
|
|
#6 |
|
Member
![]() Join Date: May 2008
Location: Finland
Posts: 1,295
|
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;
|
|
|
|
#7 | |
|
Member
![]() Join Date: Mar 2009
Location: Makati City
Posts: 69
|
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 Quote:
|
|
|
|
|
#8 |
|
Member
![]() Join Date: May 2011
Location: Makati
Posts: 2
|
don't assign value to Q...you should just monitor the value of Q so that you can control the IN
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Topics
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Beckhoff - twincat problem (newbie) | titi_nicolas | LIVE PLC Questions And Answers | 9 | January 14th, 2011 10:02 AM |
| TwinCAT EtherCAT Help Needed | sujal.sheth | LIVE PLC Questions And Answers | 11 | March 29th, 2010 09:38 AM |
| TwinCAT remote OPC connection | hatchor | LIVE PLC Questions And Answers | 2 | April 15th, 2008 07:59 PM |
| ST program calling FB with a TON inside it - TON not working help pls | matt_sd | LIVE PLC Questions And Answers | 3 | November 5th, 2007 09:11 PM |
| CP5512 and TwinCat ? | adcoPLC | LIVE PLC Questions And Answers | 2 | March 14th, 2005 02:04 AM |