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 dd63af7..a1b69b4 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 - 48 + 208 0 Max SubIndex @@ -122,106 +122,60 @@ ro - - - DT1602 - 48 - 0 - Max SubIndex - USINT - 8 - 0 - - ro - - - - 1 + 2 VoltageOffset UDINT 32 - 16 - - ro - - - - - DT1603 - 48 - - 0 - Max SubIndex - USINT - 8 - 0 + 48 ro - 1 + 3 LowPassFilterThresholdVoltage UDINT 32 - 16 - - ro - - - - - DT1604 - 48 - - 0 - Max SubIndex - USINT - 8 - 0 + 80 ro - 1 + 4 EnableOhmicSensing UDINT 32 - 16 - - ro - - - - - DT1605 - 48 - - 0 - Max SubIndex - USINT - 8 - 0 + 112 ro - 1 + 5 OhmicSensingSetupTime UDINT 32 - 16 + 144 + + ro + + + + 6 + OhmicSensingVoltageLimit + UDINT + 32 + 176 ro - DT1606 - 48 + DT1602 + 208 0 Max SubIndex @@ -234,7 +188,7 @@ 1 - OhmicSensingVoltageLimit + VoltageScale UDINT 32 16 @@ -242,6 +196,56 @@ ro + + 2 + VoltageOffset + UDINT + 32 + 48 + + ro + + + + 3 + LowPassFilterThresholdVoltage + UDINT + 32 + 80 + + ro + + + + 4 + EnableOhmicSensing + UDINT + 32 + 112 + + ro + + + + 5 + OhmicSensingSetupTime + UDINT + 32 + 144 + + ro + + + + 6 + OhmicSensingVoltageLimit + UDINT + 32 + 176 + + ro + + DT1A00 @@ -269,7 +273,7 @@ DT1A01 - 48 + 176 0 Max SubIndex @@ -290,82 +294,50 @@ ro - - - DT1A02 - 48 - 0 - Max SubIndex - USINT - 8 - 0 - - ro - - - - 1 + 2 CalculatedVoltage UDINT 32 - 16 - - ro - - - - - DT1A03 - 48 - - 0 - Max SubIndex - USINT - 8 - 0 + 48 ro - 1 + 3 Status UDINT 32 - 16 - - ro - - - - - DT1A04 - 48 - - 0 - Max SubIndex - USINT - 8 - 0 + 80 ro - 1 + 4 LowpassFilteredVoltage UDINT 32 - 16 + 112 + + ro + + + + 5 + OhmicSensingSensed + UDINT + 32 + 144 ro - DT1A05 - 48 + DT1A02 + 176 0 Max SubIndex @@ -378,7 +350,7 @@ 1 - OhmicSensingSensed + RawData UDINT 32 16 @@ -386,6 +358,46 @@ ro + + 2 + CalculatedVoltage + UDINT + 32 + 48 + + ro + + + + 3 + Status + UDINT + 32 + 80 + + ro + + + + 4 + LowpassFilteredVoltage + UDINT + 32 + 112 + + ro + + + + 5 + OhmicSensingSensed + UDINT + 32 + 144 + + ro + + DT1C00ARR @@ -422,15 +434,15 @@ DT1C12ARR UINT - 112 + 48 1 - 7 + 3 DT1C12 - 128 + 64 0 Max SubIndex @@ -444,7 +456,7 @@ Elements DT1C12ARR - 112 + 48 16 ro @@ -454,15 +466,15 @@ DT1C13ARR UINT - 96 + 48 1 - 6 + 3 DT1C13 - 112 + 64 0 Max SubIndex @@ -476,13 +488,399 @@ Elements DT1C13ARR - 96 + 48 16 ro + + DT2000 + 64 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + I2C_devicetype + USINT + 8 + 16 + + rw + + + + 2 + I2C_address + USINT + 8 + 24 + + rw + + + + 3 + LowpassFilterPoleFrequency + UDINT + 32 + 32 + + rw + + + + + DT2001 + 64 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + I2C_devicetype + USINT + 8 + 16 + + rw + + + + 2 + I2C_address + USINT + 8 + 24 + + rw + + + + 3 + LowpassFilterPoleFrequency + UDINT + 32 + 32 + + rw + + + + + DT6001 + 152 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + RawData + DINT + 32 + 16 + + ro + T + + + + 2 + CalculatedVoltage + REAL + 32 + 48 + + ro + T + + + + 3 + Status + UDINT + 32 + 80 + + ro + T + + + + 4 + LowpassFilteredVoltage + REAL + 32 + 112 + + ro + T + + + + 5 + OhmicSensingSensed + USINT + 8 + 144 + + ro + T + + + + + DT6002 + 152 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + RawData + DINT + 32 + 16 + + ro + T + + + + 2 + CalculatedVoltage + REAL + 32 + 48 + + ro + T + + + + 3 + Status + UDINT + 32 + 80 + + ro + T + + + + 4 + LowpassFilteredVoltage + REAL + 32 + 112 + + ro + T + + + + 5 + OhmicSensingSensed + USINT + 8 + 144 + + ro + T + + + + + DT7001 + 184 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + VoltageScale + REAL + 32 + 16 + + ro + R + + + + 2 + VoltageOffset + REAL + 32 + 48 + + ro + R + + + + 3 + LowPassFilterThresholdVoltage + REAL + 32 + 80 + + ro + R + + + + 4 + EnableOhmicSensing + USINT + 8 + 112 + + ro + R + + + + 5 + OhmicSensingSetupTime + UDINT + 32 + 120 + + ro + R + + + + 6 + OhmicSensingVoltageLimit + REAL + 32 + 152 + + ro + R + + + + + DT7002 + 184 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + VoltageScale + REAL + 32 + 16 + + ro + R + + + + 2 + VoltageOffset + REAL + 32 + 48 + + ro + R + + + + 3 + LowPassFilterThresholdVoltage + REAL + 32 + 80 + + ro + R + + + + 4 + EnableOhmicSensing + USINT + 8 + 112 + + ro + R + + + + 5 + OhmicSensingSetupTime + UDINT + 32 + 120 + + ro + R + + + + 6 + OhmicSensingVoltageLimit + REAL + 32 + 152 + + ro + R + + + UDINT 32 @@ -627,20 +1025,50 @@ #x1601 - VoltageScale + In_Unit1 DT1601 - 48 + 208 Max SubIndex - 1 + 6 VoltageScale - #x70010020 + #x70010120 + + + + VoltageOffset + + #x70010220 + + + + LowPassFilterThresholdVoltage + + #x70010320 + + + + EnableOhmicSensing + + #x70010408 + + + + OhmicSensingSetupTime + + #x70010520 + + + + OhmicSensingVoltageLimit + + #x70010620 @@ -649,108 +1077,50 @@ #x1602 - VoltageOffset + In_Unit2 DT1602 - 48 + 208 Max SubIndex - 1 + 6 + + + + VoltageScale + + #x70020120 VoltageOffset - #x70020020 - - - - - - - - #x1603 - LowPassFilterThresholdVoltage - DT1603 - 48 - - - Max SubIndex - - 1 + #x70020220 LowPassFilterThresholdVoltage - #x70030020 - - - - - - - - #x1604 - EnableOhmicSensing - DT1604 - 48 - - - Max SubIndex - - 1 + #x70020320 EnableOhmicSensing - #x70040008 - - - - - - - - #x1605 - OhmicSensingSetupTime - DT1605 - 48 - - - Max SubIndex - - 1 + #x70020408 OhmicSensingSetupTime - #x70050020 - - - - - - - - #x1606 - OhmicSensingVoltageLimit - DT1606 - 48 - - - Max SubIndex - - 1 + #x70020520 OhmicSensingVoltageLimit - #x70060020 + #x70020620 @@ -781,20 +1151,44 @@ #x1A01 - RawData + Out_Unit1 DT1A01 - 48 + 176 Max SubIndex - 1 + 5 RawData - #x60010020 + #x60010120 + + + + CalculatedVoltage + + #x60010220 + + + + Status + + #x60010320 + + + + LowpassFilteredVoltage + + #x60010420 + + + + OhmicSensingSensed + + #x60010508 @@ -803,86 +1197,44 @@ #x1A02 - CalculatedVoltage + Out_Unit2 DT1A02 - 48 + 176 Max SubIndex - 1 + 5 + + + + RawData + + #x60020120 CalculatedVoltage - #x60020020 - - - - - - - - #x1A03 - Status - DT1A03 - 48 - - - Max SubIndex - - 1 + #x60020220 Status - #x60030008 - - - - - - - - #x1A04 - LowpassFilteredVoltage - DT1A04 - 48 - - - Max SubIndex - - 1 + #x60020320 LowpassFilteredVoltage - #x60040020 - - - - - - - - #x1A05 - OhmicSensingSensed - DT1A05 - 48 - - - Max SubIndex - - 1 + #x60020420 OhmicSensingSensed - #x60050008 + #x60020508 @@ -933,12 +1285,12 @@ #x1C12 Sync Manager 2 PDO Assignment DT1C12 - 128 + 64 Max SubIndex - 7 + 3 @@ -959,30 +1311,6 @@ #x1602 - - PDO Mapping - - #x1603 - - - - PDO Mapping - - #x1604 - - - - PDO Mapping - - #x1605 - - - - PDO Mapping - - #x1606 - - @@ -991,12 +1319,12 @@ #x1C13 Sync Manager 3 PDO Assignment DT1C13 - 112 + 64 Max SubIndex - 6 + 3 @@ -1017,62 +1345,76 @@ #x1A02 - - PDO Mapping - - #x1A03 - - - - PDO Mapping - - #x1A04 - - - - PDO Mapping - - #x1A05 - - #x2000 - I2C_devicetype - USINT - 8 + Settings_Unit1 + DT2000 + 64 - 0 + + Max SubIndex + + 3 + + + + I2C_devicetype + + 0 + + + + I2C_address + + 0 + + + + LowpassFilterPoleFrequency + + 0 + + - rw #x2001 - I2C_address - USINT - 8 + Settings_Unit2 + DT2001 + 64 - 0 + + Max SubIndex + + 3 + + + + I2C_devicetype + + 0 + + + + I2C_address + + 0 + + + + LowpassFilterPoleFrequency + + 0 + + - rw - - - - #x2002 - LowpassFilterPoleFrequency - UDINT - 32 - - 0 - - - rw @@ -1090,67 +1432,94 @@ #x6001 - RawData - DINT - 32 + Out_Unit1 + DT6001 + 152 - 0 + + Max SubIndex + + 5 + + + + RawData + + 0 + + + + CalculatedVoltage + + 0 + + + + Status + + 0 + + + + LowpassFilteredVoltage + + 0 + + + + OhmicSensingSensed + + 0 + + - ro - T #x6002 - CalculatedVoltage - REAL - 32 + Out_Unit2 + DT6002 + 152 - 0 + + Max SubIndex + + 5 + + + + RawData + + 0 + + + + CalculatedVoltage + + 0 + + + + Status + + 0 + + + + LowpassFilteredVoltage + + 0 + + + + OhmicSensingSensed + + 0 + + - ro - T - - - - #x6003 - Status - USINT - 8 - - 0 - - - ro - T - - - - #x6004 - LowpassFilteredVoltage - REAL - 32 - - 0 - - - ro - T - - - - #x6005 - OhmicSensingSensed - USINT - 8 - - 0 - - - ro - T @@ -1168,80 +1537,106 @@ #x7001 - VoltageScale - REAL - 32 + In_Unit1 + DT7001 + 184 - 0 + + Max SubIndex + + 6 + + + + VoltageScale + + 0 + + + + VoltageOffset + + 0 + + + + LowPassFilterThresholdVoltage + + 0 + + + + EnableOhmicSensing + + 0 + + + + OhmicSensingSetupTime + + 0 + + + + OhmicSensingVoltageLimit + + 0 + + - ro - R #x7002 - VoltageOffset - REAL - 32 + In_Unit2 + DT7002 + 184 - 0 + + Max SubIndex + + 6 + + + + VoltageScale + + 0 + + + + VoltageOffset + + 0 + + + + LowPassFilterThresholdVoltage + + 0 + + + + EnableOhmicSensing + + 0 + + + + OhmicSensingSetupTime + + 0 + + + + OhmicSensingVoltageLimit + + 0 + + - ro - R - - - - #x7003 - LowPassFilterThresholdVoltage - REAL - 32 - - 0 - - - ro - R - - - - #x7004 - EnableOhmicSensing - USINT - 8 - - 0 - - - ro - R - - - - #x7005 - OhmicSensingSetupTime - UDINT - 32 - - 0 - - - ro - R - - - - #x7006 - OhmicSensingVoltageLimit - REAL - 32 - - 0 - - - ro - R @@ -1267,65 +1662,91 @@ #x1601 - VoltageScale + In_Unit1 #x7001 - #x0 + #x1 32 VoltageScale REAL + + #x7001 + #x2 + 32 + VoltageOffset + REAL + + + #x7001 + #x3 + 32 + LowPassFilterThresholdVoltage + REAL + + + #x7001 + #x4 + 8 + EnableOhmicSensing + USINT + + + #x7001 + #x5 + 32 + OhmicSensingSetupTime + UDINT + + + #x7001 + #x6 + 32 + OhmicSensingVoltageLimit + REAL + #x1602 - VoltageOffset + In_Unit2 #x7002 - #x0 + #x1 + 32 + VoltageScale + REAL + + + #x7002 + #x2 32 VoltageOffset REAL - - - #x1603 - LowPassFilterThresholdVoltage - #x7003 - #x0 + #x7002 + #x3 32 LowPassFilterThresholdVoltage REAL - - - #x1604 - EnableOhmicSensing - #x7004 - #x0 + #x7002 + #x4 8 EnableOhmicSensing USINT - - - #x1605 - OhmicSensingSetupTime - #x7005 - #x0 + #x7002 + #x5 32 OhmicSensingSetupTime UDINT - - - #x1606 - OhmicSensingVoltageLimit - #x7006 - #x0 + #x7002 + #x6 32 OhmicSensingVoltageLimit REAL @@ -1344,54 +1765,77 @@ #x1A01 - RawData + Out_Unit1 #x6001 - #x0 + #x1 32 RawData DINT - - - #x1A02 - CalculatedVoltage - #x6002 - #x0 + #x6001 + #x2 32 CalculatedVoltage REAL - - - #x1A03 - Status - #x6003 - #x0 - 8 + #x6001 + #x3 + 32 Status - USINT + UDINT - - - #x1A04 - LowpassFilteredVoltage - #x6004 - #x0 + #x6001 + #x4 32 LowpassFilteredVoltage REAL + + #x6001 + #x5 + 8 + OhmicSensingSensed + USINT + - #x1A05 - OhmicSensingSensed + #x1A02 + Out_Unit2 - #x6005 - #x0 + #x6002 + #x1 + 32 + RawData + DINT + + + #x6002 + #x2 + 32 + CalculatedVoltage + REAL + + + #x6002 + #x3 + 32 + Status + UDINT + + + #x6002 + #x4 + 32 + LowpassFilteredVoltage + REAL + + + #x6002 + #x5 8 OhmicSensingSensed USINT 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 b4423a1..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,8 +33,8 @@ #define SM3_smc 0x20 #define SM3_act 1 -#define MAX_MAPPINGS_SM2 7 -#define MAX_MAPPINGS_SM3 6 +#define MAX_MAPPINGS_SM2 13 +#define MAX_MAPPINGS_SM3 11 #define MAX_RXPDO_SIZE 512 #define MAX_TXPDO_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 3e98d6f..39b2a8d 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 @@ -35,31 +35,68 @@ "od": { "sdo": { "2000": { - "otype": "VAR", - "name": "I2C_devicetype", - "access": "RW", - "dtype": "UNSIGNED8", - "value": "0", - "isSDOitem": true, - "data": "&Obj.I2C_devicetype" + "otype": "RECORD", + "name": "Settings_Unit1", + "access": "RO", + "items": [ + { + "name": "Max SubIndex" + }, + { + "name": "I2C_devicetype", + "dtype": "UNSIGNED8", + "data": "&Obj.Settings_Unit1.I2C_devicetype", + "value": "0", + "access": "RW" + }, + { + "name": "I2C_address", + "dtype": "UNSIGNED8", + "value": "0", + "access": "RW", + "data": "&Obj.Settings_Unit1.I2C_address" + }, + { + "name": "LowpassFilterPoleFrequency", + "dtype": "UNSIGNED32", + "value": "0", + "access": "RW", + "data": "&Obj.Settings_Unit1.LowpassFilterPoleFrequency" + } + ], + "isSDOitem": true }, "2001": { - "otype": "VAR", - "name": "I2C_address", - "access": "RW", - "dtype": "UNSIGNED8", - "value": "0", - "isSDOitem": true, - "data": "&Obj.I2C_address" - }, - "2002": { - "otype": "VAR", - "name": "LowpassFilterPoleFrequency", - "access": "RW", - "dtype": "UNSIGNED32", - "value": "0", - "isSDOitem": true, - "data": "&Obj.LowpassFilterPoleFrequency" + "otype": "RECORD", + "name": "Settings_Unit2", + "access": "RO", + "items": [ + { + "name": "Max SubIndex" + }, + { + "name": "I2C_devicetype", + "dtype": "UNSIGNED8", + "data": "&Obj.Settings_Unit2.I2C_devicetype", + "value": "0", + "access": "RW" + }, + { + "name": "I2C_address", + "dtype": "UNSIGNED8", + "value": "0", + "access": "RW", + "data": "&Obj.Settings_Unit2.I2C_address" + }, + { + "name": "LowpassFilterPoleFrequency", + "dtype": "UNSIGNED32", + "value": "0", + "access": "RW", + "data": "&Obj.Settings_Unit2.LowpassFilterPoleFrequency" + } + ], + "isSDOitem": true }, "A": { "otype": "RECORD", @@ -100,59 +137,100 @@ "data": "&Obj.Input12" }, "6001": { - "otype": "VAR", - "name": "RawData", + "otype": "RECORD", + "name": "Out_Unit1", "access": "RO", + "items": [ + { + "name": "Max SubIndex" + }, + { + "name": "RawData", + "dtype": "INTEGER32", + "data": "&Obj.Out_Unit1.RawData", + "value": "0", + "access": "RO" + }, + { + "name": "CalculatedVoltage", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.Out_Unit1.CalculatedVoltage" + }, + { + "name": "Status", + "dtype": "UNSIGNED32", + "value": "0", + "access": "RO", + "data": "&Obj.Out_Unit1.Status" + }, + { + "name": "LowpassFilteredVoltage", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.Out_Unit1.LowpassFilteredVoltage" + }, + { + "name": "OhmicSensingSensed", + "dtype": "UNSIGNED8", + "value": "0", + "access": "RO", + "data": "&Obj.Out_Unit1.OhmicSensingSensed" + } + ], "pdo_mappings": [ "txpdo" - ], - "dtype": "INTEGER32", - "value": "0", - "data": "&Obj.RawData" + ] }, "6002": { - "otype": "VAR", - "name": "CalculatedVoltage", + "otype": "RECORD", + "name": "Out_Unit2", "access": "RO", + "items": [ + { + "name": "Max SubIndex" + }, + { + "name": "RawData", + "dtype": "INTEGER32", + "data": "&Obj.Out_Unit2.RawData", + "value": "0", + "access": "RO" + }, + { + "name": "CalculatedVoltage", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.Out_Unit2.CalculatedVoltage" + }, + { + "name": "Status", + "dtype": "UNSIGNED32", + "value": "0", + "access": "RO", + "data": "&Obj.Out_Unit2.Status" + }, + { + "name": "LowpassFilteredVoltage", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.Out_Unit2.LowpassFilteredVoltage" + }, + { + "name": "OhmicSensingSensed", + "dtype": "UNSIGNED8", + "value": "0", + "access": "RO", + "data": "&Obj.Out_Unit2.OhmicSensingSensed" + } + ], "pdo_mappings": [ "txpdo" - ], - "dtype": "REAL32", - "value": "0", - "data": "&Obj.CalculatedVoltage" - }, - "6003": { - "otype": "VAR", - "name": "Status", - "access": "RO", - "pdo_mappings": [ - "txpdo" - ], - "dtype": "UNSIGNED8", - "value": "0", - "data": "&Obj.Status" - }, - "6004": { - "otype": "VAR", - "name": "LowpassFilteredVoltage", - "access": "RO", - "pdo_mappings": [ - "txpdo" - ], - "dtype": "REAL32", - "value": "0", - "data": "&Obj.LowpassFilteredVoltage" - }, - "6005": { - "otype": "VAR", - "name": "OhmicSensingSensed", - "access": "RO", - "pdo_mappings": [ - "txpdo" - ], - "dtype": "UNSIGNED8", - "value": "0", - "data": "&Obj.OhmicSensingSensed" + ] } }, "rxpdo": { @@ -168,70 +246,114 @@ "data": "&Obj.Output4" }, "7001": { - "otype": "VAR", - "name": "VoltageScale", + "otype": "RECORD", + "name": "In_Unit1", "access": "RO", + "items": [ + { + "name": "Max SubIndex" + }, + { + "name": "VoltageScale", + "dtype": "REAL32", + "data": "&Obj.In_Unit1.VoltageScale", + "value": "0", + "access": "RO" + }, + { + "name": "VoltageOffset", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit1.VoltageOffset" + }, + { + "name": "LowPassFilterThresholdVoltage", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit1.LowPassFilterThresholdVoltage" + }, + { + "name": "EnableOhmicSensing", + "dtype": "UNSIGNED8", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit1.EnableOhmicSensing" + }, + { + "name": "OhmicSensingSetupTime", + "dtype": "UNSIGNED32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit1.OhmicSensingSetupTime" + }, + { + "name": "OhmicSensingVoltageLimit", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit1.OhmicSensingVoltageLimit" + } + ], "pdo_mappings": [ "rxpdo" - ], - "dtype": "REAL32", - "value": "0", - "data": "&Obj.VoltageScale" + ] }, "7002": { - "otype": "VAR", - "name": "VoltageOffset", + "otype": "RECORD", + "name": "In_Unit2", "access": "RO", + "items": [ + { + "name": "Max SubIndex" + }, + { + "name": "VoltageScale", + "dtype": "REAL32", + "data": "&Obj.In_Unit2.VoltageScale", + "value": "0", + "access": "RO" + }, + { + "name": "VoltageOffset", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit2.VoltageOffset" + }, + { + "name": "LowPassFilterThresholdVoltage", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit2.LowPassFilterThresholdVoltage" + }, + { + "name": "EnableOhmicSensing", + "dtype": "UNSIGNED8", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit2.EnableOhmicSensing" + }, + { + "name": "OhmicSensingSetupTime", + "dtype": "UNSIGNED32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit2.OhmicSensingSetupTime" + }, + { + "name": "OhmicSensingVoltageLimit", + "dtype": "REAL32", + "value": "0", + "access": "RO", + "data": "&Obj.In_Unit2.OhmicSensingVoltageLimit" + } + ], "pdo_mappings": [ "rxpdo" - ], - "dtype": "REAL32", - "value": "0", - "data": "&Obj.VoltageOffset" - }, - "7003": { - "otype": "VAR", - "name": "LowPassFilterThresholdVoltage", - "access": "RO", - "pdo_mappings": [ - "rxpdo" - ], - "dtype": "REAL32", - "value": "0", - "data": "&Obj.LowPassFilterThresholdVoltage" - }, - "7004": { - "otype": "VAR", - "name": "EnableOhmicSensing", - "access": "RO", - "pdo_mappings": [ - "rxpdo" - ], - "dtype": "UNSIGNED8", - "value": "0", - "data": "&Obj.EnableOhmicSensing" - }, - "7005": { - "otype": "VAR", - "name": "OhmicSensingSetupTime", - "access": "RO", - "pdo_mappings": [ - "rxpdo" - ], - "dtype": "UNSIGNED32", - "value": "0", - "data": "&Obj.OhmicSensingSetupTime" - }, - "7006": { - "otype": "VAR", - "name": "OhmicSensingVoltageLimit", - "access": "RO", - "pdo_mappings": [ - "rxpdo" - ], - "dtype": "REAL32", - "value": "0", - "data": "&Obj.OhmicSensingVoltageLimit" + ] }, "60664": { "otype": "VAR", 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 9914f76..77b2764 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 @@ -16,42 +16,39 @@ static const char acName1018_04[] = "Serial Number"; static const char acName1600[] = "Output4"; static const char acName1600_00[] = "Max SubIndex"; static const char acName1600_01[] = "Output4"; -static const char acName1601[] = "VoltageScale"; +static const char acName1601[] = "In_Unit1"; static const char acName1601_00[] = "Max SubIndex"; static const char acName1601_01[] = "VoltageScale"; -static const char acName1602[] = "VoltageOffset"; +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 acName1602[] = "In_Unit2"; static const char acName1602_00[] = "Max SubIndex"; -static const char acName1602_01[] = "VoltageOffset"; -static const char acName1603[] = "LowPassFilterThresholdVoltage"; -static const char acName1603_00[] = "Max SubIndex"; -static const char acName1603_01[] = "LowPassFilterThresholdVoltage"; -static const char acName1604[] = "EnableOhmicSensing"; -static const char acName1604_00[] = "Max SubIndex"; -static const char acName1604_01[] = "EnableOhmicSensing"; -static const char acName1605[] = "OhmicSensingSetupTime"; -static const char acName1605_00[] = "Max SubIndex"; -static const char acName1605_01[] = "OhmicSensingSetupTime"; -static const char acName1606[] = "OhmicSensingVoltageLimit"; -static const char acName1606_00[] = "Max SubIndex"; -static const char acName1606_01[] = "OhmicSensingVoltageLimit"; +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 acName1A00[] = "Input12"; static const char acName1A00_00[] = "Max SubIndex"; static const char acName1A00_01[] = "Input12"; -static const char acName1A01[] = "RawData"; +static const char acName1A01[] = "Out_Unit1"; static const char acName1A01_00[] = "Max SubIndex"; static const char acName1A01_01[] = "RawData"; -static const char acName1A02[] = "CalculatedVoltage"; +static const char acName1A01_02[] = "CalculatedVoltage"; +static const char acName1A01_03[] = "Status"; +static const char acName1A01_04[] = "LowpassFilteredVoltage"; +static const char acName1A01_05[] = "OhmicSensingSensed"; +static const char acName1A02[] = "Out_Unit2"; static const char acName1A02_00[] = "Max SubIndex"; -static const char acName1A02_01[] = "CalculatedVoltage"; -static const char acName1A03[] = "Status"; -static const char acName1A03_00[] = "Max SubIndex"; -static const char acName1A03_01[] = "Status"; -static const char acName1A04[] = "LowpassFilteredVoltage"; -static const char acName1A04_00[] = "Max SubIndex"; -static const char acName1A04_01[] = "LowpassFilteredVoltage"; -static const char acName1A05[] = "OhmicSensingSensed"; -static const char acName1A05_00[] = "Max SubIndex"; -static const char acName1A05_01[] = "OhmicSensingSensed"; +static const char acName1A02_01[] = "RawData"; +static const char acName1A02_02[] = "CalculatedVoltage"; +static const char acName1A02_03[] = "Status"; +static const char acName1A02_04[] = "LowpassFilteredVoltage"; +static const char acName1A02_05[] = "OhmicSensingSensed"; static const char acName1C00[] = "Sync Manager Communication Type"; static const char acName1C00_00[] = "Max SubIndex"; static const char acName1C00_01[] = "Communications Type SM0"; @@ -63,34 +60,53 @@ static const char acName1C12_00[] = "Max SubIndex"; static const char acName1C12_01[] = "PDO Mapping"; static const char acName1C12_02[] = "PDO Mapping"; static const char acName1C12_03[] = "PDO Mapping"; -static const char acName1C12_04[] = "PDO Mapping"; -static const char acName1C12_05[] = "PDO Mapping"; -static const char acName1C12_06[] = "PDO Mapping"; -static const char acName1C12_07[] = "PDO Mapping"; static const char acName1C13[] = "Sync Manager 3 PDO Assignment"; static const char acName1C13_00[] = "Max SubIndex"; static const char acName1C13_01[] = "PDO Mapping"; static const char acName1C13_02[] = "PDO Mapping"; static const char acName1C13_03[] = "PDO Mapping"; -static const char acName1C13_04[] = "PDO Mapping"; -static const char acName1C13_05[] = "PDO Mapping"; -static const char acName1C13_06[] = "PDO Mapping"; -static const char acName2000[] = "I2C_devicetype"; -static const char acName2001[] = "I2C_address"; -static const char acName2002[] = "LowpassFilterPoleFrequency"; +static const char acName2000[] = "Settings_Unit1"; +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 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 acName6000[] = "Input12"; -static const char acName6001[] = "RawData"; -static const char acName6002[] = "CalculatedVoltage"; -static const char acName6003[] = "Status"; -static const char acName6004[] = "LowpassFilteredVoltage"; -static const char acName6005[] = "OhmicSensingSensed"; +static const char acName6001[] = "Out_Unit1"; +static const char acName6001_00[] = "Max SubIndex"; +static const char acName6001_01[] = "RawData"; +static const char acName6001_02[] = "CalculatedVoltage"; +static const char acName6001_03[] = "Status"; +static const char acName6001_04[] = "LowpassFilteredVoltage"; +static const char acName6001_05[] = "OhmicSensingSensed"; +static const char acName6002[] = "Out_Unit2"; +static const char acName6002_00[] = "Max SubIndex"; +static const char acName6002_01[] = "RawData"; +static const char acName6002_02[] = "CalculatedVoltage"; +static const char acName6002_03[] = "Status"; +static const char acName6002_04[] = "LowpassFilteredVoltage"; +static const char acName6002_05[] = "OhmicSensingSensed"; static const char acName7000[] = "Output4"; -static const char acName7001[] = "VoltageScale"; -static const char acName7002[] = "VoltageOffset"; -static const char acName7003[] = "LowPassFilterThresholdVoltage"; -static const char acName7004[] = "EnableOhmicSensing"; -static const char acName7005[] = "OhmicSensingSetupTime"; -static const char acName7006[] = "OhmicSensingVoltageLimit"; +static const char acName7001[] = "In_Unit1"; +static const char acName7001_00[] = "Max SubIndex"; +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 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"; const _objd SDO1000[] = { @@ -123,33 +139,23 @@ const _objd SDO1600[] = }; const _objd SDO1601[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1601_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1601_01, 0x70010020, 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}, }; const _objd SDO1602[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1602_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1602_01, 0x70020020, NULL}, -}; -const _objd SDO1603[] = -{ - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1603_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1603_01, 0x70030020, NULL}, -}; -const _objd SDO1604[] = -{ - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1604_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1604_01, 0x70040008, NULL}, -}; -const _objd SDO1605[] = -{ - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1605_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1605_01, 0x70050020, NULL}, -}; -const _objd SDO1606[] = -{ - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1606_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1606_01, 0x70060020, 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}, }; const _objd SDO1A00[] = { @@ -158,28 +164,21 @@ const _objd SDO1A00[] = }; const _objd SDO1A01[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A01_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_01, 0x60010020, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A01_00, 5, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_01, 0x60010120, NULL}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_02, 0x60010220, NULL}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_03, 0x60010320, NULL}, + {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_04, 0x60010420, NULL}, + {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A01_05, 0x60010508, NULL}, }; const _objd SDO1A02[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A02_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_01, 0x60020020, NULL}, -}; -const _objd SDO1A03[] = -{ - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A03_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A03_01, 0x60030008, NULL}, -}; -const _objd SDO1A04[] = -{ - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A04_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A04_01, 0x60040020, NULL}, -}; -const _objd SDO1A05[] = -{ - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A05_00, 1, NULL}, - {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A05_01, 0x60050008, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A02_00, 5, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_01, 0x60020120, NULL}, + {0x02, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_02, 0x60020220, NULL}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_03, 0x60020320, NULL}, + {0x04, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_04, 0x60020420, NULL}, + {0x05, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_05, 0x60020508, NULL}, }; const _objd SDO1C00[] = { @@ -191,36 +190,31 @@ const _objd SDO1C00[] = }; const _objd SDO1C12[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 7, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C12_00, 3, NULL}, {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_01, 0x1600, NULL}, {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_02, 0x1601, NULL}, {0x03, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_03, 0x1602, NULL}, - {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_04, 0x1603, NULL}, - {0x05, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_05, 0x1604, NULL}, - {0x06, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_06, 0x1605, NULL}, - {0x07, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C12_07, 0x1606, NULL}, }; const _objd SDO1C13[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 6, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 3, NULL}, {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_01, 0x1A00, NULL}, {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_02, 0x1A01, NULL}, {0x03, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_03, 0x1A02, NULL}, - {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_04, 0x1A03, NULL}, - {0x05, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_05, 0x1A04, NULL}, - {0x06, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_06, 0x1A05, NULL}, }; const _objd SDO2000[] = { - {0x0, DTYPE_UNSIGNED8, 8, ATYPE_RW, acName2000, 0, &Obj.I2C_devicetype}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName2000_00, 3, 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}, }; const _objd SDO2001[] = { - {0x0, DTYPE_UNSIGNED8, 8, ATYPE_RW, acName2001, 0, &Obj.I2C_address}, -}; -const _objd SDO2002[] = -{ - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RW, acName2002, 0, &Obj.LowpassFilterPoleFrequency}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName2001_00, 3, 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}, }; const _objd SDO6000[] = { @@ -228,23 +222,21 @@ const _objd SDO6000[] = }; const _objd SDO6001[] = { - {0x0, DTYPE_INTEGER32, 32, ATYPE_RO | ATYPE_TXPDO, acName6001, 0, &Obj.RawData}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6001_00, 5, NULL}, + {0x01, DTYPE_INTEGER32, 32, ATYPE_RO, acName6001_01, 0, &Obj.Out_Unit1.RawData}, + {0x02, DTYPE_REAL32, 32, ATYPE_RO, acName6001_02, 0x00000000, &Obj.Out_Unit1.CalculatedVoltage}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName6001_03, 0, &Obj.Out_Unit1.Status}, + {0x04, DTYPE_REAL32, 32, ATYPE_RO, acName6001_04, 0x00000000, &Obj.Out_Unit1.LowpassFilteredVoltage}, + {0x05, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6001_05, 0, &Obj.Out_Unit1.OhmicSensingSensed}, }; const _objd SDO6002[] = { - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6002, 0x00000000, &Obj.CalculatedVoltage}, -}; -const _objd SDO6003[] = -{ - {0x0, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_TXPDO, acName6003, 0, &Obj.Status}, -}; -const _objd SDO6004[] = -{ - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6004, 0x00000000, &Obj.LowpassFilteredVoltage}, -}; -const _objd SDO6005[] = -{ - {0x0, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_TXPDO, acName6005, 0, &Obj.OhmicSensingSensed}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6002_00, 5, NULL}, + {0x01, DTYPE_INTEGER32, 32, ATYPE_RO, acName6002_01, 0, &Obj.Out_Unit2.RawData}, + {0x02, DTYPE_REAL32, 32, ATYPE_RO, acName6002_02, 0x00000000, &Obj.Out_Unit2.CalculatedVoltage}, + {0x03, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName6002_03, 0, &Obj.Out_Unit2.Status}, + {0x04, DTYPE_REAL32, 32, ATYPE_RO, acName6002_04, 0x00000000, &Obj.Out_Unit2.LowpassFilteredVoltage}, + {0x05, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName6002_05, 0, &Obj.Out_Unit2.OhmicSensingSensed}, }; const _objd SDO7000[] = { @@ -252,27 +244,23 @@ const _objd SDO7000[] = }; const _objd SDO7001[] = { - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7001, 0x00000000, &Obj.VoltageScale}, + {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}, }; const _objd SDO7002[] = { - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7002, 0x00000000, &Obj.VoltageOffset}, -}; -const _objd SDO7003[] = -{ - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7003, 0x00000000, &Obj.LowPassFilterThresholdVoltage}, -}; -const _objd SDO7004[] = -{ - {0x0, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_RXPDO, acName7004, 0, &Obj.EnableOhmicSensing}, -}; -const _objd SDO7005[] = -{ - {0x0, DTYPE_UNSIGNED32, 32, ATYPE_RO | ATYPE_RXPDO, acName7005, 0, &Obj.OhmicSensingSetupTime}, -}; -const _objd SDO7006[] = -{ - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_RXPDO, acName7006, 0x00000000, &Obj.OhmicSensingVoltageLimit}, + {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}, }; const _objectlist SDOobjects[] = @@ -283,36 +271,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, 1, 0, acName1601, SDO1601}, - {0x1602, OTYPE_RECORD, 1, 0, acName1602, SDO1602}, - {0x1603, OTYPE_RECORD, 1, 0, acName1603, SDO1603}, - {0x1604, OTYPE_RECORD, 1, 0, acName1604, SDO1604}, - {0x1605, OTYPE_RECORD, 1, 0, acName1605, SDO1605}, - {0x1606, OTYPE_RECORD, 1, 0, acName1606, SDO1606}, + {0x1601, OTYPE_RECORD, 6, 0, acName1601, SDO1601}, + {0x1602, OTYPE_RECORD, 6, 0, acName1602, SDO1602}, {0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00}, - {0x1A01, OTYPE_RECORD, 1, 0, acName1A01, SDO1A01}, - {0x1A02, OTYPE_RECORD, 1, 0, acName1A02, SDO1A02}, - {0x1A03, OTYPE_RECORD, 1, 0, acName1A03, SDO1A03}, - {0x1A04, OTYPE_RECORD, 1, 0, acName1A04, SDO1A04}, - {0x1A05, OTYPE_RECORD, 1, 0, acName1A05, SDO1A05}, + {0x1A01, OTYPE_RECORD, 5, 0, acName1A01, SDO1A01}, + {0x1A02, OTYPE_RECORD, 5, 0, acName1A02, SDO1A02}, {0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00}, - {0x1C12, OTYPE_ARRAY, 7, 0, acName1C12, SDO1C12}, - {0x1C13, OTYPE_ARRAY, 6, 0, acName1C13, SDO1C13}, - {0x2000, OTYPE_VAR, 0, 0, acName2000, SDO2000}, - {0x2001, OTYPE_VAR, 0, 0, acName2001, SDO2001}, - {0x2002, OTYPE_VAR, 0, 0, acName2002, SDO2002}, + {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}, {0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000}, - {0x6001, OTYPE_VAR, 0, 0, acName6001, SDO6001}, - {0x6002, OTYPE_VAR, 0, 0, acName6002, SDO6002}, - {0x6003, OTYPE_VAR, 0, 0, acName6003, SDO6003}, - {0x6004, OTYPE_VAR, 0, 0, acName6004, SDO6004}, - {0x6005, OTYPE_VAR, 0, 0, acName6005, SDO6005}, + {0x6001, OTYPE_RECORD, 5, 0, acName6001, SDO6001}, + {0x6002, OTYPE_RECORD, 5, 0, acName6002, SDO6002}, {0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000}, - {0x7001, OTYPE_VAR, 0, 0, acName7001, SDO7001}, - {0x7002, OTYPE_VAR, 0, 0, acName7002, SDO7002}, - {0x7003, OTYPE_VAR, 0, 0, acName7003, SDO7003}, - {0x7004, OTYPE_VAR, 0, 0, acName7004, SDO7004}, - {0x7005, OTYPE_VAR, 0, 0, acName7005, SDO7005}, - {0x7006, OTYPE_VAR, 0, 0, acName7006, SDO7006}, + {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 2fd1a01..f002718 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 @@ -14,27 +14,59 @@ typedef struct /* Inputs */ int32_t Input12; - int32_t RawData; - float CalculatedVoltage; - uint8_t Status; - float LowpassFilteredVoltage; - uint8_t OhmicSensingSensed; + struct + { + int32_t RawData; + float CalculatedVoltage; + uint32_t Status; + float LowpassFilteredVoltage; + uint8_t OhmicSensingSensed; + } Out_Unit1; + struct + { + int32_t RawData; + float CalculatedVoltage; + uint32_t Status; + float LowpassFilteredVoltage; + uint8_t OhmicSensingSensed; + } Out_Unit2; /* Outputs */ uint8_t Output4; - float VoltageScale; - float VoltageOffset; - float LowPassFilterThresholdVoltage; - uint8_t EnableOhmicSensing; - uint32_t OhmicSensingSetupTime; - float OhmicSensingVoltageLimit; + struct + { + float VoltageScale; + float VoltageOffset; + float LowPassFilterThresholdVoltage; + uint8_t EnableOhmicSensing; + uint32_t OhmicSensingSetupTime; + float OhmicSensingVoltageLimit; + } In_Unit1; + struct + { + float VoltageScale; + float VoltageOffset; + float LowPassFilterThresholdVoltage; + uint8_t EnableOhmicSensing; + uint32_t OhmicSensingSetupTime; + float OhmicSensingVoltageLimit; + } In_Unit2; /* Parameters */ - uint8_t I2C_devicetype; - uint8_t I2C_address; - uint32_t LowpassFilterPoleFrequency; + struct + { + uint8_t I2C_devicetype; + uint8_t I2C_address; + uint32_t LowpassFilterPoleFrequency; + } Settings_Unit1; + struct + { + uint8_t I2C_devicetype; + uint8_t I2C_address; + uint32_t LowpassFilterPoleFrequency; + } Settings_Unit2; } _Objects; extern _Objects Obj; diff --git a/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp b/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp index a8fac79..ac6686b 100755 --- a/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp +++ b/Cards/EaserCAT-7000-DIO+I2C/Firmware/src/main.cpp @@ -17,29 +17,35 @@ uint8_t inputPin[] = {PD15, PD14, PD13, PD12, PD11, PD10, PD9, PD8, PB15, PB14, uint8_t outputPin[] = {PE10, PE9, PE8, PE7}; const uint32_t I2C_BUS_SPEED = 400000; -uint32_t I2C_restarts = 0; +uint32_t I2C_restarts_1 = 0, I2C_restarts_2 = 0; const uint8_t MCP3221_TYPE = 1, ADS1014_TYPE = 2; -int8_t old_I2Cdevice = -1; +int8_t old_I2Cdevice_1 = -1; +int8_t old_I2Cdevice_2 = -1; #include "Wire.h" TwoWire Wire2(PB11, PB10); #include "MyMCP3221.h" -MyMCP3221 *mcp3221 = 0; +MyMCP3221 *mcp3221_1 = 0; +MyMCP3221 *mcp3221_2 = 0; #include "ADS1X15.h" -ADS1014 *ads1014 = 0; +ADS1014 *ads1014_1 = 0; +ADS1014 *ads1014_2 = 0; -void ads1014_reset() +void ads1014_reset(ADS1014 *ads) { - ads1014->reset(); - ads1014->begin(); - ads1014->setGain(1); // 1=4.096V - ads1014->setMode(0); // 0 continuous - ads1014->setDataRate(6); // Max for ads101x - ads1014->readADC_Differential_0_1(); // This is the value we are interested in + ads->reset(); + ads->begin(); + ads->setGain(1); // 1=4.096V + ads->setMode(0); // 0 continuous + ads->setDataRate(6); // Max for ads101x + ads->readADC_Differential_0_1(); // This is the value we are interested in } +void handleVoltageReader(float scale_in, float offset, float outVoltage, int32_t outRaw, + float &oldVoltage, float &oldRaw, + uint8_t devType, int8_t &old_devType, uint8_t &readStat, uint32_t &outStatus, ADS1014 *ads, MyMCP3221 *mcp, uint8_t I2C_address, uint32_t &I2C_restarts); #define bitset(byte, nbit) ((byte) |= (1 << (nbit))) #define bitclear(byte, nbit) ((byte) &= ~(1 << (nbit))) #define bitflip(byte, nbit) ((byte) ^= (1 << (nbit))) @@ -63,106 +69,204 @@ uint32_t timeSinceOhmicSensingEnabled = 0; void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation { - static float validData0 = 0.0, validVoltage0 = 0.0; + static float validData0_1 = 0.0, validVoltage0_1 = 0.0; + static float validData0_2 = 0.0, validVoltage0_2 = 0.0; + uint8_t stat_1, stat_2; + for (int i = 0; i < sizeof(inputPin); i++) Obj.Input12 = digitalRead(inputPin[i]) == HIGH ? bitset(Obj.Input12, i) : bitclear(Obj.Input12, i); - float scale = Obj.VoltageScale; - if (scale == 0.0) - scale = 1.0; - int stat = 1, data0; - switch (Obj.I2C_devicetype) + handleVoltageReader(Obj.In_Unit1.VoltageScale, Obj.In_Unit1.VoltageOffset, Obj.Out_Unit1.CalculatedVoltage, Obj.Out_Unit1.RawData, + validVoltage0_1, validData0_1, + Obj.Settings_Unit1.I2C_devicetype, old_I2Cdevice_1, stat_1, Obj.Out_Unit1.Status, + ads1014_1, mcp3221_1, Obj.Settings_Unit1.I2C_address, I2C_restarts_1); + handleVoltageReader(Obj.In_Unit2.VoltageScale, Obj.In_Unit2.VoltageOffset, Obj.Out_Unit2.CalculatedVoltage, Obj.Out_Unit2.RawData, + validVoltage0_2, validData0_2, + Obj.Settings_Unit2.I2C_devicetype, old_I2Cdevice_2, stat_2, Obj.Out_Unit2.Status, + ads1014_2, mcp3221_2, Obj.Settings_Unit2.I2C_address, I2C_restarts_2); +#if 0 + float scale_1 = Obj.In_Unit1.VoltageScale; + if (scale_1 == 0.0) + scale_1 = 1.0; + int stat_1 = 1, data0_1; + switch (Obj.Settings_Unit1.I2C_devicetype) { case 0: // Not configured. - Obj.Status = 0; - stat = data0 = 0; + Obj.Out_Unit1.Status = 0; + stat_1 = data0_1 = 0; break; case MCP3221_TYPE: - if (old_I2Cdevice != Obj.I2C_devicetype) // Initilize and make ready + if (old_I2Cdevice_1 != Obj.Settings_Unit1.I2C_devicetype) // Initilize and make ready { - if (ads1014) + if (ads1014_1) { - delete ads1014; - ads1014 = 0; + delete ads1014_1; + ads1014_1 = 0; } - if (mcp3221) + if (mcp3221_1) { - delete mcp3221; - mcp3221 = 0; + delete mcp3221_1; + mcp3221_1 = 0; } Wire2.end(); Wire2.begin(); Wire2.setClock(I2C_BUS_SPEED); - mcp3221 = new MyMCP3221(Obj.I2C_address, &Wire2); - old_I2Cdevice = mcp3221 ? MCP3221_TYPE : -1; + mcp3221_1 = new MyMCP3221(Obj.Settings_Unit1.I2C_address, &Wire2); + old_I2Cdevice_1 = mcp3221_1 ? MCP3221_TYPE : -1; } - data0 = mcp3221->getData(); - stat = mcp3221->ping(); + data0_1 = mcp3221_1->getData(); + stat_1 = mcp3221_1->ping(); break; case ADS1014_TYPE: - if (old_I2Cdevice != Obj.I2C_devicetype) // Initilize and make ready + if (old_I2Cdevice_1 != Obj.Settings_Unit1.I2C_devicetype) // Initilize and make ready { - if (ads1014) + if (ads1014_1) { - delete ads1014; - ads1014 = 0; + delete ads1014_1; + ads1014_1 = 0; } - if (mcp3221) + if (mcp3221_1) { - delete mcp3221; - mcp3221 = 0; + delete mcp3221_1; + mcp3221_1 = 0; } Wire2.end(); Wire2.begin(); Wire2.setClock(I2C_BUS_SPEED); - ads1014 = new ADS1014(Obj.I2C_address, &Wire2); - ads1014_reset(); - old_I2Cdevice = ADS1014_TYPE; + ads1014_1 = new ADS1014(Obj.Settings_Unit1.I2C_address, &Wire2); + ads1014_reset(ads1014_1); + old_I2Cdevice_1 = ADS1014_TYPE; } - data0 = ads1014->getValue(); - stat = ads1014->isConnected() == 1 ? 0 : 1; + data0_1 = ads1014_1->getValue(); + stat_1 = ads1014_1->isConnected() == 1 ? 0 : 1; break; default: // Not supported break; } - if (stat == 0) - { // Read good value - Obj.CalculatedVoltage = scale * data0 + Obj.VoltageOffset; // - Obj.RawData = data0; // Raw voltage, read by ADC - validVoltage0 = Obj.CalculatedVoltage; - validData0 = data0; + if (stat_1 == 0) + { // Read good value + Obj.Out_Unit1.CalculatedVoltage = scale_1 * data0_1 + Obj.In_Unit1.VoltageOffset; // + Obj.Out_Unit1.RawData = data0_1; // Raw voltage, read by ADC + validVoltage0_1 = Obj.Out_Unit1.CalculatedVoltage; + validData0_1 = data0_1; } else - { // Didn't read a good value. Return a hopefully useful value and restart the I2C bus - Obj.CalculatedVoltage = validVoltage0; // Use value from previous call - Obj.RawData = validData0; + { // Didn't read a good value. Return a hopefully useful value and restart the I2C bus + Obj.Out_Unit1.CalculatedVoltage = validVoltage0_1; // Use value from previous call + Obj.Out_Unit1.RawData = validData0_1; // Reset wire here Wire2.end(); Wire2.begin(); Wire2.setClock(I2C_BUS_SPEED); - I2C_restarts++; - if (Obj.I2C_devicetype == ADS1014_TYPE) - ads1014_reset(); + I2C_restarts_1++; + if (Obj.Settings_Unit1.I2C_devicetype == ADS1014_TYPE) + ads1014_reset(ads1014_1); // mcp3221 has no reset, reset the I2C bus is the best we can do } - Obj.Status = I2C_restarts + (stat << 28); // Put status as bits 28-31, the lower are number of restarts (restart attempts) + Obj.Out_Unit1.Status = I2C_restarts_1 + (stat_1 << 28); // Put status as bits 28-31, the lower are number of restarts (restart attempts) +#endif +#if 0 + + float scale_2 = Obj.In_Unit2.VoltageScale; + if (scale_2 == 0.0) + scale_2 = 1.0; + int stat_2 = 1, data0_2; + switch (Obj.Settings_Unit2.I2C_devicetype) + { + case 0: // Not configured. + Obj.Out_Unit2.Status = 0; + stat_2 = data0_2 = 0; + break; + case MCP3221_TYPE: + if (old_I2Cdevice_2 != Obj.Settings_Unit2.I2C_devicetype) // Initilize and make ready + { + if (ads1014_2) + { + delete ads1014_2; + ads1014_2 = 0; + } + if (mcp3221_2) + { + delete mcp3221_2; + mcp3221_2 = 0; + } + Wire2.end(); + Wire2.begin(); + Wire2.setClock(I2C_BUS_SPEED); + mcp3221_2 = new MyMCP3221(Obj.Settings_Unit2.I2C_address, &Wire2); + old_I2Cdevice_2 = mcp3221_2 ? MCP3221_TYPE : -1; + } + data0_2 = mcp3221_2->getData(); + stat_2 = mcp3221_2->ping(); + break; + case ADS1014_TYPE: + if (old_I2Cdevice_2 != Obj.Settings_Unit2.I2C_devicetype) // Initilize and make ready + { + if (ads1014_2) + { + delete ads1014_2; + ads1014_2 = 0; + } + if (mcp3221_2) + { + delete mcp3221_2; + mcp3221_2 = 0; + } + + Wire2.end(); + Wire2.begin(); + Wire2.setClock(I2C_BUS_SPEED); + ads1014_2 = new ADS1014(Obj.Settings_Unit2.I2C_address, &Wire2); + ads1014_reset(ads1014_2); + old_I2Cdevice_2 = ADS1014_TYPE; + } + data0_2 = ads1014_2->getValue(); + stat_2 = ads1014_2->isConnected() == 1 ? 0 : 1; + break; + default: // Not supported + break; + } + + if (stat_2 == 0) + { // Read good value + Obj.Out_Unit2.CalculatedVoltage = scale_2 * data0_2 + Obj.In_Unit2.VoltageOffset; // + Obj.Out_Unit2.RawData = data0_2; // Raw voltage, read by ADC + validVoltage0_2 = Obj.Out_Unit2.CalculatedVoltage; + validData0_2 = data0_2; + } + else + { // Didn't read a good value. Return a hopefully useful value and restart the I2C bus + Obj.Out_Unit2.CalculatedVoltage = validVoltage0_2; // Use value from previous call + Obj.Out_Unit2.RawData = validData0_2; + // Reset wire here + Wire2.end(); + Wire2.begin(); + Wire2.setClock(I2C_BUS_SPEED); + I2C_restarts_2++; + if (Obj.Settings_Unit2.I2C_devicetype == ADS1014_TYPE) + ads1014_reset(ads1014_2); + // mcp3221 has no reset, reset the I2C bus is the best we can do + } + Obj.Out_Unit2.Status = I2C_restarts_2 + (stat_2 << 28); // Put status as bits 28-31, the lower are number of restarts (restart attempts) + +#endif // Low pass filter. See lowpass in linuxcnc doc float gain = oldLowPassGain; - if (oldLowpassFilterPoleFrequency != Obj.LowpassFilterPoleFrequency) + if (oldLowpassFilterPoleFrequency != Obj.Settings_Unit1.LowpassFilterPoleFrequency) { - gain = 1 - expf(-2.0 * M_PI * Obj.LowpassFilterPoleFrequency * 0.001 /*1.0e-9 * ESC_SYNC0cycletime()*/); + gain = 1 - expf(-2.0 * M_PI * Obj.Settings_Unit1.LowpassFilterPoleFrequency * 0.001 /*1.0e-9 * ESC_SYNC0cycletime()*/); oldLowPassGain = gain; - oldLowpassFilterPoleFrequency = Obj.LowpassFilterPoleFrequency; + oldLowpassFilterPoleFrequency = Obj.Settings_Unit1.LowpassFilterPoleFrequency; } - if (Obj.CalculatedVoltage < Obj.LowPassFilterThresholdVoltage) - Obj.LowpassFilteredVoltage = Obj.CalculatedVoltage; // Just forward + if (Obj.Out_Unit1.CalculatedVoltage < Obj.In_Unit1.LowPassFilterThresholdVoltage) + Obj.Out_Unit1.LowpassFilteredVoltage = Obj.Out_Unit1.CalculatedVoltage; // Just forward else - Obj.LowpassFilteredVoltage = oldLowPassFilteredVoltage + (Obj.CalculatedVoltage - oldLowPassFilteredVoltage) * gain; - oldLowPassFilteredVoltage = Obj.LowpassFilteredVoltage; - + Obj.Out_Unit1.LowpassFilteredVoltage = oldLowPassFilteredVoltage + (Obj.Out_Unit1.CalculatedVoltage - oldLowPassFilteredVoltage) * gain; + oldLowPassFilteredVoltage = Obj.Out_Unit1.LowpassFilteredVoltage; +#if 0 Obj.OhmicSensingSensed = 0; if (Obj.EnableOhmicSensing && stat == 0) { @@ -179,6 +283,45 @@ void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation { timeSinceOhmicSensingEnabled = 0; } +#else +#define OHMIC_IDLE 0 +#define OHMIC_PROBE 1 + static uint8_t ohmicState_1 = OHMIC_IDLE; + static uint8_t ohmicState_2 = OHMIC_IDLE; + Obj.Out_Unit1.OhmicSensingSensed = 0; + if (Obj.In_Unit1.EnableOhmicSensing && stat_1 == 0) + { + if (ohmicState_1 == OHMIC_IDLE && Obj.Out_Unit1.CalculatedVoltage > Obj.In_Unit1.OhmicSensingVoltageLimit) + { + ohmicState_1 = OHMIC_PROBE; + } + if (ohmicState_1 == OHMIC_PROBE && Obj.Out_Unit1.CalculatedVoltage <= Obj.In_Unit1.OhmicSensingVoltageLimit) + { + Obj.Out_Unit1.OhmicSensingSensed = 1; + } + } + else + { + ohmicState_1 = OHMIC_IDLE; + } + + Obj.Out_Unit2.OhmicSensingSensed = 0; + if (Obj.In_Unit2.EnableOhmicSensing && stat_2 == 0) + { + if (ohmicState_2 == OHMIC_IDLE && Obj.Out_Unit2.CalculatedVoltage > Obj.In_Unit2.OhmicSensingVoltageLimit) + { + ohmicState_2 = OHMIC_PROBE; + } + if (ohmicState_2 == OHMIC_PROBE && Obj.Out_Unit2.CalculatedVoltage <= Obj.In_Unit2.OhmicSensingVoltageLimit) + { + Obj.Out_Unit2.OhmicSensingSensed = 1; + } + } + else + { + ohmicState_2 = OHMIC_IDLE; + } +#endif } void ESC_interrupt_enable(uint32_t mask); @@ -248,8 +391,8 @@ void setup(void) mcp3221 = new MyMCP3221(0x48, &Wire2); #endif #ifdef ADS1xxx - ads1014 = new ADS1014(0x48, &Wire2); - ads1014_reset(); + ads1014_1 = new ADS1014(0x49, &Wire2); + ads1014_reset(ads1014_1); #endif while (1) // Search I2C bus for devices { @@ -273,14 +416,14 @@ void setup(void) // else Serial1.printf("I2C status=%d rawdata=%d pin0=%d pin1=%d\n", ads1014.isConnected() ? 0 : -1, ads1014.readADC_Differential_0_1(), ads1014.readADC(0), ads1014.readADC(1)); // Serial1.println(ads1014.toVoltage(ads1014.readADC_Differential_0_1()), 5); for (int i = 0; i < 10; i++) - Serial1.println(ads1014->getValue()); + Serial1.println(ads1014_1->getValue()); int dummy = 0; uint32_t then = micros(); for (int i = 0; i < 1000; i++) - dummy += ads1014->getValue(); + dummy += ads1014_1->getValue(); uint32_t now = micros(); Serial1.printf("1000 I2C readings take %d microseconds\n", now - then); - Serial1.println(ads1014->toVoltage(ads1014->getValue()),4); + Serial1.println(ads1014_1->toVoltage(ads1014_1->getValue()), 4); #endif for (int i = 0; i < 12; i++) Serial1.printf("%u", digitalRead(inputPin[i])); @@ -365,3 +508,95 @@ uint16_t dc_checker(void) ESCvar.dcsync = 1; return 0; } + +#if 1 + +void handleVoltageReader(float scale_in, float offset, float outVoltage, int32_t outRaw, + float &oldVoltage, float &oldRaw, + uint8_t devType, int8_t &old_devType, uint8_t &readStat, uint32_t &outStatus, + ADS1014 *ads, MyMCP3221 *mcp, uint8_t I2C_address, uint32_t &I2C_restarts) +{ + float scale = scale_in; + if (scale == 0.0) + scale = 1.0; + int stat = 1, data0; + switch (devType) + { + case 0: // Not configured. + outStatus = 0; + stat = data0 = 0; + break; + case MCP3221_TYPE: + if (old_devType != devType) // Initilize and make ready + { + if (ads) + { + delete ads; + ads = 0; + } + if (mcp) + { + delete mcp; + mcp = 0; + } + Wire2.end(); + Wire2.begin(); + Wire2.setClock(I2C_BUS_SPEED); + mcp = new MyMCP3221(I2C_address, &Wire2); + old_devType = mcp ? MCP3221_TYPE : -1; + } + data0 = mcp->getData(); + stat = mcp->ping(); + break; + case ADS1014_TYPE: + if (old_devType != devType) // Initilize and make ready + { + if (ads) + { + delete ads; + ads = 0; + } + if (mcp) + { + delete mcp; + mcp = 0; + } + + Wire2.end(); + Wire2.begin(); + Wire2.setClock(I2C_BUS_SPEED); + ads = new ADS1014(I2C_address, &Wire2); + ads1014_reset(ads); + old_devType = ads ? ADS1014_TYPE : -1; + } + data0 = ads->getValue(); + stat = ads->isConnected() == 1 ? 0 : 1; + break; + default: // Not supported + break; + } + + if (stat == 0) + { // Read good value + outVoltage = scale * data0 + offset; // + outRaw = data0; // Raw voltage, read by ADC + oldVoltage = outVoltage; + oldRaw = data0; + } + else + { // Didn't read a good value. Return a hopefully useful value and restart the I2C bus + outVoltage = oldVoltage; // Use value from previous call + outRaw = oldRaw; + // Reset wire here + Wire2.end(); + Wire2.begin(); + Wire2.setClock(I2C_BUS_SPEED); + I2C_restarts++; + if (devType == ADS1014_TYPE) + ads1014_reset(ads); + // mcp3221 has no reset, reset the I2C bus is the best we can do + } + readStat = stat; + outStatus = I2C_restarts + (stat << 28); // Put status as bits 28-31, the lower are number of restarts (restart attempts) +} +#endif \ No newline at end of file