Index: firmware/App/Drivers/ConductivitySensors.h =================================================================== diff -u -ra9983d3e6b07e7c927fab3d16e80b715594fe221 -r7983907af837390c90979b1ac727f3f55f0b7ae2 --- firmware/App/Drivers/ConductivitySensors.h (.../ConductivitySensors.h) (revision a9983d3e6b07e7c927fab3d16e80b715594fe221) +++ firmware/App/Drivers/ConductivitySensors.h (.../ConductivitySensors.h) (revision 7983907af837390c90979b1ac727f3f55f0b7ae2) @@ -1,30 +1,31 @@ /************************************************************************** * -* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* 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) 10-Sep-2024 +* @date (last) 09-Sep-2025 * * @author (original) Vinayakam Mani -* @date (original) 10-Sep-2024 +* @date (original) 13-Sep-2024 * ***************************************************************************/ #ifndef __CONDUCTIVITY_SENSORS_H__ #define __CONDUCTIVITY_SENSORS_H__ #include "DDCommon.h" +#include "DDDefs.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 CD1,CD2, CD3 and CD4. + * for D17,D27, D29, D43, D74, P9 and P18 * * Conductivity Sensor Module * Diality P/N: TBD @@ -36,45 +37,89 @@ */ // ********** public definitions ********** +#define CONDUCTIVITY_CAL_CHAR_LENGTH 12 -/// Enumeration of conductivity sensors. -typedef enum ConductivitySensors +/// Enumeration of calibration data +typedef enum ConductivityCalDataIdx { - FIRST_COND_SENSOR = 0, ///< First conductivity sensor - D17_COND = FIRST_COND_SENSOR, ///< Bicarb only conductivity sensor - 1 - 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 - NUM_OF_CONDUCTIVITY_SENSORS ///< Number of conductivity sensors -} CONDUCTIVITY_SENSORS_T; + 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; +/// Conductivity sensor calibration struct +typedef struct { + F32 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] + F32 zeta_high; ///< (resistance offset, high range), default = 0, range = [-1000, 1000] + F32 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] + F32 zeta_low; ///< (resistance offset, low range), default = 0, range = [-1000, 1000] + F32 beta; ///< (Temperature scale factor), default = 1, range = [0.5, 2] + F32 delta; ///< (Temperature offset), default = 0, range = [-10, 10] + F32 reserved1; ///< Reserved cal slot. + F32 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 readConductivitySensors( void ); +void execConductivitySensors( void ); +void readConductivitySensorData( void ); -F32 getConductivityValue( CONDUCTIVITY_SENSORS_T sensor ); -F32 getConductivityTemperatureValue( CONDUCTIVITY_SENSORS_T sensor ); -U32 getConductivitySensorReadCount( CONDUCTIVITY_SENSORS_T sensor ); -U32 getConductivitySensorErrorCount( CONDUCTIVITY_SENSORS_T sensor ); +F32 getConductivity( CONDUCTIVITY_SENSORS_T sensor ); +F32 getConductivityTemperature( CONDUCTIVITY_SENSORS_T sensor ); -void handleConductivitySensorsReset( void ); -void handleConductivitySensorsInitProcedure( void ); -void execConductivitySensorWrite( void ); -void execConductivitySensorRead( void ); - -void requestConductivitySensorReset( CONDUCTIVITY_SENSORS_T sensor ); -void setConductivitySensorInitEnable( CONDUCTIVITY_SENSORS_T sensor ); -void conductivitySensorWriteRequest( CONDUCTIVITY_SENSORS_T sensor, U16 writeAddr, U32 data ); -void conductivitySensorReadRequest( CONDUCTIVITY_SENSORS_T sensor, U16 readAddr ); -U32 conductivitySensorReadData( CONDUCTIVITY_SENSORS_T sensor ); - -BOOL testConductivitySensorReadingsOverride( MESSAGE_T *message ); +BOOL testConductivitySensorConductivityReadingsOverride( MESSAGE_T *message ); BOOL testConductivitySensorTemperatureReadingsOverride( MESSAGE_T *message ); -BOOL testConductivitySensorReadCounterOverride( MESSAGE_T *message ); -BOOL testConductivitySensorErrorCounterOverride( MESSAGE_T *message ); +BOOL testConductivitySensorConductivityReadCounterOverride( MESSAGE_T *message ); +BOOL testConductivitySensorConductivityErrorCounterOverride( 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