Recurrent control - 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: Recurrent control (/showthread.php?tid=5443) |
Recurrent control - gtsamis - 30.05.2024 Hi everyone, I'm looking for a way to control a valve according to user-defined intervals and durations. For instance, if the interval is set to 20 minutes and the duration to 5 minutes, the valve should: 1. Turn on 2. Stay on for 5 minutes 3. Turn off 4. Wait for 20 minutes before repeating the cycle I considered using scheduled scripts, but I believe there might be a more efficient solution. Could anyone suggest the best approach to achieve this functionality? Thanks in advance, George RE: Recurrent control - Daniel - 30.05.2024 I would do it in two scripts. One event with os.sleep to turn on and after delay turn off the valve. The delay time can be parameter as object to modify. Make sure to set event script to run first instance only. Resident script which will check if valve is off and then by use grp.find() and updatetime field to check when the last telegram was sent to this specific object. Then use os.time() to calculate the delta. If delta is bigger then 20 min then you send On to object attached to your event script Again the delta can be as object to be modified by the user. RE: Recurrent control - admin - 30.05.2024 Resident script with 0 sleep time. 1/1/1 is valve control, 1/1/2 is on delay and 1/1/3 is off delay. Both delays are specified in minutes. Code: grp.write('1/1/1', true) |