Skip to main content
NewEpisode 3a is out: Carry the conversation onWatch →

This part is for members

Membership opens soon. Leave your email and we'll tell you the day it does. Founding members get the launch price.

Keep watching the free parts
Motion modes · 25c

Homing: finding a known position

25b finished the speed ramp PV and PT share; this one is homing, which uses the same ramp to find a known position. Running example: the wb40st motor powers up at 5,000 counts (it reads 4,999), a home switch on the machine is closed from 10,000 to 40,000 counts, and a host selects homing mode 7 and method 7 with the default speeds, 10 rpm / 1 rpm / 100 rpm/s; the bench is the board build boot_board (the real drv_encoder.c and the whole app stack), with a new --switches option that sets the switches from where the rotor truly is. Nine stops: an absolute multi-turn encoder knows where the motor is but not where the machine's zero is, and homing ties a reference to a switch; mode 7 puts the control layer in speed mode and selects the homing app, and HomingModeInit writes DISABLE, so ENABLE then mode in the same millisecond leaves the drive uncalibrated and disabled; the first enabled tick (1,202.55 ms) reads the method, turns the speeds into counts/s (21,845 and 2,184.5), clears the Index flag and seeds 25b's planner from the measured speed; the inputs are three active-low switches and an Index the absolute encoder makes up (the single-turn count jumps by more than half a turn, drv_encoder.c:403), which lives for one tick; method 7 searches forward at 10 rpm (the switch closes at 10,002 after 268 ms), retracts at −10 rpm (opens at 9,998), searches for the Index at −1 rpm (4.17 s, up to a full turn, 60 s), and after the wrap to 131,071 goes to DECELERATE and completes on the next tick; on that tick it writes Home_position_offset_value = raw position + Home_offset (−1) once, after which the host reads raw minus offset and PP adds it to every target; where home is: the offset is taken on the COMPLETE tick, after zero speed (under 10 rpm for 20 ms), so with a 30 rpm Index search home is 9,451 counts (26°) from the Index and a PP target of 0 after homing goes to −9,450.8, a real bug; the patched copy from fix/homing-offset-at-index gives offset 0 and target 0 at 1.6; the other branches: starting on the switch, limit switches (failed but still enabled), method 35, method 1 (refused and disabled), quick stop (failed, yet Homing_state stays idle); homing never saves the offset (the L106 TODO), so a power cycle loses home (worked out from the code). Your turn: a 5 rpm Index search gives offset −2, one tick off.

Up next26a · CSP: four points, one curve→