Reshuffle and add second reader.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user