Logic Machine Forum
Creating a step counter for the shutter - 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: Creating a step counter for the shutter (/showthread.php?tid=4577)



Creating a step counter for the shutter - Nir70 - 11.02.2023

I want to create a counter for steps so that the shutter will not go up (using only the steps command in the controller), it will only take 7 steps with a value of 1 and 7 with a value of 0. This means that the shutter can only move at angles. Thanks


RE: Creating a step counter for the shutter - admin - 13.02.2023

Can you explain in more detail what do you want to achieve? Do you want a specific object value not to exceed a certain limit?


RE: Creating a step counter for the shutter - Nir70 - 15.02.2023

Hello

I want a shutter user to not be able to lift it. Just take steps. X steps to open shutter stages. X steps back to close. that the user does not continue to click on steps in the shutter. Best regards


RE: Creating a step counter for the shutter - admin - 16.02.2023

Sorry, it still is not very clear what is needed. Do you want to convert binary object (step up/down) to a scale value (0..100%) with some limits on the output value?


RE: Creating a step counter for the shutter - Nir70 - 19.02.2023

yes  , 7 step  up  7 step down  ( 1bit)


RE: Creating a step counter for the shutter - admin - 20.02.2023

Map this script to a binary object. 0/0/2 is a numeric output object that the script modifies in the 0..6 interval (7 total steps). false is step down, true is step up.
Code:
step = event.getvalue() and 1 or -1
curr = grp.getvalue('0/0/2') + step

curr = math.min(curr, 6)
curr = math.max(curr, 0)

grp.update('0/0/2', curr)



RE: Creating a step counter for the shutter - Nir70 - 21.02.2023

(20.02.2023, 08:36)admin Wrote: Map this script to a binary object. 0/0/2 is a numeric output object that the script modifies in the 0..6 interval (7 total steps). false is step down, true is step up.
Code:
step = event.getvalue() and 1 or -1
curr = grp.getvalue('0/0/2') + step

curr = math.min(curr, 6)
curr = math.max(curr, 0)

grp.update('0/0/2', curr)

ok thanks very much i will check


RE: Creating a step counter for the shutter - Nir70 - 22.02.2023

(21.02.2023, 12:05)Nir70 Wrote:
(20.02.2023, 08:36)admin Wrote: Map this script to a binary object. 0/0/2 is a numeric output object that the script modifies in the 0..6 interval (7 total steps). false is step down, true is step up.
Code:
step = event.getvalue() and 1 or -1
curr = grp.getvalue('0/0/2') + step

curr = math.min(curr, 6)
curr = math.max(curr, 0)

grp.update('0/0/2', curr)

ok thanks very much i will check
I need to insert a virtual object, the address 0/0/2 cannot be in the controller, what does binary mean, I don't have such an option in objects


RE: Creating a step counter for the shutter - admin - 22.02.2023

You can modify the script as needed. You can put any group address there instead of 0/0/2. Binary object is datatype 01. 1 bit (boolean).


RE: Creating a step counter for the shutter - Nir70 - 27.02.2023

(22.02.2023, 13:55)admin Wrote: You can modify the script as needed. You can put any group address there instead of 0/0/2. Binary object is datatype 01. 1 bit (boolean).

Just focus. Get a value. Why does -1 appear? I send a value of 0 steps when going up, and a value of 1 step when going down.


RE: Creating a step counter for the shutter - admin - 27.02.2023

+1 / -1 is the step direction. If false is received then current_step = current_step - 1, if true is received then current_step = current_step + 1. Then the current_step value is limited between 0 and 6.