Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r9b56de8996e71443e7963a5337119ae594188274 -r5a882c7292cea58e74b5a28d4e85dd60e741b834 --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 9b56de8996e71443e7963a5337119ae594188274) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 5a882c7292cea58e74b5a28d4e85dd60e741b834) @@ -31,25 +31,25 @@ // ********** private definitions ********** -#define COND_CPO_SENSOR_PROBE_TYPE 10 ///< 0.1 K cell constant conductivity probe -#define COND_SENSOR_DECIMAL_CONVERSION 100 ///< Conductivity value from FPGA has two decimal place -#define COND_SENSOR_TEMPERATURE_COEF 0.02 ///< Linear temperature coefficient of variation at 25 Celcius for fresh water -#define COND_SENSOR_REFERENCE_TEMPERATURE 25 ///< Reference temperature for conductivity sensor -#define COND_SENSOR_REPORT_PERIOD (MS_PER_SECOND / TASK_PRIORITY_INTERVAL) ///< Broadcast conductivity values message every second +#define COND_CPO_SENSOR_PROBE_TYPE 10 ///< 0.1 K cell constant conductivity probe. +#define COND_SENSOR_DECIMAL_CONVERSION 100 ///< Conductivity value from FPGA has two decimal place. +#define COND_SENSOR_TEMPERATURE_COEF 0.02 ///< Linear temperature coefficient of variation at 25 Celcius for fresh water. +#define COND_SENSOR_REFERENCE_TEMPERATURE 25 ///< Reference temperature for conductivity sensor. +#define COND_SENSOR_REPORT_PERIOD (MS_PER_SECOND / TASK_PRIORITY_INTERVAL) ///< Broadcast conductivity values message every second. -#define COND_SENSOR_CPI_CPO_MAX_VALUE 2000 ///< Maximum inlet water conductivity -#define COND_SENSOR_CPI_CPO_MIN_VALUE 100 ///< Minimum inlet water conductivity -#define COND_SENSOR_PERSISTENCE_COUNT (5 * MS_PER_SECOND / TASK_GENERAL_INTERVAL) ///< Number of persistence count for conductivity sensor out of range error +#define COND_SENSOR_CPI_CPO_MAX_VALUE 2000 ///< Maximum inlet water conductivity. +#define COND_SENSOR_CPI_CPO_MIN_VALUE 100 ///< Minimum inlet water conductivity. +#define COND_SENSOR_PERSISTENCE_COUNT (5 * MS_PER_SECOND / TASK_GENERAL_INTERVAL) ///< Number of persistence count for conductivity sensor out of range error. -#define MAX_ALLOWED_UNCHANGED_CONDUCTIVITY_READS 100 ///< New reading every 640 ms, expect to get new reading in 1s -#define MAX_CONDUCTIVITY_SENSOR_FAILURES 5 ///< maximum number of conductivity sensor errors within window period before alarm -#define MAX_CONDUCTIVITY_SENSOR_FAILURE_WINDOW_MS (60 * MS_PER_SECOND) ///< Conductivity sensor error window +#define MAX_ALLOWED_UNCHANGED_CONDUCTIVITY_READS 100 ///< New reading every 640 ms, expect to get new reading in 1s. +#define MAX_CONDUCTIVITY_SENSOR_FAILURES 5 ///< maximum number of conductivity sensor errors within window period before alarm. +#define MAX_CONDUCTIVITY_SENSOR_FAILURE_WINDOW_MS (60 * MS_PER_SECOND) ///< Conductivity sensor error window. -#define RO_REJECTION_RATIO_REPORT_PERIOD (MS_PER_SECOND / TASK_PRIORITY_INTERVAL) ///< Broadcast RO rejection ratio message every second -#define RO_REJECTION_RATIO_OUT_OF_RANGE_VALUE 1.0 ///< Out of range value for RO rejection ratio when CPi conductivity is zero -#define MAX_RO_REJECTION_RATIO_ALLOW 0.1 ///< Maximum RO Rejection ratio -#define MAX_CPO_CONDUCTIVITY_ALLOW 15.0 ///< Maximum CPo sensor conductivity value -#define RO_REJECTION_RATIO_PERSISTENCE_COUNT (10 * MS_PER_SECOND / TASK_GENERAL_INTERVAL) ///< Number of persistence count for RO rejection ro +#define RO_REJECTION_RATIO_REPORT_PERIOD (MS_PER_SECOND / TASK_PRIORITY_INTERVAL) ///< Broadcast RO rejection ratio message every second. +#define RO_REJECTION_RATIO_OUT_OF_RANGE_VALUE 1.0 ///< Out of range value for RO rejection ratio when CPi conductivity is zero. +#define MAX_RO_REJECTION_RATIO_ALLOW 0.1 ///< Maximum RO rejection ratio. +#define MAX_CPO_CONDUCTIVITY_ALLOW 15.0 ///< Maximum CPo sensor conductivity value. +#define RO_REJECTION_RATIO_PERSISTENCE_COUNT (10 * MS_PER_SECOND / TASK_GENERAL_INTERVAL) ///< Number of persistence count for RO rejection ratio. // ********** private data ********** @@ -62,11 +62,11 @@ static U08 readCount[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Read count for conductivity readings. static U32 internalErrorCount[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Internal error count for conductivity readings. static OVERRIDE_F32_T compensatedConductivityValues[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Latest compensated conductivity values. -static F32 roRejectionRatio; ///< Latest RO rejection ratio +static F32 roRejectionRatio; ///< Latest RO rejection ratio. static OVERRIDE_U32_T conductivityDataPublishInterval = { COND_SENSOR_REPORT_PERIOD, - COND_SENSOR_REPORT_PERIOD, 0, 0 }; ///< Conductivity sensors publish time interval override -static U32 conductivityDataPublicationTimerCounter = 0; ///< Conductivity sensors data publish timer counter + COND_SENSOR_REPORT_PERIOD, 0, 0 }; ///< Conductivity sensors publish time interval override. +static U32 conductivityDataPublicationTimerCounter = 0; ///< Conductivity sensors data publish timer counter. // ********** private function prototypes ********** @@ -75,7 +75,7 @@ static void calcRORejectionRatio( void ); static DATA_GET_PROTOTYPE( U32, getConductivityDataPublishInterval ); -/************************************************************************* +/*********************************************************************//** * @brief * The initConductivitySensors function initializes the ConductivitySensors module. * @details @@ -110,7 +110,7 @@ TRUE, RO_REJECTION_RATIO_PERSISTENCE_COUNT, RO_REJECTION_RATIO_PERSISTENCE_COUNT ); } -/************************************************************************* +/*********************************************************************//** * @brief * The execConductivitySensors function gets conductivity sensors' latest * readings from FPGA and advertises them over CAN. @@ -134,12 +134,12 @@ } -/************************************************************************* +/*********************************************************************//** * @brief * The checkInletWaterConductivity checks inlet water conductivity value * and triggers an alarm when conductivity value is out of allowed range. * @details - * Inputs : none + * Inputs : CPi sensor conductivity * Outputs : Trigger alarms when conductivity is out of allowed range * @return none *************************************************************************/ @@ -153,13 +153,13 @@ checkPersistentAlarm( PERSISTENT_ALARM_INLET_WATER_LOW_CONDUCTIVITY, isCondTooLow, conductivity ); } -/************************************************************************* +/*********************************************************************//** * @brief * The checkRORejectionRatio checks RO rejection ratio and outlet water * conductivity. The function triggers an alarm when RO rejection ratio or * outlet water conductivity is out of allowed range for period of time. * @details - * Inputs : none + * Inputs : roRejectionRatio, CPo sensor conductivity * Outputs : Triggered alarm * @return none *************************************************************************/ @@ -170,14 +170,14 @@ checkPersistentAlarm( PERSISTENT_ALARM_RO_REJECTION_RATIO_OUT_OF_RANGE, isRORejectionRatioOutOfRange, roRejectionRatio ); } -/************************************************************************* +/*********************************************************************//** * @brief * The getConductivityValue function gets the compensated conductivity * value for a given conductivity sensor id. * @details * Inputs : compensatedConductivityValues[] * Outputs : none - * @param sensorId Id of conductivity sensor to get conductivity value + * @param sensorId conductivity sensor id * @return compensated conductivity *************************************************************************/ F32 getConductivityValue( U32 sensorId ) @@ -203,16 +203,16 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The calcCompensatedConductivity function calculates the compensated * conductivity based on given temperature and conductivity taken at * reference temperature of 25 Celcius. * @details - * Inputs : temperature + * Inputs : conductivity, temperature * Outputs : none - * @param conductivity Conductivity value - * @param temperature Temperature to compensate conductivity with + * @param conductivity conductivity value + * @param temperature temperature to compensate conductivity with * @return compensated conductivity based on temperature *************************************************************************/ static F32 calcCompensatedConductivity( F32 conductivity, F32 temperature) @@ -223,12 +223,12 @@ return conductivity * compensatedCoef; } -/************************************************************************* +/*********************************************************************//** * @brief * The calcRORejectionRatio function calculates the RO rejection ratio using - * the cpi sensor conductivity value and cpo sensor conductivity value. + * the CPi sensor conductivity value and CPo sensor conductivity value. * @details - * Inputs: CPi sensor conductivity and CPo sensor conductivity + * Inputs: CPi sensor conductivity, CPo sensor conductivity * Outputs: RO rejection ratio * @return none *************************************************************************/ @@ -244,7 +244,7 @@ } } -/************************************************************************* +/*********************************************************************//** * @brief * The processCPiCPoSensorRead function checks if there is an error in FPGA * and FPGA read count. If there is any error in the FPGA error, it raises an @@ -289,7 +289,7 @@ } } -/************************************************************************* +/*********************************************************************//** * @brief * The getConductivityDataPublishInterval function gets the conductivity * data publication interval. @@ -315,15 +315,15 @@ *************************************************************************/ -/************************************************************************* +/*********************************************************************//** * @brief * The testSetConductivityOverride function overrides the compensated * conductivity value of given sensor id. * @details * Inputs : compensatedConductivityValues[] * Outputs : compensatedConductivityValues[] - * @param sensorId Id of conductivity sensor to get conductivity value - * @param value Override compensated conductivity value + * @param sensorId conductivity sensor id + * @param value override compensated conductivity value * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetConductivityOverride( U32 sensorId, F32 value ) @@ -343,14 +343,14 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The testResetConductivityOverride function resets the override of the \n * conductivity sensor value. * @details * Inputs : compensatedConductivityValues[] * Outputs : compensatedConductivityValues[] - * @param sensorId Id of the conductivity sensor to override. + * @param sensorId conductivity sensor id * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetConductivityOverride( U32 sensorId ) @@ -370,14 +370,14 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The testSetConductivityDataPublishIntervalOverride function overrides * the conductivity data publish interval. * @details * Inputs : conductivityDataPublishInterval * Outputs : conductivityDataPublishInterval - * @param value Override conductivity data publish interval with (in ms) + * @param value override conductivity data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetConductivityDataPublishIntervalOverride( U32 interval_ms ) @@ -394,7 +394,7 @@ return result; } -/************************************************************************* +/*********************************************************************//** * @brief * The testResetConductivityDataPublishIntervalOverride function resets * the override of the conductivity data publish interval.