Skip to content

DC motors and their drivers: dc_motor, Pololu's 50:1 gearmotor, h_bridge, the DRV8833 and the TB6612FNG - #117

Merged
teo1747 merged 5 commits into
mainfrom
claude/dreamy-archimedes-v28ly5
Nov 9, 2026
Merged

teo1747 merged 5 commits into
mainfrom
claude/dreamy-archimedes-v28ly5

Conversation

@teo1747

@teo1747 teo1747 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

The first part of M7's robot on the floor: its motors and the drivers that power them from a battery.

What it adds

The motor

  • dc_motor, an analog primitive (core/analog/motor.c, SPEC-004): a brushed DC motor solved with the circuit.
    • Winding: resistance and inductance in series with the back EMF.
    • Rotor: inertia, friction, and a gearbox's ratio and efficiency, with a load torque on the shaft.
    • The current and the speed are two extra unknowns of the island.
    • Powered at t = 0, it starts at its stall current; turned by its load, it generates.
  • emblink/pololu_3073_gearmotor: Pololu's 50:1 Micro Metal Gearmotor HPCB 6V (extended shaft), its constants from Pololu's specifications at 6 V. Inductance and inertia are estimates, declared in the fidelity.

The drivers

  • h_bridge, an analog primitive (core/analog/hbridge.c, SPEC-004): one bridge of an integrated motor driver.
    • Output stage. FETs from VM and to the sense return, as on-resistances that follow VM, with body diodes. A motor slows as its battery sags and coasts through the diodes.
    • Inputs. Read as voltages through Schmitt thresholds and pulldowns. They are absolute, or fractions of a logic supply on VCC (vcc_ref).
    • Truth tables. DRV8833, TB6612FNG and L293D.
    • Timing. Deglitch, propagation delay, and high-to-low and low-to-high dead times.
    • Protection. UVLO on VM or VCC, slow-decay current chopping on a sense resistor, and overcurrent shutdown with retry and an open-drain FAULT.
    • Sleep and wake: nSLEEP, or STBY as standby.
  • emblink/h_bridge: the primitive as a part.
  • emblink/drv8833: TI's DRV8833, with the values of datasheet SLVSAR1E.
  • emblink/tb6612fng: Toshiba's TB6612FNG.
    • Its datasheet's H-SW control table.
    • 0.5 Ω outputs (upper + lower) and 1 V diodes.
    • Thresholds at 0.3/0.7 VCC with 200 kΩ pulldowns.
    • 50/230 ns dead times, the 1.9/2.2 V VCC lockout, and 1 µA standby.
    • SSOP24's doubled pins are separate pins joined inside.
  • French text for every part.
  • Engine changes.
    • An analog primitive takes up to 16 terminals (8 before).
    • A composite's pin declared nc needs no port.

Evidence

  • Motor fixtures: no-load, start, stall, reverse. The constants give a best-efficiency point within 6 % of Pololu's.
  • h_bridge fixtures:
    • forward: 4.83 V across 10 Ω
    • timing: 1.1 µs propagation, a 300 ns pulse lost to the deglitch, the dead time
    • uvlo
  • DRV8833 fixtures:
    • motor: 640 rpm at 6 V
    • chopping: 0.38 to 0.40 A with 0.5 Ω on AISEN
    • overcurrent: nFAULT low, then the 1.35 ms retry
    • sleep: 1.6 µA
    • awake: 1.7 mA
  • TB6612FNG fixtures:
    • drive: the gearmotor at about 640 rpm, with channel B braking
    • pwm_brake
    • standby: under 1 µA
    • vcc_thresholds: 2.0 V is low at VCC = 5 V; the 1.9 V lockout
  • Tests.
    • The full dev ctest passed (72/72) before the TB6612FNG.
    • With the TB6612FNG, test_analog, test_catalog, test_engine, catalog_fr, tools_unittests and the 16 motor and driver fixtures pass on dev, ci-clang, ci-tcc (clean build) and asan.
    • validate.py --all, catalog_text check, check_docs and check_banned are clean.
  • Merged with main after Build experimental original ESP32 execution, memory and I/O foundations #115.

Not yet

  • The L293D part on the primitive.
  • Thermal shutdown and switching edges.
  • The encoder, and the robot's body in the world.

…otor

M7's robot begins with its motors. dc_motor (core/analog/motor.c) is a
brushed DC motor in the analog engine: the winding's resistance and
inductance in series with the back EMF ke w, the rotor's inertia driven
by kt i against friction and a load torque through a gearbox's ratio and
efficiency, the current and the speed two extra unknowns integrated by
the island's method with their truncation errors in its step control.
At the operating point the rotor is at rest, so a motor powered at t = 0
starts at its stall current and spins up.

emblink/pololu_3073_gearmotor takes its constants from Pololu's
specifications at 6 V (650 rpm and 0.15 A unloaded, 1.5 A and 0.74 kg cm
stalled; the best-efficiency point they give lands within 6 % of
Pololu's); its four fixtures check no load, the start, a stall and
reverse.
One bridge of an integrated motor driver solved with the circuit
(core/analog/hbridge.c, SPEC-004): FETs from VM and to the sense return
as on-resistances that follow VM, their body diodes, logic inputs read
as voltages through Schmitt thresholds and pulldowns, the DRV8833,
TB6612FNG and L293D truth tables, deglitch, propagation delay, dead
time, nSLEEP and its wake, undervoltage lockout, slow-decay current
chopping and overcurrent shutdown with an open-drain fault.

emblink/h_bridge is the primitive as a part; emblink/drv8833 is two
bridges with the datasheet's values (SLVSAR1E), with fixtures for the
drive, timing, UVLO, a gearmotor, chopping, overcurrent, sleep and
awake currents. An analog device takes up to 16 terminals, and a
composite's pin declared nc needs no port.
@teo1747 teo1747 changed the title DC motors: the dc_motor primitive and Pololu's 50:1 micro metal gearmotor DC motors and their driver: dc_motor, Pololu's 50:1 gearmotor, h_bridge and the DRV8833 Nov 8, 2026
The primitive takes a logic supply on VCC (vcc_ref): input thresholds
as fractions of it, the lockout on it and the quiescent current from it;
a separate low-to-high dead time; boolean parameters are read as such.
emblink/tb6612fng is the TB6612FNG on it, with the datasheet's control
table, 0.5 ohm outputs, 1 V diodes, 50/230 ns dead times, 200 kohm
pulldowns, the 1.9/2.2 V VCC lockout and 1 uA standby, and four
fixtures.
… into claude/dreamy-archimedes-v28ly5

# Conflicts:
#	docs/STATUS.md
@teo1747 teo1747 changed the title DC motors and their driver: dc_motor, Pololu's 50:1 gearmotor, h_bridge and the DRV8833 DC motors and their drivers: dc_motor, Pololu's 50:1 gearmotor, h_bridge, the DRV8833 and the TB6612FNG Nov 8, 2026
@teo1747
teo1747 merged commit e4616fa into main Nov 9, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant