Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino-Controlled Sequential Solenoid Valve System with Local Override

Image of Arduino-Controlled Sequential Solenoid Valve System with Local Override

Circuit Documentation

Summary

The circuit in question appears to be a control system that utilizes an Arduino UNO microcontroller to manage a series of solenoid valves through relays. The system can be operated in either local or remote control modes. The local control is managed through a switch connected to the Arduino, while the remote control is handled via serial communication. The circuit includes a voltage converter to step down the voltage for the Arduino, a power source, and various switches and relays to control the power flow. Opto-isolators (MOC3041) are used to drive the relays, and LEDs are included to indicate the status of the opto-isolators.

Component List

  • 240v Power Source: Supplies the main power to the circuit.
  • Rocker Switch: Acts as a power on/off switch.
  • Fuse: Provides overcurrent protection.
  • Terminal PCB 2 Pin: Used for making connections between components.
  • Voltage Converter: Steps down the 240V AC to a lower voltage suitable for the Arduino UNO.
  • Arduino UNO: The main microcontroller unit for controlling the circuit.
  • Power Ground 2: A ground reference point for the circuit.
  • Relay: Electromechanical switches used to control the solenoid valves.
  • Toggle Switch SPST: Single pole single throw switch, likely used for manual control.
  • 2x 18650: Battery power source, possibly for backup or portable operation.
  • MOC3041: Opto-isolator with TRIAC driver output, used for driving the relays.
  • LED: Two Pin (red): Indicator lights, likely to show the status of the relays or opto-isolators.

Wiring Details

Power Source and Conversion

  • 240v Power Source is connected to the Fuse and Rocker Switch for safety and control.
  • Voltage Converter steps down the voltage from the Rocker Switch to power the Arduino UNO.

Control and Indication

  • Arduino UNO controls the Relays through the MOC3041 opto-isolators.
  • LEDs are connected to the MOC3041 to indicate the status of each relay channel.

Switches and Relays

  • Toggle Switch SPST is used to manually control the Relays.
  • Relays switch the power to the solenoid valves as commanded by the Arduino UNO.

Battery Backup

  • 2x 18650 batteries are connected through a Toggle Switch SPST to provide an alternative power source for the Relays.

Documented Code

const int solenoidValves[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; // Relay control pins
const int localControlPin = 12; // Local control switch pin
const unsigned long timerDuration = 5000; // 5 seconds in milliseconds
bool localControl = false;
int startValve = 0; // 0 for valve 1, 1 for valve 2, 2 for valve 3, etc.

void setup() {
  Serial.begin(9600); // Start serial communication for DCS signals
  pinMode(localControlPin, INPUT_PULLUP); // Local control switch with pull-up resistor
  
  for (int i = 0; i < 10; i++) {
    pinMode(solenoidValves[i], OUTPUT);
    digitalWrite(solenoidValves[i], LOW); // Ensure valves are off initially
  }
}

void loop() {
  if (digitalRead(localControlPin) == LOW) {
    localControl = !localControl; // Toggle local control mode
    delay(200); // Debounce delay
  }

  if (localControl) {
    // Local control logic
    // Implement the logic for local control here
    // For example, you might want to manually turn on/off valves
  } else {
    // Remote control logic
    if (Serial.available() > 0) {
      char command = Serial.read();
      if (command == '2') {
        startValve = 1; // Start from solenoid valve number 2
      } else if (command == '3') {
        startValve = 2; // Start from solenoid valve number 3
      }
    }

    // Operate the solenoid valves with a 5-second delay between each
    for (int i = startValve; i < startValve + 10; i++) {
      int valveIndex = i % 10; // Wrap around to the beginning of the array
      digitalWrite(solenoidValves[valveIndex], HIGH); // Turn on valve
      delay(timerDuration); // Wait for 5 seconds
      digitalWrite(solenoidValves[valveIndex], LOW); // Turn off valve
    }
  }
}

Code Explanation

  • solenoidValves: An array of pins connected to the relays controlling the solenoid valves.
  • localControlPin: The pin connected to a switch for toggling local control.
  • timerDuration: A constant defining the time interval between valve operations.
  • localControl: A boolean variable indicating whether local control is active.
  • startValve: An integer variable to select the starting valve for operation.
  • setup(): Initializes serial communication, configures pins, and ensures valves are off.
  • loop(): Checks for local control activation and processes serial commands or operates valves in sequence with a delay.