Skip to main content

DC synchronization (slave level)

Slave-level DC (distributed clock) properties and configuration.

Prefer the master-level method

For most scenarios use ConfigureDCAll() to configure all DC slaves in one call. The slave-level methods are for cases where individual slaves need different parameters. Both resolve an unspecified phase with the same precedence order.

Read-only properties​

CategoryFunctionReturn typeRead/writeDescription
DC stateGetSlaveHasDC(mi, si)BOOLRead-onlyWhether the ESC hardware supports DC
DC stateslave_has_esi_dc_sync(mi, si)BOOLRead-onlyWhether the ESI declares DC synchronization for this slave (high-level wrapper in slave/dc.h)
DC stateslave_esi_dc_sync_mode(mi, si)intRead-onlyDC synchronization tier declared by the ESI: 3 = DC-Sync0 + SYNC1; 2 = DC-Sync0 only; 0 = DC not declared / cannot be determined (verbatim raw value, no hardware fallback)
DC stateGetSlaveDCActive(mi, si)uint16_tRead-onlyMirror of the landed 0x0980 AssignActivate value. 0 = DC capable but not currently active (FreeRun); 0x0300 is only a common landed value, not the criterion for "armed" or "in sync" — whether the slave is armed is read from dc_sync0_armed() / C++ Sync0Armed; whether it is in sync is read from dc_get_sync_window_info() and applicable of in_sync
DC timeGetSlaveDCCycle0(mi, si)int32_tRead-onlyCurrent SYNC0 cycle (nanoseconds)
DC timeGetSlaveDCCycle1(mi, si)int32_tRead-onlyCurrent SYNC1 cycle (nanoseconds)
DC timeGetSlaveDCShift(mi, si)int32_tRead-onlyCurrent phase shift (nanoseconds)
DC timeGetDcShiftTruth(mi, si, &shift, &source)int32_tRead-onlyLanded phase shift plus its phase source tier (slave/dc.h). 1 = the output parameters are valid; <= DC_SHIFT_NO_CONCLUSION_MAX = no conclusion. Read-only, sends no frames, readable in OP
DC timeGetSlavePropagationDelay(mi, si)int32_tRead-onlyPropagation delay of a frame from the master to this slave (nanoseconds)
DC topologyGetSlaveDCNext(mi, si) / GetSlaveDCPrevious(mi, si)uint16_tRead-onlyNext / previous slave index in the DC chain
DC topologyGetSlaveDCParentPort(mi, si)int32_tRead-onlyCompatibility entry for GetSlaveParentPort: 0..3 = parent port, -1 = unknown
DC receive timeGetSlaveDCReceiveTimeA/B/C/D(mi, si)int32_tRead-onlyReceive time of each port (nanoseconds)
HasDC vs HasEsiDcSync

GetSlaveHasDC reflects only the ESC hardware bit; it does not mean the application actually uses DC. Some slaves report DC capable in the ESC while the ESI declares no DC OpMode; in that case run FreeRun / SM-Sync, because forcing DC on makes the slave refuse to enter OP.

slave_has_esi_dc_sync() performs a real ESI DC OpMode query (the ESI is handed to the SDK during construction or configuration — esi_dll_load_file() / esi_dll_load_directory() — and is bound when SetStateSequence() establishes the link): it returns true when the ESI declares DC-Sync0/01, and false for FreeRun/SM-Sync or when the ESI has no <Dc> node; while no ESI is bound it falls back to the conservative hardware-bit check of GetSlaveHasDC.

Safe pattern before enabling DC (slave_has_esi_dc_sync is a slave/dc.h high-level wrapper; call it directly):

#include "slave/dc.h"

if (GetSlaveHasDC(master, 1) && slave_has_esi_dc_sync(master, 1)) {
SetSyncBySlaveIndex(master, 1, 1000000, 0, 0);
}
FreeRun is not DC synchronization

DC_FREE_RUN can be queried, but it is the slave's local clock: it does not mean DC is enabled, and it does not mean the slave is in sync. Whether the slave is armed is read from dc_sync0_armed() / C++ Sync0Armed; whether it is in sync is read from dc_get_sync_window_info() and applicable of in_sync. Neither GetSlaveDCActive() in 0x0300 nor a GetSlaveDCCycle0() greater than 0 can be used to infer that the slave is in sync. Under FreeRun, in_sync must not be read as in-sync.

DC synchronization types declared by the ESI​

GetSlaveHasDC answers only "does the ESC hardware support DC"; slave_esi_dc_sync_mode() answers "which DC synchronization tier does the vendor require for this slave in the ESI". The tier decides whether SYNC1 may be enabled:

ValueMeaningTypical ESI
3ESI declares DC-Sync0 + SYNC1: AssignActivate contains the SYNC1 enable bit 0x0400 (for example #x700)Beckhoff EL7411
2ESI declares DC-Sync0 only: AssignActivate is non-zero but does not contain 0x0400 (for example #x300)EL7041 / Ezi-SERVO2
0ESI 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 may be requested only when the value is 3; with a value of 2 only DC-Sync0 is allowed. Treating 2 as 3 (forcing SYNC1 on) makes a slave that declares Sync0 only refuse to enter OP, and an AL status code is not necessarily reported.

ESI-declared value ≠ landed value: DarraEcat_EcEsi_GetDeviceDcAssignActivate() returns the raw 16-bit SYNC0 <Dc><OpMode><AssignActivate> declared in the ESI AssignActivate (returns 1 = declared and out is valid, 0 = not declared in the ESI, -2 = ESI not bound / bad argument). It is not the landed value written into the slave's 0x0980 — read GetSlaveDCActive() for that.

Division of labour with slave_has_esi_dc_sync(): the latter is the boolean capability query "can DC be enabled at all", and when the query fails (no ESI bound / bad parameter) it conservatively falls back to the GetSlaveHasDC hardware bit — better to over-check than to wrongly disable a slave that really can run DC. slave_esi_dc_sync_mode() is a verbatim raw reading: -1 / -2 always map to 0 (not declared / cannot be determined) with no hardware fallback at all. To tell "the ESI explicitly does not use DC" apart from "no ESI is bound at all", use the former; if only a boolean conclusion is needed, use the latter.

Prerequisite: the ESI is handed to the SDK during construction or configuration (esi_dll_load_file() / esi_dll_load_directory()), and is bound when SetStateSequence() establishes the link (or explicitly with esi_dll_apply_all_slaves()). While it is not bound, the reading only means "cannot be determined" and must not be taken as evidence that the slave does not support DC.

Example:

#include "slave/dc.h"

int mode = slave_esi_dc_sync_mode(master, 1);

if (GetSlaveHasDC(master, 1) && slave_has_esi_dc_sync(master, 1)) {
if (mode == 3) {
/* ESI declares DC-Sync0 + SYNC1 DC-Sync01 may be requested */
dc_configure_with_mode(master, 1, DC_SYNCHRON_01, 1000000, 1000000, DC_SHIFT_UNSPECIFIED);
} else {
/* DC-Sync0 only: do not enable SYNC1 */
dc_configure_with_mode(master, 1, DC_SYNCHRON, 1000000, 0, DC_SHIFT_UNSPECIFIED);
}
}

Configuration methods​

SetSyncBySlaveIndex()​

void SetSyncBySlaveIndex(uint16_t master_index, uint16_t slave_index,
uint32_t sync0_ns, uint32_t sync1_ns, int32_t shift_ns);

Configures the DC synchronization parameters of a single slave. All parameters are in nanoseconds. sync0_ns=0 disarms SYNC0 (back to FreeRun, not a 「0 ns cycle」); sync1_ns=0 means SYNC0 only; shift_ns is tri-state: DC_SHIFT_UNSPECIFIED = not specified (resolved by precedence), 0 = literal 0 phase, a negative value = explicit negative phase; the latter two are applied as given.

Phase default and FreeRun
  • Only when the phase is not specified (DC_SHIFT_UNSPECIFIED) is it resolved by precedence: ESI ShiftTimeSync0 other than 0 → explicit user shift_ns → default 「1 cycle + 70%」 sync0_ns * 70 / 100 (1 ms → 700 µs).
  • The phase is a phase shift only and adds no software propagation-delay compensation; the propagation delay is corrected in hardware by the ESC according to 0x0928.
  • shift_ns = 0 is a literal 0 phase, not "not specified", and does not fall back to 70%; pass DC_SHIFT_UNSPECIFIED if you want the default 70%.
  • For FreeRun / SM-Sync slaves the product writes 0x1C32:01 / 0x1C33:01 back to 0 to clear what the previous session left behind (otherwise the move to SafeOp may report AL=0x002D); when SM2/SM3 are not mapped the write is deferred until mapping completes.
  • Hot-plug recovery re-arms and rewrites 0x09A0 and 0x0990; 0x0990 must follow a fresh read of 0x0910 (re-read the slave DC time first, then compute the start point, and write 0x0980 to activate right after), otherwise the start point goes stale and the first SYNC0 never arrives. The phase comes from the same source as the first arming (the same resolution result, phase only) and does not jump when the slave is re-armed; if the reference clock becomes invalid it is re-selected immediately.

Example:

/* SYNC0 = 1ms, no SYNC1, phase resolved by precedence */
SetSyncBySlaveIndex(master, 1, 1000000, 0, DC_SHIFT_UNSPECIFIED);

/* SYNC0 + SYNC1, phase 500 µs */
SetSyncBySlaveIndex(master, 1, 1000000, 2000000, 500000);

/* disable DC */
SetSyncBySlaveIndex(master, 1, 0, 0, DC_SHIFT_UNSPECIFIED);

ResolveDcSyncShift()​

int32_t ResolveDcSyncShift(uint16_t master_index, uint16_t slave_index, uint32_t sync0_ns);

Single-slave automatic DC phase resolution: it outputs only the phase (the precedence between ESI ShiftTimeSync0 / the explicit user value / the default 70%); the propagation delay is corrected in hardware by the ESC according to 0x0928, and no software propagation compensation is included. When there is a phase conclusion it returns the final value, and the runtime writes it into that slave's DC shift at the same time (a subsequent GetSlaveDCShift() then reads exactly that value).

The return value has only two mutually exclusive forms:

  • A legal phase = DC_SHIFT_NO_CONCLUSION_MAXevery** ** greater than int32_t. 0 and any negative value are legal: 0 = the phase lands exactly on a cycle boundary, a negative value = a lead offset (both the ESI ShiftTimeSync0 and an explicit offset support negative phases); -1, -700000 and so on are all real phases, not failures.
  • No conclusion = occupies only the lowest 5 values of int32_t, each named, and in that case the return value is not a phase:
ConstantValueMeaning
DC_SHIFT_INPUT_UNSPECIFIEDINT32_MINA "not specified" sentinel for the input parameter only; appearing in the return-value position means the contract is broken
DC_SHIFT_NO_CONCLUSION_NOT_INITINT32_MIN + 1Not initialized / context unavailable (a runtime that is not ready also falls in this class)
DC_SHIFT_NO_CONCLUSION_BUS_GATEINT32_MIN + 2Rejected by the bus configuration gate; the current bus state does not allow resolution
DC_SHIFT_NO_CONCLUSION_BAD_SLAVEINT32_MIN + 3Invalid slave index
DC_SHIFT_NO_CONCLUSION_NO_PHASEINT32_MIN + 4No phase can be resolved under this configuration (for example sync0_ns = 0, not armed)

The only predicate is r <= DC_SHIFT_NO_CONCLUSION_MAX (DC_SHIFT_NO_CONCLUSION_MAX = INT32_MIN + 4, that is the inclusive upper bound). One comparison is enough; there is no need to enumerate the specific constants, and the predicate helpers ec_dc_shift_is_no_conclusion(r) / ec_dc_shift_is_value(r) can also be used directly.

  • Unit is nanoseconds; the value may be negative.
  • Resolves a single slave only and does not modify other slaves; to compute the whole bus in one call use AutoCalculateDCShift().
  • When there is no conclusion, that slave's DC shift is not written. To decide whether the runtime is loaded, query DarraEcat_ShellStatus(); do not guess from the return value.

Example:

#include "slave/dc.h"

int32_t shift = ResolveDcSyncShift(master, 1, 1000000);

if (ec_dc_shift_is_no_conclusion(shift)) {
/* no conclusion: the return value is not a phase; do not use it as 0 and do not write it into the DC shift */
printf("无相位结论 (返回值 %d)\n", shift); /* No phase conclusion (return value %d) */
} else {
/* 0 and negative values are all legal phases; use them as they are */
printf("从站1 SYNC0=1000000 ns 的相位偏移: %d ns\n", shift); /* Phase offset of slave 1 at SYNC0=1000000 ns: %d ns */
SetSyncBySlaveIndex(master, 1, 1000000, 0, shift);
}

GetDcShiftTruth()​

int32_t GetDcShiftTruth(uint16_t master_index, uint16_t slave_index,
int32_t* out_shift, int32_t* out_source);

Single-slave DC phase truth (read-only): reads the landed phase shift and the tier it came from. It sends no frames / writes no registers / does not go through the bus configuration gate — it reads the master context directly and is readable in OP as well; a status bar or diagnostics can use it to show honestly "what the phase is and which tier it came from". Difference from ResolveDcSyncShift(): this entry does not re-run the phase formula and does not change that slave's shift; it only reports the current state.

Parameters:

  • out_shift (int32_t*) — landed phase (ns); valid only when the return value is 1; 0 and negative values are both legal phases.
  • out_source (int32_t*) — phase source tier; valid only when the return value is 1:
ValueConstantMeaning
0EC_DC_SHIFT_SOURCE_USERExplicit user value (including a literal 0 and negative values)
1EC_DC_SHIFT_SOURCE_ESIExplicitly declared by the ESI <ShiftTimeSync0>
2EC_DC_SHIFT_SOURCE_DEFAULT70The product default 70% phase
3EC_DC_SHIFT_SOURCE_UNKNOWNNone of the three tiers matches (a carried-over value / no evidence); never guessed from the number

Return value:

  • 1 — both output parameters are filled, and out_shift is then a valid phase.
  • <= DC_SHIFT_NO_CONCLUSION_MAX — no conclusion, the output parameters are invalid; the predicate is the same as for ResolveDcSyncShift() (ec_dc_shift_is_no_conclusion()). When the runtime is not ready it likewise returns DC_SHIFT_NO_CONCLUSION_NOT_INIT.

Example:

#include "slave/dc.h"

int32_t shift = 0;
int32_t source = EC_DC_SHIFT_SOURCE_UNKNOWN;

if (GetDcShiftTruth(master, 1, &shift, &source) == 1) {
/* shift is legal whether it is 0 or negative */
printf("相位 %d ns, 来源档 %d\n", shift, source); /* Phase %d ns, source tier %d */
} else {
/* no conclusion: the output parameters are not a phase */
printf("相位真值不可用\n"); /* Phase true value unavailable */
}

SetDcSyncMode()​

typedef enum {
DC_FREE_RUN = 0, /* free run: DC not used */
DC_SM_SYNCHRON = 1, /* SM event synchronization */
DC_SYNCHRON = 2, /* DC SYNC0 synchronization */
DC_SYNCHRON_01 = 3 /* DC SYNC0 + SYNC1 */
} dc_sync_mode_t;

BOOL SetDcSyncMode(uint16_t master_index, uint16_t slave_index, uint8_t sync_type);
uint8_t GetDcSyncMode(uint16_t master_index, uint16_t slave_index);

/* high-level wrapper (slave/dc.h) */
BOOL dc_configure_with_mode(uint16_t master_index, uint16_t slave_index,
dc_sync_mode_t mode,
uint32_t sync0_ns, uint32_t sync1_ns,
int32_t shift_ns);

SetDcSyncMode() sets or reads the slave SyncManager synchronization type directly. dc_configure_with_mode() is the high-level wrapper provided by slave/dc.h; it completes the slave DC configuration in one call according to the synchronization mode (SYNC0/SYNC1 signals plus the SyncManager synchronization type). DC synchronization modes follow ETG.1020 §22 / ESI AssignActivate in four tiers.

Return values (dc_configure_with_mode, semantics tightened):

  • TRUE — the DC configuration has been issued and the synchronization type has been confirmed written by the slave
  • FALSE — invalid parameter (unknown mode) / runtime not ready / slave does not support DC / the write of synchronization type 0x1C32:01 / 0x1C33:01 was not confirmed by the slave

Failures are reported honestly, never swallowed: when the synchronization type write is not confirmed, the call returns FALSE and also writes a diagnostics line to the SDK log with master / slave / expected tier / measured tier. Callers must not read FALSE as "configuration succeeded, the status just could not be read". To check the tier actually in effect, call GetDcSyncMode() again (0 means both FreeRun and unreadable).

Calling high-level wrappers

Call dc_configure_with_mode() and the other slave/dc.h high-level wrappers directly (no handle, no function-pointer table); they require #include "slave/dc.h".

Example:

#include "slave/dc.h"

/* SYNC0 only, 1ms cycle, phase resolved by precedence */
dc_configure_with_mode(master, 1, DC_SYNCHRON, 1000000, 0, DC_SHIFT_UNSPECIFIED);

/* SYNC0 + SYNC1, shift 500 µs */
dc_configure_with_mode(master, 1, DC_SYNCHRON_01, 1000000, 2000000, 500000);

Disabling DC​

/* set SetSyncBySlaveIndex to 0 through sync0_ns */
SetSyncBySlaveIndex(master, 1, 0, 0, DC_SHIFT_UNSPECIFIED);

Sync window diagnostics​

GetSlaveSyncWindowStatus()​

BOOL GetSlaveSyncWindowStatus(uint16_t master_index, uint16_t slave_index,
int* diff_ns, int* max_diff_ns, int* min_diff_ns,
BOOL* in_sync, uint32_t* out_of_sync_count);

Reads detailed status of the slave DC sync window. Returns FALSE when DC is not supported or the read fails. Output parameters: current/maximum/minimum time difference, whether the slave is inside the DC SYNC0 sync window, and the cumulative out-of-sync count. in_sync must not be read as in-sync under FreeRun; to decide that the slave is "genuinely in the window" require dc_get_sync_window_info() and applicable = TRUE from in_sync = TRUE. DCActive / DCCycle0 do not imply the slave is in sync.

The reference clock itself: by definition 0x092C (time difference) is N/A for it, and the SDK no longer synthesizes an in-sync value. When this slave is the reference clock and SYNC0 is armed, in_sync is TRUE (same convention as C++ IsInSync() / TryIsInSync()) — a reference clock cannot be out of step with itself, which is the only conclusion that can be determined (non-reference slaves still follow the sync-window criterion). The value only means "can be treated as in sync"; it does not mean a measured deviation exists, and it does not mean the whole network clock has converged; for the reference clock dc_get_sync_window_info() still honestly reports applicable=FALSE + EC_DC_WINDOW_NA_REFERENCE_CLOCK_ITSELF.

Tri-state entry point

This function has only two outcomes, TRUE / FALSE, so it cannot distinguish "known to be outside the window" from "arming conclusion unknown". When three states are needed, use dc_sync0_armed() and dc_get_sync_window_info() from "DC diagnostics (per slave)" below.

Querying

If only in_sync or the current difference is needed, use interfaces such as GetSlaveLinkQuality / IsAllSlavesInSync; GetSlaveSyncWindowStatus() suits scenarios that need the full statistics.

ResetSlaveSyncWindowStats()​

void ResetSlaveSyncWindowStats(uint16_t master_index, uint16_t slave_index);
int GetMaxSyncDifference(uint16_t master_index);
BOOL IsAllSlavesInSync(uint16_t master_index);

ResetSlaveSyncWindowStats() resets the sync-window statistics of this slave. GetMaxSyncDifference() / IsAllSlavesInSync() are global queries.

DC diagnostics (per slave, C / C++ low level)​

Per-slave DC diagnostics answer four questions: can this slave do SYNC0, is it armed, is it in sync, and can each reading be trusted. All entry points read only the local cache; they do not read registers or send bus frames, so they can be called directly from the UI thread or a diagnostics thread.

Armed is not in sync

Armed (dc_sync0_armed() / Sync0Armed) only means the slave has committed to generating SYNC0; whether the whole network clock has converged is read from applicable and in_sync of the sync window. The two must be read separately; one must never be inferred from the other.

Entry points​

CategoryC entryC++ low-level entryRead/writeDescription
Capability tierdc_capability(mi, si)SlaveDC::GetDcCapability(dll, mi, si)Read-onlyESC capability bits plus the tier declared by the ESI. EC_DC_CAPABILITY_UNKNOWN means it cannot be determined, not "no capability"
Arm final outcomeec_dc_slave_snapshot_t.arm_outcome / arm_outcome_availableSlaveDC::TryGetDcArmOutcome(dll, mi, si)Read-onlyIn C it is always EC_DC_ARM_RESULT_UNAVAILABLE + FALSE; in C++ it is always std::nullopt. See below for the reason
0x0980 landed valuedc_assign_activate(mi, si, &out)SlaveDC::GetDcAssignActivate(...)Read-onlyReturns FALSE = no DC capability / unreadable, and does not write out; when TRUE, 0 = DC capable but not active
SYNC0 cycledc_sync0_cycle_ns(mi, si, &out)SlaveDC::GetDcSync0CycleNs(...)Read-onlyMirror of the landed 0x09A0 value; 0 = the cycle has not landed, not a "0 ns cycle"
SYNC1 cycledc_sync1_cycle_ns(mi, si, &out)SlaveDC::GetDcSync1CycleNs(...)Read-onlyMirror of the landed 0x09A4 value, semantics as above
Phase shiftdc_shift_ns(mi, si, &out)Snapshot field DcSlaveSnapshot::ShiftNsRead-onlyLanded value (ns), may be negative; the C++ low level has no per-slave phase-shift entry, read the snapshot
Propagation delaydc_propagation_delay_ns(mi, si, &out)SlaveDC::GetDcPropagationDelayNs(...)Read-onlyLanded 0x0928 value; a negative underlying value is treated as a read failure (returns FALSE)
Propagation delay origindc_propagation_delay_origin(mi, si)SlaveDC::GetDcPropagationDelaySource(...)Read-onlyEC_DC_PDELAY_ORIGIN_ZERO_NS_AMBIGUOUS = may be the domain root or may not have been measured yet; nothing is invented
Sync windowdc_get_sync_window_info(mi, si, &out) / dc_build_sync_window_info(...)SlaveDC::GetDcSyncWindow(dll, mi, si)Read-onlyPer-slave property entry; when assembling in bulk, call dc_build_sync_window_info first to reuse the already-read reference clock slave index and threshold
SYNC0 armingdc_sync0_armed(mi, si, &armed)SlaveDC::Sync0Armed(...)Read-onlyTri-state return code, see below
Convergence timedc_get_convergence_ms(mi, si, &out)MasterDiagnosticsInfo::DcConvergenceMs(si)Read-onlyComes from the most recent completed 2-second sample; unavailable unless a complete transition was observed
Steady-state jitterdc_get_jitter(mi, si, &out)MasterDiagnosticsInfo::DcJitter(si)Read-onlyThe whole reading is unavailable with fewer than 2 samples; a single point is never passed off as stable
Reference clock factsdc_reference_clock_info(mi, &out)SlaveDC::GetDcReferenceClock(dll, mi)Read-onlySlave index + tier + reason text; when no DC slave exists, an explicit instance (slave index 0) is returned rather than fabricated facts

The return code of dc_sync0_armed() is tri-state; callers must branch on it:

CategoryReturn valueMeaningHandling of *armedRead/write
DC diagnostics0Conclusion valid*armed is written: TRUE = committed to generate SYNC0, FALSE = not armed, with evidenceRead-only
DC diagnosticsnon-0Cannot be determined (bad parameter / context not ready / entry unavailable)*armed is not written; the caller keeps the previous value or treats it as "unknown"; collapsing it to "not armed" is forbiddenRead-only

C++ Sync0Armed() returns std::optional<bool>: std::nullopt means "cannot be determined", equivalent to a non-0 return above.

Sync window structure ec_dc_sync_window_info_t​

CategoryFieldRead/writeDescription
DC diagnosticsapplicableRead-onlyTRUE = this slave participates in SYNC0 and a real measurement was read; when FALSE, all has_xxx flags of the numeric fields are FALSE
DC diagnosticsna_reasonRead-onlyReason when applicable = FALSE; EC_DC_WINDOW_NA_NONE when applicable
DC diagnosticshas_diff_ns / diff_nsRead-onlyCurrent synchronization error (ns)
DC diagnosticshas_max_diff_ns / max_diff_nsRead-onlyMaximum error within the observation window (ns)
DC diagnosticshas_min_diff_ns / min_diff_nsRead-onlyMinimum error within the observation window (ns)
DC diagnosticshas_out_of_sync_count / out_of_sync_countRead-onlyCumulative number of times the sync window was exceeded
DC diagnosticshas_in_sync / in_syncRead-onlyWhether this sample is inside the window (armed and measured inside)
DC diagnosticshas_threshold_ns / threshold_nsRead-onlySync window threshold (ns)
DC diagnosticshas_reading_unchanged / reading_unchangedRead-onlyWhether the four 0x092C readings have stayed completely unchanged over several consecutive samples (frozen proxy flag); has = FALSE = not enough samples to conclude
DC diagnosticsunchanged_streakRead-onlyNumber of consecutive samples with identical readings (same counter as reading_unchanged)
DC diagnosticshas_sampled_at_utc / sampled_at_utc_msRead-onlySample timestamp of this reading (UTC milliseconds)

reading_unchanged = FALSE is not the same as "confirmed to be advancing"; it only means the freeze-decision sample count has not been reached. It is a direct observation of "the reading was not updated", not the freeze criterion for the reference clock's 1:1 ramp.

Seven states​

The seven states describe only "determinable sync window states". The C side has no single seven-state enum; the state is expressed as a combination of applicable + na_reason + in_sync / reading_unchanged:

CategoryStatePredicateMeaningC expressionC++ DcSyncWindowStateRead/write
DC diagnosticsNo capabilityNo DC capabilityThere is no SYNC0 cycle unit, so a synchronization error does not existapplicable=FALSE + EC_DC_WINDOW_NA_NO_DC_CAPABILITYNoDcCapabilityRead-only
DC diagnosticsNot armedKnown not armedNot participating in DC synchronization, 0x092C is undefinedapplicable=FALSE + EC_DC_WINDOW_NA_SYNC0_NOT_ARMEDSync0NotArmedRead-only
DC diagnosticsReference clock itselfThis slave is the reference clockA synchronization error does not exist by definitionapplicable=FALSE + EC_DC_WINDOW_NA_REFERENCE_CLOCK_ITSELFReferenceClockItselfRead-only
DC diagnosticsReading frozenApplicable and the readings are continuously unchangedAll four readings completely unchanged over several samples (frozen proxy flag)applicable=TRUE + has_reading_unchanged=TRUE + reading_unchanged=TRUEReadingFrozenRead-only
DC diagnosticsGenuinely in windowApplicable and measured inside the windowArmed and measured inside the sync windowapplicable=TRUE + has_in_sync=TRUE + in_sync=TRUEInWindowRead-only
DC diagnosticsArming unknownArming conclusion unknownThe query cannot answer; participating / not participating cannot be assertedapplicable=FALSE + EC_DC_WINDOW_NA_ARMED_UNKNOWNArmedUnknownRead-only
DC diagnosticsNever sampledApplicable but no valid sampleAll four values are 0 and in_sync=FALSE; 0 is not "perfect synchronization"applicable=FALSE + EC_DC_WINDOW_NA_NOT_SAMPLEDNotSampledRead-only

The read-failure family is not one of these seven states; the C side also goes through na_reason, and C++ State() returns std::nullopt (the reason stays readable):

CategoryReasonMeaningRead/write
DC diagnosticsEC_DC_WINDOW_NA_SLAVE_READ_FAILEDThe slave snapshot cannot be read, so even the capability cannot be determinedRead-only
DC diagnosticsEC_DC_WINDOW_NA_REFERENCE_CLOCK_UNKNOWNThe reference clock slave index cannot be read, so it cannot be decided whether this slave is the time baseRead-only
DC diagnosticsEC_DC_WINDOW_NA_WINDOW_READ_FAILEDArmed and not the reference clock, but reading the measured window failed (read failure / context generation changed)Read-only

Armed but outside the window (applicable = TRUE, in_sync = FALSE, not frozen) is none of the seven states either. C++ State() returns std::nullopt; the caller must read applicable and in_sync and take the real conclusion "outside the window", never "not armed" or "unknown".

The evaluation order is fixed: slave snapshot unreadable → no capability → reference clock slave index unreadable → this slave is the reference clock → arming unknown → known not armed → window read failed → never sampled → measured.

Three honest tri-states​

CategoryConclusionWhen there is no conclusionCC++Read/write
DC diagnosticsWhether all are in the windowNo confirmed participant → unknown, not TRUEall_in_sync_known = FALSEAllInSync = std::nulloptRead-only
DC diagnosticsMaximum synchronization differenceNo usable window at all → unknown, not 0has_max_drift_ns = FALSEMaxDriftNs = std::nulloptRead-only
DC diagnosticsSYNC0 armingThe query cannot answer → unknown, not FALSEsync0_armed_known = FALSESync0Armed = std::nulloptRead-only

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

Arm final outcome: unavailable at this layer​

The bookkeeping source of DcArmOutcome is maintained by the SDK's automatic start policy; the C / C++ low level has no equivalent source:

CategoryLanguageExpressionDescriptionRead/write
DC diagnosticsCarm_outcome = EC_DC_ARM_RESULT_UNAVAILABLE, arm_outcome_available = FALSEDedicated "unavailable" value, not EC_DC_ARM_RESULT_UNKNOWNRead-only
DC diagnosticsC++TryGetDcArmOutcome() is always std::nulloptDoes not fabricate DcArmResult::Unknown; the reason is given by DcArmOutcomeUnavailableReason()Read-only

The semantics of UNKNOWN are "bookkeeping exists, but this sample has no final-outcome record for that slave"; this layer is "no such bookkeeping at all". The two must not be mixed, and UNKNOWN must not be called "not yet armed" or "not participating". For a real final outcome, use the C# SDK.

Reference clock and time base​

  • Reference clock: in chain order, the master selects the first slave on the link that has active DC (real SYNC0); if no slave is armed, it falls back to the first DC-capable slave in the chain. The whole bus has exactly this one time base.
  • Single start point: the reference domain has exactly one start instant (the same physical instant); after converting it into each slave's time domain, the master writes it to 0x0990. Start points are not measured per slave.
  • Reference clock handover (slave drop / hot-plug / capability change): every 0x0920 written in the old clock's time domain becomes invalid. In chain order, the master re-reads 0x0920 for each DC slave that is not in OP, not dropped and not the reference clock itself, proves it by reading back, then rewrites that slave's 0x0990 in the new time domain; slaves in OP are not interrupted in their SYNC0 and have their error trimmed by online correction.
  • Phase only: 0x0928 is corrected in hardware by the ESC when generating SYNC0; shift_ns is a phase shift only and contains no propagation-delay compensation.
  • Diagnostics: the SDK does not currently expose read-only properties for 0x0990 / 0x0920; for register-level evidence see the DC synchronization diagnostics lines in events.log.

Full example​

#include "ethercat.h"
#include <stdio.h>

int main(void) {
uint16_t master = Initialize();
SetNetwork(master, "\\Device\\NPF_{GUID}", "");
SetStateSequence(master, EC_STATE_OPERATIONAL, 10000);
Start(master);

if (GetSlaveHasDC(master, 1)) {
/* configure slave 1: SYNC0 = 1ms */
SetSyncBySlaveIndex(master, 1, 1000000, 0, 0);

printf("DC 激活: %d\n", GetSlaveDCActive(master, 1)); /* DC active: %d */
printf("SYNC0 周期: %d ns\n", GetSlaveDCCycle0(master, 1)); /* SYNC0 cycle: %d ns */
printf("相位偏移: %d ns\n", GetSlaveDCShift(master, 1)); /* Phase offset: %d ns */
printf("传播延迟: %d ns\n", GetSlavePropagationDelay(master, 1)); /* Propagation delay: %d ns */

/* sync window diagnostics */
int diff, max_d, min_d;
BOOL sync;
uint32_t oos;
if (GetSlaveSyncWindowStatus(master, 1, &diff, &max_d, &min_d, &sync, &oos)) {
printf("同步差: %d ns, 同步=%s, 失步=%u\n", /* Sync difference: %d ns, in sync=%s, out-of-sync=%u */
diff, sync ? "是" : "否", oos);
}

if (IsAllSlavesInSync(master))
printf("所有从站已同步\n"); /* All slaves are synchronized */

/* disable DC */
SetSyncBySlaveIndex(master, 1, 0, 0, 0);
}

Stop(master);
Dispose(master);
return 0;
}