Implementation of TON Delay Timer - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Implementation of TON Delay Timer (/showthread.php?tid=5303) |
Implementation of TON Delay Timer - p_xatzi - 15.03.2024 Hi, I' d like to share the code I made to simulate a classic TON Delay Timer. Code: -- TON DELAY TIMER I run the following code in resident script with a time interval of 2sec (depends on required precision of course). As it is a classic TON Delay Timer, some actions take place after the time counting which starts with the enabling of the Timer (condition = true). If condition gets false before completing the Ton delay time setting, then the Timer is resetted and more generally a "condition = false" resets the timer. Someone could add code in case "B" (outside "if"'s "else") to take back actions if it is desired. I would like to ask : 1. In resident script was it necessary to use storage. That is, do variables keep their values among cycles? 2. Does writing to storage wear the SD Card? Any other suggestions are welcome. Thank you in advance. RE: Implementation of TON Delay Timer - Daniel - 15.03.2024 Have you seen this? https://forum.logicmachine.net/showthread.php?tid=4433&pid=31820#pid31820 Resident script is constantly running PID so variable will be kept. Storage is running in memory so you can write as many times you want. It is then saved to SD every 30min. RE: Implementation of TON Delay Timer - p_xatzi - 15.03.2024 (15.03.2024, 11:20)Daniel Wrote: Have you seen this? Thanks for the answer Daniel! Great thread also, I didn't know it existed! Based on the fact that it is saved per 30min to SD (I think same applies to objects), does it mean that if power cut happens sooner than 30min after last change then these storage (and objects') values are lost? |