From b3bb88cf08e29bdff30be12077ac803ca3f991c4 Mon Sep 17 00:00:00 2001 From: Hakan Bastedt Date: Wed, 8 Oct 2025 13:29:54 +0200 Subject: [PATCH] New option: voltagedrop for sensing ohmic sensing --- .../soes-esi/MetalMusings_EaserCAT_7000.xml | 104 ++++++++++++++++-- .../Firmware/lib/soes-esi/ecat_options.h | 2 +- .../Firmware/lib/soes-esi/esi.json | 14 +++ .../Firmware/lib/soes-esi/objectlist.c | 24 ++-- .../Firmware/lib/soes-esi/utypes.h | 2 + .../Firmware/src/main.cpp | 21 ++-- 6 files changed, 139 insertions(+), 28 deletions(-) diff --git a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/MetalMusings_EaserCAT_7000.xml b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/MetalMusings_EaserCAT_7000.xml index a1b69b4..1938e60 100755 --- a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/MetalMusings_EaserCAT_7000.xml +++ b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/MetalMusings_EaserCAT_7000.xml @@ -101,7 +101,7 @@ DT1601 - 208 + 240 0 Max SubIndex @@ -172,10 +172,20 @@ ro + + 7 + OhmicSensingVoltageDrop + UDINT + 32 + 208 + + ro + + DT1602 - 208 + 240 0 Max SubIndex @@ -246,6 +256,16 @@ ro + + 7 + OhmicSensingVoltageDrop + UDINT + 32 + 208 + + ro + + DT1A00 @@ -723,7 +743,7 @@ DT7001 - 184 + 216 0 Max SubIndex @@ -800,10 +820,21 @@ R + + 7 + OhmicSensingVoltageDrop + REAL + 32 + 184 + + ro + R + + DT7002 - 184 + 216 0 Max SubIndex @@ -880,6 +911,17 @@ R + + 7 + OhmicSensingVoltageDrop + REAL + 32 + 184 + + ro + R + + UDINT @@ -1027,12 +1069,12 @@ #x1601 In_Unit1 DT1601 - 208 + 240 Max SubIndex - 6 + 7 @@ -1071,6 +1113,12 @@ #x70010620 + + OhmicSensingVoltageDrop + + #x70010720 + + @@ -1079,12 +1127,12 @@ #x1602 In_Unit2 DT1602 - 208 + 240 Max SubIndex - 6 + 7 @@ -1123,6 +1171,12 @@ #x70020620 + + OhmicSensingVoltageDrop + + #x70020720 + + @@ -1539,12 +1593,12 @@ #x7001 In_Unit1 DT7001 - 184 + 216 Max SubIndex - 6 + 7 @@ -1583,6 +1637,12 @@ 0 + + OhmicSensingVoltageDrop + + 0 + + @@ -1591,12 +1651,12 @@ #x7002 In_Unit2 DT7002 - 184 + 216 Max SubIndex - 6 + 7 @@ -1635,6 +1695,12 @@ 0 + + OhmicSensingVoltageDrop + + 0 + + @@ -1705,6 +1771,13 @@ OhmicSensingVoltageLimit REAL + + #x7001 + #x7 + 32 + OhmicSensingVoltageDrop + REAL + #x1602 @@ -1751,6 +1824,13 @@ OhmicSensingVoltageLimit REAL + + #x7002 + #x7 + 32 + OhmicSensingVoltageDrop + REAL + #x1A00 diff --git a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/ecat_options.h b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/ecat_options.h index cc7e92b..00c21a6 100755 --- a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/ecat_options.h +++ b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/ecat_options.h @@ -33,7 +33,7 @@ #define SM3_smc 0x20 #define SM3_act 1 -#define MAX_MAPPINGS_SM2 13 +#define MAX_MAPPINGS_SM2 15 #define MAX_MAPPINGS_SM3 11 #define MAX_RXPDO_SIZE 512 diff --git a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/esi.json b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/esi.json index 39b2a8d..6a3aad0 100755 --- a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/esi.json +++ b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/esi.json @@ -294,6 +294,13 @@ "value": "0", "access": "RO", "data": "&Obj.In_Unit1.OhmicSensingVoltageLimit" + }, + { + "name": "OhmicSensingVoltageDrop", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit1.OhmicSensingVoltageDrop" } ], "pdo_mappings": [ @@ -349,6 +356,13 @@ "value": "0", "access": "RO", "data": "&Obj.In_Unit2.OhmicSensingVoltageLimit" + }, + { + "name": "OhmicSensingVoltageDrop", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit2.OhmicSensingVoltageDrop" } ], "pdo_mappings": [ diff --git a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/objectlist.c b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/objectlist.c index 77b2764..a065313 100755 --- a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/objectlist.c +++ b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/objectlist.c @@ -24,6 +24,7 @@ static const char acName1601_03[] = "LowPassFilterThresholdVoltage"; static const char acName1601_04[] = "EnableOhmicSensing"; static const char acName1601_05[] = "OhmicSensingSetupTime"; static const char acName1601_06[] = "OhmicSensingVoltageLimit"; +static const char acName1601_07[] = "OhmicSensingVoltageDrop"; static const char acName1602[] = "In_Unit2"; static const char acName1602_00[] = "Max SubIndex"; static const char acName1602_01[] = "VoltageScale"; @@ -32,6 +33,7 @@ static const char acName1602_03[] = "LowPassFilterThresholdVoltage"; static const char acName1602_04[] = "EnableOhmicSensing"; static const char acName1602_05[] = "OhmicSensingSetupTime"; static const char acName1602_06[] = "OhmicSensingVoltageLimit"; +static const char acName1602_07[] = "OhmicSensingVoltageDrop"; static const char acName1A00[] = "Input12"; static const char acName1A00_00[] = "Max SubIndex"; static const char acName1A00_01[] = "Input12"; @@ -99,6 +101,7 @@ static const char acName7001_03[] = "LowPassFilterThresholdVoltage"; static const char acName7001_04[] = "EnableOhmicSensing"; static const char acName7001_05[] = "OhmicSensingSetupTime"; static const char acName7001_06[] = "OhmicSensingVoltageLimit"; +static const char acName7001_07[] = "OhmicSensingVoltageDrop"; static const char acName7002[] = "In_Unit2"; static const char acName7002_00[] = "Max SubIndex"; static const char acName7002_01[] = "VoltageScale"; @@ -107,6 +110,7 @@ static const char acName7002_03[] = "LowPassFilterThresholdVoltage"; static const char acName7002_04[] = "EnableOhmicSensing"; static const char acName7002_05[] = "OhmicSensingSetupTime"; static const char acName7002_06[] = "OhmicSensingVoltageLimit"; +static const char acName7002_07[] = "OhmicSensingVoltageDrop"; const _objd SDO1000[] = { @@ -139,23 +143,25 @@ const _objd SDO1600[] = }; const _objd SDO1601[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 6, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 7, NULL}, {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_01, 0x70010120, NULL}, {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_02, 0x70010220, NULL}, {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_03, 0x70010320, NULL}, {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_04, 0x70010408, NULL}, {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_05, 0x70010520, NULL}, {0x06, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_06, 0x70010620, NULL}, + {0x07, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_07, 0x70010720, NULL}, }; const _objd SDO1602[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1602_00, 6, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1602_00, 7, NULL}, {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_01, 0x70020120, NULL}, {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_02, 0x70020220, NULL}, {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_03, 0x70020320, NULL}, {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_04, 0x70020408, NULL}, {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_05, 0x70020520, NULL}, {0x06, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_06, 0x70020620, NULL}, + {0x07, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_07, 0x70020720, NULL}, }; const _objd SDO1A00[] = { @@ -244,23 +250,25 @@ const _objd SDO7000[] = }; const _objd SDO7001[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7001_00, 6, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7001_00, 7, NULL}, {0x01, DTYPE_REAL32, 32, ATYPE_RO, acName7001_01, 0x00000000, &Obj.In_Unit1.VoltageScale}, {0x02, DTYPE_REAL32, 32, ATYPE_RO, acName7001_02, 0x00000000, &Obj.In_Unit1.VoltageOffset}, {0x03, DTYPE_REAL32, 32, ATYPE_RO, acName7001_03, 0x00000000, &Obj.In_Unit1.LowPassFilterThresholdVoltage}, {0x04, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7001_04, 0, &Obj.In_Unit1.EnableOhmicSensing}, {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName7001_05, 0, &Obj.In_Unit1.OhmicSensingSetupTime}, {0x06, DTYPE_REAL32, 32, ATYPE_RO, acName7001_06, 0x00000000, &Obj.In_Unit1.OhmicSensingVoltageLimit}, + {0x07, DTYPE_REAL32, 32, ATYPE_RO, acName7001_07, 0x00000000, &Obj.In_Unit1.OhmicSensingVoltageDrop}, }; const _objd SDO7002[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7002_00, 6, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7002_00, 7, NULL}, {0x01, DTYPE_REAL32, 32, ATYPE_RO, acName7002_01, 0x00000000, &Obj.In_Unit2.VoltageScale}, {0x02, DTYPE_REAL32, 32, ATYPE_RO, acName7002_02, 0x00000000, &Obj.In_Unit2.VoltageOffset}, {0x03, DTYPE_REAL32, 32, ATYPE_RO, acName7002_03, 0x00000000, &Obj.In_Unit2.LowPassFilterThresholdVoltage}, {0x04, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7002_04, 0, &Obj.In_Unit2.EnableOhmicSensing}, {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName7002_05, 0, &Obj.In_Unit2.OhmicSensingSetupTime}, {0x06, DTYPE_REAL32, 32, ATYPE_RO, acName7002_06, 0x00000000, &Obj.In_Unit2.OhmicSensingVoltageLimit}, + {0x07, DTYPE_REAL32, 32, ATYPE_RO, acName7002_07, 0x00000000, &Obj.In_Unit2.OhmicSensingVoltageDrop}, }; const _objectlist SDOobjects[] = @@ -271,8 +279,8 @@ const _objectlist SDOobjects[] = {0x100A, OTYPE_VAR, 0, 0, acName100A, SDO100A}, {0x1018, OTYPE_RECORD, 4, 0, acName1018, SDO1018}, {0x1600, OTYPE_RECORD, 1, 0, acName1600, SDO1600}, - {0x1601, OTYPE_RECORD, 6, 0, acName1601, SDO1601}, - {0x1602, OTYPE_RECORD, 6, 0, acName1602, SDO1602}, + {0x1601, OTYPE_RECORD, 7, 0, acName1601, SDO1601}, + {0x1602, OTYPE_RECORD, 7, 0, acName1602, SDO1602}, {0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00}, {0x1A01, OTYPE_RECORD, 5, 0, acName1A01, SDO1A01}, {0x1A02, OTYPE_RECORD, 5, 0, acName1A02, SDO1A02}, @@ -285,7 +293,7 @@ const _objectlist SDOobjects[] = {0x6001, OTYPE_RECORD, 5, 0, acName6001, SDO6001}, {0x6002, OTYPE_RECORD, 5, 0, acName6002, SDO6002}, {0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000}, - {0x7001, OTYPE_RECORD, 6, 0, acName7001, SDO7001}, - {0x7002, OTYPE_RECORD, 6, 0, acName7002, SDO7002}, + {0x7001, OTYPE_RECORD, 7, 0, acName7001, SDO7001}, + {0x7002, OTYPE_RECORD, 7, 0, acName7002, SDO7002}, {0xffff, 0xff, 0xff, 0xff, NULL, NULL} }; diff --git a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/utypes.h b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/utypes.h index f002718..3468255 100755 --- a/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/utypes.h +++ b/Cards/EaserCAT-7000-DIO+I2C/Firmware/lib/soes-esi/utypes.h @@ -42,6 +42,7 @@ typedef struct uint8_t EnableOhmicSensing; uint32_t OhmicSensingSetupTime; float OhmicSensingVoltageLimit; + float OhmicSensingVoltageDrop; } In_Unit1; struct { @@ -51,6 +52,7 @@ typedef struct uint8_t EnableOhmicSensing; uint32_t OhmicSensingSetupTime; float OhmicSensingVoltageLimit; + float OhmicSensingVoltageDrop; } In_Unit2; /* Parameters */ diff --git a/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp b/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp index 6c7ed0d..3f945d5 100755 --- a/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp +++ b/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp @@ -46,7 +46,8 @@ void ads1014_reset(ADS1014 *ads) { class OhmicSensing { public: void handle(uint8_t voltageState, float inVoltage, float limitVoltage, - uint32_t setupTime, uint8_t enabled, uint8_t &sensed); + float voltageDropLimit, uint32_t setupTime, uint8_t enabled, + uint8_t &sensed); private: enum OhmicStates { OHMIC_IDLE, OHMIC_SETUP, OHMIC_PROBE }; @@ -128,11 +129,13 @@ void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation Ohm1.handle( stat_1, Obj.Out_Unit1.CalculatedVoltage, - Obj.In_Unit1.OhmicSensingVoltageLimit, Obj.In_Unit1.OhmicSensingSetupTime, + Obj.In_Unit1.OhmicSensingVoltageLimit, + Obj.In_Unit1.OhmicSensingVoltageDrop, Obj.In_Unit1.OhmicSensingSetupTime, Obj.In_Unit1.EnableOhmicSensing, Obj.Out_Unit1.OhmicSensingSensed); Ohm2.handle( stat_2, Obj.Out_Unit2.CalculatedVoltage, - Obj.In_Unit2.OhmicSensingVoltageLimit, Obj.In_Unit2.OhmicSensingSetupTime, + Obj.In_Unit2.OhmicSensingVoltageLimit, + Obj.In_Unit2.OhmicSensingVoltageDrop, Obj.In_Unit2.OhmicSensingSetupTime, Obj.In_Unit2.EnableOhmicSensing, Obj.Out_Unit2.OhmicSensingSensed); } @@ -427,8 +430,9 @@ void lowpassFilter(float &oldLowPassGain, } void OhmicSensing::handle(uint8_t voltageState, float inVoltage, - float limitVoltage, uint32_t setupTime, - uint8_t enabled, uint8_t &sensed) { + float limitVoltage, float voltageDropLimit, + uint32_t setupTime, uint8_t enabled, + uint8_t &sensed) { sensed = 0; if (enabled && voltageState == 0) { if (ohmicState == OHMIC_IDLE && inVoltage > limitVoltage) { @@ -446,8 +450,11 @@ void OhmicSensing::handle(uint8_t voltageState, float inVoltage, voltages.push(inVoltage); #define N_VOLTAGES 3 while (voltages.size() > N_VOLTAGES) voltages.pop(); // Only N_VOLTAGES - if (inVoltage <= limitVoltage || oldVoltage - inVoltage >= 1.0 || - voltages.front() - voltages.back() > 2.0) { + if (inVoltage <= limitVoltage || // Below threshold + (abs(voltageDropLimit) > 1e-3 && // Immediate drop + oldVoltage - inVoltage >= voltageDropLimit) || + (abs(voltageDropLimit) > 1e-3 && // Drop over 3 cycles + voltages.front() - voltages.back() > voltageDropLimit)) { sensed = 1; } oldVoltage = inVoltage;