Intensity and Pulse Width
There is a nonlinear relationship between the duty ratio of the PWM signal and the ultrasound output.
To correct this relationship, you can use PulseWidthEncoder
.
Inside the firmware, there is a table that determines the pulse width (–) of the PWM signal using the value (–) obtained by multiplying the Intensity
data of Gain
/FociSTM
/GainSTM
by the data of Modulation
(–) and dividing by .
This table can be modified by PulseWidthEncoder
.
Note that the period of the PWM signal is 256 for firmware v10 and 512 for v11 and later.
By default, to make the intensity value and ultrasound output (theoretically) linear, is written to the table. Here, is the period and represents the nearest integer.
For example, if you send the following PulseWidthEncoder
, the relationship between the intensity value and the pulse width will be linear (i.e., the intensity value and ultrasound output will be nonlinear).
use autd3::prelude::*;
fn main() {
let _ =
// For firmware v11 or later
PulseWidthEncoder::new(|_dev| |i| PulseWidth::<9, u16>::from_duty(i.0 as f32 / 510.0).unwrap());
let _ =
// For firmware v10
PulseWidthEncoder::new(|_dev| |i| PulseWidth::<8, u8>::from_duty(i.0 as f32 / 510.0).unwrap());
}
#include<autd3.hpp>
#include<autd3/link/nop.hpp>
#include<vector>
int main() {
using namespace autd3;
auto autd =
Controller::open({AUTD3{}}, link::Nop{});
PulseWidthEncoder([](const auto& dev) {
return [](const auto i) {
return PulseWidth::from_duty(static_cast<float>(i.value()) / 510.0f);
};
});
return 0; }
using AUTD3Sharp;
new PulseWidthEncoder(_dev => i => PulseWidth.FromDuty((float)i.Item1 / 510.0f));
from pyautd3 import PulseWidthEncoder, PulseWidth
PulseWidthEncoder(lambda _dev: lambda i: PulseWidth.from_duty(i.value / 510.0))
The constructor argument is a function Fn(&Device) -> Fn(Intensity) -> PulseWidth
that returns a function that returns the pulse width for each device using the table index as an argument.
NOTE: Support for firmware v10 is only available in the Rust version.