This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Creating a step counter for the shutter
#1
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
Reply
#2
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?
Reply
#3
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
Reply
#4
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?
Reply
#5
yes  , 7 step  up  7 step down  ( 1bit)
Reply
#6
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)
Reply
#7
(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
Reply
#8
(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
Reply
#9
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).
Reply
#10
(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.
Reply
#11
+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.
Reply


Forum Jump: