Bang Bang
This article discusses the control scheme. For information about digital communication emulation, see Bit-bang.
Bang-bang control
Real World Application
In Robotics
Example
// Port where line sensor is plugged in
#define LINE_SENSOR 4
// Line threshold value
#define LINE_THRESHOLD 1512
void autonomous() {
// DO NOT RUN THIS CODE. Use a PID controller for line following instead.
while (1) {
if (analogRead(LINE_SENSOR) < LINE_THRESHOLD) {
// If line is seen, turn right
setDrive(60, 0);
} else {
// If line is not seen, turn left
setDrive(0, 60);
}
// There are only two discrete output value combinations, so this is a bang-bang controller
// If this were to be run, the robot would rapidly wiggle along the line, moving very
// slowly and stressing the drive train...
delay(20);
}
}Advantages
Disadvantages
Teams Contributed to this Article:
Last updated
Was this helpful?
