added centi Kelvin units, extended number of ADC readings over uavcan to 4

This commit is contained in:
Jacob Dahl 2020-08-13 16:20:55 -08:00
parent 56341689ec
commit 8fd1b42000
6 changed files with 48 additions and 18 deletions

View File

@ -1,4 +1,6 @@
uint64 timestamp # time since system start (microseconds)
uint16[2] voltage
uint16[2] current
uint16[4] voltage # mV
uint16[4] current # mA
uint16[4] temperature # Kelvin * 100

View File

@ -1,6 +1,7 @@
uint2 UNITS_RAW = 0
uint2 UNITS_MV = 1
uint2 UNITS_MA = 2
uint2[2] unit_type
uint3 UNITS_NONE = 0
uint3 UNITS_MV = 1
uint3 UNITS_MA = 2
uint3 UNITS_CK = 3
uint3[4] unit_type
int16[2] values # TODO: do we want to include all of the ADC measurements or just two for voltage/current on power port?
int16[4] values

View File

@ -65,18 +65,21 @@ UavcanAdcBridge::adc_sub_cb(const
{
analog_voltage_current_s report{};
static constexpr int numIndices = 2;
static constexpr int numIndices = 4;
static constexpr uint16_t mV = com::volansi::equipment::adc::Report::UNITS_MV;
static constexpr uint16_t mA = com::volansi::equipment::adc::Report::UNITS_MA;
static constexpr uint16_t cK = com::volansi::equipment::adc::Report::UNITS_CK;
for (int i = 0; i < numIndices; i++) {
// TODO: do we want to publish raw ADC values? What about temperature?
if (msg.unit_type[i] == mV) {
report.voltage[i] = msg.values[i];
} else if (msg.unit_type[i] == mA) {
report.current[i] = msg.values[i];
} else if (msg.unit_type[i] == cK) {
report.temperature[i] = msg.values[i];
}
}

View File

@ -545,15 +545,34 @@ void UavcanNode::send_adc_measurements()
int32_t adc1_units = 0;
int32_t adc2_units = 0;
int32_t adc3_units = 0;
int32_t adc4_units = 0;
(void)param_get(param_find("ADC1_UNIT_TYPE"), &adc1_units);
(void)param_get(param_find("ADC2_UNIT_TYPE"), &adc2_units);
(void)param_get(param_find("ADC3_UNIT_TYPE"), &adc3_units);
(void)param_get(param_find("ADC4_UNIT_TYPE"), &adc4_units);
report.unit_type[0] = (unsigned)adc1_units;
report.unit_type[1] = (unsigned)adc2_units;
report.unit_type[2] = (unsigned)adc3_units;
report.unit_type[3] = (unsigned)adc4_units;
// Always indices 0 and 1?
report.values[0] = adc_report.raw_data[0];
report.values[1] = adc_report.raw_data[1];
if (adc1_units != 0) {
report.values[0] = adc_report.raw_data[0];
}
if (adc2_units != 0) {
report.values[1] = adc_report.raw_data[1];
}
if (adc3_units != 0) {
report.values[2] = adc_report.raw_data[2];
}
if (adc4_units != 0) {
report.values[3] = adc_report.raw_data[3];
}
_adc_report_publisher.broadcast(report);
}

View File

@ -1,6 +1,7 @@
uint2 UNITS_RAW = 0
uint2 UNITS_MV = 1
uint2 UNITS_MA = 2
uint2[2] unit_type
uint3 UNITS_NONE = 0
uint3 UNITS_MV = 1
uint3 UNITS_MA = 2
uint3 UNITS_CK = 3
uint3[4] unit_type
int16[2] values # TODO: do we want to include all of the ADC measurements or just two for voltage/current on power port?
int16[4] values

View File

@ -53,10 +53,14 @@ PARAM_DEFINE_INT32(CANNODE_BITRATE, 1000000);
/**
* Units associated with ADC measurement.
* 0 - raw
* 0 - unused
* 1 - mV
* 2 - mA
* 3 - cK
* @group UAVCAN
*/
PARAM_DEFINE_INT32(ADC1_UNIT_TYPE, 1);
PARAM_DEFINE_INT32(ADC2_UNIT_TYPE, 2);
PARAM_DEFINE_INT32(ADC3_UNIT_TYPE, 0);
PARAM_DEFINE_INT32(ADC4_UNIT_TYPE, 0);