Skip to main content

fit_sweep

Function fit_sweep 

Source
pub fn fit_sweep(
    entry: &MachineEntry,
    cfg: &Config,
    motor: usize,
    measured: &[SweepPoint],
    amplitude: f64,
) -> Result<Option<SweepFit>, ConfigError>
Expand description

Stage 2 on a measured sweep, taken on motor with a torque amplitude: a dip of the measured sweep, and of the config’s own sweep the dip of the same mode. The config’s sweep has the measured frequencies and, at the step of each end, more beyond them up to a factor of √2: its dip of the same mode may lie near an end, where the range misses one of its flanks. Before, the config’s lowest dip with both flanks was taken: on the T-shaped belt gantry with its belt at 0.8 of the stiffness, swept from 50 to 130 Hz, its dip at 55 Hz missed its lower flank by 0.1 of 726, and the next one, at 94 Hz, was set against the measured 61.5 Hz (factor 0.42 for 1.25). None where the measured sweep shows no dip with both flanks, or the config’s none at all.

Which dip is the measured mode is told by how the config’s dips move with the stiffness, not by being the nearest (that holds only while the stiffness is off by less than the ratio of neighbouring dips’ frequencies, 61.5 and 103 Hz on the T-shaped belt gantry: a factor of 1.3 either way). The config is swept a second time with BELT_STIFFNESS_KEY raised by STIFFNESS_PROBE, and each dip matched to the nearest dip of that sweep gives its exponent s in f ~ k^s: 1/2 for a mode the belt carries alone, less for one it shares, 0 for one it does not carry. Each dip with s of at least 1/4 is tried as each of the measured sweep’s dips: the stiffness that puts it there moves every dip by its own exponent, and the pair is taken whose moved dips meet the measured sweep’s dips best (the sum of the log distances, each measured dip to the nearest moved one and each moved one inside the measured range to the nearest measured one; of equal sums the nearer). Before, the measured sweep’s lowest dip was the one: on the T-shaped belt gantry swept from 5 to 500 Hz that is a 22 Hz mode the belt hardly moves, and it was set against the config’s 60 Hz belt mode (× 0.103 for 1). With no such dip, or no key BELT_STIFFNESS_KEY in the config, the nearest dip of all. The cost is a second sweep of the config. On the T-shaped belt gantry swept from 30 to 200 Hz this takes the 60 Hz dip for a belt from half to 2.5 times as stiff (sweep.rs); the nearest dip took the 102 Hz one beyond 1.8 times. The factor (SweepFit::factor) is then the one at which the config’s dip lies at the measured frequency, found by sweeping the config at it (a secant, SECANT_STEPS sweeps at most); without the key, the pure belt law (f_measured / f_config)^2.