Motor Controller for a Robot Arm

Created 2 project docs

Firmware Starter — STM32G431CBT6

View Document

MCU: STM32G431CBT6 Framework: STM32 HAL

Board Bring-Up Plan — Closed-Loop DC Motor Controller

View Document

Equipment: current-limited bench supply, DMM, oscilloscope, ST-LINK/SWD debugger, USB-UART adapter, encoder simulator or known encoder, dumm...
Implemented and verified the schematic for the closed-loop brushed DC motor controller.
What was completed:
  • Added a robust 12 V nominal motor-controller architecture: MC33926 H-bridge, STM32G431 MCU, INA240 current sense, LMR33630 3.3 V buck, LM74700 reverse protection, encoder conditioning, connectors, LEDs, and protection.
  • Wired power, motor drive, current sensing, encoder A/B/Z, SWD, UART control, reset/BOOT0, and fault/status paths.
  • Ran schematic/ERC checks; there are no open ERROR/WARNING/UNCERTAIN checks in the reviewed schematic categories.
Project files created/updated:
Open items:
  • Layout is not started yet; high-current motor paths, shunt Kelvin routing, buck layout, and thermal copper will be critical.
  • Firmware starter is a HAL bring-up baseline; final PID/current-limit tuning still needs motor characterization.
Suggested next steps:
  1. Set PCB constraints: board size, stackup, current-aware trace widths, and clearance rules.
  2. Place components with power path and thermal priorities.
  3. Route the PCB, then run DRC/PI checks.
  4. Add test points for 3V3, VM_PROT, HBRIDGE_EN, current sense, and encoder signals.
Set constraints and layout
Set PCB constraints
Place components
Route the PCB
Add test points
Review BOM risks

Refine this doc
Ask about this doc
Board Bring-Up Plan — Closed-Loop DC Motor Controller
Prerequisites
  • Equipment: current-limited bench supply, DMM, oscilloscope, ST-LINK/SWD debugger, USB-UART adapter, encoder simulator or known encoder, dummy resistive load or lamp load, thermal camera or IR thermometer.
  • Firmware: see Firmware Starter — STM32G431CBT6.
  • Safety: first power-on must be from a bench supply, not a battery. Do not connect the final motor until power, default-disabled H-bridge behavior, current sense, and firmware current limiting are verified.
1. Visual Inspection
  • Inspect U2 MC33926 thermal pad/power pins, U3 LMR33630 buck area, U5 LM74700/Q1 reverse-protection orientation, U4 INA240, R13 shunt, and all connector solder joints.
  • Confirm J1 polarity: PIN1 = VIN_IN positive input, PIN2 = GND.
  • Confirm J2 motor output is isolated from GND and VM_PROT except through the intended H-bridge paths.
2. Power Rail Verification

Table


RailSourceExpected VoltageToleranceMeasure AtCurrent LimitPass Criteria
VIN_INJ1 pin 1Applied input, start 3-5 V then 12 V nominalSupply settingJ1/F1 input50-100 mA first powerNo short/current-limit hit
VIN_RAWF1 output / input TVS / LM74700 anodeApproximately VIN_IN after PTCDepends on PTC dropF1 P2 or U5 ANODE50-100 mA first powerTracks input with correct polarity
VM_PROTLM74700/Q1 protected busApproximately VIN_RAW minus MOSFET drop<100 mV drop at light loadU5 CATHODE, U3 VIN, U2 VPWR50-100 mA first powerComes up only with correct input polarity
3V3U3 LMR33630 buck output3.3 V+/-5% initialC9-C12/C32 or U1 VDDLogic-only <250 mA expected3.135-3.465 V, no oscillation
BUCK_SWU3 SW/L1Switching waveformN/AU3 SW or L1 P1Probe onlyRegular switching, no overheating
MOTOR_A/MOTOR_BU2/J2Hi-Z while disabledN/AJ2 pinsNo motor connectedNo unintended drive during reset
Procedure:
  1. With power off, measure resistance: VIN_IN-GND, VIN_RAW-GND, VM_PROT-GND, 3V3-GND, MOTOR_A-GND, MOTOR_B-GND, and MOTOR_A-MOTOR_B.
  2. Apply 3-5 V with 50-100 mA current limit and no motor connected.
  3. Verify VM_PROT and 3V3. Increase input to 8 V, then 12 V only if current draw is normal.
  4. Scope 3V3 ripple and BUCK_SW; stop if 3V3 is out of tolerance or U3 heats.
  5. Verify U2 stays disabled through MCU reset and firmware boot.
3. Critical Signal Verification

Table


SignalNetExpected StateMeasure AtNotes
ResetNRSTHigh at idle, low when SW1 pressedU1 PG10-NRST or J4 pin 5SWD reset also uses this net
Boot strapBOOT0LowU1 PB8 / R4Normal flash boot
H-bridge enableHBRIDGE_ENLow until firmware armsU2 EN / U1 PB5R12 pull-down is safety default
Disable D1HBRIDGE_D1Low at resetU2 D1 / U1 PA10High disables bridge
Disable D2_NHBRIDGE_D2_NHigh at resetU2 D2 / U1 PA11Low disables bridge
FaultHBRIDGE_FAULT_NHigh when no faultU2 SF / U1 PB6Active-low open drain via R7
Current zeroMOTOR_CURRENT_ADCAbout 1.65 V at zero motor currentR14/C27/U1 PA1INA240 REF1=3V3, REF2=GND
Power-goodPWR_GOODHigh when 3V3 validU3 PG / U1 PB12R3 pull-up to 3V3
4. Connector and Interface Tests

Table


ConnectorTypePins to VerifyTest Method
J12-pin power terminalPIN1 VIN_IN, PIN2 GNDDMM continuity and polarity mark check
J22-pin motor terminalPIN1 MOTOR_A, PIN2 MOTOR_BDMM continuity to R13/U2 outputs; no short to GND
J36-pin encoder header3V3, GND, ENC_A_RAW, ENC_B_RAW, ENC_Z_RAW, GND/shieldApply slow 0-3.3 V pulses; verify U6 outputs and MCU timer count
J42x3 SWD3V3, SWDIO, SWCLK, GND, NRST, SWOST-LINK target detect/read ID
J51x4 control UART3V3, GND, UART_TX, UART_RX115200 baud UART telemetry and echo/control test
5. Programming and Debug Interface

Table


InterfaceSignalsConnectorTool
SWD3V3, SWDIO, SWCLK, NRST, GNDJ4ST-LINK / STM32CubeProgrammer
UART telemetry/controlUART_TX, UART_RX, GNDJ5USB-UART at 3.3 V logic
Procedure:
  1. Power at 12 V current-limited with no motor.
  2. Connect ST-LINK to J4 and verify target detection.
  3. Read MCU device ID.
  4. Flash safety firmware with HBRIDGE_EN held low by default.
  5. Confirm UART telemetry on J5.
6. Functional Validation

Table


TestComponentsInputExpected OutputPass Criteria
Power LEDU3, LED1/R213V3 validLED1 onLED current limited, no overheating
Heartbeat LEDU1, LED3/R23Firmware runningLED3 togglesConfirms MCU boot loop
Fault LEDU1, LED2/R22, U2 SFSimulated fault or firmware commandLED2 changesFault input readable
EncoderJ3, D3, R15-R20, C28-C30, U6, U1 TIM3Slow A/B quadrature pulsesEncoder count changesDirection and count correct
Current senseR13, U4, U1 ADCDummy load currentADC matches DMM within calibration toleranceZero-current around 1.65 V
H-bridge no-load PWMU1/U2Firmware low-duty command, no loadMOTOR_A/MOTOR_B switch as expectedTruth table matches MC33926
Dummy load driveU2/R13/U410-50 ohm power resistor or lampControlled current and PWMNo current-limit trip, no overheating
Real motorU2/J2Final motor unloaded, low dutySmooth rotation and valid encoder feedbackCurrent below configured limit
7. Expected Measurements Reference

Table


MeasurementLocationExpected ValueToleranceInstrument
3V3 railC32/U1 VDD3.3 V+/-5% initialDMM/scope
INA240 zero outputC27/R14~1.65 V+/-100 mV before calibrationDMM/ADC
R13 shunt voltage at 2 AR13 Kelvin pads20 mVDepends on loadDMM/scope
INA240 output swing at 2 AMOTOR_CURRENT_ADC+/-0.4 V from 1.65 VAfter calibrationADC/scope
MC33926 FB at 2 AHBRIDGE_FB_ADC~1.30 V with 270 ohm R6Approximate, coarse feedbackADC/DMM
HBRIDGE_EN reset stateU2 EN0 VLogic lowScope/DMM
HBRIDGE_FAULT_N no-faultU2 SF3.3 VLogic highScope/DMM
8. Motor-Specific Precautions
  • Use no-load and dummy-load tests before a real motor.
  • Do not rely on F1 PTC for fast motor current limiting; implement firmware current limit first.
  • Watch VM_PROT during deceleration/braking because regenerative energy can pump the bus above the bench supply setpoint.
  • Avoid aggressive braking and reversal until TVS heating and bus overshoot are validated.
  • Start final motor at low voltage, low duty cycle, and no mechanical load.
Pass/Fail Summary

Table


Test SectionResultNotes
Visual Inspection[ ] Pass / [ ] Fail
Power Rails[ ] Pass / [ ] Fail
Critical Signals[ ] Pass / [ ] Fail
Connectors[ ] Pass / [ ] Fail
Programming[ ] Pass / [ ] Fail
Encoder[ ] Pass / [ ] Fail
Current Sense[ ] Pass / [ ] Fail
Motor Drive[ ] Pass / [ ] Fail
Board Status: [ ] Ready for controlled motor test / [ ] Requires rework
  • Prerequisites

  • 1. Visual Inspection

  • 2. Power Rail Verification

  • 3. Critical Signal Verification

  • 4. Connector and Interface Tests

  • 5. Programming and Debug Interface

  • 6. Functional Validation

  • 7. Expected Measurements Reference

  • 8. Motor-Specific Precautions

  • Pass/Fail Summary

Closed-Loop DC Motor Controller

Closed-Loop DC Motor Controller thumbnail
Robotics-ready closed-loop brushed DC motor controller with bidirectional 2 A H-bridge drive, quadrature encoder feedback, current sensing, protection, MCU control, debug access, and status indicators.

Properties

Properties describe core aspects of the project.

Pricing & Availability

Distributor

Qty 1

Arrow

$13.69–$22.87

Digi-Key

$18.16

HQonline

$3.75

LCSC

$17.95–$18.00

Mouser

$28.86

TME

$8.93

Verical

$11.17–$25.75

Controls