← Back

This preview is the content that will print. Choose “Save as PDF” in your browser’s print dialog to make a PDF.

Metatransformer report

Feedback and PID control

Practice · 70 minutes · Build a feedback loop and choose proportional, integral, and derivative actions from observed error behavior.

Text report: images and diagrams are omitted, and links to project files are inactive. Keep the exported project alongside this PDF for wiring diagrams, models, and linked files.

Learning outcomes

  • Trace reference, measurement, error, controller output, plant, and disturbance through a closed loop.
  • Calculate a discrete PID update and explain the distinct role and risk of each term.

Prerequisites

  • signals-systems
  • programming-state

Concepts

Feedback compares what you want with what you measure and uses the difference to act. A toy car that adjusts steering from camera position can reject a side push; a fixed steering command cannot. Define reference r, measured output y_m, and error e = r - y_m. The controller produces u, the plant responds, and the sensor closes the loop. The sign matters: an action intended to reduce positive error must not increase it.

A continuous PID law is u(t) = K_p e(t) + K_i ∫e(t)dt + K_d de/dt. Proportional action reacts to present error. Integral action accumulates persistent error and can remove offset. Derivative action responds to change and can add damping, but it amplifies measurement noise and is often applied to measured output rather than a suddenly changing reference. In sampled code, one simple form uses I_k = I_{k-1} + e_kΔt and D_k = (e_k - e_{k-1})/Δt.

Actuators saturate. A PWM command cannot exceed its allowed range, and a motor driver cannot supply infinite voltage or current. If integration continues during saturation, the stored integral “winds up,” causing prolonged overshoot after the error changes sign. Clamp or condition integration, and record saturation explicitly. A specific build decision for a geared desk robot is to set output limits from driver and motor constraints before increasing K_i.

A common misconception is that PID terms are three magic improvements that should all be increased. More K_p can speed response but also magnify noise or excite oscillation; more K_i can correct bias but erode stability; K_d can become a noise command. Another failure is testing with the mechanism connected before confirming feedback direction. First command a small bounded output, observe sensor sign, and verify that the computed correction opposes displacement. PID does not compensate for an encoder that intermittently disconnects or a mechanically jammed axis.

Worked example

Problem

A sampled PI controller has K_p = 0.8 output/degree, K_i = 0.5 output/(degree·s), Δt = 0.10 s, prior integral I = 2.0 degree·s, reference 30°, and measurement 26°. Find the unconstrained output.

Steps

  1. Error is e = 30° - 26° = 4°.
  2. Update integral: I = 2.0 + 4 × 0.10 = 2.4 degree·s.
  3. Proportional contribution is 0.8 × 4 = 3.2 output units; integral contribution is 0.5 × 2.4 = 1.2.
  4. Total unconstrained output is u = 3.2 + 1.2 = 4.4 output units.

Result

The PI update commands 4.4 output units before saturation or direction mapping.

Sanity check

Positive reference error gives positive corrective output under the declared sign convention; reversing sensor polarity would make that dangerous.

Check your understanding

A position loop remains at a small constant error because proportional effort exactly balances a constant load. Which change most directly removes the offset?

A. Add integral action with anti-windup B. Increase derivative action only C. Remove the sensor D. Reverse feedback polarity

Your answer: ______________________________

Reasoning:



Answer key

ANSWER KEY — check only after attempting the question.

A. Add integral action with anti-windup

Integral action accumulates the persistent error until it supplies the needed bias; anti-windup keeps that state bounded during saturation. Derivative of a constant error is zero. Removing the sensor opens the loop, and reversing polarity creates positive feedback.

Hands-on lab

Goal

Implement and diagnose a bounded position loop on a safe low-energy mechanism.

Equipment

  • Low-voltage servo-like axis or motor with position sensor
  • Current-limited supply
  • Microcontroller
  • Serial plotter
  • Physical travel stops

Procedure

  1. With motor power disabled, move the axis by hand and confirm sensor direction and travel limits.
  2. Enable a small proportional-only output limit, apply a modest setpoint step, and record error, command, and saturation state.
  3. Add limited integral action only if a repeatable offset remains; compare settling and overshoot.
  4. Deliberate fault: invert the sensor sign in a software test while output remains tightly limited; identify growing error and disable immediately, then restore negative feedback.

What to observe

  • Expected: proportional control reduces error, and careful integral action reduces steady offset but may increase overshoot.
  • Measure: actual reference, sensor value, command, sample time, and saturation; never substitute expected stability for a recorded trace.

Transfer challenge

Specify output limits and anti-windup behavior for a camera pan axis that may hit a cable-imposed travel limit.

Cautions

  • Use a low-energy axis, current limiting, clear stops, and an immediate power disconnect; never test first on an appliance or road vehicle.

Evidence record

Learner: ____________________ Date: ____________________

Evidence artifact or file: ____________________________________________

ItemRecord
Prediction or expected result
Actual observation or measurement
Conditions and tools used
Difference from expectation
Next decision or follow-up

Notes:




Sources and references

  1. Control Tutorials for MATLAB and Simulink (opens in a new tab)
  2. Modern Robotics (opens in a new tab)