Skip to main content

DC synchronization

Slave-level Distributed Clocks (DC) configuration. Access it through the slave.dc() instance obtained from SlaveDC.

Prefer master-level methods

In most scenarios, use master.configure_dc_all() to configure all DC slaves in one call. Slave-level methods are for scenarios where individual slaves need different parameters.

Read-only properties​

CategoryMethodTypeRead/writeDescription
DC stateslave.has_dc()Option<bool>read-onlyWhether the ESC hardware supports DC (None = the slave structure cannot be read, which does not mean there is no DC)
slave.dc().has_esi_dc_sync()boolread-onlyWhether the ESI declares DC synchronization for this slave (OpMode/AssignActivate non-zero)
slave.dc().esi_dc_sync_mode()i32read-onlyDC synchronization tier declared by the ESI: 3 = DC-Sync0 + SYNC1; 2 = DC-Sync0 only; 0 = not declared / undeterminable
slave.dc_active()u16read-onlyLanded value of 0x0980 (AssignActivate). 0 = DC not enabled; 0x0300 is only a common landed value and not the criterion for "armed" — whether armed is reported by dc().dc_sync0_armed() (underlying tri-state), and whether synchronized by dc().dc_sync_window().in_sync()
DC timeslave.dc_cycle0()i32read-onlyCurrent SYNC0 cycle (nanoseconds)
slave.dc_cycle1()i32read-onlyCurrent SYNC1 cycle (nanoseconds)
slave.dc_shift()i32read-onlyCurrent phase shift (nanoseconds)
slave.dc().propagation_delay()i32read-onlyPropagation delay of a frame from the master to this slave (nanoseconds)
DC topologyslave.dc_next() / dc_previous()u16read-onlyIndex of the next / previous slave in the DC chain
slave.dc_parent_port()i32read-onlyCompatibility entry for parent_port(): 0..3 = parent port, -1 = unknown or invalid parameter
slave.dc_receive_time_a/b/c/d()i32read-onlyReceive time per port (nanoseconds)
has_dc vs has_esi_dc_sync

has_dc() reflects only the ESC hardware bit and does not mean the application layer uses DC. Some slaves report DC capable in the ESC but their ESI does not declare a DC OpMode; in that case run FreeRun / SM-Sync, because forcing DC makes the slave refuse to enter OP.

has_dc() returns Option<bool>: Some(true) = explicitly supported, Some(false) = explicitly unsupported, None = the slave structure cannot be read (master not created / invalid slave index) — do not treat None as "no DC" when judging capability.

A safe pattern before enabling DC:

if slave.has_dc() == Some(true) && slave.dc().has_esi_dc_sync() {
slave.dc().configure(1_000_000, 0, None)?;
}
FreeRun is not DC synchronization

DcSyncMode::FreeRun can be queried, but it is the slave's local clock: it is not DC enabled and not synchronized. DC synchronization = SYNC0 (0x1C32/0x1C33 = 2) plus dc().dc_sync0_armed() == Some(true) (armed); whether the clocks across the whole network have converged is reported by dc().dc_sync_window().in_sync(). The dc_active() in 0x0300 is only a common landed value, not a criterion. in_sync is always false under FreeRun.

DC synchronization types declared by the ESI​

has_dc() answers only "does the ESC hardware support DC"; esi_dc_sync_mode() answers "which DC synchronization tier the vendor requires for this slave in the ESI". The tier decides whether SYNC1 can be enabled:

ValueMeaningTypical ESI
3ESI declares DC-Sync0 + SYNC1: AssignActivate contains the SYNC1 enable bit 0x0400 (e.g. #x700)Beckhoff EL7411
2ESI declares DC-Sync0 only: AssignActivate is non-zero but does not contain 0x0400 (e.g. #x300)EL7041 / Ezi-SERVO2
0ESI does not declare DC, or it is undeterminable (ESI not bound / cannot be read)EK1100 / EK1110 / EL6022 / GCAN-8200

There is only one rule: DC-Sync01 can be requested only when the value is 3; with 2 only DC-Sync0 is possible. Treating 2 as 3 (forcing SYNC1) makes a slave that declares only Sync0 refuse to enter OP, and it does not necessarily report an AL status code.

ESI-declared value ≠ landed value: slave.dc().esi_dc_assign_activate() returns a three-state EsiDeclaredValue { state, value }. With state = Declared, value is the raw 16-bit SYNC0 <Dc><OpMode><AssignActivate> declared in the ESI AssignActivate (Declared is a legitimate declared value under 0); state = NotDeclared means the ESI does not declare it (take the fallback); state = Unreadable means unbound / bad argument / cannot be read — the last two are not the same thing, do not collapse them. It is not the landed value written into the slave's 0x0980 — read slave.dc_active() (or slave.dc().dc_assign_activate()) for that.

How the three entry points divide the work:

  • dc_sync_mode_from_esi() — the raw underlying value, keeping negative values such as -1 (the ESI declares no <Dc>) / -2 (no ESI bound), for callers that need to distinguish "explicitly no DC" from "cannot be read";
  • esi_dc_sync_mode() — the normalized public view: >= 2 is returned as is (2 / 3), while 0 / 1 and negative values all yield 0. Normalization happens only here; upper layers must not parse the raw value themselves;
  • has_esi_dc_sync() — a Boolean capability judgment; when >= 0 it is equivalent to >= 2; when the underlying call returns -2 (not bound) it degrades conservatively to has_dc() (when the hardware bit also cannot be read, it is treated as "unsupported" — this function returns an availability conclusion, not a raw reading).

Use esi_dc_sync_mode() when you need to know exactly "which tier the ESI declares"; use has_esi_dc_sync() when you need "do not wrongly turn DC off while unbound".

Example:

let dc = slave.dc();
let mode = dc.esi_dc_sync_mode();

if slave.has_dc() == Some(true) && dc.has_esi_dc_sync() {
if mode == 3 {
dc.configure_mode(DcSyncMode::DcSynchron01, 1_000_000, 1_000_000, None)?; // SYNC0 + SYNC1
} else {
dc.configure_mode(DcSyncMode::DcSynchron, 1_000_000, 0, None)?; // SYNC0 only
}
}

Configuration methods​

dc().configure()​

pub fn configure(&self, sync0_ns: u32, sync1_ns: u32, shift_ns: Option<i32>) -> Result<()>

Configures DC synchronization for the slave. All parameter units are nanoseconds (ns).

Parameters:

  • sync0_ns (u32) — SYNC0 cycle (nanoseconds); 0 means disarm SYNC0 (back to FreeRun)
  • sync1_ns (u32) — SYNC1 increment time (nanoseconds); 0 means SYNC0 only
  • shift_ns (Option<i32>) — phase shift (nanoseconds): None = phase not specified, resolved by the single underlying source (ESI explicit → user explicit → default 70%); Some(0) and negative values are both user-explicit phases and are sent as is (Some(0) is the literal 0 phase and does not fall back to 70%)

Example:

slave.dc().configure(1_000_000, 0, None)?;              // SYNC0 = 1ms, phase uses default resolution
slave.dc().configure(1_000_000, 0, Some(0))?; // SYNC0 = 1ms, phase 0 ns
Phase default and FreeRun
  • Only None triggers resolution by precedence: ESI ShiftTimeSync0 not 0 → user explicit → default 「1 cycle + 70%」 sync0_ns * 70 / 100 (1 ms → 700 µs).
  • The phase is only a phase shift and is not combined with software propagation delay compensation; the propagation delay is corrected by the ESC in hardware according to 0x0928.
  • Some(0) is the literal 0 phase, not "unspecified", and does not fall back to 70%; pass None for the default 70% (underlying sentinel DC_SHIFT_UNSPECIFIED = i32::MIN).
  • sync0_ns = 0 means disarm SYNC0 (FreeRun), not a 「0 ns cycle」. Slaves with PDOs write 0x1C32:01 / 0x1C33:01 back to 0 to clear leftovers from the previous session (otherwise the transition to SafeOp may report AL=0x002D); when SM2/SM3 are not mapped, the write is postponed until mapping completes.
  • On hot-plug recovery the SDK re-arms the DC start point and activates SYNC0 automatically (the start point is based on the re-read slave DC time). The phase comes from the same source as the first time (the same resolution result, phase only) and does not jump on re-arming; if the reference clock fails, it is reselected immediately.

dc().configure_mode()​

pub fn configure_mode(&self, mode: DcSyncMode, sync0_ns: u32, sync1_ns: u32, shift_ns: Option<i32>) -> Result<bool>

Configures DC according to the synchronization mode (ETG.1020). Returns Ok(true) = this configuration took effect; Ok(false) = the underlying layer did not land it (the caller may report this truthfully and must not treat it as success); Err = the call failed.

Parameters:

  • mode (DcSyncMode) — DC synchronization mode
  • sync0_ns (u32) — SYNC0 cycle (nanoseconds), used only in DcSynchron mode
  • sync1_ns (u32) — SYNC1 cycle (nanoseconds), used only in DcSynchron mode
  • shift_ns (Option<i32>) — phase shift (nanoseconds), used only in DcSynchron mode; None = unspecified (resolved by precedence), Some(0) and negative values take effect as is

Related structures:

#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DcSyncMode {
FreeRun = 0, // free run (local clock, not DC synchronization)
SmSynchron = 1, // SM synchronization - triggered by SM events
DcSynchron = 2, // DC synchronization - SYNC0 only
DcSynchron01 = 3, // DC synchronization - SYNC0 + SYNC1
}

Example:

slave.dc().configure_mode(DcSyncMode::DcSynchron, 1_000_000, 0, None)?;  // DC SYNC0 = 1ms
slave.dc().configure_mode(DcSyncMode::SmSynchron, 0, 0, None)?; // SM synchronization mode
slave.dc().configure_mode(DcSyncMode::FreeRun, 0, 0, None)?; // free run

dc().current_dc_sync_mode()​

pub fn current_dc_sync_mode(&self) -> Option<DcSyncMode>

Gets the current synchronization mode; returns None when it cannot be read (FreeRun is not invented). FreeRun / SmSynchron can be queried, but they are not DC synchronization. DC synchronization is only DcSynchron / DcSynchron01 and requires 0x1C32/0x1C33 = 2 and dc().dc_sync0_armed() == Some(true); whether the whole network has converged is reported by dc().dc_sync_window().in_sync(). dc_active() == 0x0300 is not a criterion (0x0300 is only a common landed value).

Example:

let mode = slave.dc().current_dc_sync_mode();
println!("当前 DC 同步模式: {:?}", mode); // Current DC sync mode: {:?}

dc().disable()​

pub fn disable(&self)

Disables DC synchronization for this slave.

slave.set_dc_sync()​

pub fn set_dc_sync(&self, sync0_ns: u32, sync1_ns: u32, shift_ns: i32)

The raw DC configuration entry on the slave handle: all parameters are integers, it returns nothing, and it does not report whether the settings were actually landed. The call registers a "user-explicit configuration" intent — later automatic arming does not override it.

Parameters:

  • sync0_ns (u32) — SYNC0 cycle (nanoseconds); 0 = disarm SYNC0 (back to FreeRun)
  • sync1_ns (u32) — SYNC1 increment time (nanoseconds); 0 = SYNC0 only
  • shift_ns (i32) — phase shift (nanoseconds), tri-state: DC_SHIFT_UNSPECIFIED (i32::MIN) = not specified, resolved by the single underlying source (ESI explicit → user explicit → default 70%); 0 = the literal 0 phase; a negative value = an explicit negative phase. The latter two are sent as is

Returns: nothing. The hardware is really rewritten only in the writable configuration phase (in practice every slave is in INIT / PreOp); a call made at runtime registers the intent but does not send it, and no error signal is available. For a landed conclusion use dc().configure_mode() (Ok(false) = not landed) or slave.arm_sync_auto(); to check afterwards use dc().dc_sync0_armed().

How it relates to dc().configure()

Both send the same action: configure() takes the phase as Option<i32> (None means not specified) and is the more commonly used entry; set_dc_sync() is the raw integer form, in which the caller expresses the phase tri-state itself.

slave.arm_sync_auto()​

pub fn arm_sync_auto(&self, sync0_ns: u32, sync1_ns: u32, shift_ns: i32) -> SyncArmOutcome

Arms SYNC0 automatically according to the slave's intent. This entry does not register a "user-explicit configuration" intent — it is meant for flows such as automatic startup and hot-plug recovery that "arm once more according to the current capability", and it does not override an existing user intent record; conversely, a slave that already has an "explicit FreeRun" intent on record is not forcibly armed by it.

Parameters:

  • sync0_ns (u32) — SYNC0 cycle (nanoseconds); 0 = disarm (this direction is not subject to the contract gate)
  • sync1_ns (u32) — SYNC1 cycle (nanoseconds); 0 = SYNC0 only
  • shift_ns (i32) — phase (nanoseconds), with the same tri-state semantics as set_dc_sync()

Returns: SyncArmOutcome (not a Result); a failure is likewise reported truthfully through the enum:

pub enum SyncArmOutcome {
Armed, // Arming dispatched; if the hardware is already armed the same way, return this tier directly (do not stop / write / activate again)
MasterUnavailable, // The master has no usable context (not open / closing) or the station number is out of range; the intent is unchanged
WriteDeferred, // Not currently in a writable configuration phase (some station has reached SafeOp / OP, or the state cannot be read); nothing was sent this time
DcDisabled, // The configuration contract marks DC as disabled, so automatic sources are refused (explicit user configuration paths are allowed)
ExplicitFreeRun, // This station has recorded an "explicit FreeRun" intent; an automatic source must not override it
Unrecognized(i32), // Unclassified return code
}

impl SyncArmOutcome {
pub fn is_armed(self) -> bool; // true only when Armed
}

Timing preconditions:

  • A usable master instance must exist and the slave index must be within the current slave range; otherwise MasterUnavailable.
  • Arming (sync0_ns > 0) is really sent only in the writable configuration phase (in practice every slave is in INIT / PreOp); when it is blocked at runtime (a slave has reached SafeOp / OP, or the state cannot be read) it returns WriteDeferred: nothing is sent and no intent is registered this time.
  • Disarming (sync0_ns == 0) is not bound by the DC contract or a FreeRun intent — recalling a leftover arming is exactly its intended action.

Example:

let outcome = slave.arm_sync_auto(1_000_000, 0, i32::MIN);   // Phase not specified
if outcome.is_armed() {
println!("SYNC0 已武装"); // SYNC0 armed
} else {
println!("未武装: {:?}", outcome); // Unarmed: {:?}
}

Sync window diagnostics​

dc().sync_window_status()​

pub fn sync_window_status(&self) -> Option<SyncWindowStatus>

Gets the detailed status of the slave DC synchronization window. Returns None when DC is unsupported or the read fails.

Returns:

  • Option<SyncWindowStatus> — sync window status

Related structures:

pub struct SyncWindowStatus {
pub diff_ns: i32, // current time difference (nanoseconds)
pub max_diff_ns: i32, // maximum time difference (nanoseconds)
pub min_diff_ns: i32, // minimum time difference (nanoseconds)
pub in_sync: bool, // whether inside the DC SYNC0 synchronization window. Always false under FreeRun; must not be taken as synchronized
pub out_of_sync_count: u32, // number of times outside the synchronization window
}
Properties

If you only need in_sync or sync_time_difference, access them through slave.diagnostics().dc(). is_in_sync() returns Some(true) for "reference clock and SYNC0 armed" (0x092C is by definition N/A for the reference clock itself, and the underlying layer no longer synthesizes an in-sync value; it only means the slave can be treated as synchronized, not that measured convergence was observed). sync_window_status() suits scenarios that need the full statistics.

dc().reset_sync_window_stats()​

pub fn reset_sync_window_stats(&self)

Resets the sync window statistics of this slave (max/min time difference, number of times outside the sync window, and so on).

DC diagnostics (per slave)​

The per-slave DC diagnostics surface is entirely read-only and reads the diagnostic data already held locally (slave structure / sync window status); it sends no bus frames and may be called from the UI thread or a background thread. When unavailable it always reports None / Unknown with a reason and never substitutes 0 / false.

Method table​

CategoryMethodReturn typeRead/writeDescription
DC capabilitydc().dc_capability()DcCapabilityread-onlyCapability tier: Unknown / None / FreeRunOnly / Sync0 / Sync0AndSync1. Unknown = undeterminable, not "no capability"
DC diagnosticsdc().dc_arm_outcome()Option<DcArmResult>read-onlyAlways None: the arming outcome is accounted by the SDK, and this language has no equivalent read entry point; see DC_ARM_OUTCOME_UNAVAILABLE_REASON for the reason. None is not the same as DcArmResult::Unknown
DC diagnosticsdc().dc_assign_activate()Option<u16>read-onlyLanded value of 0x0980. None = no DC / cannot be read; Some(0) = DC capable but currently inactive (FreeRun)
DC diagnosticsdc().dc_sync0_cycle_ns()Option<i32>read-onlyLanded value of 0x09A0. Some(0) = cycle not landed by the underlying layer (not armed / FreeRun), not a 「0 ns cycle」
DC diagnosticsdc().dc_sync1_cycle_ns()Option<i32>read-onlyLanded value of 0x09A4, same semantics as above
DC diagnosticsdc().dc_shift_ns()Option<i32>read-onlyCurrent landed DC phase shift (nanoseconds). None = no DC capability / cannot be read; Some(0) = 0 phase landed. Reads the post-write read-back mirror and sends no bus frame
DC diagnosticsdc().dc_propagation_delay_ns()Option<i32>read-onlyLanded value of 0x0928 (ns). None = no DC / cannot be read / raw value negative
DC diagnosticsdc().dc_propagation_delay_source()DcPropagationDelayOriginread-onlyPropagation delay source tier: Unknown / ZeroNsAmbiguous / NonZeroLandedBaseline. The underlying layer does not distinguish the 0 ns ambiguity (domain root / not measured), so it reports ZeroNsAmbiguous
DC diagnosticsdc().dc_sync_window()DcSyncWindowInforead-onlyMeasured sync window surface; when unavailable, applicable() == false and all numeric fields are None
DC diagnosticsdc().dc_sync0_armed()Option<bool>read-onlySYNC0 arming tri-state: Some(true) committed to generate SYNC0; Some(false) not armed with evidence; None = the underlying layer cannot answer
DC diagnosticsdc().dc_convergence_ms()Option<i32>read-onlyConvergence time (ms) from the 2 s snapshot. None = no complete transition observed / not sampled yet
DC diagnosticsdc().dc_jitter()Option<DcJitterStats>read-onlySteady-state quality (σ / peak-to-peak / largest adjacent change) from the 2 s snapshot; None when there are fewer than 2 samples

DcSyncWindowInfo fields:

CategoryMethodReturnRead/writeDescription
DC diagnosticsapplicable()boolread-onlyWhether this sample has usable measurements (when false, see not_applicable_reason())
DC diagnosticsnot_applicable_reason()DcSyncWindowNaReasonread-onlyReason for unavailability, see the table below; DcSyncWindowNaReason::None when available
DC diagnosticsdiff_ns()Option<i32>read-onlyCurrent synchronization difference (ns)
DC diagnosticsmax_diff_ns()Option<i32>read-onlyMaximum difference within the window (ns)
DC diagnosticsmin_diff_ns()Option<i32>read-onlyMinimum difference within the window (ns)
DC diagnosticsout_of_sync_count()Option<u32>read-onlyCumulative number of times outside the window
DC diagnosticsin_sync()Option<bool>read-onlyWhether this sample is inside the sync window (the AND of the underlying measurement and armed)
DC diagnosticssync_window_threshold_ns()Option<i32>read-onlyWindow threshold (ns); None = cannot be read
DC diagnosticsreading_unchanged()Option<bool>read-onlyWhether the four 0x092C readings stayed completely unchanged for several consecutive samples (frozen-proxy bit). false does not mean "confirmed to be advancing"
DC diagnosticsunchanged_streak()i32read-onlyNumber of consecutive samples with identical readings
DC diagnosticssampled_at_utc()Option<SystemTime>read-onlySampling time of this sample (UTC)

Seven states​

The seven states describe only "decidable synchronization window states"; the read-failure family and "armed but outside the window" are not among them.

CategoryStateRead/writeRust expressionMeaning
DC diagnosticsNo capabilityread-onlynot_applicable_reason() == NoDcCapabilityNo SYNC0 cycle unit, so synchronization error does not exist
DC diagnosticsNot armedread-onlynot_applicable_reason() == Sync0NotArmedKnown not to participate in DC synchronization, so 0x092C is undefined
DC diagnosticsReference clock itselfread-onlynot_applicable_reason() == ReferenceClockItselfSynchronization error does not exist by definition
DC diagnosticsArmed but readings frozenread-onlyapplicable() == true and reading_unchanged() == Some(true)The four readings stayed completely unchanged for several consecutive samples
DC diagnosticsTruly in the windowread-onlyapplicable() == true and in_sync() == Some(true)Armed and measured inside the window
DC diagnosticsArming unknownread-onlynot_applicable_reason() == ArmedUnknownThe underlying layer cannot answer, so participation cannot be asserted either way
DC diagnosticsNever sampledread-onlynot_applicable_reason() == NotSampledAll four are 0 and in_sync == false; 0 is not "perfect synchronization"

Read-failure family (also in not_applicable_reason(), not part of the seven states):

CategoryReasonRead/writeMeaning
DC diagnosticsSlaveReadFailedread-onlyThe slave snapshot cannot be read, so even the capability cannot be determined
DC diagnosticsWindowReadFailedread-onlyArmed and not the reference clock, but the measured window read failed
DC diagnosticsReferenceClockUnknownread-onlyThe reference clock slave index cannot be read. The Rust side never produces this tier: the underlying interface that fetches the reference clock has no failure channel (0 also means "no reference clock"), so the enum is kept only for semantic alignment with the other languages

Armed but outside the window = applicable() == true and in_sync() == Some(false) (not frozen). It belongs to none of the seven states, and the caller must read it truthfully as "outside the window", never as "not armed" or "unknown".

Three honest tri-states​

CategoryConclusionRead/writeRust expressionWhen there is no conclusion
DC diagnosticsWhether all are in the windowread-onlymaster.diagnostics_info().dc_diagnostics().all_in_syncNo confirmed participant (no DC / all unarmed / only the reference clock) → None, not true
DC diagnosticsMaximum synchronization differenceread-onlymaster.diagnostics_info().dc_diagnostics().max_drift_nsNo usable window → None, not 0
DC diagnosticsSYNC0 armedread-onlydc().dc_sync0_armed()The underlying layer cannot answer → None, not false

"Not applicable" is never written as 0: the sync window of the reference clock itself is always N/A, and not armed / no DC / never sampled likewise never produce 0 ns.

Arming outcome unavailable

dc_arm_outcome() and the snapshot field arm_outcome are always None in this language, meaning "this SDK does not provide that conclusion", not DcArmResult::Unknown (the latter means "there is accounting, but this sample has no record for that slave"). Do not write it as "not armed yet" or "not participating".

Reference clock and time base​

  • Reference clock: the master selects the first slave on the link, in chain order, that is DC active (real SYNC0); when there is no armed slave at all, it falls back to the first DC-capable slave in the chain. The whole bus has only this one time base.
  • Single start point: the reference domain has one start instant (the same physical moment), which the master converts into the time domain of each slave and writes into 0x0990; each slave does not measure its own start point.
  • Reference clock change (slave loss / hot-plug / capability change): every 0x0920 written in the time domain of the old clock becomes invalid. In chain order, the master re-reads 0x0920 for each DC slave that is not in OP, not lost, and not the reference clock itself, proves it by reading back, and then rewrites that slave's 0x0990 in the new time domain; slaves in OP are not interrupted in their SYNC0 and have the error corrected by online compensation.
  • Phase only: 0x0928 is corrected in hardware by the ESC when generating SYNC0; shift_ns is only a phase shift and contains no propagation delay compensation.
  • Diagnostics: the current SDK does not expose read-only properties for 0x0990 / 0x0920; register-level evidence is in the DC diagnostic log lines of events.log.

Complete example​

let slave = master.slave(1);

if slave.has_dc() == Some(true) {
let dc = slave.dc();
dc.configure(1_000_000, 0, None)?; // SYNC0 = 1ms, automatic offset

println!("DCActive={}, DCCycle0={}ns, DCShift={}ns",
slave.dc_active(), slave.dc_cycle0(), slave.dc_shift());

// detailed sync window status
if let Some(status) = dc.sync_window_status() {
println!("同步差={}ns, 同步={}", status.diff_ns, status.in_sync); // Sync diff={}ns, in sync={}
}

dc.disable();
}