Controlling 4 relays for an automatic water flowing system for hydroponics

hi im Sean and im kinda new to XOD language , so i have a 4 relay module and want to control 3 pumps and solenoid vale. pump (1) for water outlet i.e removing the water from the reservoir , pump (2) pumps water into the hydroponic system , pump (3) pumps new clean water into the reservoir , solenoid valve pumps nutrient concentration into the reservoir . so the objective of the various pumps are , pump (2) stops pumping water for set time to allow pump (1) to pump used nutrient water out of the reservoir for set time , then the pumps turn off and pump (3) turns on along with the solenoid valve to refill the reservoir with clean nutrient water then turns of which is followed by pump (2) turnning on to start the flow of the new water into the hydroponic system

Sounds very similar to this discussion: Need some advice

hey that helped me a bit but how do I put the first relay off while the second on ?
such that relay 1 is one for (time) then relay two comes on and relay 1 goes off then relay 2 goes off and the cycle repeats with a delay of 30 sec

Do you need relay2 to go on BEFORE relay1 goes off? The other thread shows how to have only one relay on at a time if you don’t need the over-lap. If you do need the overlap, then you will need another delay node that turns both relays on for the over-lap time (so each relay would need to be fed by an ‘or’ node so multiple delay nodes can turn them on).

so this is how the system should run
(1)relay 1 turns on for 30 sec then stops, while relays 2 and 3 are off ( by default)
(2)relay 2 and 3 turns on for 30 and 40 sec respectively then turn off
this cycle is delayed for 5 min then starts again
iv mentioned that the cycle should begin again only after 5 min and not after 6 days, which my system requires to test if the loop functions correctly.
in my previous attempts at coding i could only successfully control one relay functionality and had a problem controlling two using " any" “delay” “defer” and “boot” nodes
would really appreciate it if you could help me out a bit


rough sketch of the code

You are close.

I don’t know what pulse-timed is; I would replace it with another delay node. delay-DONE would then link to defer node.

You have relay-ACT linked to 2nd set of delay nodes. This would trigger when relay turns on as well as off, and is NOT what you want. Instead, delay-DONE from first delay node should link to delay-SET of 2nd set.

I think those 2 changes would give you what you want.


hey so i did what you told me to do but the relays are switching on and off in a random order

Not sure what happened, but I suggested that relay-ACK should NOT be used to pulse delay. This is more what I was suggesting:
image
This is very close to the code you originally posted, but instead of relay-ACK pulsing delay nodes, delay-DONE is always used to pulse the next delay node.

Above code assumes you know which of the 2nd set of delay nodes will take longer (in this case, they are hard-coded, so that is a safe assumption, but you might change values later…). If you don’t know which one will run longer, you can code to force both to pulse before continuing:
image
Pulse wait-all-once-RST the same time you pulse the 2nd set of delay nodes, then wait for both delay-DONE to pulse.

Hey

So you aren’t using any kind of sensors to measure your fluid levels, and you just rely on the possibly quite same volume output of your pumps. I’m just wondering if your loop stops working after days of usage because your fluid levels are deliberately off and partly spilled on the ground :slight_smile: Just something to consider

His type of system doesn’t store all the water in buckets / totes (& maybe another reservoir), like the DWC (Deep Water Culture) systems, where the plants roots live in the water 24 x 7.
His system pumps the water up to the roots, the plants live in those holes drilled into the top of those larger white PVC pipes. The roots are bathed in nutrients for a set period of time and then it returns back to the reservoir. After another delay the pumping process would be repeated. This would continue for the life of the plant.