Index: firmware/App/Drivers/FlowSensor.c =================================================================== diff -u -r5aaed18e3cd460c091c36c95c81635273bad61c6 -reaadab648c4c1d6d34f3927df6ce5cfb59cdebb6 --- firmware/App/Drivers/FlowSensor.c (.../FlowSensor.c) (revision 5aaed18e3cd460c091c36c95c81635273bad61c6) +++ firmware/App/Drivers/FlowSensor.c (.../FlowSensor.c) (revision eaadab648c4c1d6d34f3927df6ce5cfb59cdebb6) @@ -15,28 +15,28 @@ * ***************************************************************************/ -#include "AlarmMgmtRO.h" +#include "AlarmMgmtRO.h" #include "FlowSensor.h" -#include "FpgaRO.h" +#include "FpgaRO.h" #include "Messaging.h" #include "PersistentAlarm.h" - -/** - * @addtogroup FlowSensor - * @{ - */ - -// ********** private definitions ********** +/** + * @addtogroup FlowSensor + * @{ + */ + +// ********** private definitions ********** + #define FLOW_TEMPERATURE_DIVIDER 10.0F ///< Divider for converting flow readings to mL/min flow rates. -// ********** private data ********** - +// ********** private data ********** + static OVERRIDE_F32_T currentFlowReadings[ NUM_OF_FLOW_SENSORS ]; ///< Current flow sensor pressure readings (overrideable). static OVERRIDE_F32_T currentFlowTempReadings[ NUM_OF_FLOW_SENSORS ]; ///< Current flow sensor temperature readings (overrideable). -// ********** private function prototypes ********** - +// ********** private function prototypes ********** + /*********************************************************************//** * @brief * The initFlowSensor function initializes the Flow Sensor unit. @@ -77,11 +77,11 @@ { // Update and convert raw flow rates to mL/min currentFlowReadings[ FLOW_SENSOR_RO_OUTLET ].data = (F32)( (S16)getFPGAFlowFMP() ); - //currentFlowReadings[ FLOW_SENSOR_WATER_INLET ].data = TBD; + currentFlowReadings[ FLOW_SENSOR_WATER_INLET ].data = (F32)( (S16)getFPGAFlowFMS() ); // Update and convert raw flow sensor temperatures to deg C currentFlowTempReadings[ FLOW_SENSOR_RO_OUTLET ].data = (F32)( (S16)getFPGAFlowFMPTemp() ) / FLOW_TEMPERATURE_DIVIDER; - //currentFlowTempReadings[ FLOW_SENSOR_WATER_INLET ].data = TBD + currentFlowTempReadings[ FLOW_SENSOR_WATER_INLET ].data = (F32)( (S16)getFPGAFlowFMSTemp() ) / FLOW_TEMPERATURE_DIVIDER; } /*********************************************************************//** @@ -144,12 +144,12 @@ return result; } - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + /*********************************************************************//** * @brief * The testFlowSensorReadingsOverride function overrides the value of @@ -166,7 +166,7 @@ return result; } - + /*********************************************************************//** * @brief * The testFlowSensorTemperatureReadingsOverride function overrides the @@ -184,4 +184,4 @@ return result; } -/**@}*/ +/**@}*/ Index: firmware/App/Monitors/Level.c =================================================================== diff -u -rd4d21b42ee8bd292a6d9f7966fe37abe0271dfda -reaadab648c4c1d6d34f3927df6ce5cfb59cdebb6 --- firmware/App/Monitors/Level.c (.../Level.c) (revision d4d21b42ee8bd292a6d9f7966fe37abe0271dfda) +++ firmware/App/Monitors/Level.c (.../Level.c) (revision eaadab648c4c1d6d34f3927df6ce5cfb59cdebb6) @@ -33,6 +33,10 @@ #define LEVEL_DEBOUNCE_TIME_MS ( MS_PER_SECOND / 10 ) ///< Level debounce time in milliseconds. #define DATA_PUBLISH_COUNTER_START_COUNT 7 ///< Data publish counter start count. +#define LOW_LEVEL_SWITCH_BIT 0x01 ///< Bit position for lower level switch. +#define HIGH_LEVEL_SWITCH_BIT 0x02 ///< Bit position for upper level switch. +#define LEVEL_SWITCH_BIT_MASK 0x03 ///< Bit mask for level switch bits. + /// Level status structure typedef struct { @@ -85,8 +89,22 @@ *************************************************************************/ void execLevels( void ) { - U32 currentLevelState = ( getFPGAFloaterState() != 0 ? LEVEL_STATE_LOW : LEVEL_STATE_MEDIUM ); + U08 levelBits = getFPGAFloaterState() & LEVEL_SWITCH_BIT_MASK; + U32 currentLevelState = LEVEL_STATE_LOW; + // Convert floater switch bits to level + if ( ( levelBits & LOW_LEVEL_SWITCH_BIT ) != 0 ) + { + if ( ( levelBits & HIGH_LEVEL_SWITCH_BIT ) != 0 ) + { // upper switch is active low + currentLevelState = LEVEL_STATE_MEDIUM; + } + else + { + currentLevelState = LEVEL_STATE_HIGH; + } + } + // Check if the current level status is not the same as the recorded data if ( currentLevelState != levelState.level.data ) { Index: firmware/App/Services/FpgaRO.c =================================================================== diff -u -rce66580e076bffa157868ff7e422556f78a95cac -reaadab648c4c1d6d34f3927df6ce5cfb59cdebb6 --- firmware/App/Services/FpgaRO.c (.../FpgaRO.c) (revision ce66580e076bffa157868ff7e422556f78a95cac) +++ firmware/App/Services/FpgaRO.c (.../FpgaRO.c) (revision eaadab648c4c1d6d34f3927df6ce5cfb59cdebb6) @@ -766,6 +766,33 @@ /*********************************************************************//** * @brief + * The getFPGAFlowFMS function gets the FMS flow rate (in mL/min). + * @details \b Inputs: fpgaSensorReadings.flowRateFms + * @details \b Outputs: none + * @return FMS flow rate (in mL/min) + *************************************************************************/ +U16 getFPGAFlowFMS( void ) +{ + //return fpgaSensorReadings.flowRateFms; + return 0; +} + +/*********************************************************************//** + * @brief + * The getFPGAFlowFMSTemp function gets the FMS flow sensor temperature, the + * temperature of the fluid flowing through the sensor. + * @details \b Inputs: fpgaSensorReadings.flowTempFms + * @details \b Outputs: none + * @return FMS fluid temperature + *************************************************************************/ +U16 getFPGAFlowFMSTemp( void ) +{ + //return fpgaSensorReadings.flowTempFms; + return 0; +} + +/*********************************************************************//** + * @brief * The setFPGACPiControl function sets the FPGA CPi sensor control register * to perform a given action. * bit 4..7: unused Index: firmware/App/Services/FpgaRO.h =================================================================== diff -u -rce66580e076bffa157868ff7e422556f78a95cac -reaadab648c4c1d6d34f3927df6ce5cfb59cdebb6 --- firmware/App/Services/FpgaRO.h (.../FpgaRO.h) (revision ce66580e076bffa157868ff7e422556f78a95cac) +++ firmware/App/Services/FpgaRO.h (.../FpgaRO.h) (revision eaadab648c4c1d6d34f3927df6ce5cfb59cdebb6) @@ -83,8 +83,8 @@ U16 getFPGAFlowFMP( void ); U16 getFPGAFlowFMPTemp( void ); -//U16 getFPGAFlowFMS( void ); -//U16 getFPGAFlowFMSTemp( void ); +U16 getFPGAFlowFMS( void ); +U16 getFPGAFlowFMSTemp( void ); void setFPGACPiControl( U08 control ); void setFPGACPiAddress( U16 address ); Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r2205857f59dd884c4af450239381387cfb560c2e -reaadab648c4c1d6d34f3927df6ce5cfb59cdebb6 --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 2205857f59dd884c4af450239381387cfb560c2e) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision eaadab648c4c1d6d34f3927df6ce5cfb59cdebb6) @@ -1,5 +1,6 @@ #include "Conductivity.h" +#include "Flow.h" #include "FPGA.h" #include "InternalADC.h" #include "Level.h" @@ -42,6 +43,9 @@ // Monitor pressure sensors execPressureSensor(); + // Monitor flow sensors + execFlowMonitor(); + // Control valves execValves(); Index: firmware/source/sys_main.c =================================================================== diff -u -rf47296145b6a0adb78df0e325587629171909fd6 -reaadab648c4c1d6d34f3927df6ce5cfb59cdebb6 --- firmware/source/sys_main.c (.../sys_main.c) (revision f47296145b6a0adb78df0e325587629171909fd6) +++ firmware/source/sys_main.c (.../sys_main.c) (revision eaadab648c4c1d6d34f3927df6ce5cfb59cdebb6) @@ -64,6 +64,7 @@ #include "AlarmMgmtRO.h" #include "CommBuffers.h" #include "Conductivity.h" +#include "Flow.h" #include "FpgaRO.h" #include "Interrupts.h" #include "Level.h" @@ -167,6 +168,7 @@ initLevels(); initPressure(); initTemperature(); + initFlow(); initROPump(); initValves();