Posted 30 Oct 2008 Which PLC Model? What kind of timer resolution do you want? You can use the pre-defined External Variables [1min, 1sec or 0.1sec PLC clock pulse bits]. At the rising edge add 1 to a variable in your ST program. Then use comparison to monitor time. When variable has reached a number then timer is done. Voila! Share this post Link to post Share on other sites
Posted 30 Oct 2008 Look at the picture, I have a CJ1M plc How can I program this in ST. Share this post Link to post Share on other sites
Posted 30 Oct 2008 (edited) IF NOT Timer_ENABLE (*IF Timer_ENABLE is OFF THEN Reset Timer_DONE and Timer_Preset*) THEN Timer_DONE:=FALSE; Timer_Preset:=0; ELSIF Timer_Preset=5 (*IF Timer_ENABLE is ON AND Preset = 5 seconds*) THEN Timer_DONE:=TRUE; (*Turn ON Timer_DONE*) END_IF; (*Increment timer with Oneshot from 1 second PLC clock bit when Timer_DONE is OFF*) IF P_1s AND NOT Oneshot AND NOT Timer_DONE THEN Timer_Preset:= Timer_Preset +1; (*Incremente*) Oneshot:= TRUE; ELSIF NOT P_1s THEN Oneshot:= FALSE; END_IF; This is ONE way of implementing a TIMER in ST. I am sure there are many others!!! Post your ideas guys!! Edited 30 Oct 2008 by BITS N BYTES 1 person likes this Share this post Link to post Share on other sites
Posted 30 Oct 2008 Hello Chaps, You could always add the (eg) "_CPU004_TON_BIN" timer FB to your ST header, then just call it as you would just like a regular Function Block something like... LibTimerFB ( EN:= TRUE, IN:= StartTimer, PT := TimerValue, ET => ElapsedTime, ENO => TimerDone) where "LibTimerFB" is an internal variable of type Function Block, and "StartTimer", "TimerValue", "ElapsedTime", and "TimerDone" are variables delred within your ST header. Hope this helps... By the way BnB, elegant solution using just ST Share this post Link to post Share on other sites
Posted 30 Oct 2008 OOOOOOoooooo. Love that oneshot!!! much better than mine!! Share this post Link to post Share on other sites
Posted 10 Apr 2017 Hello guys, do you have an example in .cxp file? I have an compile error but i dont know why. I talk about solution by guest. Share this post Link to post Share on other sites