James Harton James Harton

Week Fifteen: Ticks and Talks

Servo drivers get a 100Hz ETS-backed control loop and I give a talk at Code Camp Wellington.

A fortnight of shipping things that tick and saying things out loud.

Code Camp Wellington

I spoke at Code Camp Wellington on Saturday, presenting my take on Zach Daniel's Building on Bedrock: Elixir's Fundamental Design Advantage talk (with his blessing), with a brief aside about Beam Bots. If you're in the Wellington area and missed it — sorry, you'll have to wait for next time.

Servo Drivers: The Rework Lands

The servo driver rework I've been banging on about is done. Both bb_servo_feetech v0.2.2 and bb_servo_robotis v0.2.2 have shipped with the new architecture:

  • ETS-backed state — actuators write goal_position and goal_speed directly to a shared ETS table instead of casting to the controller GenServer. Any process can read full servo state (position, temperature, voltage, current, hardware error) without going through a bottleneck.
  • Fixed-rate control loop — the controller runs a single 100Hz loop (configurable via loop_interval_ms) that batches pending commands into sync_write operations and reads positions via fast_sync_read. No more separate poll timers.
  • Safer arming — enabling torque now reads present positions first and writes them as goal_position, preventing the "stale goal jump" where a servo lurches to wherever it was last told to go three power cycles ago.

Both drivers are hardware-tested. The Feetech version batches all position writes via sync_write_raw. The Robotis version uses individual write_raw calls per servo because the upstream robotis library doesn't expose sync_write_raw — a minor inefficiency for now, but functionally identical.

Breaking changes (both drivers):

  • poll_interval_ms is replaced by loop_interval_ms (default 10ms instead of 50ms)
  • register_servo now returns {:ok, ets_table_ref} instead of :ok
  • handle_cast handlers for write/write_raw/sync_write are removed

If you're using either driver, you'll need to update your configuration. The new defaults are sensible for most use cases.

Dependency Gardening

The usual Dependabot round. Across the ecosystem:

PackageFromToNotes
igniter0.7.20.7.6Better task compilation errors, Mix.shell().cmd/1 fix
ex_cldr_numbers2.38.02.38.1Elixir 1.20 type warning fixes
ex_cldr_units2.27.12.27.2Elixir 1.20 type warning fixes
phoenix_live_view1.1.261.1.27Chrome bug fix, Elixir 1.20 compat
floki0.38.00.38.1Performance improvements
credo1.7.161.7.17New CondInsteadOfIfElse check
git_ops2.9.02.9.2Fix: abort release when tag not fetched

What's Next

With the servo driver rework shipped, the next step is a PR against pkinney/robotis to add sync_write_raw support. Powell Kinney has been an early booster of Beam Bots, so we expect a smooth path to getting batched Robotis writes on par with Feetech.