The project I'm working on became a bit more complicated than anticipated, so I upgraded to a Mega this week. Now I'm thinking about upgrading the 12v side to IRFZ44N mosfets. Have been using two sets of 8-channel optocoupled relays, but want to gain some speed during different operations vs waiting between relay calls, and hoping it'll help in cleaning up the wiring a bit.
The relays control sixteen 12v solenoid & ball valves, which are used to control recirculation of different liquids & gases back into their given reservoirs. The liquids should not be mixed together, else a reaction could occur; one of them is an acid.
I want to dummy proof things a bit, speed up the process, and minimize residual liquids in the pipes. So, are the initial LOW/HIGH calls to the relays with digitalWrite to check the relays necessary?
int PINS[15] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19 }; // Pin 13 used by something else
void setup() {
for (int j = 0; j <= 15; j++) {
pinMode(PINS[j], INPUT_PULLUP);
pinMode(PINS[j], OUTPUT);
}
}
void loop(){
for (int k = 15; k >= 0; k--) {
if (k > 9) {
digitalWrite(PINS[k], LOW); // slower ball valves, allow 5 second openings.
time_5_sec();
digitalWrite(PINS[k], HIGH); // close slowly too, but moving on while they do...
time_1_sec();
} else {
digitalWrite(PINS[k], LOW); // want to replace relays with mosfets for faster timing.
time_1_sec();
digitalWrite(PINS[k], HIGH);
time_1_sec();
}
}
}
Note: The slower ball valves get called first, mostly because they were added last and control the different reservoirs.