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).
- Motor
Tuning - 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
BRACKETdoublings or halvings from the config’s own (together: a start that fails is doubled once to see which way the slack grows), then byBISECTIONSbisections (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_ROUNDStimes. - 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_posesmeettargetsand the loop isLoopMargins::stableat every pose (the other motors as they are at that point). Tn stays and Kv follows aswith_gainsays. Then, wheretargets.notchis 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::modesat that pose, or up toPEAK_OVER_MODEtimes above it), a notch is put on that mode (the highest such) withNOTCH_WIDTHtimes its frequency as its width, the gain is searched again, and the notch stays only where the gain isNOTCH_MIN_GAINtimes higher. The switch is the whole machine’s: where a notch stays it is on, and every motor without one getsnotch_frequency_hz = 0(no notch). A final call ofvelocity_loop_marginson the whole tuned config verifies all motors; a motor that fails there is lowered byJOINT_FACTOR, at mostJOINT_ROUNDStimes, 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 targetsmetis false and the gains are the best found. One search takes at mostBRACKET + BISECTIONS + 1calls per motor (and as many for the notch).