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 1938e60..71a94f9 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 - 240 + 208 0 Max SubIndex @@ -154,7 +154,7 @@ 5 - OhmicSensingSetupTime + OhmicSensingVoltageLimit UDINT 32 144 @@ -164,20 +164,10 @@ 6 - OhmicSensingVoltageLimit - UDINT - 32 - 176 - - ro - - - - 7 OhmicSensingVoltageDrop UDINT 32 - 208 + 176 ro @@ -185,7 +175,7 @@ DT1602 - 240 + 208 0 Max SubIndex @@ -238,7 +228,7 @@ 5 - OhmicSensingSetupTime + OhmicSensingVoltageLimit UDINT 32 144 @@ -248,20 +238,10 @@ 6 - OhmicSensingVoltageLimit - UDINT - 32 - 176 - - ro - - - - 7 OhmicSensingVoltageDrop UDINT 32 - 208 + 176 ro @@ -517,7 +497,7 @@ DT2000 - 64 + 96 0 Max SubIndex @@ -558,10 +538,30 @@ rw + + 4 + OhmicSensingSetupTime + UINT + 16 + 64 + + rw + + + + 5 + OhmicSensingPulseLength + UINT + 16 + 80 + + rw + + DT2001 - 64 + 96 0 Max SubIndex @@ -602,6 +602,26 @@ rw + + 4 + OhmicSensingSetupTime + UINT + 16 + 64 + + rw + + + + 5 + OhmicSensingPulseLength + UINT + 16 + 80 + + rw + + DT6001 @@ -743,7 +763,7 @@ DT7001 - 216 + 184 0 Max SubIndex @@ -800,8 +820,8 @@ 5 - OhmicSensingSetupTime - UDINT + OhmicSensingVoltageLimit + REAL 32 120 @@ -811,21 +831,10 @@ 6 - OhmicSensingVoltageLimit - REAL - 32 - 152 - - ro - R - - - - 7 OhmicSensingVoltageDrop REAL 32 - 184 + 152 ro R @@ -834,7 +843,7 @@ DT7002 - 216 + 184 0 Max SubIndex @@ -891,8 +900,8 @@ 5 - OhmicSensingSetupTime - UDINT + OhmicSensingVoltageLimit + REAL 32 120 @@ -902,21 +911,10 @@ 6 - OhmicSensingVoltageLimit - REAL - 32 - 152 - - ro - R - - - - 7 OhmicSensingVoltageDrop REAL 32 - 184 + 152 ro R @@ -1069,12 +1067,12 @@ #x1601 In_Unit1 DT1601 - 240 + 208 Max SubIndex - 7 + 6 @@ -1102,21 +1100,15 @@ - OhmicSensingSetupTime + OhmicSensingVoltageLimit #x70010520 - - OhmicSensingVoltageLimit - - #x70010620 - - OhmicSensingVoltageDrop - #x70010720 + #x70010620 @@ -1127,12 +1119,12 @@ #x1602 In_Unit2 DT1602 - 240 + 208 Max SubIndex - 7 + 6 @@ -1160,21 +1152,15 @@ - OhmicSensingSetupTime + OhmicSensingVoltageLimit #x70020520 - - OhmicSensingVoltageLimit - - #x70020620 - - OhmicSensingVoltageDrop - #x70020720 + #x70020620 @@ -1407,12 +1393,12 @@ #x2000 Settings_Unit1 DT2000 - 64 + 96 Max SubIndex - 3 + 5 @@ -1433,6 +1419,18 @@ 0 + + OhmicSensingSetupTime + + 100 + + + + OhmicSensingPulseLength + + 5 + + @@ -1441,12 +1439,12 @@ #x2001 Settings_Unit2 DT2001 - 64 + 96 Max SubIndex - 3 + 5 @@ -1467,6 +1465,18 @@ 0 + + OhmicSensingSetupTime + + 100 + + + + OhmicSensingPulseLength + + 5 + + @@ -1593,12 +1603,12 @@ #x7001 In_Unit1 DT7001 - 216 + 184 Max SubIndex - 7 + 6 @@ -1625,12 +1635,6 @@ 0 - - OhmicSensingSetupTime - - 0 - - OhmicSensingVoltageLimit @@ -1651,12 +1655,12 @@ #x7002 In_Unit2 DT7002 - 216 + 184 Max SubIndex - 7 + 6 @@ -1683,12 +1687,6 @@ 0 - - OhmicSensingSetupTime - - 0 - - OhmicSensingVoltageLimit @@ -1761,19 +1759,12 @@ #x7001 #x5 32 - OhmicSensingSetupTime - UDINT - - - #x7001 - #x6 - 32 OhmicSensingVoltageLimit REAL #x7001 - #x7 + #x6 32 OhmicSensingVoltageDrop REAL @@ -1814,19 +1805,12 @@ #x7002 #x5 32 - OhmicSensingSetupTime - UDINT - - - #x7002 - #x6 - 32 OhmicSensingVoltageLimit REAL #x7002 - #x7 + #x6 32 OhmicSensingVoltageDrop REAL 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 00c21a6..cc7e92b 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 15 +#define MAX_MAPPINGS_SM2 13 #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 6a3aad0..20d44cf 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 @@ -62,6 +62,20 @@ "value": "0", "access": "RW", "data": "&Obj.Settings_Unit1.LowpassFilterPoleFrequency" + }, + { + "name": "OhmicSensingSetupTime", + "dtype": "UNSIGNED16", + "value": "100", + "access": "RW", + "data": "&Obj.Settings_Unit1.OhmicSensingSetupTime" + }, + { + "name": "OhmicSensingPulseLength", + "dtype": "UNSIGNED16", + "value": "5", + "access": "RW", + "data": "&Obj.Settings_Unit1.OhmicSensingPulseLength" } ], "isSDOitem": true @@ -94,6 +108,20 @@ "value": "0", "access": "RW", "data": "&Obj.Settings_Unit2.LowpassFilterPoleFrequency" + }, + { + "name": "OhmicSensingSetupTime", + "dtype": "UNSIGNED16", + "value": "100", + "access": "RW", + "data": "&Obj.Settings_Unit2.OhmicSensingSetupTime" + }, + { + "name": "OhmicSensingPulseLength", + "dtype": "UNSIGNED16", + "value": "5", + "access": "RW", + "data": "&Obj.Settings_Unit2.OhmicSensingPulseLength" } ], "isSDOitem": true @@ -281,13 +309,6 @@ "access": "RO", "data": "&Obj.In_Unit1.EnableOhmicSensing" }, - { - "name": "OhmicSensingSetupTime", - "dtype": "UNSIGNED32", - "value": "0", - "access": "RO", - "data": "&Obj.In_Unit1.OhmicSensingSetupTime" - }, { "name": "OhmicSensingVoltageLimit", "dtype": "REAL32", @@ -343,13 +364,6 @@ "access": "RO", "data": "&Obj.In_Unit2.EnableOhmicSensing" }, - { - "name": "OhmicSensingSetupTime", - "dtype": "UNSIGNED32", - "value": "0", - "access": "RO", - "data": "&Obj.In_Unit2.OhmicSensingSetupTime" - }, { "name": "OhmicSensingVoltageLimit", "dtype": "REAL32", 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 a065313..ab1f73d 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 @@ -22,18 +22,16 @@ static const char acName1601_01[] = "VoltageScale"; static const char acName1601_02[] = "VoltageOffset"; 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 acName1601_05[] = "OhmicSensingVoltageLimit"; +static const char acName1601_06[] = "OhmicSensingVoltageDrop"; static const char acName1602[] = "In_Unit2"; static const char acName1602_00[] = "Max SubIndex"; static const char acName1602_01[] = "VoltageScale"; static const char acName1602_02[] = "VoltageOffset"; 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 acName1602_05[] = "OhmicSensingVoltageLimit"; +static const char acName1602_06[] = "OhmicSensingVoltageDrop"; static const char acName1A00[] = "Input12"; static const char acName1A00_00[] = "Max SubIndex"; static const char acName1A00_01[] = "Input12"; @@ -72,11 +70,15 @@ static const char acName2000_00[] = "Max SubIndex"; static const char acName2000_01[] = "I2C_devicetype"; static const char acName2000_02[] = "I2C_address"; static const char acName2000_03[] = "LowpassFilterPoleFrequency"; +static const char acName2000_04[] = "OhmicSensingSetupTime"; +static const char acName2000_05[] = "OhmicSensingPulseLength"; static const char acName2001[] = "Settings_Unit2"; static const char acName2001_00[] = "Max SubIndex"; static const char acName2001_01[] = "I2C_devicetype"; static const char acName2001_02[] = "I2C_address"; static const char acName2001_03[] = "LowpassFilterPoleFrequency"; +static const char acName2001_04[] = "OhmicSensingSetupTime"; +static const char acName2001_05[] = "OhmicSensingPulseLength"; static const char acName6000[] = "Input12"; static const char acName6001[] = "Out_Unit1"; static const char acName6001_00[] = "Max SubIndex"; @@ -99,18 +101,16 @@ static const char acName7001_01[] = "VoltageScale"; static const char acName7001_02[] = "VoltageOffset"; 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 acName7001_05[] = "OhmicSensingVoltageLimit"; +static const char acName7001_06[] = "OhmicSensingVoltageDrop"; static const char acName7002[] = "In_Unit2"; static const char acName7002_00[] = "Max SubIndex"; static const char acName7002_01[] = "VoltageScale"; static const char acName7002_02[] = "VoltageOffset"; 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"; +static const char acName7002_05[] = "OhmicSensingVoltageLimit"; +static const char acName7002_06[] = "OhmicSensingVoltageDrop"; const _objd SDO1000[] = { @@ -143,25 +143,23 @@ const _objd SDO1600[] = }; const _objd SDO1601[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 7, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 6, 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, 7, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1602_00, 6, 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[] = { @@ -210,17 +208,21 @@ const _objd SDO1C13[] = }; const _objd SDO2000[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName2000_00, 3, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName2000_00, 5, NULL}, {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RW, acName2000_01, 0, &Obj.Settings_Unit1.I2C_devicetype}, {0x02, DTYPE_UNSIGNED8, 8, ATYPE_RW, acName2000_02, 0, &Obj.Settings_Unit1.I2C_address}, {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName2000_03, 0, &Obj.Settings_Unit1.LowpassFilterPoleFrequency}, + {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName2000_04, 100, &Obj.Settings_Unit1.OhmicSensingSetupTime}, + {0x05, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName2000_05, 5, &Obj.Settings_Unit1.OhmicSensingPulseLength}, }; const _objd SDO2001[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName2001_00, 3, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName2001_00, 5, NULL}, {0x01, DTYPE_UNSIGNED8, 8, ATYPE_RW, acName2001_01, 0, &Obj.Settings_Unit2.I2C_devicetype}, {0x02, DTYPE_UNSIGNED8, 8, ATYPE_RW, acName2001_02, 0, &Obj.Settings_Unit2.I2C_address}, {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName2001_03, 0, &Obj.Settings_Unit2.LowpassFilterPoleFrequency}, + {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName2001_04, 100, &Obj.Settings_Unit2.OhmicSensingSetupTime}, + {0x05, DTYPE_UNSIGNED16, 16, ATYPE_RW, acName2001_05, 5, &Obj.Settings_Unit2.OhmicSensingPulseLength}, }; const _objd SDO6000[] = { @@ -250,25 +252,23 @@ const _objd SDO7000[] = }; const _objd SDO7001[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7001_00, 7, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7001_00, 6, 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}, + {0x05, DTYPE_REAL32, 32, ATYPE_RO, acName7001_05, 0x00000000, &Obj.In_Unit1.OhmicSensingVoltageLimit}, + {0x06, DTYPE_REAL32, 32, ATYPE_RO, acName7001_06, 0x00000000, &Obj.In_Unit1.OhmicSensingVoltageDrop}, }; const _objd SDO7002[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7002_00, 7, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName7002_00, 6, 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}, + {0x05, DTYPE_REAL32, 32, ATYPE_RO, acName7002_05, 0x00000000, &Obj.In_Unit2.OhmicSensingVoltageLimit}, + {0x06, DTYPE_REAL32, 32, ATYPE_RO, acName7002_06, 0x00000000, &Obj.In_Unit2.OhmicSensingVoltageDrop}, }; const _objectlist SDOobjects[] = @@ -279,21 +279,21 @@ 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, 7, 0, acName1601, SDO1601}, - {0x1602, OTYPE_RECORD, 7, 0, acName1602, SDO1602}, + {0x1601, OTYPE_RECORD, 6, 0, acName1601, SDO1601}, + {0x1602, OTYPE_RECORD, 6, 0, acName1602, SDO1602}, {0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00}, {0x1A01, OTYPE_RECORD, 5, 0, acName1A01, SDO1A01}, {0x1A02, OTYPE_RECORD, 5, 0, acName1A02, SDO1A02}, {0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00}, {0x1C12, OTYPE_ARRAY, 3, 0, acName1C12, SDO1C12}, {0x1C13, OTYPE_ARRAY, 3, 0, acName1C13, SDO1C13}, - {0x2000, OTYPE_RECORD, 3, 0, acName2000, SDO2000}, - {0x2001, OTYPE_RECORD, 3, 0, acName2001, SDO2001}, + {0x2000, OTYPE_RECORD, 5, 0, acName2000, SDO2000}, + {0x2001, OTYPE_RECORD, 5, 0, acName2001, SDO2001}, {0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000}, {0x6001, OTYPE_RECORD, 5, 0, acName6001, SDO6001}, {0x6002, OTYPE_RECORD, 5, 0, acName6002, SDO6002}, {0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000}, - {0x7001, OTYPE_RECORD, 7, 0, acName7001, SDO7001}, - {0x7002, OTYPE_RECORD, 7, 0, acName7002, SDO7002}, + {0x7001, OTYPE_RECORD, 6, 0, acName7001, SDO7001}, + {0x7002, OTYPE_RECORD, 6, 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 3468255..50e8a24 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 @@ -40,7 +40,6 @@ typedef struct float VoltageOffset; float LowPassFilterThresholdVoltage; uint8_t EnableOhmicSensing; - uint32_t OhmicSensingSetupTime; float OhmicSensingVoltageLimit; float OhmicSensingVoltageDrop; } In_Unit1; @@ -50,7 +49,6 @@ typedef struct float VoltageOffset; float LowPassFilterThresholdVoltage; uint8_t EnableOhmicSensing; - uint32_t OhmicSensingSetupTime; float OhmicSensingVoltageLimit; float OhmicSensingVoltageDrop; } In_Unit2; @@ -62,12 +60,16 @@ typedef struct uint8_t I2C_devicetype; uint8_t I2C_address; uint32_t LowpassFilterPoleFrequency; + uint16_t OhmicSensingSetupTime; + uint16_t OhmicSensingPulseLength; } Settings_Unit1; struct { uint8_t I2C_devicetype; uint8_t I2C_address; uint32_t LowpassFilterPoleFrequency; + uint16_t OhmicSensingSetupTime; + uint16_t OhmicSensingPulseLength; } Settings_Unit2; } _Objects; diff --git a/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp b/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp index 63c6664..dbe2e11 100755 --- a/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp +++ b/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp @@ -45,13 +45,14 @@ void ads1014_reset(ADS1014 *ads) { class OhmicSensing { public: void handle(uint8_t voltageState, float inVoltage, float limitVoltage, - float voltageDropLimit, uint32_t setupTime, uint8_t enabled, - uint8_t &sensed); + float voltageDropLimit, uint32_t setupTime, uint16_t pulseLength, + uint8_t enabled, uint8_t &sensed); // private: - enum OhmicStates { OHMIC_IDLE, OHMIC_SETUP, OHMIC_PROBE }; + enum OhmicStates { OHMIC_IDLE, OHMIC_SETUP, OHMIC_PROBE, OHMIC_PULSE }; OhmicStates ohmicState = OHMIC_IDLE; uint64_t startTime; + uint64_t contactTime; float_t oldVoltage = 0.0; std::queue voltages; float_t refVoltage; @@ -126,16 +127,20 @@ void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation Obj.Out_Unit2.CalculatedVoltage, Obj.Out_Unit2.LowpassFilteredVoltage); - Ohm1.handle( - stat_1, Obj.Out_Unit1.CalculatedVoltage, - 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.OhmicSensingVoltageDrop, Obj.In_Unit2.OhmicSensingSetupTime, - Obj.In_Unit2.EnableOhmicSensing, Obj.Out_Unit2.OhmicSensingSensed); + Ohm1.handle(stat_1, Obj.Out_Unit1.CalculatedVoltage, + Obj.In_Unit1.OhmicSensingVoltageLimit, + Obj.In_Unit1.OhmicSensingVoltageDrop, + Obj.Settings_Unit1.OhmicSensingSetupTime, + Obj.Settings_Unit1.OhmicSensingPulseLength, + Obj.In_Unit1.EnableOhmicSensing, + Obj.Out_Unit1.OhmicSensingSensed); + Ohm2.handle(stat_2, Obj.Out_Unit2.CalculatedVoltage, + Obj.In_Unit2.OhmicSensingVoltageLimit, + Obj.In_Unit2.OhmicSensingVoltageDrop, + Obj.Settings_Unit2.OhmicSensingSetupTime, + Obj.Settings_Unit2.OhmicSensingPulseLength, + Obj.In_Unit2.EnableOhmicSensing, + Obj.Out_Unit2.OhmicSensingSensed); Obj.Out_Unit1.RawData = (int)Ohm2.ohmicState; } @@ -370,8 +375,8 @@ void lowpassFilter(float &oldLowPassGain, #define N_VOLTAGES 3 void OhmicSensing::handle(uint8_t voltageState, float inVoltage, float limitVoltage, float voltageDropLimit, - uint32_t setupTime, uint8_t enabled, - uint8_t &sensed) { + uint32_t setupTime, uint16_t pulseLength, + uint8_t enabled, uint8_t &sensed) { sensed = 0; uint64_t dTime; Obj.Out_Unit1.RawData = ohmicState; @@ -381,19 +386,18 @@ void OhmicSensing::handle(uint8_t voltageState, float inVoltage, startTime = longTime.extendTime(micros()); while (!voltages.empty()) voltages.pop(); // Remove history - return; } - if (ohmicState == OHMIC_SETUP) { + switch (ohmicState) { + case OHMIC_SETUP: dTime = longTime.extendTime(micros()) - startTime; if (dTime > setupTime * 1000) { ohmicState = OHMIC_PROBE; startTime = longTime.extendTime(micros()); oldVoltage = 0.0; refVoltage = inVoltage; // RefVoltage = voltage at end of setup - return; } - } - if (ohmicState == OHMIC_PROBE) { + break; + case OHMIC_PROBE: { dTime = longTime.extendTime(micros()) - startTime; voltages.push(inVoltage); while (voltages.size() > N_VOLTAGES) @@ -403,6 +407,7 @@ void OhmicSensing::handle(uint8_t voltageState, float inVoltage, return; } byte c1 = (inVoltage <= limitVoltage) ? 1 : 0; // Below starting threshold + byte c2 = (fabs(voltageDropLimit) > 1e-3 && refVoltage - inVoltage >= voltageDropLimit) ? 2 @@ -417,10 +422,26 @@ void OhmicSensing::handle(uint8_t voltageState, float inVoltage, : 0; Obj.Out_Unit2.RawData = c1 + c2 + c3 + c4; if (c1 + c2 + c3 + c4 > 0) { - sensed = 1; + if (pulseLength == 0) { // Real pulse length + sensed = 1; + } else { // Timed pulse length + contactTime = longTime.extendTime(micros()); + sensed = 1; + ohmicState = OHMIC_PULSE; + } } + } oldVoltage = inVoltage; - return; + break; + case OHMIC_PULSE: // For a pulse with a set length + int dTime = longTime.extendTime(micros()) - contactTime; + if (dTime < pulseLength * 1000) { + sensed = 1; + } else { + sensed = 0; + ohmicState = OHMIC_IDLE; + } + break; } } else { ohmicState = OHMIC_IDLE;