-
-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding bang-bang control algorithm #968
base: main
Are you sure you want to change the base?
Changes from all commits
2f0f689
c7bc7a3
50f5806
a0297e2
b29de3b
739dc2f
1c3c0bd
d6a49de
f812eac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Bang-Bang Control | ||
|
||
A bang-bang controller is one of the simplest forms of feedback controller, used in systems where a simple on/off control signal is used to regulate some aspect of the system (temperature, for example). | ||
The controller compares the measured system state with user-defined min/max limits and toggles the input between on/off states as needed to keep the system within the specified range. | ||
Common everyday examples include water heaters and air conditioning controllers. | ||
|
||
##### Simple Example: Water Heater Control | ||
Imagine a water heater that needs to regulate temperature, keeping within an allowable range of 45 to 50°C. | ||
The heater only has binary on/off control with no in-between states. | ||
In order to regulate the system temperature, the heater must cycle between on/off states to keep the temperature within the specified range. | ||
A basic bang-bang controller would implement the following logic: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if here is the best place but I would love a section on the unit step function that makes this possible. Potentially with a full signals diagram and a work up of the example |
||
|
||
| System State | Action | | ||
| -------------- | ------------- | | ||
| Temperature is below desired range (<45°C) | Turn heater ON | | ||
| Temperature exceeds desired range (>50°C) | Turn heater OFF | | ||
|
||
Implementing just these two rules will keep the system temperature within the desired range. | ||
The overall system will oscillate between the two limits as the heater turns on and off: | ||
<p> | ||
<img class="center" src="res/bang_bang_temp_history.png" style="width:70%" /> | ||
</p> | ||
<p> | ||
<img class="center" src="res/bang_bang_control_history.png" style="width:70%" /> | ||
</p> | ||
|
||
An important factor to consider when designing a bang-bang controller is the frequency at which a given controller will toggle the system state. | ||
In the example above, with a wide allowable temperature band of 45-50°C, the heater would be powered every ~18 minutes to maintain the overall system. | ||
If tighter control over the output is desired (for example, limiting temperature to a narrow range of 45 - 45.2°C), a bang-bang controller can still be used to regulate the system, but the heater would have to toggle on/off much more frequently to keep the temperature in the specified range. | ||
Depending on the system being controlled, this rapid on/off cycling may be undesirable: | ||
|
||
<p> | ||
<img class="center" src="res/bang_temp_fast.png" style="width:70%" /> | ||
</p> | ||
<p> | ||
<img class="center" src="res/bang_control_fast.png" style="width:70%" /> | ||
</p> | ||
|
||
##### Pros: | ||
1. Very simple to implement. | ||
2. Can be used to control a system that has only binary on/off states. | ||
|
||
|
||
##### Cons: | ||
1. The system is not controlled to a *specific* target value; it instead oscillates between specified upper and lower limits. | ||
2. Setting tight min/max limits on the system output may require the controller to toggle on/off very frequently to maintain the correct output. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like this to also discuss overshooting. Since it's a binary operation often used for heating/cooling, it's often over shot when implemented exactly at the limit of the target. |
||
This may be undesirable depending on the system being controlled (for example, excess wear and tear caused by rapidly turning a pump on and off.) | ||
|
||
##### More Reading: | ||
Bang-bang controllers are only meant for systems controlled with binary on/off inputs. | ||
For systems with a continously variable input signal (for example, cruise control in a car), try PID Control. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we do not have a PID chapter yet in the AAA, could you link to external sources for now? |
||
|
||
|
||
## License | ||
The text of this chapter was written by [wca747](https://github.com/wca747) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode). | ||
|
||
[<p><img class="center" src="../cc/CC-BY-SA_icon.svg" /></p>](https://creativecommons.org/licenses/by-sa/4.0/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a sentence on why it's called "bang-bang" and a link to an original paper?