Index: firmware/App/Drivers/ConductivitySensors.c =================================================================== diff -u -r53eaeea39c88b1894a6b2d7b5c2733fbf037e0da -r94a98f376c6c8c3785f05f5a1b19cc1108fe336e --- firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 53eaeea39c88b1894a6b2d7b5c2733fbf037e0da) +++ firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 94a98f376c6c8c3785f05f5a1b19cc1108fe336e) @@ -905,6 +905,12 @@ F32 zeta = 0.0; F32 R = conductivitySensorStatus[ sensorNum ].rawResistance; + // To prevent nan's being thrown into our rolling average by dividing by 0, we set to 1. + if ( R == 0 ) + { + R = 1; + } + if ( TRUE == isFPSensor ) { eta = conductivitySensorCoefficients[ sensorNum ].eta_low; Index: firmware/App/Drivers/ConductivityTeensy.c =================================================================== diff -u -r53eaeea39c88b1894a6b2d7b5c2733fbf037e0da -r94a98f376c6c8c3785f05f5a1b19cc1108fe336e --- firmware/App/Drivers/ConductivityTeensy.c (.../ConductivityTeensy.c) (revision 53eaeea39c88b1894a6b2d7b5c2733fbf037e0da) +++ firmware/App/Drivers/ConductivityTeensy.c (.../ConductivityTeensy.c) (revision 94a98f376c6c8c3785f05f5a1b19cc1108fe336e) @@ -1790,12 +1790,12 @@ // Store Raw value in array index for position ( sensorNum - 1 ) memcpy( &condRawMeasurement[ tempSensor.sensorNum - 1 ], &tempSensor, sizeof( COND_SENSOR_DATA_T ) ); - // Calculate and store Conductivity from raw values - calculateConductivity( tempSensor.sensorNum - 1 ); - // Calculate and store Temperature from raw values. calculateTemperature( tempSensor.sensorNum - 1 ); + // Calculate and store Conductivity from raw values + calculateConductivity( tempSensor.sensorNum - 1 ); + parseStatus = COND_PARSE_SUCCESS; } } @@ -1972,6 +1972,11 @@ { R = COND_INFINITE_R_VALUE; } + // To prevent nan's being thrown into our rolling average by dividing by 0, we set to 1. + else if ( R == 0 ) + { + R = 1; + } if ( TRUE == isFPSensor ) { @@ -2049,13 +2054,18 @@ F64 k = 0.0; F32 R = condRawMeasurement[ sensorNum ].impRzMag; - // Aly sensors are known to send the driver INF in unfavorable conditions for impedance. e.g: open air + // Sensors are known to send the driver INF in unfavorable conditions for impedance. e.g: open air // Change it to some high value that can be determined that we are reading INF. // Otherwise we will publish no updated value or 0. if ( R == INFINITY ) { R = COND_INFINITE_R_VALUE; } + // To prevent nan's being thrown into our rolling average by dividing by 0, we set to 1. + else if ( R == 0 ) + { + R = 1; + } if ( TRUE == isFPSensor ) { @@ -2169,13 +2179,13 @@ { F32 value = payload.state.f32; - condCalculatedMeasurement[ payload.index ].Conductivity.ovData = value; - condCalculatedMeasurement[ payload.index ].Conductivity.override = OVERRIDE_KEY; + condCalculatedMeasurement[ getTeensyCondId( payload.index ) ].Conductivity.ovData = value; + condCalculatedMeasurement[ getTeensyCondId( payload.index ) ].Conductivity.override = OVERRIDE_KEY; } else { - condCalculatedMeasurement[ payload.index ].Conductivity.override = OVERRIDE_RESET; - condCalculatedMeasurement[ payload.index ].Conductivity.ovData = condCalculatedMeasurement[ payload.index ].Conductivity.ovInitData; + condCalculatedMeasurement[ getTeensyCondId( payload.index ) ].Conductivity.override = OVERRIDE_RESET; + condCalculatedMeasurement[ getTeensyCondId( payload.index ) ].Conductivity.ovData = condCalculatedMeasurement[ payload.index ].Conductivity.ovInitData; } } } Index: firmware/App/Monitors/Conductivity.c =================================================================== diff -u -r53eaeea39c88b1894a6b2d7b5c2733fbf037e0da -r94a98f376c6c8c3785f05f5a1b19cc1108fe336e --- firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 53eaeea39c88b1894a6b2d7b5c2733fbf037e0da) +++ firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 94a98f376c6c8c3785f05f5a1b19cc1108fe336e) @@ -694,10 +694,6 @@ if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) != TRUE ) { - result = testConductivitySensorConductivityReadingsOverride( message ); - } - else - { if ( payload.index != D74_COND ) { @@ -708,6 +704,10 @@ result = testConductivitySensorReadingsOverride( message ); } } + else + { + result = testConductivitySensorConductivityReadingsOverride( message ); + } return result; } @@ -731,10 +731,6 @@ if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) != TRUE ) { - result = testConductivitySensorTemperatureReadingsOverride( message ); - } - else - { if ( payload.index != D74_COND ) { @@ -745,6 +741,10 @@ result = testConductivitySensorTemperatureReadingsOverride( message ); } } + else + { + result = testConductivitySensorTemperatureReadingsOverride( message ); + } return result; } Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -r60a51700339b700e37dad4da6edffa8a4481c725 -r94a98f376c6c8c3785f05f5a1b19cc1108fe336e --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 60a51700339b700e37dad4da6edffa8a4481c725) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 94a98f376c6c8c3785f05f5a1b19cc1108fe336e) @@ -656,8 +656,8 @@ void initFPGADD( void ) { // Initialize fpga driver for beta 2 hardware - initFPGA( (U08*)&fpgaHeader, (U08*)&fpgaBeta19SensorReadings, (U08*)&fpgaBeta19ActuatorSetPoints, - sizeof(FPGA_HEADER_T), sizeof(DD_FPGA_SENSORS_BETA_1_9_T), sizeof(FPGA_ACTUATORS_BETA_1_9_T) ); + initFPGA( (U08*)&fpgaHeader, (U08*)&fpgaSensorReadings, (U08*)&fpgaActuatorSetPoints, + sizeof(FPGA_HEADER_T), sizeof(DD_FPGA_SENSORS_T), sizeof(FPGA_ACTUATORS_T) ); // initialize fpga data structures memset( &fpgaHeader, 0, sizeof( FPGA_HEADER_T ) );