Opening/Closing multiple ball valves at the same time

I am working on a project that was started by someone else who went out of business. My customer has a washer that opens multiple valves (electronically) and then closes them after a period of time. It seems there is no issue in opening the valves on call - but I can't quite figure out how to close them.

My sketch is:

int valvePins[] = {12,11,10,9,8,7,6,5};
int pinCount = 8;  // Number of pins being used to relay controller

// Variables for cleaning method
int pushButton;     // Delaring 1 pin as push button pin
const int rinsePeriod = 15000; // 15 Seconds
const int surgePush = 15000; // 15 Seconds
const int drainPeriod = 10000; // Drain Between Surges
const int waitBetweenPhases = 2000; // 2 Seconds
const int gas = 2000; // 5 Seconds
const int purge = 10000; // 10 Seconds


void setup() {

  for (int i = 0; i < pinCount; i++) {
  pinMode(valvePins[i], OUTPUT);
}

  pushButton = 2;  
  pinMode(pushButton, INPUT_PULLUP);


}

void loop() {

  // Check to see if button has been pressed
  if(digitalRead(pushButton) == LOW)
  {
   // RINSE STAGE 
   phaseOne();
   delay(waitBetweenPhases);
   // CLEANING STAGE
   for (int i=0; i < 2; i++) { // Runs stage 2 times
   phaseTwo();
   delay(waitBetweenPhases);
   }
   //RINSE STAGE (2nd Pass)
   phaseOne();
   // SANI STAGE
   for (int i=0; i < 2; i++) { // Runs stage 2 times
   phaseThree();
   delay(waitBetweenPhases);
   }
   // GAS PURGE STAGE
   phaseFour();
   delay(waitBetweenPhases);
 
  }

  
}
/*============================================================================================*/

void phaseOne() {
  // Uses pins 5,6 & 12: PIN5[7], PIN6[6], PIN12[0]
  digitalWrite(valvePins[0], HIGH);
  digitalWrite(valvePins[5], HIGH); 
  digitalWrite(valvePins[6], HIGH);
  digitalWrite(valvePins[7], HIGH); //PUMP
  delay(rinsePeriod);
  digitalWrite(valvePins[7], LOW); //PUMP
  delay(drainPeriod);
  digitalWrite(valvePins[0], LOW);
  digitalWrite(valvePins[6], LOW);
  digitalWrite(valvePins[5], LOW); 
}

void phaseTwo() {
  // Uses pins 5 & 7-9: PIN7[5] - CO2, PIN8[4] - BOTTOM CAUSTIC, PIN9[3] - TOP CAUSTIC
  digitalWrite(valvePins[3], HIGH);
  digitalWrite(valvePins[4], HIGH);
  digitalWrite(valvePins[5], HIGH);
  digitalWrite(valvePins[7], HIGH);
  delay(surgePush);
  digitalWrite(valvePins[7], LOW);
  delay(drainPeriod);
  digitalWrite(valvePins[3], LOW);
  digitalWrite(valvePins[4], LOW);
  digitalWrite(valvePins[5], LOW);
}

void phaseThree() {
  // Uses pins 7,10, & 11: PIN7[5] - CO2, PIN10[2] - BOTTOM SANI, PIN11[1] - TOP SANI
  digitalWrite(valvePins[1], HIGH);
  digitalWrite(valvePins[2], HIGH);
  digitalWrite(valvePins[5], HIGH);
  digitalWrite(valvePins[7], HIGH);
  delay(surgePush);
  digitalWrite(valvePins[7], LOW);
  delay(drainPeriod);
  digitalWrite(valvePins[1], LOW);
  digitalWrite(valvePins[2], LOW);
  digitalWrite(valvePins[5], LOW);
}

void phaseFour() {
  // Uses pin 7: PIN7[5] - CO2
  digitalWrite(valvePins[5], HIGH);
  delay(co2Purge);
  digitalWrite(valvePins[5], LOW);
}

When I push the button the pins pull high and the process starts fine - the valves can be heard opening. I think from my understanding of these valves, changing the digitalWrite to LOW doesn't make them go the other way but simply tells the relay to stop with the HIGH. I am using 8 pins on the Arduino for control and 7 of them go to an 8 module relay to open the 7 valves. The other turns the pump on and off. Would I need to have the polarity from the relay to reverse the valves? Or can this be done with 1 wire controlling the switch from the code? I am not extremely new to Arduino, but controlling this many valves at one time is new for me.

I can add a drawing of my setup if needed.

Thanks for any push in the right direction! You guys on this forum rock.

If he was charging money for a program like that it's not surprising he went out of business.

Can you post a link to the datasheet for the ball valves so we can understand how they need to be controlled?

If you have a good (i.e. understandable) wiring diagram please also post that. See this Simple Image Posting Guide

...R

Robin2:
If he was charging money for a program like that it's not surprising he went out of business.

+1 for that observation! :sunglasses:

I'm afraid we need to know more about the ball valves being used. Do you have any information about them, like the maker and model number/name?

It will be important to know if the valves have built-in limit switches. If so, you may only need one SPDT relay per valve. If not, you will likely need two relays per valve.

Pictures of the valve
Make and model
Data sheet
Some details about the valve

I also see some 15 second delay statements - that will cause your program to stop and wait at that statement for the 15 seconds (or 2 or 10 in other lines) - you probably also want to look at the doing several things at once at the link below - the others can do a better job knowing if the delay staymemts will mess up the program

https://forum.arduino.cc/index.php?topic=223286.0

Some Possible Valve operations
1: 2 wires reverse power to reverse direction
2: 3wire. One always connected bring either of the others to power 1 opens other closes
3: 3wire. 2 are power 3rd is signal. Bring high valve opens. Low it clozes. Open aand valve does not move.
4 : 3wire proportional to voltage in
5: 3 wire rapid pulse opens slow pulse closes.
6: 4wire 4-20mA signal
7:4wire 0-10v signal
8: voltage on one opens. On other closes
There are more versions and then we add self closing and more options.

Bottom line is that we can control it.but really need to know what signals it needs

Sorry guys - I have been tied up most of yesterday/today with other projects.
I don't have images of the valves, but I can get them later as I am stopping by that customer on the way home.

The valves being used are HSH-Flo CR04 models. 2 Wire. Attached is their wiring. From what I can tell it's an "open on power / close when no power" but specs for this guy seem to be few and far between.

There have been multiple hands in the "project" so I am still gathering what all has been done before my involvement.

I will get a drawing of the whole system if I can this evening.

From what I can gather, these are "auto-return" valves, apply power (12VDC?, ?Amps), valve opens, remove power, valve closes. Sounds like you have bad valves or, if stored with dirty water inside, may need to be disassembled and cleaned (good luck with that :confused: ).
EDIT:
Without the valve in hand, no idea how the closing mechanism works. Wound spring motor? Rechargeable battery (surely not)?

Those are simple power on open/power off closed valves.

When you say " I can't quite figure out how to close them" does that mean you haven't applied the correct power and lack of power to open and close them or does it mean that you have and the valves still do not work?

Do you have a valve outside the apparatus in question (spare part) you can use for testing and to perfect your method of control?