Index: firmware/App/Drivers/ConductivitySensors.c =================================================================== diff -u -r7983907af837390c90979b1ac727f3f55f0b7ae2 -rbc7dad193df69c64cf213db463e5115b1ba8a5f0 --- firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 7983907af837390c90979b1ac727f3f55f0b7ae2) +++ firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision bc7dad193df69c64cf213db463e5115b1ba8a5f0) @@ -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 -r7983907af837390c90979b1ac727f3f55f0b7ae2 -rbc7dad193df69c64cf213db463e5115b1ba8a5f0 --- firmware/App/Drivers/ConductivityTeensy.c (.../ConductivityTeensy.c) (revision 7983907af837390c90979b1ac727f3f55f0b7ae2) +++ firmware/App/Drivers/ConductivityTeensy.c (.../ConductivityTeensy.c) (revision bc7dad193df69c64cf213db463e5115b1ba8a5f0) @@ -1789,12 +1789,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; } } @@ -1971,6 +1971,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 ) { @@ -2048,13 +2053,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 ) { @@ -2168,13 +2178,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 -r7983907af837390c90979b1ac727f3f55f0b7ae2 -rbc7dad193df69c64cf213db463e5115b1ba8a5f0 --- firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 7983907af837390c90979b1ac727f3f55f0b7ae2) +++ firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision bc7dad193df69c64cf213db463e5115b1ba8a5f0) @@ -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 -r1077fee46974061e6e0038b6c0ce0e1471715b61 -rbc7dad193df69c64cf213db463e5115b1ba8a5f0 --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 1077fee46974061e6e0038b6c0ce0e1471715b61) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision bc7dad193df69c64cf213db463e5115b1ba8a5f0) @@ -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 ) );