DC synchronization
Slave-level Distributed Clocks (DC) configuration. DC properties are accessed directly through slave.*; DC configuration methods are operated through the DcConfig class.
In most scenarios, use master.configure_dc() to configure all DC slaves in one call.
The slave-level methods are for scenarios where individual slaves need different parameters.
Read-only properties
| Category | Property | Type | Read/write | Description |
|---|---|---|---|---|
| DC state | has_dc | Optional[bool] | read-only | Whether DC is supported (ESC hardware bit): True / False are definite conclusions; returns None (unknown) when the read fails |
| DC state | dc_config.has_esi_dc_sync | bool | read-only | Whether the ESI declares DC synchronization for this slave (falls back conservatively to has_dc when the ESI is not bound) |
| DC state | dc_config.esi_dc_sync_mode | int | read-only | DC synchronization tier declared by the ESI: 3 = DC-Sync0 + SYNC1; 2 = DC-Sync0 only; 0 = not declared / undeterminable |
| DC state | dc_config.current_dc_sync_mode | Optional<DcSyncMode> | read-only | Currently landed DC synchronization type (FreeRun / SmSynchron are not DC synchronization); returns None when the read fails |
| dc_active | int | read-only | Current landed value of DC AssignActivate. 0 = not enabled; non-0 = DC-active. 0x0980 in 0x0300 is only a common landed value, not the criterion for "SYNC0 activated" — whether it is armed is determined by dc_config.sync0_armed (an underlying tri-state), and whether it is synchronized by dc_config.sync_window.in_sync | |
| DC time | dc_cycle0 | int | read-only | Current SYNC0 cycle (nanoseconds) |
| dc_cycle1 | int | read-only | Current SYNC1 cycle (nanoseconds) | |
| dc_shift | int | read-only | Current phase shift (nanoseconds) | |
| propagation_delay | int | read-only | Propagation delay of a frame from the master to this slave (nanoseconds) | |
| DC topology | dc_next / dc_previous | int | read-only | Index of the next / previous slave in the DC chain |
| dc_receive_time_a/b/c/d | int | read-only | Receive time per port (nanoseconds) | |
| dc_parent_port | int | read-only | Compatibility entry point for parent_port: 0..3 = the parent port, -1 = unknown or invalid parameter |
DcConfig.dc_sync_mode_from_esi()
def dc_sync_mode_from_esi(self) -> int
Queries the raw underlying value of the DC synchronization mode declared by the ESI, preserving negative-value semantics:
| Value | Meaning |
|---|---|
3 | Declares DC-Sync0 + SYNC1 (AssignActivate contains the SYNC1 enable bit 0x0400, e.g. #x700) |
2 | Declares DC-Sync0 only (AssignActivate is something like #x300, without 0x0400) |
1 | SM-Sync |
0 | The ESI has <Dc> but declares FreeRun only |
-1 | The ESI does not declare <Dc> |
-2 | Invalid parameter / the slave has no bound ESI |
Use this method when you need to distinguish "the ESI explicitly does not use DC" from "the ESI is not bound at all"; for outward decisions use esi_dc_sync_mode uniformly.
DcConfig.esi_dc_sync_mode
@property
def esi_dc_sync_mode(self) -> int
The DC synchronization tier the ESI declares for this slave (the normalized outward value, equivalent to C# Slave.EsiDcSyncMode), used by upper layers to decide "whether SYNC1 can be enabled":
| Value | Meaning | Typical ESI |
|---|---|---|
3 | ESI declares DC-Sync0 + SYNC1: AssignActivate contains the SYNC1 enable bit 0x0400 (e.g. #x700) | Beckhoff EL7411 |
2 | ESI declares DC-Sync0 only: AssignActivate is non-zero but does not contain 0x0400 (e.g. #x300) | EL7041 / Ezi-SERVO2 |
0 | ESI does not declare DC, or it cannot be determined (ESI not bound / unreadable) | 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: dc_config.esi_dc_assign_activate returns the three-state EsiDeclareU16 (DECLARED / NOT_DECLARED / UNREADABLE, never collapsed) carrying the raw 16-bit SYNC0 <Dc><OpMode><AssignActivate> declared in the ESI AssignActivate. It is not the landed value written into the slave's 0x0980 — read dc_active (or dc_config.assign_activate) for that.
Relationship with has_esi_dc_sync: on the four branches 0 / 1 / 2 / 3 both agree (has_esi_dc_sync is esi_dc_sync_mode >= 2); the only difference is that when the underlying layer returns -2 (ESI not bound), has_esi_dc_sync falls back conservatively to has_dc, while esi_dc_sync_mode reports "undeterminable" truthfully as 0. Use the former when you must "not switch DC off by mistake while unbound"; use the latter when you need to know exactly which tier the ESI declared.
Example:
from darra_ethercat.slave.dc import DcSyncMode
slave = master[1]
dc = slave.dc_config
mode = dc.esi_dc_sync_mode
if slave.has_dc and dc.has_esi_dc_sync:
if mode == 3:
dc.configure_mode(DcSyncMode.DcSynchron01, 1_000_000, 1_000_000) # SYNC0 + SYNC1
else:
dc.configure_mode(DcSyncMode.DcSynchron, 1_000_000) # SYNC0 only
DcConfig.has_esi_dc_sync
@property
def has_esi_dc_sync(self) -> bool # DcConfig property
Whether the ESI file declares DC synchronization for this slave. slave.has_dc reflects only the ESC hardware bit and does not mean the application layer enables DC. Before enabling DC, check slave.has_dc and slave.dc_config.has_esi_dc_sync together; this filters out slaves whose ESC reports capable but whose ESI does not declare a DC OpMode (such as the GCAN-8200) and avoids forcing DCCUC, which makes the slave hang.
When the ESI is not loaded it falls back conservatively to has_dc.
has_dc is tri-stateslave.has_dc returns None (unknown) when the read fails and is never folded into False. if slave.has_dc: treats unknown as "no DC" and skips configuration; when you need to tell them apart, test is True / is False / is None explicitly. DcConfig.has_dc has the same semantics and the same tri-state as Slave.has_dc.
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) and armed: whether it is armed is determined by dc_config.sync0_armed (an underlying tri-state; None means undeterminable), and whether it is synchronized by dc_config.sync_window.in_sync. dc_active == 0x0300 is not the criterion — 0x0300 is only a common landed value of 0x0980. in_sync is always False under FreeRun.
Example:
slave = master[1]
if slave.has_dc and slave.dc_config.has_esi_dc_sync:
master.configure_dc(1_000_000)
else:
print(f"从站 {slave.slave_num} 跳过 DC 配置") # Slave {slave.slave_num} skips DC configuration
Configuration methods
DcConfig.configure()
def configure(sync0_cycle_ns: int, sync1_cycle_ns: int = 0,
shift_ns: Optional[int] = None) -> bool
Configures slave DC synchronization. All parameter units are nanoseconds (ns).
Parameters:
sync0_cycle_ns(int) — SYNC0 cycle (nanoseconds); 0 means disarm SYNC0 (back to FreeRun)sync1_cycle_ns(int) — SYNC1 increment time (nanoseconds); 0 means SYNC0 onlyshift_ns(Optional[int]) — phase shift (nanoseconds):None= no phase specified, resolved by the SDK in order of precedence (the ESIShiftTimeSync0declaration → 70% by default); an integer (including0and negative values) = an explicit user phase, sent as-is (0is the literal 0 phase, with no fallback to 70%)
Returns:
bool— whether the parameters were sent (Truedoes not mean the hardware is locked; for the real synchronization state checksync_window_status/in_sync)
Example:
# obtained through the public slave.dc_config accessor
dc = master[1].dc_config
dc.configure(1_000_000) # SYNC0 = 1ms, phase resolved by default
dc.configure(1_000_000, 500_000) # SYNC0 = 1ms, SYNC1 = 500 µs
- Precedence resolution happens only when
shift_ns=None: an ESIShiftTimeSync0that is not 0 → otherwise the default 70% of 1 cycle,sync0_cycle_ns * 70 // 100(1 ms → 700 µs). - The phase is a phase shift only and does not add software propagation delay compensation; the propagation delay is corrected by the ESC hardware.
shift_ns=0is the literal 0 phase, not "unspecified", and does not fall back to 70%; passNoneif you want the default 70%.sync0_cycle_ns=0disarms SYNC0 (FreeRun), it is not a 0 ns cycle. A slave with PDO writes0x1C32:01/0x1C33:01back to 0, clearing residue from the previous session (otherwise it may block SafeOp, AL=0x002D); when SM2/SM3 are not mapped the write is deferred until after mapping.- On hot-plug recovery the SDK re-arms the DC start point and activates SYNC0 automatically (the start point is based on the newly read slave DC time). The phase keeps the first resolution result (phase only) and does not jump on re-arming; if the reference clock fails a new one is selected immediately.
DcConfig.configure_mode()
dc.configure_mode(mode: DcSyncMode, sync0_cycle_ns: int = 0,
sync1_cycle_ns: int = 0, shift_ns: Optional[int] = None) -> bool
Configures DC by synchronization mode.
Parameters:
mode(DcSyncMode) — DC synchronization modesync0_cycle_ns(int) — SYNC0 cycle (nanoseconds)sync1_cycle_ns(int) — SYNC1 increment time (nanoseconds,DcSynchron01mode only)shift_ns(Optional[int]) — phase shift (nanoseconds);None= unspecified (resolved by precedence), an integer (including0and negative values) takes effect as-is
Returns:
bool— the SYNC0/1 parameters were sent successfully and the SM synchronization type (0x1C32/0x1C33) was configured successfully; returningFalsefor a slave that does not support the synchronization type object dictionary is normal
Related structures:
class DcSyncMode(IntEnum):
FreeRun = 0 # free run (local clock, not DC synchronization)
SmSynchron = 1 # SM event synchronization
DcSynchron = 2 # DC synchronization, SYNC0 signal only
DcSynchron01 = 3 # DC synchronization, SYNC0 + SYNC1 signals
DcSyncMode is defined only in darra_ethercat.slave.dc, with four values (FreeRun / SmSynchron / DcSynchron / DcSynchron01); from darra_ethercat import DcSyncMode at the top level gives the same class, and no second copy exists.
Example:
from darra_ethercat.slave.dc import DcSyncMode
dc.configure_mode(DcSyncMode.DcSynchron, 1_000_000) # SYNC0 = 1ms
dc.configure_mode(DcSyncMode.DcSynchron01, 1_000_000, 500_000) # SYNC0 + SYNC1
dc.configure_mode(DcSyncMode.FreeRun) # disable DC
DcConfig.disable()
dc.disable() -> bool
Disables DC synchronization for this slave (back to FreeRun). True means the disable request was sent.
Slave.set_sync()
def set_sync(self, sync0_ns: int, sync1_ns: int = 0,
shift_ns: Optional[int] = None)
Sends the DC synchronization parameters directly, slave by slave (slave.set_sync(...)). It sends the same parameter set as DcConfig.configure(); this method returns no result, because the underlying layer only registers the intent to send and does not report success or failure.
Parameters:
sync0_ns(int) — SYNC0 cycle (nanoseconds);0= disarm SYNC0 (back to FreeRun)sync1_ns(int) — SYNC1 cycle (nanoseconds);0= disable SYNC1, default0shift_ns(Optional[int]) — DC phase (nanoseconds), defaultNone:None= unspecified; the underlying layer resolves it with the pure-phase precedence of the ESI declaration → 70% default, without adding software propagation compensation0= literal 0 phase, sent as it is- a negative value = an explicit negative phase, sent as it is
- any value other than
Noneis not overridden by the 70% default
The call only means the parameters have been registered. To check whether the hardware is armed and inside the synchronization window, read slave.dc_config.sync0_armed and slave.dc_config.sync_window.in_sync (or slave.sync_window_status).
Example:
slave = master[1]
slave.set_sync(1_000_000) # SYNC0 = 1 ms, phase resolved to the default
slave.set_sync(1_000_000, 500_000, 0) # SYNC0 = 1 ms, SYNC1 = 500 µs, literal 0 phase
slave.set_sync(0) # disarm SYNC0 (back to FreeRun)
Synchronization window diagnostics
slave.sync_window_status
@property
def sync_window_status(self) -> Optional[dict]
Gets the detailed status of the slave DC synchronization window. Returns None when DC is not supported or the read fails.
Returns:
Optional[dict]— synchronization window status dictionary
{
'diff_ns': int, # current time difference (nanoseconds)
'max_diff_ns': int, # maximum time difference (nanoseconds)
'min_diff_ns': int, # minimum time difference (nanoseconds)
'in_sync': int, # raw underlying synchronization flag (0/1). May report a false positive under FreeRun / unarmed SYNC0; use dc_config.get_sync_window_status() for the real synchronization verdict
'out_of_sync_count': int, # number of times the synchronization window was exceeded
}
If you only need is_in_sync or sync_time_difference, use slave.diagnostics.dc (returns Optional; None when there is no DC or the read fails). is_in_sync returns True for "reference clock and SYNC0 armed" (0x092C is N/A by definition for the reference clock itself, so the underlying layer no longer synthesizes an in-sync value; it only means the slave can be treated as synchronized, not that convergence was measured).
DcConfig.get_sync_window_status()
dc.get_sync_window_status() -> Optional[SyncWindowStatus]
Gets the synchronization window status through DcConfig and returns a SyncWindowStatus object. Returns None when the read fails. The returned in_sync already folds in the SYNC0 arming conclusion: it is decided by the underlying tri-state, and when arming is unknown the whole window is unusable (returns None) and is never folded into False. Under FreeRun (known unarmed) it is always False and never reports "synchronized" by mistake.
SyncWindowStatus is an ordinary property container class (not a @dataclass); its fields are diff_ns / max_diff_ns / min_diff_ns / in_sync / out_of_sync_count.
slave.reset_sync_stats()
def reset_sync_stats(self) -> None
Resets the synchronization window statistics of this slave (maximum/minimum time difference, out-of-sync count and so on).
DcConfig.reset_sync_window_stats()
dc.reset_sync_window_stats() -> None
Resets the synchronization window statistics of this slave from the dc_config side; same effect as slave.reset_sync_stats().
DC diagnostics (per slave)
A set of read-only properties on slave.dc_config, using the same conventions as the 2-second master-level snapshot. All of them read the local cache and send no bus frames, so they can be read directly on the UI thread or a diagnostics thread. Unknown / not applicable is always None or a reason enum; 0 is never used as a substitute.
Properties
| Category | Property | Type | Read/write | Description |
|---|---|---|---|---|
| DC diagnostics | capability | DcCapability | read-only | Capability tier: Unknown / None_ / FreeRunOnly / Sync0 / Sync0AndSync1. Unknown = the slave snapshot is unreadable / the ESI is not bound / not declared, not "no capability" |
| DC diagnostics | assign_activate | Optional[int] | read-only | 0x0980 landed value (a cache mirror already proven by write-then-read-back in the underlying layer). None = no DC capability / unreadable; 0 = DC capable but not currently active (FreeRun) |
| DC diagnostics | sync0_cycle_ns | Optional[int] | read-only | 0x09A0 landed value. None = no DC / unreadable; 0 = no cycle landed in the underlying layer (unarmed / FreeRun), not a "0 ns cycle" |
| DC diagnostics | sync1_cycle_ns | Optional[int] | read-only | 0x09A4 landed value, same semantics as sync0_cycle_ns |
| DC diagnostics | propagation_delay_ns | Optional[int] | read-only | 0x0928 landed value (nanoseconds). None = no DC / unreadable / the underlying value is negative |
| DC diagnostics | propagation_delay_source | DcPropagationDelayOrigin | read-only | Source tier: Unknown / ZeroNsAmbiguous (0 ns is ambiguous: domain root or not measured) / NonZeroLandedBaseline |
| DC diagnostics | sync_window | DcSyncWindowInfo | read-only | Per-slave synchronization window (the 0x092C measured surface plus the applicability envelope), see below |
| DC diagnostics | sync0_armed | Optional[bool] | read-only | Whether SYNC0 is armed: True = the slave has committed to producing SYNC0; False = unarmed with evidence; None = the underlying layer cannot answer, must not be folded into False |
| DC diagnostics | is_reference_clock_self | Optional[bool] | read-only | Whether this slave is the reference clock (tri-state: True yes / False known not / None the slave index could not be read) |
| DC diagnostics | master.dc_diagnostics snapshot find(index).convergence_ms | Optional[int] | read-only | Convergence time (ms): from the first "armed but not yet in window" to the first entry into the window, at the 2-second sampling granularity; None when no complete transition was observed. The per-slave DcConfig property surface does not provide that historical conclusion |
| DC diagnostics | master.dc_diagnostics snapshot find(index).jitter | Optional[DcJitterStats] | read-only | Steady-state jitter (σ / peak-to-peak / maximum adjacent change), 2-second sampling surface; None when there are fewer than 2 samples |
sync0_armed only means "this slave has committed to producing SYNC0"; it does not mean the whole network clock has converged — for convergence check sync_window.in_sync / applicable.
DcSyncWindowInfo
| Category | Field | Type | Read/write | Description |
|---|---|---|---|---|
| DC diagnostics | applicable | bool | read-only | True = this slave participates in SYNC0 and a measurement was read; False = check not_applicable_reason |
| DC diagnostics | not_applicable_reason | DcSyncWindowNaReason | read-only | Enumeration of the not-applicable reason; None_ when applicable |
| DC diagnostics | diff_ns | Optional[int] | read-only | Current synchronization error (ns); None when not applicable |
| DC diagnostics | max_diff_ns | Optional[int] | read-only | Maximum time difference within the window (ns); None when not applicable |
| DC diagnostics | min_diff_ns | Optional[int] | read-only | Minimum time difference within the window (ns); None when not applicable |
| DC diagnostics | out_of_sync_count | Optional[int] | read-only | Total number of times the synchronization window was exceeded; None when not applicable |
| DC diagnostics | in_sync | Optional[bool] | read-only | Whether this sample is inside the synchronization window (measured ∧ SYNC0 armed); None when not applicable |
| DC diagnostics | sync_window_threshold_ns | Optional[int] | read-only | Synchronization window threshold (ns); None = unreadable (distinct from "threshold 0") |
| DC diagnostics | reading_unchanged | Optional[bool] | read-only | Whether the four 0x092C readings have stayed completely unchanged across several consecutive samples (freeze proxy bit); None = not enough samples to conclude. It is always None when this property is read directly (the property carries no history) |
| DC diagnostics | unchanged_streak | int | read-only | Number of consecutive samples with identical readings (the same count as reading_unchanged); 0 when this property is read directly |
| DC diagnostics | sampled_at_utc | Optional[datetime] | read-only | Sampling time of this sample (UTC); None when not applicable |
When applicable=False, the measured numeric fields (diff_ns / max_diff_ns / min_diff_ns / out_of_sync_count / in_sync) and reading_unchanged are always None, never 0; unchanged_streak is a count and is 0 in that case.
Convergence time and steady-state jitter are not on the per-slave property surface: they need consecutive samples and are provided only by the master 2-second sampling surface — read the per-slave snapshot of master.dc_diagnostics (convergence_ms / jitter).
Seven states (decidable synchronization window states)
| Category | State | Python expression | Read/write | Meaning |
|---|---|---|---|---|
| DC diagnostics | No capability | applicable is False, reason DcSyncWindowNaReason.NoDcCapability | read-only | There is no SYNC0 cycle unit, so a synchronization error does not exist |
| DC diagnostics | Unarmed | applicable is False, reason Sync0NotArmed | read-only | Known not to participate in DC synchronization, so the window is undefined |
| DC diagnostics | Reference clock itself | applicable is False, reason ReferenceClockItself | read-only | A synchronization error does not exist by definition |
| DC diagnostics | Armed but readings frozen | applicable is True and reading_unchanged is True | read-only | The four window readings have stayed completely unchanged across several consecutive samples (freeze proxy bit); the conclusion comes from the 2-second sampling surface |
| DC diagnostics | Truly in window | applicable is True and in_sync is True | read-only | Armed and measured inside the synchronization window |
| DC diagnostics | Arming unknown | applicable is False, reason ArmedUnknown | read-only | The underlying layer cannot answer, so participation cannot be asserted either way |
| DC diagnostics | Never sampled | applicable is False, reason NotSampled | read-only | All four items are 0 and it is not in the window; 0 is not "perfect synchronization" |
Determination order: slave snapshot unreadable → no capability → reference clock slave index unreadable → this slave is the reference clock → arming unknown → known unarmed → window read failed → never sampled → measured. When the window is usable (applicable=True), reading_unchanged is True reports "readings frozen" first; otherwise the in_sync value splits "truly in window / armed but out of window".
Read-failure family (not part of the seven states):
| Category | Reason | Meaning | Read/write |
|---|---|---|---|
| DC diagnostics | SlaveReadFailed | The slave snapshot is unreadable, so even the capability cannot be determined | read-only |
| DC diagnostics | ReferenceClockUnknown | The reference clock slave index is unreadable, so it cannot be decided whether this slave is the time base | read-only |
| DC diagnostics | WindowReadFailed | Armed and not the reference clock, but reading the window measurement failed | read-only |
Armed but out of window: applicable is True, in_sync is False (and not frozen). It does not belong to any of the seven states and must be handled as the real conclusion in_sync=False; do not treat it as "unarmed" or "unknown".
Three honest tri-states
| Category | Conclusion | When there is no conclusion | Python expression | Read/write |
|---|---|---|---|---|
| DC diagnostics | Whether all are in window | No confirmed participant → unknown, not True | master.dc_diagnostics.all_in_sync is None | read-only |
| DC diagnostics | Maximum synchronization difference | No usable window → unknown, not 0 | master.dc_diagnostics.max_drift_ns is None | read-only |
| DC diagnostics | SYNC0 arming | The underlying layer cannot answer → unknown, not False | dc_config.sync0_armed is None | read-only |
"Not applicable" is never written as 0: the synchronization window of the reference clock itself is always N/A; unarmed / no DC / never sampled likewise never produce 0 ns.
Example:
slave = master[1]
dc = slave.dc_config
print("能力档:", dc.capability.name) # Capability tier:
print("已武装:", dc.sync0_armed) # True / False / None (undeterminable)
w = dc.sync_window
if not w.applicable:
print("窗口不适用:", w.not_applicable_reason.name) # Window not applicable:
else:
print(f"同步差 {w.diff_ns} ns, 阈值 {w.sync_window_threshold_ns} ns, " # Sync deviation {w.diff_ns} ns, threshold {w.sync_window_threshold_ns} ns,
f"在窗 {w.in_sync}") # In window {w.in_sync}
SYNC0 relative cycle jitter (per slave)
Distribution of the phase offset of SYNC0 pulses relative to the cycle start; servo commissioning uses it to judge how much SYNC0 jitters relative to the cycle. The offset range is [−cycle/2, +cycle/2): in steady state it is nearly constant (the geometric phase determined by the shift passed to configure), and jitter amplitude = sync0_jitter_max_ns − sync0_jitter_min_ns. The window accumulates from the last reset_sync0_jitter_stats() (it is invalidated automatically when the session changes and reopens automatically at the limit); with no samples everything is None, never 0 as a substitute. Samples accumulate per cycle while OP is running; the pre-OP / recovery phases are not mixed in. Each of the four properties is read once, so values across properties may come from different samples.
| Category | Property | Type | Read/write | Description |
|---|---|---|---|---|
| DC diagnostics | dc_config.sync0_jitter_min_ns | Optional<int> | read-only | Minimum phase offset within the window (ns) |
| DC diagnostics | dc_config.sync0_jitter_max_ns | Optional<int> | read-only | Maximum phase offset within the window (ns) |
| DC diagnostics | dc_config.sync0_jitter_avg_ns | Optional<int> | read-only | Average phase offset within the window (integer ns, truncated toward zero) |
| DC diagnostics | dc_config.sync0_jitter_sample_count | Optional<int> | read-only | Number of samples accumulated in the window (the three values above are valid when > 0) |
| Statistics | DcConfig.reset_sync0_jitter_stats() | None | write-only | Clears the statistics of this slave; the next sample opens a new window |
if (dc.sync0_jitter_sample_count or 0) > 0:
lo, hi = dc.sync0_jitter_min_ns, dc.sync0_jitter_max_ns
print(f"SYNC0 相位偏移 {lo}..{hi} ns,抖动 {hi - lo} ns") # SYNC0 phase offset {lo}..{hi} ns, jitter {hi - lo} ns
dc.reset_sync0_jitter_stats()
Complete example
slave = master[1] # 1-based index
if slave.has_dc:
dc = slave.dc_config # public accessor
dc.configure(1_000_000) # SYNC0 = 1ms
print(f"DCActive={slave.dc_active}, DCCycle0={slave.dc_cycle0}ns, DCShift={slave.dc_shift}ns")
# detailed synchronization window status
status = slave.sync_window_status
if status is not None:
print(f"同步差={status['diff_ns']}ns, 同步={status['in_sync']}") # Sync deviation={status['diff_ns']}ns, in sync={status['in_sync']}
dc.disable()
Failures and handling
| Symptom | Cause | Handling |
|---|---|---|
| in_sync is False | The DC mode declared by the ESI does not match the configuration, the reference clock is not armed, or SYNC0 does not match the PDO cycle | Check the DC mode in the ESI and the reference clock; set SYNC0 to the cycle or an integer fraction of it |
| get_sync_window_status returns None | The SYNC0 arming conclusion is unknown (the underlying layer returns -1/-2), or the window read failed | Treat it as unknown, not as synchronized; confirm has_dc / sync0_armed and re-read |
| sync0_jitter_min_ns / max_ns / avg_ns / sample_count is None | No DC, no samples yet, or the read failed | Treat it as unknown; samples accumulate while OP is running, so read again after entering OP |
| configure_mode returns False | This slave does not support DC, or the ESI does not declare that DC mode | Skip this slave and let it run free; check the hardware of that slave and the ESI declaration |
| A synchronization-loss callback is received | The deviation of this slave exceeds the synchronization window threshold | Record the slave index and deviation and check the DC mode and cycle of that slave |
| Readings do not return to zero after reset_sync_stats | The statistics were cleared but the window is still sampling | Re-read the window status and use the new sample as authoritative |