更新
This commit is contained in:
@@ -222,7 +222,8 @@ namespace COFTester.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 零點標定,向 M1300 寫入命令 1
|
||||
/// 零點標定,向 M1300 寫入脉冲信号(复归型按钮)
|
||||
/// 实现方式:写入 true → 延迟 100ms → 写入 false → 延迟 100ms
|
||||
/// </summary>
|
||||
public virtual async void ZeroCalibration()
|
||||
{
|
||||
@@ -230,8 +231,23 @@ namespace COFTester.Services
|
||||
{
|
||||
if (_modbusMaster != null && _isConnected)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("[Modbus] 發送零點標定命令 (1) 到 M1300");
|
||||
await WriteCalibrationRegisterAsync((ushort)ModbusCalibrationCommand.ZeroCalibration);
|
||||
System.Diagnostics.Debug.WriteLine("[Modbus] 發送零點標定脉冲命令到 M1300");
|
||||
|
||||
// 写入 true(触发)
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 1300, true);
|
||||
System.Diagnostics.Debug.WriteLine("[Modbus] M1300 = true");
|
||||
|
||||
// 延迟 100ms
|
||||
await Task.Delay(100);
|
||||
|
||||
// 写入 false(复位)
|
||||
await _modbusMaster.WriteSingleCoilAsync(1, 1300, false);
|
||||
System.Diagnostics.Debug.WriteLine("[Modbus] M1300 = false");
|
||||
|
||||
// 延迟 100ms 确保 PLC 处理完成
|
||||
await Task.Delay(100);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("[Modbus] 零點標定脉冲命令发送完成");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user