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.

1 bit counter
#1
Hi,
I want to create a script where, upon receiving a 1-bit input, it triggers another G/A to increment a counter by 1.
Each time a 1 is received, the counter should increase by +1.

And other question will this counter have a memenry. So after a power loss will this counter still beĀ "alive"?
Reply
#2
Hello

You can use the graphical logical function editor (FB editor) for this case.
There is already a counter available.

Regards.
Reply
#3
Create event script on your object which is triggering counter and change group address in this script to your counter object
Code:
counterObject = '1/1/1'
value = event.getvalue()

if value then
    value = grp.getvalue(counterObject)
    grp.write(counterObject, value +1)
end
------------------------------
Ctrl+F5
Reply
#4
(25.11.2024, 11:58)Daniel Wrote: Create event script on your object which is triggering counter and change group address in this script to your counter object
Code:
counterObject = '1/1/1'
value = event.getvalue()

if value then
    value = grp.getvalue(counterObject)
    grp.write(counterObject, value +1)
end

Perfect. Thanks.
Does it have memory on this in case of a reboot? Or will it then start at 0 again?
Reply
#5
The scripts checks current value of counter object and adds 1 to it. Objects are synced every 30 min so if power down will happen you may loos last 30min of counting and after power up it will keep counting where the last value was saved.
------------------------------
Ctrl+F5
Reply


Forum Jump: