# Week 5 — GPIO, motor drivers, power, and failsafe

DIS OpenLab · Foundations of Autonomous Systems · v0.1.0-prepilot · 2026-10-15
Track: software limits plus de-energized/circuit-simulator study; optional adult-supervised low-voltage bench only after approval
License proposal: CC BY 4.0 for original text, pending rights review

## Learning objectives

Learners will distinguish logic output from motor power; explain H-bridge direction and PWM control; identify controller, motor, and common-ground boundaries; map stop conditions to safe outputs; and review component ratings against measured motor stall current.

## Mandatory safety rules

- No mains wiring, improvised chargers, damaged cells, exposed conductors, or unprotected lithium packs.
- Never power a motor from a GPIO pin.
- Use a vendor-rated driver, current-limited/protected supply, isolation switch, strain relief, and physical test barrier.
- Power off before changing wiring. An adult verifies polarity and continuity before energizing.
- Stall tests and battery decisions are outside the student activity until a technical lead approves a procedure.

## Session A — read the interface, not just the code

Create an interface table for a dual H-bridge:

| Signal | Direction | Logic voltage | Safe default | Meaning |
|---|---|---:|---|---|
| STBY/ENABLE | controller → driver | verify exact part | disabled | master output gate |
| AIN1/AIN2 | controller → driver | verify exact part | low/low | motor A direction/brake mode |
| PWMA | controller → driver | verify exact part | 0% | motor A command |
| VM | supply → driver | verify exact part | isolated | motor power |
| VCC | logic supply → driver | verify exact part | off | driver logic power |
| GND | common reference | — | connected as designed | reference/return |

Do not fill a voltage from memory. Record the exact selected board/module, manufacturer document, revision, and page/table.

## Session B — software failsafe tests

Run or inspect the controller tests for:

1. `enabled=False` → zero left/right command;
2. `dt` beyond watchdog → zero command;
3. non-finite sensor input → zero command;
4. command values clamped to the configured limit.

Add a test case for a negative or zero time step. Explain why a software zero target cannot guarantee that a failed driver or processor removes motor energy.

## Pico/Pico 2 versus ESP32 planning

Both variants need separate validated adapters. Record:

| Question | Pico/Pico 2 | ESP32 selected model |
|---|---|---|
| Exact board and firmware | | |
| GPIO logic level | 3.3 V family; verify selected board | verify selected board |
| PWM API/frequency | verify firmware and pins | verify framework and pins |
| Reserved/boot-sensitive pins | verify official pinout | verify selected module datasheet |
| Watchdog implementation | | |
| Motor-disable pin behavior during reset | | |

Do not state that pin layouts, ADC behavior, PWM channels, or MicroPython features are interchangeable.

## Student safety checklist

- [ ] Exact board, driver, motors, and supply identified.
- [ ] Driver voltage and current ratings traced to primary documentation.
- [ ] Motor stall current measured or supplied by a credible manufacturer source.
- [ ] Logic and motor power paths marked separately.
- [ ] Polarity and continuity checked with power isolated.
- [ ] Manual isolation is reachable by the supervising adult.
- [ ] Wheels are raised/guarded for first motion and speed starts at zero.
- [ ] Faulted parts have a quarantine location and record.

## Evidence to submit

- completed interface table with primary-source references;
- software failsafe test output and one added case;
- annotated wiring boundary, not a claim of assembled hardware;
- signed checklist with `NOT APPLICABLE — NO HARDWARE` where appropriate;
- one paragraph explaining why GPIO compatibility is not full system compatibility.

## Instructor notes

Many low-cost breakout listings omit whether stated current is continuous, per-channel, combined, or peak. Accept no substitution based on product title alone. The TB6612FNG-class reference is a selection category until the exact module and motor stall current are reviewed.

If no approved equipment exists, keep the lesson de-energized. A wiring diagram, driver truth table, and software test are meaningful evidence.

## Low-bandwidth and accessibility option

Use large-print wire labels and a non-color key (signal names plus line styles). Provide a raised-line or verbal diagram. Students who cannot manipulate small connectors may own the interface table, software test, hazard review, or documentation role.

## Exit ticket

List the independent software and physical actions that should occur when sensor updates stop, and identify which action has not yet been physically verified.
