Checking multiple relay status

Hi,

I have 19 Relays that control water valves and 1 controls water pump

i need to continuously check if any of the 19 relays is on to keep the water pump on

and if any of them is off the water pump should turns off, to not break the pipes from the pressure if all 19

relays are off and the water pump is on alone.

what is the best way to solve this issue?

Thanks

What's turning the relays on and off?....

Are they not under your control so that you would know which ones are on or off anyway?

twinkleyan:
What's turning the relays on and off?....

Are they not under your control so that you would know which ones are on or off anyway?

yes i'm controlling them using Arduino mega,

i can know the relay state now from the digital pin,

my question is the best way to check all 19 pins continuously and what is the efficient way to do so

presumably you periodically check some sensor to determine if a particular valve needs to be open. you can count the number of valves that are open. If the count is > 0, turn/leave the pump on, if the count == 0, turn the pump off.

my question is the best way to check all 19 pins continuously and what is the efficient way to do so

Put the pin numbers in an array and iterate through it

Most three-phase equipment is intended to rotate in one direction. Pumps are good examples. An impeller that rotates in the wrong direction will do no useful work and may damage the equipment if left in this condition. The direction of the motor rotation is related to the phase rotation of the power system. This rotation can be changed simply by switching the order of two of the three power conductors connected to the equipment. Motor protection relays provide reverse phase protection aid in the proper installation of the equipment and also detect and protect motors if a change occurs in the power system. This can occur in the replacement of a transformer or other wiring upstream of the motor control cabinet.

KareemWaheed:
i can know the relay state now from the digital pin,

If your program has set the state of the I/O pin why would you need to check the pin - just keep a record of the states of the pins as your program sets them.

OR, better still ...

Have your program write the relay state into an array and use the content of the array to set the I/O pins.

Any time you need to know if one of the relays is OFF you can just check the values in the array.

...R

Robin2:
If your program has set the state of the I/O pin why would you need to check the pin - just keep a record of the states of the pins as your program sets them.

My thinking too, which is why I asked what controlled the relays in the first place.

Keep a counter, numberOfRelaysThatAreCurrentlyTurnedOn, initialise 0. Every time you turn one one, increment the counter; when you turn one off, decrement. Check the counter any time you like to see if at least one is on...

Are we missing something? That seemed too easy.

Thank You Guys, i thought of the counter or array of states and it is really good solution

Thank you