Aging mechanical test equipment
Hardware configuration
- Master: Windows x64 × 1 + Intel i5 × 1 (the example on this page is the C# SDK, running on Windows x64)
- Servo drive: Inovance SV660N 1.5 kW (EtherCAT, CiA 402) × 1
- Servo motor: 1.5 kW with brake × 1
- Linear module: precision ball screw (lead 5 mm, stroke 150 mm, thrust 8 kN) × 1
- Force sensor: S-type tension/compression 5 kN (accuracy 0.02% F.S.) × 1
- Weighing module: Beckhoff EL3356-0010 (24-bit) × 1
- Displacement sensor: LVDT ±25 mm (0-10 V conditioned output) × 1
- Analog input: Beckhoff EL3164 (16-bit) × 1
This page is a single-axis fatigue test example, not a synchronized-axis or electronic-gearing use case: only one servo applies the reciprocating load. For strict multi-axis coupling, see Synchronized axes / electronic gearing.
The default PDO cycle is 1 ms (1 kHz), and DC Sync0 uses the same value as the bus cycle; 1 ms is sufficient and more stable for single-axis fatigue. Use 125 µs only in a verified RT environment.
Cost analysis
| Category | Model/spec | Reference unit price (¥) | Qty | Subtotal (¥) |
|---|---|---|---|---|
| Servo drive | Inovance SV660N 1.5 kW EtherCAT | 2,500 | 1 | 2,500 |
| Servo motor | 1.5 kW with brake | 1,200 | 1 | 1,200 |
| Ball-screw module | lead 5 mm, stroke 150 mm, 8 kN | 3,500 | 1 | 3,500 |
| S-type force sensor | 5 kN 0.02% F.S. | 2,000 | 1 | 2,000 |
| Weighing module | EL3356-0010 (24-bit) | 2,500 | 1 | 2,500 |
| LVDT displacement sensor | ±25 mm, 0-10 V conditioned output | 1,800 | 1 | 1,800 |
| Analog input | EL3164 (16-bit, 4 channels) | 800 | 1 | 800 |
| Industrial PC | Intel i5 class | 3,000 | 1 | 3,000 |
| Total for the line (reference) | ≈ ¥17,300 |
Reference prices (RMB) for the core components; rack, fixtures, cabling, and power distribution are not included.
Performance figures
- Maximum thrust: ±5 kN (tension/compression)
- Stroke: ±25 mm
- Fatigue frequency: 1-5 Hz (sine)
- Force resolution: 24-bit (EL3356, ±0.001% F.S.)
- Displacement resolution: 16-bit (EL3164, 0.0008 mm)
- PDO cycle: 1 ms (1 kHz, DC Sync0)
Application scenario
Low-frequency fatigue life testing of automotive components.
A servo and ball screw apply a reciprocating load, the S-type sensor measures force precisely, and the LVDT measures the actual specimen deformation.
Sine displacement control, tracking the peak force of every cycle in real time to detect stiffness degradation (a force-amplitude drop of > 20% is judged as failure).
Suited to ten-thousand-cycle fatigue testing of rubber bushings, seal rings, springs and similar parts.
Code description
System architecture
Key design:
- Sine displacement control — a Stopwatch real-time clock generates the sine trajectory and writes it into the PDO mapping
- Force and displacement limits — over-force or over-displacement stops the machine and protects the specimen
- Stiffness degradation detection — tracks the peak force every cycle; a drop beyond the threshold is judged as failure
- Producer-consumer — the control thread enqueues, the logging thread writes batches to disk
The fatigue test control algorithms in this case (sine trajectory generation, stiffness degradation detection, S-N curve analysis, and so on) and the underlying timing logic such as force-sensor calibration and LVDT signal conditioning are additional custom work and are not included in the EtherCAT master software license.
Code example
PDO structure definitions
using System.Runtime.InteropServices;
/// <summary>
/// INOVANCE SV660N servo drive input PDO (TxPDO, CiA 402 default mapping)
/// Field order = 0x603F -> 0x6041 -> 0x6061 -> 0x6064 -> 0x606C -> 0x6077, 15 bytes accumulated byte by byte
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct SV660N_Input
{
public ushort ErrorCode; // 0x603F error code offset 0
public ushort StatusWord; // 0x6041 status word offset 2
public sbyte ModesOfOperationDisplay; // 0x6061 actual mode offset 4
public int ActualPosition; // 0x6064 actual position offset 5
public int ActualVelocity; // 0x606C actual velocity offset 9
public short ActualTorque; // 0x6077 actual torque offset 13 (0.1% of rated)
}
/// <summary>
/// INOVANCE SV660N servo drive output PDO (RxPDO, CiA 402 CSP mode default mapping)
/// Field order = 0x6040 -> 0x6060 -> 0x607A, 7 bytes accumulated byte by byte
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct SV660N_Output
{
public ushort ControlWord; // 0x6040 control word offset 0
public sbyte ModesOfOperation; // 0x6060 mode of operation offset 2 (8=CSP)
public int TargetPosition; // 0x607A target position offset 3
}
/// <summary>
/// EL3356-0010 weighing module input PDO (24-bit)
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct EL3356_Input
{
public ushort Status; // Status word
public int Value; // Weight value (24 significant bits)
}
/// <summary>
/// EL3164 analog input PDO (channel 1 used to sample the LVDT)
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct EL3164_Input
{
public ushort Ch1_Status;
public short Ch1_Value; // LVDT (16-bit, 0-10 V)
public ushort Ch2_Status;
public short Ch2_Value;
public ushort Ch3_Status;
public short Ch3_Value;
public ushort Ch4_Status;
public short Ch4_Value;
}
/// <summary>
/// Test data point
/// </summary>
public class TestDataPoint
{
public long SampleIndex { get; set; }
public double Time { get; set; } // Time (seconds)
public double TargetDisplacement { get; set; } // Target displacement (mm)
public double ActualDisplacement { get; set; } // Measured displacement (mm)
public double Force { get; set; } // Force (N)
public int CycleCount { get; set; } // Current loop count
}
The structs above are added byte by byte in each device's default ESI mapping order (for example, SV660N_Input is 15 bytes = 2+2+1+4+4+2, EL3356_Input is 6 bytes = 2+4, and EL3164_Input is 2+2 per channel, 16 bytes in total). When you change the model or modify the PDO assignment, rewrite the structs according to the actual mapping exported by DENI; if a struct is larger than the process image, InputsMapping<T>() throws "struct larger than input PDO".
Control code
using System;
using System.Diagnostics;
using System.Threading;
using System.Collections.Concurrent;
using System.IO;
using DarraEtherCAT_Master;
/// <summary>
/// Test parameters
/// </summary>
public class FatigueTestParams
{
public double Amplitude { get; set; } // Displacement amplitude (mm)
public double Frequency { get; set; } // Fatigue frequency (Hz)
public double MaxForce { get; set; } // Force limit (N), stop when exceeded
public int MaxCycles { get; set; } // Maximum loop count
public double FailureThreshold { get; set; } // Stiffness degradation threshold (0.8 = down to 80%)
}
class FatigueTestController
{
// Slave index (EtherCAT daisy-chain topology)
const int SLAVE_SERVO = 0; // INOVANCE SV660N servo drive
const int SLAVE_LOADCELL = 1; // EL3356 weighing module
const int SLAVE_LVDT = 2; // EL3164 analog input (LVDT)
// CiA 402 constants
const ushort CW_SHUTDOWN = 0x0006; // Shutdown (normal stop command)
const ushort CW_DISABLE_VOLTAGE = 0x0000; // Used only to leave QuickStopActive (T12); never in any other state
const ushort CW_SWITCH_ON = 0x0007;
const ushort CW_ENABLE_OPERATION = 0x000F; // bit4 is undefined in CSP, so do not write 0x001F
const ushort CW_QUICK_STOP = 0x0002;
const ushort CW_FAULT_RESET_EDGE = 0x0086; // bit7 + the Shutdown bits form a clean rising edge
const ushort SW_MASK_OP = 0x006F; // Running state mask
const ushort SW_MASK_STATE = 0x004F; // Fault / not-ready mask
const sbyte MODE_CSP = 8; // Cyclic Synchronous Position
// ============ Configurable parameters ============
/// <summary> Encoder pulses/mm (motor encoder resolution / screw lead) </summary>
public static double PulsesPerMm { get; set; } = 100000.0 / 5.0; // Encoder / 5 mm lead
/// <summary> EL3356 force conversion: raw value -> N (calibrate per sensor) </summary>
public static double ForceScale { get; set; } = 5000.0 / (1 << 23); // 5000 N / 24-bit
/// <summary> EL3164 displacement conversion: raw value -> mm (0-10 V maps to LVDT 0-50 mm) </summary>
public static double LvdtScale { get; set; } = 50.0 / 32767.0;
/// <summary> LVDT zero offset (mm) </summary>
public static double LvdtOffset { get; set; } = -25.0; // ±25mm midpoint offset
/// <summary> Test parameters </summary>
public static FatigueTestParams TestParams { get; set; } = new FatigueTestParams
{
Amplitude = 5.0, // ±5mm
Frequency = 2.0, // 2Hz
MaxForce = 4500.0, // 4500 N (90% of the sensor range)
MaxCycles = 10000,
FailureThreshold = 0.8 // Fail when stiffness degrades to 80%
};
// Data buffer
static ConcurrentQueue<TestDataPoint> dataBuffer = new ConcurrentQueue<TestDataPoint>();
static volatile bool isRunning = true;
// Motion request: the main thread/UI only sets flags; the CiA 402 state machine advances only inside the PDO callback
static volatile bool enableRequested;
static volatile bool faultResetRequested;
static volatile bool emergencyStopRequested;
static int faultResetTicks; // Callback thread only
// Fatigue test loop state (used by the cycle callback)
static DarraEtherCAT master;
static FatigueTestParams testParam;
static int homePosition;
static long sampleIndex = 0;
static int cycleCount = 0;
static double prevTarget = 0;
static double peakForce = 0;
static double initialPeakForce = 0;
static bool initialCalibrated = false;
static DateTime lastDisplayTime = DateTime.Now;
static Stopwatch stopwatch;
static void Main(string[] args)
{
const uint CYCLE_NS = 1_000_000; // 1 ms; 125 µs only in a verified RT environment
var build = new DarraEtherCAT()
.SetENI("config.deni")
.EnableAutoStartup()
.Build();
if (!build.Success)
{
Console.WriteLine($"主站初始化失败: {build.Message}"); // Master initialization failed: {build.Message}
return;
}
master = build.Master;
if (master == null)
{
Console.WriteLine("主站初始化失败: BuildResult.Master 为空"); // Master initialization failed: BuildResult.Master is null
return;
}
try
{
Console.WriteLine($"发现 {master.SlaveCount} 个从站"); // Found {master.SlaveCount} slaves
if (master.SlaveCount < 3)
{
Console.WriteLine($"从站不足: 需要 伺服 + 称重 + LVDT 共 3 个, 实际 {master.SlaveCount}"); // Not enough slaves: 3 needed in total (servo + weighing + LVDT), {master.SlaveCount} found
return;
}
// Set the cycle time first and read it back to verify; refuse to start if it does not match
master.LoopCycle = CYCLE_NS;
if (master.LoopCycle != CYCLE_NS)
{
Console.WriteLine($"LoopCycle 读回 {master.LoopCycle}ns ≠ {CYCLE_NS}ns, 拒绝启动"); // LoopCycle read back {master.LoopCycle}ns ≠ {CYCLE_NS}ns, refusing to start
return;
}
if (!master.SetState(EcState.PreOp))
{
Console.WriteLine("无法进入 PreOp"); // Failed to enter PreOp
return;
}
// DC Sync0 equals the bus cycle; lack of DC capability is reported honestly
if (master.Slaves[SLAVE_SERVO].HasDC)
{
if (!master.Slaves[SLAVE_SERVO].ConfigureDC(CYCLE_NS))
{
Console.WriteLine("DC Sync0 配置失败 — CSP 依赖周期同步, 拒绝启动"); // DC Sync0 configuration failed — CSP depends on cyclic synchronization, refusing to start
return;
}
}
else
{
Console.WriteLine("警告: 伺服无 DC 能力, 未配置 Sync0 (同步精度下降)"); // Warning: the servo has no DC capability, Sync0 was not configured (synchronization accuracy degrades)
}
if (!master.SetState(EcState.SafeOp))
{
Console.WriteLine("无法进入 SafeOp"); // Failed to enter SafeOp
return;
}
// Before entering OP: target=actual, mode CSP, control word Shutdown, so the first enable does not jump from a 0 target
{
ref var out0 = ref master.Slaves[SLAVE_SERVO].PDO.OutputsMapping<SV660N_Output>();
ref readonly var in0 = ref master.Slaves[SLAVE_SERVO].PDO.InputsMapping<SV660N_Input>();
out0.ModesOfOperation = MODE_CSP;
out0.ControlWord = CW_SHUTDOWN;
out0.TargetPosition = in0.ActualPosition;
}
if (!master.SetState(EcState.OP))
{
Console.WriteLine("无法进入 OP 状态"); // Failed to enter the OP state
return;
}
// Set the enable request only; the PDO callback advances 0x06 -> 0x07 -> 0x0F from the status word
Console.WriteLine("请求使能 (CiA 402 状态机由周期回调推进)"); // Requesting enable (the CiA 402 state machine is advanced by the cyclic callback)
enableRequested = true;
Console.WriteLine("老化力学测试设备启动!"); // Aging mechanical test rig started!
Console.WriteLine($"幅值: ±{TestParams.Amplitude}mm, " + // Amplitude: ±{TestParams.Amplitude}mm,
$"频率: {TestParams.Frequency}Hz, " + // Frequency: {TestParams.Frequency}Hz,
$"目标循环: {TestParams.MaxCycles}"); // Target cycles: {TestParams.MaxCycles}
// Start the data logging thread
var logThread = new Thread(() => DataLogLoop("fatigue_data.csv"));
logThread.IsBackground = true;
logThread.Start();
// Run the fatigue test
RunFatigueTest(master, TestParams);
}
finally
{
isRunning = false;
try { master?.Events.ProcessDataCyclicSync -= OnPdoCycle; } catch { }
master.Dispose();
}
}
/// <summary>
/// Advance the CiA 402 enable from the status word: 0x06 -> 0x07 -> 0x0F
/// </summary>
static ushort NextEnableCommand(ushort sw, bool enable)
{
// The only legal exit from QuickStopActive = 0x0000 (Disable Voltage, T12);
// Sending 0x0006 in this state is undefined; the axis would be stuck in QuickStopActive for good
if ((sw & SW_MASK_OP) == 0x07) return CW_DISABLE_VOLTAGE;
if (!enable) return CW_SHUTDOWN; // Shutdown
if ((sw & SW_MASK_STATE) == 0x40) return CW_SHUTDOWN; // SwitchOnDisabled
if ((sw & SW_MASK_OP) == 0x21) return CW_SWITCH_ON; // ReadyToSwitchOn
if ((sw & SW_MASK_OP) == 0x23) return CW_ENABLE_OPERATION; // SwitchedOn
if ((sw & SW_MASK_OP) == 0x27) return CW_ENABLE_OPERATION; // OperationEnabled
return CW_SHUTDOWN; // NotReady / FaultReaction
}
/// <summary>
/// Controlled stop: withdraw the enable request, the callback keeps sending 0x0006, and the callback is detached only after the state is confirmed
/// </summary>
static void StopServoAndWait(DarraEtherCAT m, int timeoutMs = 1500)
{
enableRequested = false;
var wait = Stopwatch.StartNew();
while (wait.ElapsedMilliseconds < timeoutMs)
{
ref readonly var servoIn = ref m.Slaves[SLAVE_SERVO].PDO.InputsMapping<SV660N_Input>();
ushort sw = servoIn.StatusWord;
if ((sw & SW_MASK_STATE) == 0x40 || (sw & SW_MASK_STATE) == 0x08 ||
(sw & SW_MASK_OP) == 0x21)
return; // SwitchOnDisabled / Fault / ReadyToSwitchOn
Thread.Sleep(10); // Non-real-time wait, not inside the PDO callback
}
}
/// <summary>
/// Fatigue test: register a PDO cycle callback (real-time motion control is driven by the SDK cycle event)
/// </summary>
static void RunFatigueTest(DarraEtherCAT master, FatigueTestParams param)
{
ref readonly var servoIn = ref master.Slaves[SLAVE_SERVO].PDO.InputsMapping<SV660N_Input>();
testParam = param;
homePosition = servoIn.ActualPosition;
sampleIndex = 0;
cycleCount = 0;
prevTarget = 0;
peakForce = 0;
initialPeakForce = 0;
initialCalibrated = false;
lastDisplayTime = DateTime.Now;
stopwatch = Stopwatch.StartNew();
Console.WriteLine("疲劳测试开始...\n"); // Fatigue test starting...
// The real-time motion control loop is handed to the SDK cycle callback (1 ms DC Sync0); no user-space spin sets the pace
master.Events.ProcessDataCyclicSync += OnPdoCycle;
// Wait for the test to end (isRunning goes false on failure / limit exceeded / reaching the max loop count)
// This is a non-real-time wait, not inside the PDO callback
while (isRunning && cycleCount < param.MaxCycles)
Thread.Sleep(50);
// Controlled stop: target=actual -> 0x0006, detach the callback only after OperationEnabled has really left
StopServoAndWait(master);
master.Events.ProcessDataCyclicSync -= OnPdoCycle;
Console.WriteLine($"\n测试完成! 循环: {cycleCount}, " + // Test complete! Cycles: {cycleCount},
$"采样: {sampleIndex}"); // Samples: {sampleIndex}
}
/// <summary>
/// PDO cycle callback (once per EtherCAT cycle, real-time motion control)
/// </summary>
static void OnPdoCycle(ushort mi)
{
try
{
var m = master;
if (m == null) return;
// PDO mapping
ref readonly var servoIn = ref m.Slaves[SLAVE_SERVO].PDO.InputsMapping<SV660N_Input>();
ref var servoOut = ref m.Slaves[SLAVE_SERVO].PDO.OutputsMapping<SV660N_Output>();
ref readonly var forceIn = ref m.Slaves[SLAVE_LOADCELL].PDO.InputsMapping<EL3356_Input>();
ref readonly var lvdtIn = ref m.Slaves[SLAVE_LVDT].PDO.InputsMapping<EL3164_Input>();
// ==================== CiA 402 state machine (advanced every cycle, no Sleep) ====================
ushort sw = servoIn.StatusWord;
bool opEnabled = (sw & SW_MASK_OP) == 0x27; // 0x6F is used for the running state
bool fault = (sw & SW_MASK_STATE) == 0x08; // 0x4F is used for the fault state
servoOut.ModesOfOperation = MODE_CSP;
// Fault reset: bit7 rising edge, low phase 0x0006 / high phase 0x0086, never 0x0000 during the reset
// (0x0000 is only used when leaving QuickStopActive, see NextEnableCommand)
if (faultResetRequested && fault)
{
faultResetTicks++;
servoOut.ControlWord = ((faultResetTicks / 400) % 2 == 0) ? CW_FAULT_RESET_EDGE : CW_SHUTDOWN;
servoOut.TargetPosition = servoIn.ActualPosition;
return;
}
faultResetRequested = false;
faultResetTicks = 0;
// Emergency stop: 0x0002 Quick Stop on the 0x6085 ramp -> confirm QuickStopActive
// -> 0x0000 leaves QuickStopActive -> 0x0006 disables
if (emergencyStopRequested)
{
if (opEnabled)
{
servoOut.ControlWord = CW_QUICK_STOP;
}
else if ((sw & SW_MASK_OP) == 0x07)
{
servoOut.ControlWord = CW_DISABLE_VOLTAGE; // Only exit from QuickStopActive (T12)
}
else if ((sw & SW_MASK_STATE) == 0x40)
{
servoOut.ControlWord = CW_SHUTDOWN; // Already back to SwitchOnDisabled, resting in the disabled state
emergencyStopRequested = false;
}
else
{
servoOut.ControlWord = NextEnableCommand(sw, false);
}
servoOut.TargetPosition = servoIn.ActualPosition;
return;
}
// Disabled / faulted / handshaking / QuickStop / NotReady: target=actual
if (!enableRequested || fault || !opEnabled)
{
servoOut.ControlWord = NextEnableCommand(sw, enableRequested && !fault);
servoOut.TargetPosition = servoIn.ActualPosition;
return;
}
// Only OperationEnabled may send sine targets
servoOut.ControlWord = CW_ENABLE_OPERATION;
if (!isRunning)
{
servoOut.TargetPosition = servoIn.ActualPosition;
return;
}
var param = testParam;
double t = stopwatch.Elapsed.TotalSeconds;
// 1. Sine-wave displacement -> PDO mapping
double targetDisp = param.Amplitude * Math.Sin(2 * Math.PI * param.Frequency * t);
servoOut.TargetPosition = homePosition + (int)(targetDisp * PulsesPerMm);
// 2. Read the sensor (PDO mapping)
double currentForce = forceIn.Value * ForceScale;
double currentDisp = lvdtIn.Ch1_Value * LvdtScale + LvdtOffset;
// 3. Cycle counter (rising edge at zero crossing)
if (prevTarget < 0 && targetDisp >= 0)
{
if (!initialCalibrated && cycleCount >= 3)
{
initialPeakForce = peakForce;
initialCalibrated = true;
Console.WriteLine($"初始刚度标定: 峰值力 = {initialPeakForce:F1}N"); // Initial stiffness calibration: peak force = {initialPeakForce:F1}N
}
if (initialCalibrated && peakForce < initialPeakForce * param.FailureThreshold)
{
double ratio = peakForce / initialPeakForce * 100;
Console.WriteLine($"\n[试件失效] 刚度退化至 {ratio:F1}%, " + // [Specimen failure] stiffness degraded to {ratio:F1}%,
$"循环数: {cycleCount}"); // Cycle count: {cycleCount}
isRunning = false;
return;
}
cycleCount++;
peakForce = 0;
}
prevTarget = targetDisp;
if (Math.Abs(currentForce) > peakForce)
peakForce = Math.Abs(currentForce);
// 4. Log the data
dataBuffer.Enqueue(new TestDataPoint
{
SampleIndex = sampleIndex++,
Time = t,
TargetDisplacement = targetDisp,
ActualDisplacement = currentDisp,
Force = currentForce,
CycleCount = cycleCount
});
// 5. Safety check
if (Math.Abs(currentForce) > param.MaxForce)
{
Console.WriteLine($"\n[安全停止] 力超限: " + // [Safety stop] force over limit:
$"{currentForce:F1}N > {param.MaxForce:F1}N");
RequestEmergencyStop();
return;
}
// 6. Status display
if ((DateTime.Now - lastDisplayTime).TotalSeconds >= 1)
{
string stiff = initialCalibrated
? $", 刚度: {peakForce / initialPeakForce * 100:F1}%" // , Stiffness: {peakForce / initialPeakForce * 100:F1}%
: "";
Console.WriteLine(
$"循环: {cycleCount}/{param.MaxCycles}, " + // Cycles: {cycleCount}/{param.MaxCycles},
$"力: {currentForce:F1}N, " + // Force: {currentForce:F1}N,
$"位移: {currentDisp:F3}mm{stiff}"); // Displacement: {currentDisp:F3}mm{stiff}
lastDisplayTime = DateTime.Now;
}
}
catch (Exception ex)
{
Console.WriteLine($"PDO 周期回调异常: {ex.Message}"); // PDO cyclic callback exception: {ex.Message}
}
}
/// <summary>
/// Emergency stop request: only sets a flag; Quick Stop is executed by the PDO callback through the state machine (never blocks inside the callback)
/// </summary>
static void RequestEmergencyStop()
{
emergencyStopRequested = true;
enableRequested = false; // Withdraw the enable request: after an emergency stop it must not re-enable automatically before the operator resets it
isRunning = false;
Console.WriteLine("[紧急停止] 已请求 Quick Stop (0x0002), " + // [Emergency stop] Quick Stop (0x0002) requested,
"由周期回调确认 QuickStopActive 后发 0x0000 退出, 再回 0x0006 失能"); // once QuickStopActive is confirmed by the cyclic callback, send 0x0000 to exit, then send 0x0006 to disable
}
/// <summary>
/// Data logging thread (low-frequency batched writes)
/// </summary>
static void DataLogLoop(string filename)
{
using (var writer = new StreamWriter(filename))
{
writer.WriteLine("Index,Time_s,Target_mm," +
"Actual_mm,Force_N,Cycle");
while (isRunning)
{
while (dataBuffer.TryDequeue(out var d))
{
writer.WriteLine(
$"{d.SampleIndex},{d.Time:F3}," +
$"{d.TargetDisplacement:F4}," +
$"{d.ActualDisplacement:F4}," +
$"{d.Force:F2},{d.CycleCount}");
}
writer.Flush();
Thread.Sleep(100);
}
}
}
}
Complete example code
This page is a scenario description; for a runnable reference see Ezi-SERVO2_CSP_PP (single-axis CiA 402, CSP / PP dual mode, real PDO mapping and a cyclic-callback state machine). The weighing / analog acquisition and the stiffness decision are custom to this page's scenario; the reference project has no corresponding implementation.