The worksheetDownload the PDF
Answers

U5.1 The feedback loop

Feedback control · University · about 25 min

BugBotLab

What this lesson is about

Setpoint, error, controller, plant, measurement: the block diagram and the names.

Questions 6 marks in all

  1. [1 mark]The first loop is run on a list of distances instead of the sensor. What does it print?

    TARGET = 20.0
    for d in (60, 45, 30, 22, 18):
        error = d - TARGET
        print(error, max(-50, min(50, 2.0 * error)))
    Answer:
    40.0 50
    25.0 50
    10.0 20.0
    2.0 4.0
    -2.0 -4.0

    The errors are 40, 25, 10, 2 and -2 cm. At gain 2 the first asks for 80 and is clipped to 50; then 50, 20, 4 and -4. The command shrinks as the robot approaches.

  2. [1 mark]With error = distance() - TARGET, positive drive() forwards, and the gain made negative by mistake, what happens?

    1. AThe robot drives away from the target as fast as the gain allows
    2. BThe robot approaches the target slowly
    3. CThe robot oscillates around the target
    4. DNothing, because the sign convention does not matter
    Answer: A. Too far away now produces a backwards command, which makes the error larger, which makes the command larger. That is positive feedback.
  3. [1 mark]When does open loop control work?

    1. AWhen the plant is perfectly known and nothing disturbs it
    2. BWhen the gain is small
    3. CWhen the sensor is noisy
    4. DWhen the actuator saturates
    Answer: A. Open loop has nothing coming back, so any mismatch or disturbance goes uncorrected. On a real robot that condition is never met.
  4. [1 mark]Follow a signal once round the feedback loop, starting at the comparison.

    Number the lines 1 to 5 to put them in the right order.

    1. plant
    2. sensor
    3. error = setpoint compared with measurement
    4. controller
    5. actuator
    Answer:
    error = setpoint compared with measurement
    controller
    actuator
    plant
    sensor

    The error goes through the controller to the actuator, which moves the plant; the sensor measures the output and feeds it back to the comparison.

  5. [1 mark]Raising the gain of this loop typically buys which two qualities?

    Tick every answer that is true.

    1. ASpeed
    2. BAccuracy
    3. CStability
    4. DLess actuator effort
    Answer: A, B. More gain responds harder, so it arrives faster and closer. It spends stability and usually effort, which is why the four qualities fight.
  6. [1 mark]In the lesson's table, what is the name for the robot and the mat, the thing being controlled?

    Answer: plant. The plant is the physical system being controlled, here with a time constant of about 0.25 s.

The task: close the loop

Settle 20 cm from the wall, plotting the error as you go. The wall's face is 150 cm up the mat and the robot starts at 60.

from bugbot import *
connect()

TARGET = 20.0

The hint students can ask for: The wall's face is 150 cm up the mat and the robot starts at 60, so 20 cm from the wall is 70 cm of travel. Error is where you want to be minus where you are; drive in proportion to it.

A solution

from bugbot import *
connect()

TARGET = 20.0            # cm from the wall
for tick in range(300):
    gap = distance()
    error = gap - TARGET
    plot("error", error)
    drive(max(-50.0, min(50.0, 2.0 * error)), 0, 0)
    wait(0.1)
stop()

Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.