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
Sensors · 12a

Multi-turn 1: one more turn when it crosses zero

Episode 11 ended with a count inside one turn (box 3); this episode adds a sixth box, enc_sum_p: the position over all turns, the one the position loop controls. Running example: the gim6010 joint motor (MT68xx, 2,097,152 counts a turn) at 2000 rpm, 6,990.5 counts every 100 µs. On tick 158 the count drops from 2,090,519 to 357, and motor_pos_sensor decides by the half-turn rule that it crossed zero forward: one more turn (the whole function, line by line). With one reading every 100 µs the rule holds up to 300,000 rpm (the gim6010 tops out at 2500). The driver's second crossing detector uses the same rule but only sets a flag: it fires once, on the same tick 158, AppStatusScanFast clears it by reading it, and homing takes it as its index. Direction is set twice: the driver's a_dir (1 = reversed) and the model's dir (1 = keep). Your turn: the same motor backwards, where the count jumps from 357 to 2,090,519 on tick 145 and box 6 becomes −6,633.

Up next12b · Multi-turn 2: which turn it is on after power-up→