GitHub Digital Lab

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

Drag the bar to a step and let go to stop there; Play continues from it. Drag the picture to turn, scroll to zoom. Pin view looks straight down at the step. Tap a step, a part or a pin.
All 8 wiring steps
  1. 1Start with the LaunchPad, USB-C outThe AM13E230 on the bench with no cable in. The driver board goes on before any power.
  2. 2Switches S4 and S6 to BPThey sit between the right header and the chip, each marked BP and CAN. BP means BoosterPack: the Hall signals go up to the driver board. On CAN they go to the CAN chip instead and the motor never learns its table.
  3. 3Press the EVM onto J1 to J4Screw terminals pointing away from the USB-C. Its Hall-block socket covers J2 and J4, the nFAULT-side socket covers J1 and J3, with its far pin on J1 pin 1.The EVM sits flat with no pin showing between the boards, and its screw terminals point away from the USB-C.
  4. 4Jumper J13 on the GVDD pairGVDD is the driver's own 5 V. This motor's Hall sensors need 4.5 V or more, so the 3.3 V choice is too low. The jumper goes on the two pins marked GVDD, not the 3V3 pair.J13 covers the GVDD pair. The 3V3 pin stands alone.
  5. 5Hall wires into the green blockBottom to top: white HALL A, blue HALL B, green HALL C, red HALL POWER, black HALL GROUND. A Hall sensor is a small switch that flips as a rotor magnet passes it; three of them tell the program which sixth of a turn the rotor is in. A, B and C can be in any order because the program learns the table; power and ground must be right.Five wires in, red at the fourth terminal from the bottom, black at the top. Tug each one.
  6. 6Motor phases into the three-way terminalYellow to OUT A, red to OUT B, black to OUT C. Any order works; the learn step finds the table. Leave the shaft free to turn.
  7. 7Supply into the two-way terminalRed to VBAT, black to PGND, supply switched off. 12 V from an adapter with the barrel cut off is the tested supply; 5 V from a cut USB cable on a 2 A charger also spins it. Keep it under 20 V for this motor. For the first power-up use a supply that limits current to about 0.5 A, or an adapter rated no higher.Before power: a meter between VBAT and PGND reads open, not a short, and red is on VBAT. Swapped supply wires can destroy the driver.
  8. 8USB-C in, then the supply onVM, AVDD and GVDD light; MCU lights when the program runs. Open the serial port at 115200, press l to learn the Hall table (the shaft clicks round six steps, about 25 s), then 2 and g to spin. In the animation the yellow dots are supply current, the blue dots the Hall signals coming back, the orange dots the drive going out.Three lights on and NFAULT off. If NFAULT is on, switch the supply off: a phase wire is loose or shorted, or the supply sagged. Then open the motor console or the serial port.
Every wire and signal, far end to board end
Every wire, far end to board end
WireFromToStep
Hall AMotor Hall lead, 5 wiresHALL A, white5
Hall BHALL B, blue5
Hall CHALL C, green5
Hall powerHALL POWER, red5
Hall groundHALL GROUND, black5
Phase AMotor phase leadsOUT A, yellow6
Phase BOUT B, red6
Phase COUT C, black6
Supply positiveSupply +VBAT, red7
Supply groundSupply −PGND, black7
Every signal between the boards
SignalDriver board pinLaunchPad pinWhat the program does with it
INHA, INLAJ4 40, 39PB3, PA7Phase A high and low side PWM, 20 kHz
INHB, INLBJ4 38, 37PB1, PA2Phase B PWM
INHC, INLCJ4 36, 35PB2, PA25Phase C PWM
HALL A, B, CJ4 34, 33, 32PB7, PB6, PA12Inputs; captured for speed
nSLEEPJ1 9PA23Output, high wakes the driver
nFAULTJ1 8PB4Input; trips the PWM in hardware (EVM J9 pin 6)
DRVOFFJ2 13PB18Output, starts high; low turns the outputs on
ISENA, ISENB, ISENCJ3 27 to 29PA27, PA30, PA29Phase current to the ADC and the over-current comparators
VSENA, VSENVMJ3 26, 23PA17, PA16Phase A and bus voltage to the ADC
HALL POWERJ13 to GVDD5 V to the Hall sensors; this motor needs 4.5 V or more
VBAT, PGNDscrew terminalMotor supply, 4.5 to 65 V on the EVM; 12 V tested here, keep under 20 V for this motor

The build, step by step

What you need

Works on this board
LP-AM13E230
Jumper wires x10the wires drawn in the build
Micro-USB cablecomes with the board; powers and programs it
DRV8376EVM three-phase motor driver evaluation modulethe motor driverAnaheim Automation BLY171S-24V-4000 brushless motorthe motor12 V DC power supply, 0.5 A or moremotor power, to the VBAT and PGND screw terminals
Small screwdriverfor the screw terminals: 3 motor phase wires, 5 Hall wires and the 2...
On Linux or WindowsThe steps were recorded on a Mac; paths and port names in them are the Mac ones.

macOS (recorded)

TI's tools
/Applications/ti, or ~/ti
Serial port
/dev/cu.usbmodem<serial>1
Probe access
nothing to do

Linux

TI's tools
~/ti (also searched: /opt/ti)
Serial port
/dev/ttyACM0 (by name: /dev/serial/by-id/*<serial>*-if00*)
Probe access
one udev rule, how

Windows

TI's tools
C:\ti (also searched: %USERPROFILE%\ti)
Serial port
COM<n>, named "XDS110 Class Application/User UART" in Device Manager
Probe access
the XDS110 USB driver from UniFlash or CCStudio

Your probe's serial on any system: python3 tools/frl/frl.py detect. Not run on a board under Linux or Windows. Everything else that differs: the full table.

Steps

  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.TERMINAL

    With one LaunchPad on USB the script finds its probe and writes the connection file it needs; with more than one it lists their serials and asks for ./build.sh --flash <serial>.

    cd am13e230/bldc-drv8376 && ./build.sh --flash

    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.

Read the serial output

Open the board's USB serial port in any terminal program at 115200 baud. The lines the program prints appear there.

What to build next

How fast a chip reacts to a signalHow many cycles from a signal to its handler, and one motor-control step timed
Dim an LED or move a servoThe LED dims up and down, or a hobby servo swings
Measure a board's current draw, for battery lifeRunning current read through the debug probe, even on a board with no meter of its own

Every build

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 AM13E230x SDK 26.01.00.03, SysConfig 1.28.0 and TI Arm Clang 5.1.1.LTS where the script expects them (its first lines name the folders and the environment variables); python3 tools/frl/frl.py doctor --board am13e230 lists what is missing with download links.
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.

Get the code

Ran here, with steps. Ran three ways on this setup (2026-10-15 to 2026-10-17): six-step on the Halls, TI's Hall FOC, and FOC with the observer driving and the Halls only logged.

Start it

Paste this in a terminal. It hands off to an AI assistant with this board's notes.

./start.sh am13e230 bldc-spin --assistant claudegit 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
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. Tell me when to plug in the board and what you saw at each step.
Only the code for this board
git sparse-checkout set am13e230git clone --depth 1 --filter=blob:none --sparse https://github.com/Fox-Red-Labs/fox-red-labs.git cd fox-red-labs git sparse-checkout set am13e230
Or take the whole repository
git clone https://github.com/Fox-Red-Labs/fox-red-labs.git
Reports from others, and the report forms

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.

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. Results, sources, timing and limits.

How it works

Three Hall sensors sit around the rotor and report which of six sectors it is in. In six-step drive, also called trapezoidal control, the program reads the three Hall bits and turns on the two phases that pull the rotor into the next sector, so the motor steps round. Field-oriented control replaces the table with a current loop that keeps the magnetic field 90 degrees ahead of the rotor; sensorless FOC estimates the rotor angle from the phase currents and voltages and leaves the Halls out of the loop.

The same card drawing plays here at full size: Hall bits change, the lit coil pair steps round, the rotor follows. On the measured run, unloaded at 40 Hz, the sensorless loop ran on 0.063 A of phase current, the calibrated Halls on 0.13 A, and the Halls at their best angle shift on 0.087 A.

How it fits together

  1. Your computerbuilds and flashes, then reads the motor's live state over USB serial
  2. LP-AM13E230runs the control loops and the PWM
  3. DRV8376EVMplugs onto the LaunchPad and switches the motor's three phases
  4. BLY171S motorspins; its Hall sensors report the rotor position

The same flow on every version below; only the tools on your computer change.

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 µs 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.
  • 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 (3)

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...
WorksDo the F2800137's building blocks hold up to the driver-quality tests, and can an open-source STM32 motor library's maths run on it?
LAUNCHXL-F2800137, 2026-11-13
114 driverlib test cases for 12 blocks of the F2800137 pass in 3 of 3 runs with no wires, and the maths of an open-source STM32 FOC library runs on the chip with one changed line

Source files