GitHub

Fox Red Labs / Builds / Motor control, power and sensing

Spin a brushless motor: six-step, FOC and sensorless FOC

An AM13E230 and a plug-on driver board turn a Hall-sensor motor; drive it from the serial port, the browser console or a phone.

HardWiring needed1 evening for six-step

Parts and steps

Which version

You need

The DRV8376EVM with the Hall block, motor phase terminals and supply terminals marked
The 40-pin edge is four 10-pin headers. Hold the board with the USB connector at the top: J1 (pins 1 to 10) and J3 (21 to 30) are the two left rows, J4 (31 to 40) and J2 (11 to 20) the two right rows. Pin 1 of J1 and pin 21 of J3 are the top pins of the left rows, nearest the USB connector; J4 and J2 count the other way, so pin 40 and pin 20 are at the top. Nothing needs a jumper wire between the boards: the EVM plugs onto J1 to J4 with its screw terminals pointing away from the USB-C connector. The loose wires are the motor's: phases yellow, red, black to OUT A, B, C (any order), and the Hall leads red, black, blue, green, white to HALL POWER, HALL GROUND, HALL A, B, C. Supply 4.5 to 65 V to VBAT and PGND; 12 V is plenty. The pin table is the one in am13e230/bldc-drv8376/README.md. Full size.
Pin table
EVM pinLaunchPad pinWhat it isNeeded
EVM INHA, INLAJ4 pins 40, 39 (PB3, PA7)gate drive, phase A: MCPWM4 1A, 1Brequired
EVM INHB, INLBJ4 pins 38, 37 (PB1, PA2)gate drive, phase B: MCPWM4 2A, 2Brequired
EVM INHC, INLCJ4 pins 36, 35 (PB2, PA25)gate drive, phase C: MCPWM4 3A, 3Brequired
EVM HALL A, B, CJ4 pins 34, 33, 32 (PB7, PB6, PA12)Hall inputs; the EVM has 10 k pull-ups to 3.3 Vrequired
EVM nSLEEPJ1 pin 9 (PA23)high wakes the driverrequired
EVM nFAULTJ1 pin 8 (PB4)low means a driver faultrequired
EVM DRVOFFJ2 pin 13 (PB18)driver output enablerequired
EVM VSENVMJ3 pin 23 (PA16)bus voltage through the EVM's dividerrequired
EVM VSENAJ3 pin 26 (PA17)phase A voltageoptional
LaunchPad S6 and S4both to BPsend PB6, PB7, PA11 and PA12 to the headers, not the CAN chiprequired
EVM J13GVDD position (5 V)powers the Hall sensors; the motor's Halls want 4.5 V or morerequired
  1. With USB unplugged: set EVM jumper J13 to GVDD, wire the motor and Hall leads as in the table, set LaunchPad switches S6 and S4 to BP, and press the EVM onto J1 to J4 with its screw terminals pointing away from the USB-C connector.BENCH

    You should see: The EVM sits flat on all four headers. Nothing is lit.

  2. Build and flash the six-step program: cd am13e230/bldc-drv8376 && ./build.sh --flashTERMINAL

    You should see: About 3 s to build and 5 s to flash over the LaunchPad kit's own probe; 32 kB of flash.

  3. Plug in USB-C, then switch the motor supply on.BENCH

    Open the LaunchPad kit's serial port at 115200 baud and type v.

    You should see: The EVM's VM, AVDD and GVDD lights are on and NFAULT is off. v shows bus volts near your supply and a Hall state from 1 to 6. The current image boots with the driver off; Check the supply voltage and the driver wiring before the first start.

  4. Learn the Hall table once per power-up: type l.TERMINAL

    It takes about 25 s with no hands.

    You should see: The shaft clicks round six steps and a table prints with six different Hall states.

  5. Type 2 then g.TERMINAL

    2g

    You should see: The motor turns. A line a second shows duty, direction, Hall state, rpm, bus volts and fault. At 20 percent duty it settles near 920 rpm.

  6. Type s, then r, then g for the other direction. b brakes. 0 then s ends.TERMINAL

    You should see: Reverse runs 4 to 10 percent slower than forward at the same duty.

Or hand it to a coding assistant

Paste this in a terminal. It hands off to an AI assistant.

git clone --depth 1 --filter=blob:none https://github.com/Fox-Red-Labs/fox-red-labs.git && cd fox-red-labs ./start.sh am13e230 bldc-spin --assistant claude

It runs the steps above and reports what it saw.

Not Claude Code? Copy this prompt instead.
Clone https://github.com/Fox-Red-Labs/fox-red-labs and read am13e230/AGENTS.md first. Then run Spin a brushless motor on my LP-AM13E230, following docs/builds/bldc-spin.md. Tell me when to plug in a board and what you saw at each step.

If something goes wrong

Every Hall line later reads state 7The J13 jumper is missing or the Hall ground lead is open.
The build cannot find its toolsInstall the SDK, SysConfig and compiler versions in step 1.
It says no bus voltage on VMThe supply is off or on the wrong terminals.
It says learn failedA Hall wire is loose (state 0 or 7), or the rotor did not move: raise the supply voltage.
It says DRIVER FAULTLower the duty and check the supply can give the current, then type c to clear.
More troubleshooting
It runs rough or stalls at onceType a to trim the commutation advance, then g again.

Every fix for this board: the FAQ.

What to build next

Every build. The code for all of them is in the GitHub repository.

Evidence and limitsSpins on all three: six-step to 3,632 rpm, Hall FOC held at a set speed, and sensorless FOC at 40 Hz on 0.063 A against 0.13 A on the Halls. Unloaded, 12.4 V. Ran on 1 board. Results, sources, timing and limits.

Six-step on the Hall sensors

Expected result: At 10 to 60 percent duty the motor runs from about 400 to about 3,630 rpm forward and 380 to 3,440 rpm in reverse, unloaded, on 12.4 V.

What this shows

  • A plug-on driver board and about 350 lines of C turn a Hall-sensor motor, with the Hall table learned by the program in about 25 s.
  • Unloaded, the motor started from standstill on every try at 10 and at 20 percent duty.
  • Median speed at 20, 40 and 60 percent duty, forward: 924, 2,312 and 3,632 rpm; reverse: 891, 2,091 and 3,442.
What this does not establish, and limits

What this does not establish

  • Torque or efficiency: nothing was loaded and phase current was not measured in this version.
  • That the speeds are exact: they come from Hall edge timing, and a tachometer would settle whether they read high.
  • That the speed sweep repeats: it was run once. The same motor later turned under the FOC image.

Limits to keep in mind

  • Open loop in duty: speed follows the duty you type, with no speed loop in the base program.
  • One motor, one driver board, 12.4 V from a small adapter, 60 percent duty cap, unloaded.
  • The Hall sensors sit about 7 electrical degrees off their ideal spacing; the program learns the table rather than assuming it.

Sources

Versions, sizes and timing

Speed sweep10 to 60 percent duty, 3 runs each, 20 kHz PWM, 6x PWM mode, Hall-timed rpmREADME notes
MotorAnaheim BLY171S-24V-4000: 24 V, 4,000 rpm, 1.8 A, 4 pole pairs, 2.45 V per 1,000 rpm (label)README notes

Evidence

  • Duty sweep on 2026-10-15: three 4.5 s starts from standstill at each of 10 to 60 percent duty, both directions, bus 12.4 to 12.5 V, unloaded, no driver fault. Speed is timed from Hall edges, not read from a tachometer. README notes
  • Starts from standstill: 20 of 20 at 10 and at 20 percent duty, 0 of 20 at 5 percent. README notes

Other boards

What the status words mean

Works ran here and did what it shouldCould work some of it ran; real porting effort is left; hover for whatNot for this chip the chip or its vendor software cannot; hover for why

FOC on the Hall sensors

Expected result: The motor holds a set electrical speed in closed loop on TI's FOC, stops on its own at the cap, and a +5 Hz step settles in about 80 ms with the designed gains.

What this shows

  • TI's Hall FOC solution runs on a driver board it was not written for: about 650 lines of change, no fault, peak current 0.57 A in a 12 s run at 10 Hz.
  • The firmware guard stops every run on its own: a time cap, 1 s after the host goes quiet, a phase-current trip, a speed clamp and a bus voltage window. Host cut-off was tested: the motor stopped 1.0 s after the last packet.
  • Speed gains designed for the 0.5 ms speed tick halve the step's rise: 50 ms median (41 to 129) against 91 ms (79 to 182) with TI's defaults, five runs against three.
What this does not establish, and limits

What this does not establish

  • Overshoot: one Hall-timed speed sample is only resolved to about 0.7 Hz, 14 percent of the 5 Hz step, so none is reported.
  • That the designed gains are better everywhere: they hold 10 Hz tighter but hunt more at 15 Hz (13.84 to 15.92 Hz p5 to p95 against 14.47 to 15.92).
  • That TI's default gains work for reversals: with them, 7 of 7 reversals faulted and 3 of 14 runs at 20 Hz reached a 20 s cap.

Limits to keep in mind

  • The campaign.py script these steps call is not in this copy, so the Hall calibration, speed-loop and observer steps cannot be repeated from it; the results are the recorded runs.
  • Unloaded, one motor, 12.4 V, 10 to 20 Hz electrical; a +5 Hz step only; the 30 Hz design row was not run.
  • Current polarity and gain rest on the EVM's documented 1 V/A; the gain resistors were not read off the board.

Sources

Versions, sizes and timing

Step responserise 10 to 90 percent 50 ms median with raised gains against 91 ms with TI's defaults; settle to a 1.25 Hz band 82 ms against 151 ms
Live linkTI's MotorVision protocol at 9.2 Mbaud over the LaunchPad kit's USB serial; guard version 6README notes
PortTI's 3sh_hall_sen_foc_drv8323rh solution, 20 kHz PWM, 2.0 us minimum compare, 0.4 A software torque ceilingREADME notes

Evidence

  • On 2026-10-17 TI's Hall FOC held closed-loop speed on this setup: a 12 s run at 10 Hz electrical reached closed loop at 8.9 s and stopped at its cap with a 0.57 A peak, no fault. README notes
  • Speed gains designed for the firmware's 0.5 ms speed tick, stepped 10 to 15 Hz electrical, five runs against three on TI's defaults: rise 50 ms against 91 ms, settling 82 ms against 151 ms, no faults.

Other boards

What the status words mean

Works ran here and did what it shouldCould work some of it ran; real porting effort is left; hover for whatNot for this chip the chip or its vendor software cannot; hover for why

FOC with no sensor in the loop

Expected result: After an align and open-loop start the motor runs on FAST alone at 40.0 Hz electrical, drawing about half the current the Hall version needs.

What this shows

  • TI's FAST observer identifies its own model and read the rotor angle to 2 or 3 degrees with no help from the Halls; the ESMO observer needed a 31 degree trim from the sweep because its gains came from another motor.
  • TI's automatic Hall calibration left the Hall angle 49 degrees off the rotor, which is why the Hall version draws about 2 times the current.
  • Hall-free runs held 40.0 Hz at 0.063 A (two FAST runs, one ESMO run), against 0.13 A on the Halls at the same speed.
What this does not establish, and limits

What this does not establish

  • That the Halls are not needed: they stay wired as a referee, and the firmware only logs them in this mode.
  • Loaded starts, speeds below about 20 Hz electrical, reversals or speed steps on the observer: none were run.
  • That the 49 degree answer is exact: it rests on a 1/cos current fit over six points, with a 45 to 52.5 degree band.

Limits to keep in mind

  • The campaign.py script these steps call is not in this copy, so the Hall calibration, speed-loop and observer steps cannot be repeated from it; the results are the recorded runs.
  • Unloaded, one motor, 12.4 V, one steady speed (40 Hz electrical, 600 rpm).
  • ESMO's 31 degree trim came from this motor's sweep and would need its own sweep on another motor.
  • The start is TI's align and open loop; a rotor that cannot align (a loaded shaft) is outside the tested cases.

Sources

Versions, sizes and timing

Angle sweepcurrent = 0.087 A / cos(shift - 49), 4.4 mA rms residual, two runs each side
Hall-free runs3 runs of 20 s: FAST 52.1 degrees from the Hall table (referee), ESMO 50.9; no fault

Evidence

  • Hall-free runs on 2026-10-17, 20 s each, no fault: FAST held 40.0 Hz at 0.063 A mean phase current, twice. ESMO with a fixed 31 degree trim did the same once. TI's Hall FOC at the same speed drew 0.13 A.
  • A current-minimum sweep put the rotor 49 degrees (45 to 52.5) past TI's calibrated Hall table; FAST read within 2 to 3 degrees of that untrimmed.

Other boards

What the status words mean

Works ran here and did what it shouldCould work some of it ran; real porting effort is left; hover for whatNot for this chip the chip or its vendor software cannot; hover for why

Result grid

Project
LP-MSPM0G3507MSPM0G3507 chip
LP-MSPM0L1306MSPM0L1306 chip
LP-EM-CC2340R5CC2340R52 chip
LAUNCHXL-F2800137TMS320F2800137 chip
Spin a brushless motor
LP-MSPM0G3507
LP-MSPM0L1306
LP-EM-CC2340R5
LAUNCHXL-F2800137

Works ran here and did what it shouldShould work it builds; only naming, packaging or build glue is in the way; hover for whichCould work some of it ran; real porting effort is left; hover for whatNot for this chip the chip or its vendor software cannot; hover for why

Experiments (2)

StatusWhat was triedResult
WorksCan the LP-AM13E230 spin a Hall-sensor brushless motor through TI's DRV8376EVM, with no motor BoosterPack and no C2000?
AM13E230, 2026-10-15
The DRV8376EVM plugs straight onto the AM13E230 and a 350-line six-step program spun an Anaheim BLY171S-24V-4000 at 924, 2,312 and 3,632 rpm (medians of three runs) at 20, 40 and 60 percent duty on a 12.4 V bus,...
Can SimpleFOC, the open-source motor library, drive a motor from the LP-AM13E230 and the DRV8376EVM?
AM13E230 with DRV8376EVM, 2026-11-03
SimpleFOC 2.4.0, which lists no TI chip, builds for the AM13E230 with none of its 3,097 compiled lines changed (23.1 kB of flash, 160 lines of port code plus a 146-line sketch) and its loop pass costs 1.35k cycles...

Source files

    Get the code and tell us how it wentThe clone command, the board folder with its AGENTS.md, reports from others, and the three report forms.

    Get the code

    Clone the repository and open the board's folder below. AGENTS.md is a plain text file of notes for AI coding assistants, and llms.txt at the root indexes the site for one.

    git clone https://github.com/Fox-Red-Labs/fox-red-labs.git

    Code is BSD-3-Clause, writing is CC BY 4.0; third-party folders keep their own licenses.

    Built it? Tell us

    Built this, or got stuck? Report it on GitHub with a few short answers. Your report shows here in your words, marked as yours. A failure that repeats on the bench gets its fix here.