/************************************************************************** * * Copyright (c) 2024-2026 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file ConductivitySensors.h * * @author (last) Vinayakam Mani * @date (last) 09-Sep-2025 * * @author (original) Vinayakam Mani * @date (original) 13-Sep-2024 * ***************************************************************************/ #ifndef __CONDUCTIVITY_SENSORS_H__ #define __CONDUCTIVITY_SENSORS_H__ #include "DDCommon.h" /** * @defgroup ConductivitySensors ConductivitySensors * @brief Conductivity Sensors monitor module. Monitors and filters conductivity sensor readings. * The module uses AD5941 - high precision, low power analog front ends(AFEs) for conductivity measurement * for D17,D27, D29, D43, D74, P9 and P18 * * Conductivity Sensor Module * Diality P/N: TBD * Manufacturer: TBD * Manufacture P/N: TBD * * @addtogroup ConductivitySensors * @{ */ // ********** public definitions ********** #define CONDUCTIVITY_CAL_CHAR_LENGTH 10 /// Enumeration of conductivity sensors. typedef enum ConductivitySensors { D17_COND = 0, ///< Bicarb only conductivity sensor - 1 FIRST_DD_COND_SENSOR = D17_COND, ///< First conductivity sensor D27_COND, ///< Acid and Bicarb mix conductivity sensor - 1 D29_COND, ///< Acid and Bicarb mix conductivity sensor - 2 D43_COND, ///< Spent dialysate conductivity sensor D74_COND, ///< Bicarb only conductivity sensor - 2 LAST_DD_COND_SENSOR = D74_COND, ///< Last conductivity sensor P9_COND, ///< Inlet water conductivity sensor FIRST_FP_COND_SENSOR = P9_COND, ///< First FP conductivity sensor P18_COND, ///< RO outlet water conductivity sensor LAST_FP_COND_SENSOR = P18_COND, ///< Last FP conductivity sensor NUM_OF_CONDUCTIVITY_SENSORS ///< Number of conductivity sensors } CONDUCTIVITY_SENSORS_T; typedef enum ConductivityCalDataIdx { CAL_DATA_1, ///< Cal Data 1. cell coefficient, high range FIRST_CAL_DATA = CAL_DATA_1, ///< First index of calibration data CAL_DATA_2, ///< Cal Data 2. temperature correction, high range CAL_DATA_3, ///< Cal Data 3. resistance scale factor, high range CAL_DATA_4, ///< Cal Data 4. resistance offset, high range CAL_DATA_5, ///< Cal Data 5. cell coefficient, low range CAL_DATA_6, ///< Cal Data 6. temperature correction, low range CAL_DATA_7, ///< Cal Data 7. resistance scale factor, low range CAL_DATA_8, ///< Cal Data 8. resistance offset, low range CAL_DATA_9, ///< Cal Data 9. cell coefficient, high range CAL_DATA_10, ///< Cal Data 10. Temperature scale factor CAL_DATA_11, ///< Cal Data 11. Reserved. CAL_DATA_12, ///< Cal Data 12. Reserved LAST_CAL_DATA = CAL_DATA_12, ///< Last index of calibration data SW_REV_LOWER_WORD, ///< SW Revision. 3 - 0 bytes FIRST_SW_REV = SW_REV_LOWER_WORD, ///< First index of SW revision SW_REV_MID_WORD, ///< SW Revision. 7 - 4 bytes SW_REV_UPPER_WORD, ///< SW Revision. 9 - 8 bytes + 0'd 10th & 11th byte ( 0x0000 ) LAST_SW_REV = SW_REV_UPPER_WORD, ///< Last index of SW revision HW_REV_LOWER_WORD, ///< HW Revision. 3 - 0 bytes FIRST_HW_REV = HW_REV_LOWER_WORD, ///< First index of HW revision HW_REV_MID_WORD, ///< HW Revision. 7 - 4 bytes HW_REV_UPPER_WORD, ///< HW Revision. 9 - 8 bytes + 0'd 10th & 11th byte ( 0x0000 ) LAST_HW_REV = HW_REV_UPPER_WORD, ///< Last index of HW revision HW_SERIAL_LOWER_WORD, ///< HW Serial Number. 3 - 0 bytes FIRST_SERIAL_REV = HW_SERIAL_LOWER_WORD, ///< First index of HW Serial Number HW_SERIAL_MID_WORD, ///< HW Serial Number. 7 - 4 bytes HW_SERIAL_UPPER_WORD, ///< HW Serial Number. 9 - 8 bytes + 0'd 10th & 11th byte ( 0x0000 ) LAST_SERIAL_REV = HW_SERIAL_UPPER_WORD, ///< Last index of HW Serial Number NUM_OF_CONDUCTIVTY_CAL_IDXS, ///< Number of conductivity cal indexes. } CONDUCTIVITY_CAL_IDX_T; typedef struct { U32 K_high; ///< (cell coefficient, high range), default = 4, range = [3, 6] F32 alpha_high; ///< (temperature correction, high range), default = 0.02, range = [0.005, 0.04] F32 eta_high; ///< (resistance scale factor, high range), default = 1, range = [0.5, 3] S32 zeta_high; ///< (resistance offset, high range), default = 0, range = [-1000, 1000] U32 K_low; ///< (cell coefficient, low range), default = 4, range = [3, 6] F32 alpha_low; ///< (temperature correction, low range), default = 0.02, range = [0.005, 0.04] F32 eta_low; ///< (resistance scale factor, low range), default = 1, range = [0.5, 3] S32 zeta_low; ///< (resistance offset, low range), default = 0, range = [-1000, 1000] F32 beta; ///< (Temperature scale factor), default = 1, range = [0.5, 2] S32 delta; ///< (Temperature offset), default = 0, range = [-10, 10] U32 reserved1; ///< Reserved cal slot. U32 reserved2; ///< Reserved cal slot. } CONDUCTIVITY_COEFFICIENTS_T; typedef struct { U08 swRev[ CONDUCTIVITY_CAL_CHAR_LENGTH ]; ///< SW Revision. U08 hwRev[ CONDUCTIVITY_CAL_CHAR_LENGTH ]; ///< HW Revision U08 hwSerial[ CONDUCTIVITY_CAL_CHAR_LENGTH ]; ///< HW Serial Number. } CONDUCTIVITY_REVISIONS_T; // ********** public function prototypes ********** void initConductivitySensors( void ); void execConductivitySensors( void ); void readConductivitySensorData( void ); F32 getConductivityValue( CONDUCTIVITY_SENSORS_T sensor ); F32 getConductivityTemperatureValue( CONDUCTIVITY_SENSORS_T sensor ); BOOL testDDConductivitySensorReadingsOverride( MESSAGE_T *message ); BOOL testDDConductivitySensorTemperatureReadingsOverride( MESSAGE_T *message ); BOOL testDDConductivitySensorConductivityReadCounterOverride( MESSAGE_T *message ); BOOL testDDConductivitySensorConductivityErrorCounterOverride( MESSAGE_T *message ); BOOL testDDConductivitySensorTemperatureReadCounterOverride( MESSAGE_T *message ); BOOL testDDConductivitySensorTemperatureErrorCounterOverride( MESSAGE_T *message ); BOOL testFPConductivitySensorReadingsOverride( MESSAGE_T *message ); BOOL testFPConductivitySensorTemperatureReadingsOverride( MESSAGE_T *message ); BOOL testFPConductivitySensorConductivityReadCounterOverride( MESSAGE_T *message ); BOOL testFPConductivitySensorConductivityErrorCounterOverride( MESSAGE_T *message ); BOOL testFPConductivitySensorTemperatureReadCounterOverride( MESSAGE_T *message ); BOOL testFPConductivitySensorTemperatureErrorCounterOverride( MESSAGE_T *message ); /**@}*/ #endif