diff --git a/src/boards/RIGv2/Configs/SensorsConfig.h b/src/boards/RIGv2/Configs/SensorsConfig.h index 03f499d8b9042082b757d6f17a510dc97b6a388d..c25b47445dc60d327e79e43e405f7023b5d551b8 100644 --- a/src/boards/RIGv2/Configs/SensorsConfig.h +++ b/src/boards/RIGv2/Configs/SensorsConfig.h @@ -104,6 +104,9 @@ static constexpr unsigned int CALIBRATE_SAMPLE_COUNT = 10; static constexpr unsigned int CALIBRATE_SAMPLE_PERIOD = 40; // LC Tank sensor calibration data +// - 1.866kg V: 0.000941 +// - 5.050kg V: 0.002550 +// - 6.916kg V: 0.003559 static constexpr float TANK_P0_VOLTAGE = 0.000941; static constexpr float TANK_P0_MASS = 1.866; static constexpr float TANK_P1_VOLTAGE = 0.003559; diff --git a/src/boards/RIGv2/Sensors/Sensors.cpp b/src/boards/RIGv2/Sensors/Sensors.cpp index 882ea23b7e8b21a0627552c583155d90d9e84664..e94b65858aebdbb1aa5d9956c708cef22ddb0a80 100644 --- a/src/boards/RIGv2/Sensors/Sensors.cpp +++ b/src/boards/RIGv2/Sensors/Sensors.cpp @@ -37,9 +37,18 @@ bool Sensors::isStarted() { return started; } bool Sensors::start() { SensorManager::SensorMap_t map; - internalAdcInit(map); - adc1Init(map); - tc1Init(map); + if (Config::Sensors::InternalADC::ENABLED) + { + internalAdcInit(map); + } + if (Config::Sensors::ADS131M08::ENABLED) + { + adc1Init(map); + } + if (Config::Sensors::MAX31856::ENABLED) + { + tc1Init(map); + } vesselPressureInit(map); fillingPressureInit(map); topTankPressureInit(map); @@ -202,10 +211,8 @@ void Sensors::internalAdcInit(Boardcore::SensorManager::SensorMap_t &map) internalAdc->enableTemperature(); internalAdc->enableVbat(); - SensorInfo info( - "InternalAdc", Config::Sensors::InternalADC::SAMPLE_PERIOD, - [this]() { internalAdcCallback(); }, - Config::Sensors::InternalADC::ENABLED); + SensorInfo info("InternalAdc", Config::Sensors::InternalADC::SAMPLE_PERIOD, + [this]() { internalAdcCallback(); }); map.emplace(internalAdc.get(), info); } @@ -286,9 +293,8 @@ void Sensors::adc1Init(SensorManager::SensorMap_t &map) sensors::ADS131_1::cs::getPin(), spiConfig, config); - SensorInfo info( - "ADS131M08_1", Config::Sensors::ADS131M08::SAMPLE_PERIOD, - [this]() { adc1Callback(); }, Config::Sensors::ADS131M08::ENABLED); + SensorInfo info("ADS131M08_1", Config::Sensors::ADS131M08::SAMPLE_PERIOD, + [this]() { adc1Callback(); }); map.emplace(std::make_pair(adc1.get(), info)); } @@ -325,9 +331,8 @@ void Sensors::tc1Init(SensorManager::SensorMap_t &map) sensors::MAX31856_1::cs::getPin(), spiConfig, MAX31856::ThermocoupleType::K_TYPE); - SensorInfo info( - "MAX31856_1", Config::Sensors::MAX31856::SAMPLE_PERIOD, - [this]() { tc1Callback(); }, Config::Sensors::MAX31856::ENABLED); + SensorInfo info("MAX31856_1", Config::Sensors::MAX31856::SAMPLE_PERIOD, + [this]() { tc1Callback(); }); map.emplace(std::make_pair(tc1.get(), info)); } @@ -345,7 +350,7 @@ void Sensors::vesselPressureInit(Boardcore::SensorManager::SensorMap_t &map) vesselPressure = std::make_unique<TrafagPressureSensor>( [this]() { - auto sample = adc1->getLastSample(); + auto sample = getADC1LastSample(); return sample.getVoltage( Config::Sensors::ADS131M08::VESSEL_PT_CHANNEL); }, @@ -371,7 +376,7 @@ void Sensors::fillingPressureInit(Boardcore::SensorManager::SensorMap_t &map) fillingPressure = std::make_unique<TrafagPressureSensor>( [this]() { - auto sample = adc1->getLastSample(); + auto sample = getADC1LastSample(); return sample.getVoltage( Config::Sensors::ADS131M08::FILLING_PT_CHANNEL); }, @@ -398,7 +403,7 @@ void Sensors::topTankPressureInit(Boardcore::SensorManager::SensorMap_t &map) topTankPressure = std::make_unique<TrafagPressureSensor>( [this]() { - auto sample = adc1->getLastSample(); + auto sample = getADC1LastSample(); return sample.getVoltage( Config::Sensors::ADS131M08::TOP_PT_CHANNEL); }, @@ -425,7 +430,7 @@ void Sensors::bottomTankPressureInit(Boardcore::SensorManager::SensorMap_t &map) bottomTankPressure = std::make_unique<TrafagPressureSensor>( [this]() { - auto sample = adc1->getLastSample(); + auto sample = getADC1LastSample(); return sample.getVoltage( Config::Sensors::ADS131M08::BOTTOM_PT_CHANNEL); }, @@ -452,11 +457,14 @@ void Sensors::vesselWeightInit(Boardcore::SensorManager::SensorMap_t &map) vesselWeight = std::make_unique<AnalogLoadCellSensor>( [this]() { - auto sample = adc1->getLastSample(); + auto sample = getADC1LastSample(); return sample.getVoltage( Config::Sensors::ADS131M08::VESSEL_LC_CHANNEL); }, - Config::Sensors::LoadCell::VESSEL_SCALE); + Config::Sensors::LoadCell::VESSEL_P0_VOLTAGE, + Config::Sensors::LoadCell::VESSEL_P0_MASS, + Config::Sensors::LoadCell::VESSEL_P1_VOLTAGE, + Config::Sensors::LoadCell::VESSEL_P1_MASS); SensorInfo info("VesselWeight", Config::Sensors::ADS131M08::SAMPLE_PERIOD, [this]() { vesselWeightCallback(); }); @@ -476,11 +484,14 @@ void Sensors::tankWeightInit(Boardcore::SensorManager::SensorMap_t &map) tankWeight = std::make_unique<AnalogLoadCellSensor>( [this]() { - auto sample = adc1->getLastSample(); + auto sample = getADC1LastSample(); return sample.getVoltage( Config::Sensors::ADS131M08::TANK_LC_CHANNEL); }, - Config::Sensors::LoadCell::TANK_SCALE); + Config::Sensors::LoadCell::TANK_P0_VOLTAGE, + Config::Sensors::LoadCell::TANK_P0_MASS, + Config::Sensors::LoadCell::TANK_P1_VOLTAGE, + Config::Sensors::LoadCell::TANK_P1_MASS); SensorInfo info("TankWeight", Config::Sensors::ADS131M08::SAMPLE_PERIOD, [this]() { tankWeightCallback(); });