Open-Loop Control System with Arduino

Open-loop control is one of the simplest forms of control strategies. It works well in systems that are predictable and consistent, especially in batch processes where tasks are repetitive and require little variation. A common example of a batch process would be using a washing machine.

Imagine you’ve ever washed clothes in a washing machine, and let's use control system terminology to describe how open-loop control works through this simple example. The table below outlines the process of using a washing machine, both without and with control system terminology.

Table 1: The Process of Washing Clothes in a Washing Machine

Without Control System TerminologyWith Control System Terminology
1) You place clothes in the washing machine and set the timer for 30 minutes.1) The user sets the SETPOINT on the controller for 30 minutes.
2) The machine starts filling with water.2) The controller sends a DRIVE=ON signal to the actuator, turning the INPUT stream on to fill the machine with water.
3) The washing cycle begins.3) The process runs.
4) After 30 minutes, the machine stops automatically.4) The controller sends a DRIVE=OFF signal to the actuator, stopping the machine after the set time.

In this example, the controller's operation can be summarized as follows:

FOR 30 MINUTES, DRIVE = ON. THEN, DRIVE = OFF.

This straightforward command can be considered our control algorithm. To gain a clearer understanding of the entire process, we can visualize it with a functional block diagram, as depicted in open loop control system washing machine diagram below:

Open loop control system with Arduino

How Does the Controller Work?

The controller doesn’t have any feedback mechanism to adjust its operation based on changing conditions. It relies on the user to set a specific SETPOINT, in this case, the timer, to control the washing duration.

During the design phase, the washing machine was calibrated to determine various cycle durations. The manufacturer observed that 45 minutes is typically suitable for a heavy load, while 15 minutes might suffice for a quick wash. They then marked these duration on the machine's control panel with icons or numbers, as shown in control system washing machine diagram above.

Note that there’s no sensor in this system; it operates based on pre-set conditions. Users might need to familiarize themselves with the settings by experimenting with different wash times for their laundry needs.

Watch the following animation of how open loop control system works with Arduino as controller.


Open Loop Control System with Arduino Program code

#define relay_pin 10 // Pin connected to relay
#define btn_pin A1  // Pin connected to button

const int runTime = 2000; // select run time

void setup() {
  pinMode(relay_pin, OUTPUT);
  pinMode(btn_pin, INPUT);
  digitalWrite(relay_pin, LOW); // Start with the relay off
  digitalWrite(btn_pin, HIGH); // Turn off motor
}

void loop() {
   if(digitalRead(btn_pin) == LOW){
     digitalWrite(relay_pin, HIGH); // Turn on relay (start motor)
     delay(runTime); // Run for the specified duration
     
  }
  else if(btn_pin == HIGH){
   digitalWrite(relay_pin, LOW); // Turn off relay (stop motor)
   }
   else
   digitalWrite(relay_pin, LOW); // Turn off relay (stop motor)
}

Another possible open loop control program code is the following

#define relay_pin 10 // Pin connected to relay
#define btn_pin A1   // Pin connected to button

const int runTime = 2000;      // Runtime in milliseconds (2 seconds)
const int debounceDelay = 50;  // Debounce time in milliseconds
unsigned long lastDebounceTime = 0; // Last time the button was toggled
bool motorRunning = false;     // Motor state flag
unsigned long startTime = 0;   // Start time for motor runtime

void setup() {
  pinMode(relay_pin, OUTPUT);
  pinMode(btn_pin, INPUT_PULLUP); // Use internal pull-up resistor
  digitalWrite(relay_pin, LOW);   // Start with the relay off
}

void loop() {
  // Read the current state of the button
  int reading = digitalRead(btn_pin);

  // If button is pressed and motor is not currently running
  if (reading == LOW && !motorRunning) {
    unsigned long currentMillis = millis();

    // Check if enough time has passed for debouncing
    if (currentMillis - lastDebounceTime > debounceDelay) {
      lastDebounceTime = currentMillis; // Update last debounce time

      // Start the motor and lock button presses
      digitalWrite(relay_pin, HIGH);
      motorRunning = true;
      startTime = millis(); // Record start time
    }
  }

  // If the motor is running and the runtime has elapsed
  if (motorRunning && (millis() - startTime >= runTime)) {
    digitalWrite(relay_pin, LOW); // Turn off the relay (stop motor)
    motorRunning = false;         // Reset motor state to allow button press
  }
}


The above code includes debounce code which is required in actual push button. Also the code is such that the motor runs for a fixed runtime when the button is pressed, and any subsequent button presses during this runtime are ignored. A "lock" mechanism is used. This will ensure that the button input is only accepted after the motor has completed its set runtime.

Another Example: Controlling Room Temperature with an Electric Heater

Let's consider another common example of open-loop control: using an electric heater to maintain room temperature.

Suppose you're using an electric heater to warm a small room during winter. In an open-loop system, you could set the heater to run for a specific amount of time based on your experience, without any sensors to measure the actual temperature.

  1. Initial Observation: You notice that running the heater at full power for 2 hours keeps the room comfortably warm at approximately 22°C. This information helps you set a manual timer for future use.

  2. Establishing a Relationship: From your observation, you realize that running the heater at full power for 2 hours generally results in a temperature increase from 15°C to 22°C. You can fix the heater's settings at full power and use the same duration each time you want to heat the room, similar to our washing machine example.

  3. Control Algorithm: You create a simple control algorithm to turn the heater on for 2 hours whenever you want to achieve the desired room temperature:

    FOR 2 HOURS, HEATER = ON. THEN, HEATER = OFF.

  4. Open-Loop Gain Constant: Based on your observation, you can calculate an open-loop gain constant, kL, that relates the desired temperature increase (SETPOINT) to the heater's operation time:

    Given that:

    HEATER TIME=2 hours for a 7°C increase\text{HEATER TIME} = 2 \text{ hours for a 7°C increase}

    You can determine kL:

    kL=2 hours7°C0.286 hours per °CkL = \frac{2 \text{ hours}}{7°C} \approx 0.286 \text{ hours per °C}

    Now, our control algorithm becomes:

    HEATER TIME=(0.286 hours per °C)×TEMPERATURE INCREASE\text{HEATER TIME} = (0.286 \text{ hours per °C}) \times \text{TEMPERATURE INCREASE}
  5. Application of the Algorithm: If you want to increase the temperature by 10°C, you can use the following calculation:

    HEATER TIME=0.286 hours per °C×10°C=2.86 hours

    This strategy can be effective for consistent conditions, like a well-insulated room on a cold day. However, it won’t adapt to external factors like open windows or sudden weather changes.

Conclusion

Open-loop control is effective for straightforward, predictable systems where the conditions remain constant. It doesn’t rely on feedback, which makes it simple but also limits its adaptability. Understanding these principles is essential for designing and implementing efficient control systems in both everyday appliances and more complex engineering applications.

Resources

Arduino PID Controller - Temperature PID Controller

Post a Comment

Previous Post Next Post