Skip to content
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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@
* [Quantum Information](contents/quantum_information/quantum_information.md)
* [Computus](contents/computus/computus.md)
* [Approximate Counting Algorithm](contents/approximate_counting/approximate_counting.md)
* [Bang-Bang Control](contents/bang-bang/bang-bang.md)

57 changes: 57 additions & 0 deletions contents/bang-bang/bang-bang.md
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).
Copy link
Member

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?

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:
Copy link
Member

Choose a reason for hiding this comment

The 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.
Copy link
Member

Choose a reason for hiding this comment

The 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.
Copy link
Member

Choose a reason for hiding this comment

The 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/)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contents/bang-bang/res/bang_bang_temp_history.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contents/bang-bang/res/bang_control_fast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added contents/bang-bang/res/bang_temp_fast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.