SetCpuConfig
SetCpuConfig is a command that changes the settings the CPU firmware uses internally (the failsafe, the watchdog, PTP synchronization parameters, and so on).
let config = CpuConfig { sync_guard, failsafe_timeout, ptp_unlock_failsafe_timeout, fpga_bus_wait, cpu_watchdog_timeout, ptp: PtpConfig { sync_interval, tx_timestamp_timeout, delay_resp_timeout, holdover, lock_samples, step_threshold, lock_threshold, kp_milli, ki_milli, max_freq_ppb, delay_req_syncs, path_delay_filter_shift, pause_quanta, pause_hold_syncs, pause_retry, },};SetCpuConfig::new(config);config = CpuConfig( sync_guard=sync_guard, failsafe_timeout=failsafe_timeout, ptp_unlock_failsafe_timeout=ptp_unlock_failsafe_timeout, fpga_bus_wait=fpga_bus_wait, cpu_watchdog_timeout=cpu_watchdog_timeout, ptp=PtpConfig( sync_interval=sync_interval, tx_timestamp_timeout=tx_timestamp_timeout, delay_resp_timeout=delay_resp_timeout, holdover=holdover, lock_samples=lock_samples, step_threshold=step_threshold, lock_threshold=lock_threshold, kp_milli=kp_milli, ki_milli=ki_milli, max_freq_ppb=max_freq_ppb, delay_req_syncs=delay_req_syncs, path_delay_filter_shift=path_delay_filter_shift, pause_quanta=pause_quanta, pause_hold_syncs=pause_hold_syncs, pause_retry=pause_retry, ),)SetCpuConfig(config)var config = new CpuConfig{ SyncGuard = syncGuard, FailsafeTimeout = failsafeTimeout, PtpUnlockFailsafeTimeout = ptpUnlockFailsafeTimeout, FpgaBusWait = fpgaBusWait, CpuWatchdogTimeout = cpuWatchdogTimeout, Ptp = new PtpConfig { SyncInterval = syncInterval, TxTimestampTimeout = txTimestampTimeout, DelayRespTimeout = delayRespTimeout, Holdover = holdover, LockSamples = lockSamples, StepThreshold = stepThreshold, LockThreshold = lockThreshold, KpMilli = kpMilli, KiMilli = kiMilli, MaxFreqPpb = maxFreqPpb, DelayReqSyncs = delayReqSyncs, PathDelayFilterShift = pathDelayFilterShift, PauseQuanta = pauseQuanta, PauseHoldSyncs = pauseHoldSyncs, PauseRetry = pauseRetry, },};new SetCpuConfig(config);CpuConfig
Section titled “CpuConfig”| Field | Type | Default | Description |
|---|---|---|---|
sync_guard |
Duration |
250 μs | Margin for choosing the synchronization start time |
failsafe_timeout |
Option<Duration> |
None |
A device stops its output once nothing has arrived from the host for this long (failsafe). None disables the failsafe |
ptp_unlock_failsafe_timeout |
Option<Duration> |
None |
A device stops its output once it has been without its PTP lock for this long. None disables it |
fpga_bus_wait |
FpgaBusWait |
Cycles3 |
Wait cycles of the bus the CPU reads and writes the FPGA through. Cycles2 or Cycles3 |
cpu_watchdog_timeout |
Option<Duration> |
1 s | Once the CPU firmware has stopped for this long, the device stops the output. None disables it |
ptp |
PtpConfig |
PTP synchronization parameters |
PtpConfig
Section titled “PtpConfig”| Field | Type | Default | Description |
|---|---|---|---|
sync_interval |
Duration |
8 ms | Interval at which Sync messages are sent |
tx_timestamp_timeout |
Duration |
3 ms | How long to wait for the transmit timestamp of Delay_Req |
delay_resp_timeout |
Duration |
6 ms | How long to wait for Delay_Resp |
holdover |
Duration |
1 s | How long the lock is kept while locked and no Sync arrives |
lock_samples |
NonZeroU16 |
64 | Number of consecutive samples required to lock |
step_threshold |
Duration |
10 μs | The clock is stepped when the time offset exceeds this |
lock_threshold |
Duration |
100 ns | Samples whose time offset is below this count toward the lock |
kp_milli |
u32 |
50 | Proportional gain of the servo × 1000 |
ki_milli |
u32 |
1 | Integral gain of the servo × 1000 |
max_freq_ppb |
u32 |
500,000 | Limit of the frequency correction [ppb]. 0 to 2,147,483,647 (the device rejects larger values) |
delay_req_syncs |
NonZeroU16 |
32 | Interval at which the path delay is measured again once locked (in Sync messages) |
path_delay_filter_shift |
u8 |
5 | Smoothing factor 1 / 2^n of the path delay. 0 to 16 (the device rejects larger values). 0 disables the smoothing |
pause_quanta |
Option<NonZeroU16> |
48 | Length of the PAUSE sent to the host when the link is saturated [512 bit times]. None sends no PAUSE |
pause_hold_syncs |
u16 |
64 | Number of Sync messages for which a PAUSE keeps being sent on every send after the link was found saturated |
pause_retry |
Duration |
8 ms | How long PAUSE keeps being sent while a Sync cannot be sent out |
The settings return to their defaults on Clear and on power cycling. Reopening the client does not reset them.
Example
Section titled “Example”use std::time::Duration;
use autd3_rs::commands::{Clear, CpuConfig, SetCpuConfig, Synchronize};use autd3_rs::geometry::{Autd3, Geometry};use autd3_rs::Client;use autd3_rs::udp::TransportOption;
let geometry = Geometry::new(vec![Autd3::default()]);let option = TransportOption::default();let mut client = Client::open(&geometry, &option).await?;client.send(Clear).await?;client.send(Synchronize).await?;
client.send(SetCpuConfig::new(CpuConfig { ptp_unlock_failsafe_timeout: Some(Duration::from_secs(2)), ..Default::default()})).await?;import asyncio
from autd3 import Client, Duration, TransportOptionfrom autd3.commands import Clear, CpuConfig, SetCpuConfig, Synchronizefrom autd3.geometry import Autd3, Geometry
async def main() -> None: geometry = Geometry([Autd3()]) with await Client.open(geometry, TransportOption()) as client: await client.send(Clear()) await client.send(Synchronize())
await client.send(SetCpuConfig(CpuConfig(ptp_unlock_failsafe_timeout=Duration.from_secs(2))))
asyncio.run(main())using System;using System.Threading.Tasks;using AUTD3;
var geometry = new Geometry(new[] { new Autd3() });using var client = await Client.OpenAsync(geometry, new TransportOption());await client.SendAsync(new Clear());await client.SendAsync(new Synchronize());
await client.SendAsync(new SetCpuConfig(new CpuConfig { PtpUnlockFailsafeTimeout = TimeSpan.FromSeconds(2) }));