convert percentage to 3 digital outputs - 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: convert percentage to 3 digital outputs (/showthread.php?tid=4090) |
convert percentage to 3 digital outputs - stavros - 14.06.2022 Hello, I would like to convert a numeric (percentage) to 3 digital outputs (group addresses). For example i want to make the first DO to be 1 when the percentage is between 5-30%, the second between 35-70% and the third between 75-100%. I want this to control o fcu. Is there any idea how to do this. Thank you RE: convert percentage to 3 digital outputs - admin - 14.06.2022 You have gaps between 30..35 and 70..75. Is this intended? Do you want to have hysteresis between these values? RE: convert percentage to 3 digital outputs - stavros - 14.06.2022 i have gaps, because i want to ensure that the digital outputs will never be energized simultaneously. Hysterisis is a good idea. RE: convert percentage to 3 digital outputs - RomansP - 14.06.2022 Hi, is that what you need? Code: percent_val = event.getvalue() -- your value RE: convert percentage to 3 digital outputs - Erwin van der Zwart - 14.06.2022 I would improve this a bit as now you can have (shortly) 2 high contacts.. First write to false before writing anything to true (5-30% and 35-70% are not doing that) Even a better way to do this is to have a “switch on” delay in the ETS application so you have a second pauze before a contact is closed. RE: convert percentage to 3 digital outputs - RomansP - 15.06.2022 Erwin van der Zwart, thank you for your feedback. Code: percent_val = event.getvalue() -- your value RE: convert percentage to 3 digital outputs - Erwin van der Zwart - 15.06.2022 I would not use os.sleep in this script as you can have weird behavior when the input value is changed within a second (script can run in paralell), use 1 second “on delay” in the application of your actuator. RE: convert percentage to 3 digital outputs - admin - 15.06.2022 It should be fine if the % value probably comes from a PID script where control value is sent every X seconds. |