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.

Long loop run for water pump !
#1
Hi everybody ! Hope everyone can help me!

I have a problem that I don't know how to do, the owner asked me to program the water pump to run in a loop. Specifically, run for 1 hour, rest for 30 minutes, then run again for 1 hour, then rest for 30 minutes. And so on until they press the stop command. Has anyone done this before? I would really appreciate your help.
Thank you very much !
Reply
#2
What you can do is create a boolean start/stop object and add this script to it:
Code:
script.set('Pump Interval', event.getvalue())
and add a resident script called 'Pump Interval' (set it to 0 seconds) and add this script to it:
Code:
pump_address = '1/1/1'
grp.checkwrite(pump_address, true)
os.sleep(3600)
grp.checkwrite(pump_address, false)
os.sleep(1800)
BR,

Erwin
Reply
#3
Thank so much ! I will try it ! Smile)
Reply
#4
It makes sense to turn the pump off when the script is disabled. Otherwise it can be left on when the resident script is disabled.

Event script:
Code:
pump_address = '1/1/1'

value = event.getvalue()
script.set('Pump Interval', value)
grp.checkwrite(pump_address, value)
Reply
#5
Good catch (:
Reply
#6
Hello ! I have a little trouble in this loop !
I already did that loop! Thanks everyone
I have the following problem and have the following objects:
-4 valve address is 1/1/1 ; 1/1/2 ; 1/1/3 ;1/1/4
- Pump address is 2/1/1
I want to program 1 of the other 4 valves to be ON then the pump must be ON. And if pump is ON, all 4 valves are ON. Pump is OFF, all 4 valves are OFF
In the 2/1/1 address pump I'm writing:
-----------------------------------
value = event.getvalue()
if value==true then
grp.write('1/1/1',true)
grp.write('1/1/2',true)
grp.write('1/1/3',true)
grp.write('1/1/4',true)
else
grp.write('1/1/1',false)
grp.write('1/1/2',false)
grp.write('1/1/3',false)
grp.write('1/1/4',false)
end
---------------------------------
In each valve I write, for example valve number 1 1/1/1:
value = event.getvalue()
if value==true then
grp.write('2/1/1',true)
end
---------------------------------
I am having an endless loop, and there is no way to solve the above problem.
Reply
#7
Replace grp.write with grp.checkwrite. First script can be made shorter like this:
Code:
value = event.getvalue()
grp.checkwrite('1/1/1', value)
grp.checkwrite('1/1/2', value)
grp.checkwrite('1/1/3', value)
grp.checkwrite('1/1/4', value)
Reply
#8
I tried and it didn't work.! For example, all 4 of my values are OFF(1/1/1;1/1/2;1/1/3;1/1/4). When I 1/1/1=ON then 2/1/1=ON, so all my values are also =ON (and I don't want the rest to be ON) (Only 1 valve value is OFF, here it pulls all 4 valves, that's not correct)
Sad
Reply
#9
In this case you can add checks that the event script was not triggered by another event script.
Code:
if event.sender ~= 'se' then
  value = event.getvalue()
  grp.checkwrite('1/1/1', value)
  grp.checkwrite('1/1/2', value)
  grp.checkwrite('1/1/3', value)
  grp.checkwrite('1/1/4', value)
end

Code:
value = event.getvalue()
if value == true and event.sender ~= 'se' then
  grp.write('2/1/1',true)
end
Reply


Forum Jump: