Posted 6 Feb 2020 Is there any instruction in Sysmac Studio Structure text to detect rising Edge (DIFU/DIFD) ? Share this post Link to post Share on other sites
Posted 6 Feb 2020 (edited) Oops Edited 6 Feb 2020 by vasekd Oopps Share this post Link to post Share on other sites
Posted 6 Feb 2020 why not make one? that is what i do whenever i work on a platform that does not have what i need. edge detection is simple, just compare current state with previous state. this means creating variable that will hold last value. then you do comparison and update the variable. Share this post Link to post Share on other sites
Posted 7 Feb 2020 How will it work if I am only interested in Trigger Up? timeOut:= Timer(TimeBit,UINT#100,TimerSt,TimerDone,ElapseTime); IF ( timeOut<>PreviosState ) THEN Counter:=Counter+1; PreviosState:=timeOut;; END_IF; The Counter will increase by 2. with ladder, with dIFU, that will not happen Share this post Link to post Share on other sites
Posted 7 Feb 2020 This is why ladder is way easier for many things. Here is how I would do this: TimeOut:=Timer(TimeBit,UINT#100,TimerST,TimerDone,ElapseTime); IF TimerDone=TRUE AND Oneshot=false THEN; Counter:=Counter+1; Oneshot:=TRUE; END_IF; IF TimerDone=FALSE AND Oneshot=TRUE THEN; Oneshot:=FALSE; END_IF; Share this post Link to post Share on other sites
Posted 7 Feb 2020 simonongsk: in your code the rising and falling edge is increase the counter. One other solution: IF timeOut AND NOT PreviosState THEN Counter:=Counter+1; END_IF; PreviosState:=timeOut; Or in ST you can use R_TRIG variable: rtrigTimeout(Clk := timeOut); IF rtrigTimeout.Q THEN Counter := Counter + 1; END_IF; In that case declare rtrigTimeout with R_TRIG data type. 1 person likes this Share this post Link to post Share on other sites
Posted 8 Feb 2020 language does not matter. if you speak it well enough, you can do anything you want to. if you need to detect rising and falling edge of a BOOL signal, why waste INT or TIMER or COUNTER when just another BOOL is needed to store old value? suppose you want to detect one or both edges of some signal "A" we need another variable that stores old value of A (previous scan). this variable is same type as A but separate memory location. for example, consider pseudo code:: RisingEdge= (A==TRUE) AND (OLD_A==FALSE) FallingEdge = (A==TRUE) AND (OLD_A==TRUE) OLD_A=A ; copy current A value to OLD_A to be used in next scan this can be written shorter as: RisingEdge= A AND NOT OLD_A FallingEdge = OLD_A AND NOT A OLD_A=A ; copy current A value to OLD_A to be used in next scan and if you only need rising edge... so be it, remove middle line with FallingEdge signal. this is very simple and short piece of code using only the most basic logic operations that every controller and programming language can handle (NO, AND and assignment): RisingEdge= A AND NOT OLD_A OLD_A=A note that length of the pulse is one scan time. Share this post Link to post Share on other sites
Posted 8 Feb 2020 that is no different that using Ladder. It is the exact same code. language does not matter. it is how one thinks and uses it. execution time may be different depending on efficiency of interpreter or compiler but logic IS the same Share this post Link to post Share on other sites
Posted 9 Feb 2020 Geez - an up or down arrow in a contact looks simple hey - or an @ on a function. LOL Share this post Link to post Share on other sites
Posted 9 Feb 2020 yes, Omron software is quite flexible if using ladder. probably same instruction exist in ST too. funny thing is this same thing is shown in screenshot at Omron's Sysmac Studio (under Standards): https://automation.omron.com/en/ca/products/family/SYSSTDIO Share this post Link to post Share on other sites
Posted 12 Feb 2020 @panic mode, Well your explanation really give me a hard knock! PLC 101!!! Thanks for the lesson! Share this post Link to post Share on other sites
Posted 14 Feb 2020 Did anyone think about the F_TRIG and R_TRIG function blocks? They are built in and create a rising or falling edge... Toolbox, Sequence Input... Share this post Link to post Share on other sites