Index: firmware/.launches/HD.launch
===================================================================
diff -u -r7665e7b142961a50c5e77c44877247366a374526 -rf5f00981805e265ce63058f650d784f06db4d188
--- firmware/.launches/HD.launch (.../HD.launch) (revision 7665e7b142961a50c5e77c44877247366a374526)
+++ firmware/.launches/HD.launch (.../HD.launch) (revision f5f00981805e265ce63058f650d784f06db4d188)
@@ -7,6 +7,7 @@
+
@@ -22,13 +23,16 @@
+
+
+
Index: firmware/App/Controllers/Fans.c
===================================================================
diff -u -r4164cba570c42566aee10d7cce23c3cea0d903ee -rf5f00981805e265ce63058f650d784f06db4d188
--- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 4164cba570c42566aee10d7cce23c3cea0d903ee)
+++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision f5f00981805e265ce63058f650d784f06db4d188)
@@ -42,24 +42,25 @@
/// Fans exec states
typedef enum fans_Exec_States
{
- FANS_EXEC_STATE_WAIT_FOR_POST_STATE = 0, ///< Fans exec state start state
- FANS_EXEC_STATE_RUN_STATE, ///< Fans exec state run state
- NUM_OF_FANS_EXEC_STATES, ///< Number of fans exec states
+ FANS_EXEC_STATE_WAIT_FOR_POST_STATE = 0, ///< Fans exec state start state
+ FANS_EXEC_STATE_RUN_STATE, ///< Fans exec state run state
+ NUM_OF_FANS_EXEC_STATES, ///< Number of fans exec states
} FANS_EXEC_STATES_T;
/// Fans status struct
typedef struct
{
- F32 targetDutyCycle; ///< Fan's target duty cycle that was fed to the fans
- U32 rpm[ NUM_OF_FANS_NAMES ]; ///< Fan's current tachometers reading in RPM
+ F32 targetDutyCycle; ///< Fan's target duty cycle that was fed to the fans
+ U32 rpm[ NUM_OF_FANS_NAMES ]; ///< Fan's current tachometers reading in RPM
} FAN_STATUS_T;
-static FAN_STATUS_T fansStatus; ///< Fans status.
-static FANS_EXEC_STATES_T fansExecState = FANS_EXEC_STATE_WAIT_FOR_POST_STATE; ///< Fans exec state.
-static U32 fansControlCounter = 0; ///< Fans control interval counter.
-static U32 fansPublishCounter = 0; ///< Fans data publish interval counter.
-static U32 fansMonitorCounter = 0; ///< Fans monitor interval counter.
-static BOOL isPOSTComplete = FALSE; ///< Flag that indicates whether POST is complete or not.
+static FAN_STATUS_T fansStatus; ///< Fans status.
+static FANS_EXEC_STATES_T fansExecState = FANS_EXEC_STATE_WAIT_FOR_POST_STATE; ///< Fans exec state.
+static U32 fansControlCounter = 0; ///< Fans control interval counter.
+static U32 fansPublishCounter = 0; ///< Fans data publish interval counter.
+static U32 fansMonitorCounter = 0; ///< Fans monitor interval counter.
+static BOOL isPOSTComplete = FALSE; ///< Flag that indicates whether POST is complete or not.
+static BOOL hasAlarmBeenRaised = FALSE; ///< Flag that indicates whether RPM out of range alarm has been raised once.
/// Temperature to duty cycle conversion slope (duty cycle not in percent)
static const F32 SLOPE = ( FANS_MAX_DUTY_CYCLE - FANS_MIN_DUTY_CYCLE ) / ( MAX_ALLOWED_AMBINET_TEMPERATURE - MIN_ALLOWED_AMBIENT_TEMPERATURE );
@@ -95,6 +96,7 @@
fansPublishCounter = 0;
fansMonitorCounter = 0;
isPOSTComplete = FALSE;
+ hasAlarmBeenRaised = FALSE;
// Initialize a persistent alarm for fans RPM out of range
initPersistentAlarm( ALARM_ID_HD_FAN_RPM_OUT_OF_RANGE, FANS_MAX_ALLOWED_RPM_OUT_OF_RANGE_INTERVAL, FANS_MAX_ALLOWED_RPM_OUT_OF_RANGE_INTERVAL );
@@ -129,9 +131,6 @@
*************************************************************************/
void execFans( void )
{
- // Monitor the fans
- //monitorFans(); TODO uncomment. this is to investigate why the fans RPM are out of range
-
switch ( fansExecState )
{
case FANS_EXEC_STATE_WAIT_FOR_POST_STATE:
@@ -148,6 +147,12 @@
break;
}
+ // Convert the counts to RPM
+ convertTogglePeriod2RPM();
+
+ // Monitor the RPM of the fans
+ monitorFans();
+
publishFansData();
}
@@ -297,7 +302,8 @@
************************************************************************/
static F32 getMaximumTemperature( void )
{
- F32 temperature = 0.0;
+ F32 temperature;
+
F32 maxTemperature = 0.0;
// NOTE: a for loop was not used because the venous pressure sensor's temperature
@@ -361,19 +367,25 @@
if ( ++fansMonitorCounter >= FANS_MONITOR_INTERVAL_COUNT )
{
- // The RPM is expected to be 5500 @ 100% duty cycle
- // The nominal RPM = duty cycle * 5500 / 1.0
- // The RPM tolerance is -25% to +50% of the nominal RPM
- F32 fansNominalRPM = fansStatus.targetDutyCycle * FANS_MAX_ALLOWED_RPM;
- F32 fansMinAllowedRPM = fansNominalRPM - ( fansNominalRPM * FANS_MIN_RPM_OUT_OF_RANGE_TOL );
- F32 fansMaxAllowedRPM = fansNominalRPM - ( fansNominalRPM * FANS_MAX_RPM_OUT_OF_RANGE_TOL );
+ if ( FALSE == hasAlarmBeenRaised )
+ {
+ BOOL isFanRPMOutOfRange;
- convertTogglePeriod2RPM();
+ // The RPM is expected to be 5500 @ 100% duty cycle
+ // The nominal RPM = duty cycle * 5500 / 1.0
+ // The RPM tolerance is -25% to +50% of the nominal RPM
+ F32 fansNominalRPM = fansStatus.targetDutyCycle * FANS_MAX_ALLOWED_RPM;
+ F32 fansMinAllowedRPM = fansNominalRPM - ( fansNominalRPM * FANS_MIN_RPM_OUT_OF_RANGE_TOL );
+ F32 fansMaxAllowedRPM = fansNominalRPM + ( fansNominalRPM * FANS_MAX_RPM_OUT_OF_RANGE_TOL );
- for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ )
- {
- BOOL fanRpmOutOfRange = ( fansStatus.rpm[ fan ] < fansMinAllowedRPM ) || ( fansStatus.rpm[ fan ] > fansMaxAllowedRPM );
- isPersistentAlarmTriggered( ALARM_ID_DG_FAN_RPM_OUT_OF_RANGE, fanRpmOutOfRange );
+ for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ )
+ {
+ isFanRPMOutOfRange = ( fansStatus.rpm[ fan ] < fansMinAllowedRPM ) || ( fansStatus.rpm[ fan ] > fansMaxAllowedRPM );
+ isPersistentAlarmTriggered( ALARM_ID_DG_FAN_RPM_OUT_OF_RANGE, isFanRPMOutOfRange );
+
+ // If the RPM out of range alarm has been raised, do not raise it again, until its alarm silence time has been elapsed
+ hasAlarmBeenRaised = ( TRUE == isAlarmActive( ALARM_ID_DG_FAN_RPM_OUT_OF_RANGE ) ? TRUE : FALSE );
+ }
}
fansMonitorCounter = 0;
Index: firmware/App/Controllers/PresOccl.c
===================================================================
diff -u -r78cee9347b3766ac7c14d413ed848be758c7e9cd -rf5f00981805e265ce63058f650d784f06db4d188
--- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 78cee9347b3766ac7c14d413ed848be758c7e9cd)
+++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision f5f00981805e265ce63058f650d784f06db4d188)
@@ -22,7 +22,8 @@
#include "OperationModes.h"
#include "PersistentAlarm.h"
#include "SystemCommMessages.h"
-#include "TaskGeneral.h"
+#include "TaskGeneral.h"
+#include "Temperatures.h"
#include "Timers.h"
/**
@@ -299,7 +300,7 @@
U16 venPres = fpgaVenPres & 0x3FFF; // 14-bit data
U08 venPresStatus = (U08)( fpgaVenPres >> 14 ); // High 2 bits is status code for venous pressure
F32 venPresPSI;
- F32 venTemp = getFPGAVenousPressureTemperature();
+ F32 venTemp = getTemperatureValue( TEMPSENSOR_VENOUS_PRESSURE_SENSOR );
U08 venReadCtr = getFPGAVenousPressureReadCounter();
// TODO - any filtering required???
Index: firmware/App/Controllers/Switches.c
===================================================================
diff -u -r076d41f2a507a2f1e5ceb929100bd025cee3b840 -rf5f00981805e265ce63058f650d784f06db4d188
--- firmware/App/Controllers/Switches.c (.../Switches.c) (revision 076d41f2a507a2f1e5ceb929100bd025cee3b840)
+++ firmware/App/Controllers/Switches.c (.../Switches.c) (revision f5f00981805e265ce63058f650d784f06db4d188)
@@ -68,20 +68,19 @@
void execSwitches( void )
{
U08 i;
+ U16 currentSwitchStatus;
- U16 currentSwitchStatus = 0;
-
for ( i = 0; i < NUM_OF_DOORS_AND_SWITCHES; i++ )
{
// Get the current switch status
switch ( i )
{
case FRONT_DOOR:
- currentSwitchStatus = getFPGAFrontDoorStatus();
+ currentSwitchStatus = ( 0 == getFPGAFrontDoorStatus() ? STATE_OPEN : STATE_CLOSED );
break;
case PUMP_TRACK_SWITCH:
- currentSwitchStatus = getFPGAPumpTrackSwitchStatus();
+ currentSwitchStatus = ( 0 == getFPGAPumpTrackSwitchStatus() ? STATE_OPEN : STATE_CLOSED );
break;
default:
@@ -103,7 +102,7 @@
switchesStatus[ i ].debounceStartTime = 0;
// If the bit is 0, the door switch is open, because it is normally open switch
// TODO investigate the polarity of the pump track switch once it tied to the cartridge latch
- switchesStatus[ i ].status.data = ( 0 == currentSwitchStatus ? STATE_OPEN : STATE_CLOSED );
+ switchesStatus[ i ].status.data = currentSwitchStatus;
}
}
else
Index: firmware/App/Controllers/Temperatures.c
===================================================================
diff -u -r4164cba570c42566aee10d7cce23c3cea0d903ee -rf5f00981805e265ce63058f650d784f06db4d188
--- firmware/App/Controllers/Temperatures.c (.../Temperatures.c) (revision 4164cba570c42566aee10d7cce23c3cea0d903ee)
+++ firmware/App/Controllers/Temperatures.c (.../Temperatures.c) (revision f5f00981805e265ce63058f650d784f06db4d188)
@@ -58,7 +58,7 @@
static const F32 THERMISTOR_VOLTAGE_CONV_COEFF = THERMISTOR_REFERENCE_VOLTAGE /
(F32)TWELVE_BIT_RESOLUTION; ///< On board thermistor ADC to voltage conversion coefficient.
static const F32 ON_BOARD_THERMISTOR_REF_TEMP_INV = 1.0 / THERMISTOR_REFERENCE_TEMPERATURE; ///< On board thermistor reference inverse.
-static const F32 FGPA_BOARD_TEMP_CONVERSION_COEFF = 1.0 / 13584.0; ///< FPGA board temperature conversion coefficient.
+static const F32 FGPA_BOARD_TEMP_CONVERSION_COEFF = 503.975 / (F32)TWELVE_BIT_RESOLUTION; ///< FPGA board temperature conversion coefficient.
static const F32 VENOUS_PRESS_SENSOR_TEMP_CONVERSION_COEFF = 200.0 / 2047.0; ///< Venous pressure sensor temperature conversion coefficient.
static const F32 VENOUS_PRESS_SENSOR_TEMP_CONVERSION_CONSTANT = 50.0; ///< Venous pressure sensor temperature conversion constant.
static const F32 ADC_BOARD_TEMP_SENSOR_CONVERSION_COEFF = 1.0 / 13584.0; ///< ADC board temperatures sensor conversion coefficient.
@@ -217,10 +217,11 @@
if ( ++adcReadCounter >= TEMPERATURES_ADC_READ_INTERVAL )
{
// Get all the raw readings in ADC
- temperaturesStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR );
- temperaturesStatus[ THERMISTOR_POWER_SUPPLY_1 ].rawADCRead = getIntADCReading( INT_ADC_PS_THERMISTOR );
- temperaturesStatus[ TEMPSENSOR_FPGA_BOARD_SENSOR ].rawADCRead = getFPGABoardTemperature();
- temperaturesStatus[ TEMPSENSOR_PBA_ADC_SENSOR ].rawADCRead = getFPGAPBAADCTemperature();
+ temperaturesStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR );
+ temperaturesStatus[ THERMISTOR_POWER_SUPPLY_1 ].rawADCRead = getIntADCReading( INT_ADC_PS_THERMISTOR );
+ temperaturesStatus[ TEMPSENSOR_FPGA_BOARD_SENSOR ].rawADCRead = getFPGABoardTemperature();
+ temperaturesStatus[ TEMPSENSOR_VENOUS_PRESSURE_SENSOR ].rawADCRead = getFPGAVenousPressureTemperature();
+ temperaturesStatus[ TEMPSENSOR_PBA_ADC_SENSOR ].rawADCRead = getFPGAPBAADCTemperature();
// Convert the ADC values to temperature
convertADC2Temperature();
@@ -317,8 +318,8 @@
/*********************************************************************//**
* @brief
- * The calculateOnBoardThemristorTemperature function converts the ADC value
- * of the onboard thermistor into temperature in C. Below are the calculation
+ * The calculateThemristorTemperature function converts the ADC value
+ * of thermistors into temperature in C. Below are the calculation
* steps:
* voltage = ADC x 3 / 2^12
* voltage = 3 x 10000 / ( 10000 + R(T) )
Index: firmware/App/Services/FPGA.c
===================================================================
diff -u -r01470ee3c64ededcc77a4f7378e49013a7ee5602 -rf5f00981805e265ce63058f650d784f06db4d188
--- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 01470ee3c64ededcc77a4f7378e49013a7ee5602)
+++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision f5f00981805e265ce63058f650d784f06db4d188)
@@ -1578,11 +1578,9 @@
* @details Outputs: none
* @return last venous pressure sensor temperature reading
*************************************************************************/
-F32 getFPGAVenousPressureTemperature( void )
+U16 getFPGAVenousPressureTemperature( void )
{
- F32 result = ( (F32)fpgaSensorReadings.venousTemperature / FPGA_PBO_TEMP_DIVISOR ) * FPGA_PBO_TEMP_GAIN - FPGA_PBO_TEMP_OFFSET;
-
- return result;
+ return fpgaSensorReadings.venousTemperature;
}
/*********************************************************************//**
Index: firmware/App/Services/FPGA.h
===================================================================
diff -u -r01470ee3c64ededcc77a4f7378e49013a7ee5602 -rf5f00981805e265ce63058f650d784f06db4d188
--- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 01470ee3c64ededcc77a4f7378e49013a7ee5602)
+++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision f5f00981805e265ce63058f650d784f06db4d188)
@@ -80,7 +80,7 @@
U32 getFPGAArterialPressure( void );
U16 getFPGAVenousPressure( void );
-F32 getFPGAVenousPressureTemperature( void );
+U16 getFPGAVenousPressureTemperature( void );
U08 getFPGAVenousPressureReadCounter( void );
U16 getFPGABloodPumpOcclusion( void );
U16 getFPGADialInPumpOcclusion( void );
Index: firmware/App/Tasks/TaskGeneral.c
===================================================================
diff -u -r69b93e39861c5493d273f25d9e43cacd0b5819e2 -rf5f00981805e265ce63058f650d784f06db4d188
--- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 69b93e39861c5493d273f25d9e43cacd0b5819e2)
+++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision f5f00981805e265ce63058f650d784f06db4d188)
@@ -22,6 +22,7 @@
#include "DGInterface.h"
#include "DialInFlow.h"
#include "DialOutFlow.h"
+#include "Fans.h"
#include "NVDataMgmt.h"
#include "OperationModes.h"
#include "PresOccl.h"
@@ -30,6 +31,7 @@
#include "SystemComm.h"
#include "SystemCommMessages.h"
#include "TaskGeneral.h"
+#include "Temperatures.h"
#include "Voltages.h"
#include "WatchdogMgmt.h"
@@ -99,6 +101,12 @@
// Monitor switches
execSwitches();
+
+ // Monitor temperatures
+ execTemperatures();
+
+ // Monitor/Control fans
+ execFans();
#endif
// Manage NVDataMgmt process record state machine
Index: firmware/source/sys_main.c
===================================================================
diff -u -r01470ee3c64ededcc77a4f7378e49013a7ee5602 -rf5f00981805e265ce63058f650d784f06db4d188
--- firmware/source/sys_main.c (.../sys_main.c) (revision 01470ee3c64ededcc77a4f7378e49013a7ee5602)
+++ firmware/source/sys_main.c (.../sys_main.c) (revision f5f00981805e265ce63058f650d784f06db4d188)
@@ -75,6 +75,7 @@
#include "CPLD.h"
#include "DialInFlow.h"
#include "DialOutFlow.h"
+#include "Fans.h"
#include "FluidLeak.h"
#include "FPGA.h"
#include "Integrity.h"
@@ -208,6 +209,7 @@
initDialOutFlow();
initSyringePump();
initValves();
+ initFans();
// Initialize modes
initOperationModes();
// Initialize async interrupt handlers