Skip to content

Moving the Focal Point

In AUTD3, a Pattern is overwritten each time it is sent. Therefore, running code like the following moves the focal position roughly once per second.

let mut phases = geometry.phase_buffer();
loop {
for sign in [1.0_f32, -1.0] {
let target = center + offset((sign * 20.0) * mm, 0.0 * mm, 0.0 * mm);
autd3_rs_pattern::focus(
&geometry,
target,
wavelength,
&mut phases,
);
client.send(Pattern::new(&phases, Intensity::MAX)).await?;
tokio::time::sleep(Duration::from_secs(1)).await;
}
}

The code above controls the timing in software. Its accuracy depends on the OS and the execution environment, so if higher-precision control is needed, using FociStm / PatternStm is recommended.

The code that achieves behavior equivalent to the above using FociStm is as follows.

let points = [
ControlPoints::from(center + offset(20.0 * mm, 0.0 * mm, 0.0 * mm)),
ControlPoints::from(center + offset(-20.0 * mm, 0.0 * mm, 0.0 * mm)),
];
let config = SamplingConfig::from_freq(1.0 * Hz)?;
client.send(FociStm::new(config, &points, FociStmOption::default())).await?;

Because FociStm / PatternStm loops inside the AUTD3 device, no software loop is needed, and it automatically loops infinitely after being sent. In addition, the timing is controlled by the timer built into the AUTD3 device, so it is highly accurate and can be specified with a resolution as fine as 25 µs. However, due to constraints of this timer, there are frequencies that cannot be output.

The switching timing of FociStm / PatternStm is specified by SamplingConfig.

To switch an arbitrary Pattern rather than just a focal point, use PatternStm instead of FociStm.