Skip to main content

Module tune

Module tune 

Source
Expand description

Tuning of the velocity loops from their measured margins: the procedure the shipped gains were found with by hand (sim-cli margins at every pose of the cycle, the gain raised until 35 degrees and 6 dB are the least left, the notch put where a resonance holds the gain back), run by the program.

Structs§

Gains
A velocity loop’s gains: Kp (N m s/rad), Tn (s) and the position loop’s Kv (1/s).
Least
The least margins of one motor’s loop over the poses, with the pose (the run’s name, “” the start pose).
MotorTuning
What came out for one motor.
Notch
A notch the tuning kept.
Targets
What the tuning holds the loops to, and whether it may use the notch.
Tuned
The result of velocity_loops.

Constants§

BISECTIONS
BRACKET
Per motor the gain is searched over a bracket of BRACKET doublings or halvings from the config’s own (together: a start that fails is doubled once to see which way the slack grows), then by BISECTIONS bisections (in the logarithm): at most 1 + 8 + 6 = 15 evaluations (velocity_loop_margins, which measures every motor at every pose), the last resolving the gain to 1.1 %.
JOINT_FACTOR
The joint check at the end lowers a gain that fails with all motors tuned by this factor, at most JOINT_ROUNDS times.
JOINT_ROUNDS
NOTCH_MIN_GAIN
A notch stays only where the verified gain rises at least by this factor: one that buys less costs phase for nothing.
NOTCH_WIDTH
The notch’s width as a share of its centre frequency, as the flying saw’s (250 Hz at 360 Hz, hand-tuned).
PEAK_OVER_MODE
A gain margin limit counts as a resonance’s where the sensitivity peaks at a mode of the machine or up to this factor above it (the flying saw without its notch: the mode at 367 Hz, the peak at 475 to 520 Hz).

Functions§

velocity_loops
Tunes every motor’s velocity loop: for each motor, in the order the machine lists them, the largest velocity gain at which the least phase margin and the least gain margin over all poses of margin_poses meet targets and the loop is LoopMargins::stable at every pose (the other motors as they are at that point). Tn stays and Kv follows as with_gain says. Then, where targets.notch is set and the notch is off, for each motor in turn: if the gain margin is what stops its gain, at a resonance (the sensitivity of the gain that fails peaks at a mode of the machine, Machine::modes at that pose, or up to PEAK_OVER_MODE times above it), a notch is put on that mode (the highest such) with NOTCH_WIDTH times its frequency as its width, the gain is searched again, and the notch stays only where the gain is NOTCH_MIN_GAIN times higher. The switch is the whole machine’s: where a notch stays it is on, and every motor without one gets notch_frequency_hz = 0 (no notch). A final call of velocity_loop_margins on the whole tuned config verifies all motors; a motor that fails there is lowered by JOINT_FACTOR, at most JOINT_ROUNDS times, and says so (lowered_in_joint_check). The gains returned are those of the last verification. Every measurement is taken with friction as configured and with it off (measure). Where no gain meets the targets met is false and the gains are the best found. One search takes at most BRACKET + BISECTIONS + 1 calls per motor (and as many for the notch).