Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r261cfc6d93996e76e26c1e9c3f5740077ad2ec22 -rcd3f58205f4dab89291b29ee73b7fa9c31773abc --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 261cfc6d93996e76e26c1e9c3f5740077ad2ec22) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision cd3f58205f4dab89291b29ee73b7fa9c31773abc) @@ -632,6 +632,7 @@ static HEATERS_STATE_T handleHeaterStateTrimmerControlToTarget( void ) { HEATERS_STATE_T state = HEATER_EXEC_STATE_TRIMMER_CONTROL_TO_TARGET; + F32 tempDutyCycle = 0.0; // If the inactive reservoir has changed from the last run transition to ramp state to recalculate the // duty cycle for the next delivery @@ -647,9 +648,13 @@ F32 targetTemperature = heatersStatus[ DG_TRIMMER_HEATER ].targetTemp; F32 targetFlowLPM = heatersStatus[ DG_TRIMMER_HEATER ].targetFlow; F32 dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, outletRedundantTemperature, targetFlowLPM, TRUE ); - trimmerHeaterControlCounter = 0; - setHeaterDutyCycle( DG_TRIMMER_HEATER, ( heatersStatus[ DG_TRIMMER_HEATER ].dutyCycle + dutyCycle ) ); + + tempDutyCycle = heatersStatus[ DG_TRIMMER_HEATER ].dutyCycle + dutyCycle; + tempDutyCycle = MIN( tempDutyCycle, HEATERS_MAX_DUTY_CYCLE ); + tempDutyCycle = MAX( tempDutyCycle, HEATERS_MIN_DUTY_CYCLE ); + + setHeaterDutyCycle( DG_TRIMMER_HEATER, tempDutyCycle ); } return state; @@ -854,7 +859,7 @@ static void monitorHeatersVoltage( void ) { // NOTE: Default to using Primary heater voltage from FPGA - F32 mainPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_PRIM_HTR_V );; + F32 mainPriVoltage = getMonitoredLineLevel( MONITORED_LINE_24V_PRIM_HTR_V ); #ifndef _RELEASE_ if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) { @@ -870,17 +875,17 @@ F32 smallPriDC = heatersStatus[ DG_PRIMARY_HEATER ].dutyCycle; F32 trimmerDC = heatersStatus[ DG_TRIMMER_HEATER ].dutyCycle; - F32 mainPriExpectedVoltage = HEATERS_MAX_OPERATING_VOLTAGE_V * ( 1.0 - mainPriDC ); - F32 smallPriExpectedVoltage = HEATERS_MAX_OPERATING_VOLTAGE_V * ( 1.0 - smallPriDC ); - F32 trimmerExpectedVoltage = HEATERS_MAX_OPERATING_VOLTAGE_V * ( 1.0 - trimmerDC ); + F32 mainPriExpectedVoltage = HEATERS_MAX_OPERATING_VOLTAGE_V * ( 1.0F - mainPriDC ); + F32 smallPriExpectedVoltage = HEATERS_MAX_OPERATING_VOLTAGE_V * ( 1.0F - smallPriDC ); + F32 trimmerExpectedVoltage = HEATERS_MAX_OPERATING_VOLTAGE_V * ( 1.0F - trimmerDC ); BOOL isMainPriOut = ( fabs( mainPriExpectedVoltage - mainPriVoltage ) > HEATERS_VOLTAGE_TOLERANCE_V ? TRUE : FALSE ); BOOL isSmallPriOut = ( fabs( smallPriExpectedVoltage - smallPriVoltage ) > HEATERS_VOLTAGE_TOLERANCE_V ? TRUE : FALSE ); BOOL isTrimmerOut = ( fabs( trimmerExpectedVoltage - trimmerVoltage ) > HEATERS_VOLTAGE_TOLERANCE_V ? TRUE : FALSE ); - //checkPersistentAlarm( ALARM_ID_DG_MAIN_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, isMainPriOut, mainPriDC, HEATERS_VOLTAGE_TOLERANCE_V ); - //checkPersistentAlarm( ALARM_ID_DG_SMALL_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, isSmallPriOut, smallPriDC, HEATERS_VOLTAGE_TOLERANCE_V ); - //checkPersistentAlarm( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, isTrimmerOut, trimmerDC, HEATERS_VOLTAGE_TOLERANCE_V ); + checkPersistentAlarm( ALARM_ID_DG_MAIN_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, isMainPriOut, mainPriDC, HEATERS_VOLTAGE_TOLERANCE_V ); + checkPersistentAlarm( ALARM_ID_DG_SMALL_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, isSmallPriOut, smallPriDC, HEATERS_VOLTAGE_TOLERANCE_V ); + checkPersistentAlarm( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, isTrimmerOut, trimmerDC, HEATERS_VOLTAGE_TOLERANCE_V ); } Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r261cfc6d93996e76e26c1e9c3f5740077ad2ec22 -rcd3f58205f4dab89291b29ee73b7fa9c31773abc --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 261cfc6d93996e76e26c1e9c3f5740077ad2ec22) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision cd3f58205f4dab89291b29ee73b7fa9c31773abc) @@ -348,6 +348,7 @@ // to make sure the hardware (especially the ROF) is not damaged. If it is the case, we need to stop immediately F32 actualPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); BOOL isPressureMax = ( actualPressure >= MAX_ALLOWED_MEASURED_PRESSURE_PSI ? TRUE : FALSE ); + BOOL isDutyCylceOutOfRange = FALSE; // Update sum for flow average calculation measuredFlowReadingsSum += (S32)roFlowReading; @@ -396,10 +397,6 @@ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_RO_PUMP_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) #endif { - // The feedback voltage is on the 0V line so when the duty cycle is 0, the feedback is 2.5V - // The duty cycle is calculated by getting the 1 - (ratio of feedback / to the voltage at 0 percent duty cycle). - roPumpFeedbackDutyCyclePct = 1.0F - ( roFeedbackVoltage / ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); - // To monitor the flow, the control mode must be in closed loop mode and the pump should be control to flow state // If the pump is controlled to the maximum pressure, the flow might be different from the target flow for more than 10% // but the pump is not able to achieve the flow. @@ -408,7 +405,7 @@ F32 currentFlow = getMeasuredROFlowRateLPM(); F32 targetFlow = getTargetROPumpFlowRateLPM(); // The flow cannot be out of range for than 10% of the target flow - BOOL isFlowOutOfRange = ( fabs( 1.0 - ( currentFlow / targetFlow ) ) > MAX_ALLOWED_FLOW_DEVIATION ? TRUE : FALSE ); + BOOL isFlowOutOfRange = ( fabs( 1.0F - ( currentFlow / targetFlow ) ) > MAX_ALLOWED_FLOW_DEVIATION ? TRUE : FALSE ); // Figure out whether flow is out of range from which side BOOL isFlowOutOfUpperRange = ( isFlowOutOfRange && ( currentFlow > targetFlow ) ? TRUE : FALSE ); BOOL isFlowOutOfLowerRange = ( isFlowOutOfRange && ( currentFlow < targetFlow ) ? TRUE : FALSE ); @@ -417,18 +414,23 @@ checkPersistentAlarm( ALARM_ID_FLOW_RATE_OUT_OF_LOWER_RANGE, isFlowOutOfLowerRange, currentFlow, targetFlow ); } - // Check whether the Duty cycle is out of range - BOOL isDCOutOfRange = ( fabs( roPumpFeedbackDutyCyclePct - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + // The feedback voltage is on the 0V line so when the duty cycle is 0, the feedback is 2.5V + // The duty cycle is calculated by getting the 1 - (ratio of feedback / to the voltage at 0 percent duty cycle). + roPumpFeedbackDutyCyclePct = 1.0F - ( roFeedbackVoltage / ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); + isDutyCylceOutOfRange = ( fabs( roPumpFeedbackDutyCyclePct - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); - /* TODO this is commented out until the DVT boards are available - checkPersistentAlarm( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDCOutOfRange, roPumpFeedbackDutyCyclePct, roPumpDutyCyclePctSet ); + checkPersistentAlarm( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDutyCylceOutOfRange, roPumpFeedbackDutyCyclePct, roPumpDutyCyclePctSet ); - // Check if it the alarm has timed out and if the pump is supposed to be off but it is still on, activate the safety shutdown - - if ( ( TRUE == isAlarmActive( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE ) ) && ( FALSE == isROPumpOn ) ) - { - activateSafetyShutdown(); - }*/ + // Check if it the alarm has timed out and if the pump is supposed to be off but it is still on, activate the safety shutdown + if ( ( TRUE == isAlarmActive( ALARM_ID_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE ) ) && ( FALSE == isROPumpOn ) ) + { + activateSafetyShutdown(); + } + } } // Publish RO pump data on interval Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -r788c0f92052a7d8f0d67dd4ab607b48520013589 -rcd3f58205f4dab89291b29ee73b7fa9c31773abc --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 788c0f92052a7d8f0d67dd4ab607b48520013589) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision cd3f58205f4dab89291b29ee73b7fa9c31773abc) @@ -681,7 +681,7 @@ // To update the moving average of a temperature sensor, both ADC and internal // error flags must be valid - if ( ( TRUE == isADCValid ) && ( FALSE == isTemperatureNotValid ) ) + //if ( ( TRUE == isADCValid ) && ( FALSE == isTemperatureNotValid ) ) { processADCRead( sensorIndex, convertedADC ); } Index: firmware/App/Controllers/Voltages.c =================================================================== diff -u -r98a1a2a624373a1d140daed0136522ab6e635237 -rcd3f58205f4dab89291b29ee73b7fa9c31773abc --- firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision 98a1a2a624373a1d140daed0136522ab6e635237) +++ firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision cd3f58205f4dab89291b29ee73b7fa9c31773abc) @@ -34,31 +34,31 @@ #define VOLTAGES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the voltages data is published on the CAN bus. #define VOLTAGES_ALARM_PERSISTENCE ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Alarm persistence period for voltage monitor alarms. #define DATA_PUBLISH_COUNTER_START_COUNT 1 ///< Data publish counter start count. -/*#define SIZE_OF_ROLLING_AVG 16 ///< Number of DG FPGA ADC samples in rolling average calculations for each channel. +#define SIZE_OF_ROLLING_AVG 16 ///< Number of DG FPGA ADC samples in rolling average calculations for each channel. #define ROLLING_AVG_SHIFT_DIVIDER 4 ///< Rolling average shift divider for DG FPGA ADC readings. #define FPGA_ADC_BITS_PER_CHANNEL 12 ///< DG FPGA ADC bits per channel. -#define FPGA_ADC_FULL_SCALE_BITS ((1<> ROLLING_AVG_SHIFT_DIVIDER; - adcReadingsIdx[ ch ] = INC_WRAP( adcReadingsIdx[ ch ], 0, SIZE_OF_ROLLING_AVG - 1 ); - fpgaVoltage[ch] = (F32)adcReadingsAvgs[ ch ] * FPGA_ADC_READ_TO_UNITS[ ch ]; - }*/ + adcReadingsAvgs[ ch ] = adcReadingsTotals[ ch ] >> ROLLING_AVG_SHIFT_DIVIDER; + adcReadingsIdx[ ch ] = INC_WRAP( adcReadingsIdx[ ch ], 0, SIZE_OF_ROLLING_AVG - 1 ); + fpgaVoltage[ ch ] = (F32)adcReadingsAvgs[ ch ] * FPGA_ADC_READ_TO_UNITS[ ch ]; + } } /*********************************************************************//** @@ -362,23 +366,24 @@ if ( ++voltagesDataPublicationTimerCounter >= getU32OverrideValue( &voltagesDataPublishInterval ) ) { VOLTAGES_DATA_PAYLOAD_T data; - data.adc1VFPGA = getMonitoredLineLevel( MONITORED_LINE_1V_FPGA ); - data.adc1_2VProc = getMonitoredLineLevel( MONITORED_LINE_1_2V_PROC ); - data.adc1_8VProc = getMonitoredLineLevel( MONITORED_LINE_1_8V_PROC ); - data.adc1_8VFPGA = getMonitoredLineLevel( MONITORED_LINE_1_8V_FPGA ); - data.adc3VRef = getMonitoredLineLevel( MONITORED_LINE_V_REF ); - data.adc3VExtADC1 = getMonitoredLineLevel( MONITORED_LINE_EXT_ADC_1_REF_V ); - data.adc3VExtADC2 = getMonitoredLineLevel( MONITORED_LINE_EXT_ADC_2_REF_V ); - data.adc3_3V = getMonitoredLineLevel( MONITORED_LINE_3_3V ); - data.adc3_3VSensors = getMonitoredLineLevel( MONITORED_LINE_3_3V_SENSORS ); - data.adc5VLogic = getMonitoredLineLevel( MONITORED_LINE_5V_LOGIC ); - data.adc5VSensors = getMonitoredLineLevel( MONITORED_LINE_5V_SENSORS ); - data.adc5VPSGateDriver = getMonitoredLineLevel( MONITORED_LINE_PS_GATE_DRIVER_V ); - data.adc24V = getMonitoredLineLevel( MONITORED_LINE_24V_MAIN ); - data.adc24VPrimaryHtr = getMonitoredLineLevel( MONITORED_LINE_24V_PRIM_HTR_V ); - data.adc24VPrimaryHtrGnd = getMonitoredLineLevel( MONITORED_LINE_24V_PRIM_HTR_V ); - data.adc24VSecondaryHtr = getMonitoredLineLevel( MONITORED_LINE_24V_SEC_HTR_V ); - data.adc24VTrimmerHtr = getMonitoredLineLevel( MONITORED_LINE_24V_TRIM_HTR_V ); + + data.adc1VFPGA = getMonitoredLineLevel( MONITORED_LINE_1V_FPGA ); + data.adc1_2VProc = getMonitoredLineLevel( MONITORED_LINE_1_2V_PROC ); + data.adc1_8VProc = getMonitoredLineLevel( MONITORED_LINE_1_8V_PROC ); + data.adc1_8VFPGA = getMonitoredLineLevel( MONITORED_LINE_1_8V_FPGA ); + data.adc3VRef = getMonitoredLineLevel( MONITORED_LINE_V_REF ); + data.adc3VExtADC1 = getMonitoredLineLevel( MONITORED_LINE_EXT_ADC_1_REF_V ); + data.adc3VExtADC2 = getMonitoredLineLevel( MONITORED_LINE_EXT_ADC_2_REF_V ); + data.adc3_3V = getMonitoredLineLevel( MONITORED_LINE_3_3V ); + data.adc3_3VSensors = getMonitoredLineLevel( MONITORED_LINE_3_3V_SENSORS ); + data.adc5VLogic = getMonitoredLineLevel( MONITORED_LINE_5V_LOGIC ); + data.adc5VSensors = getMonitoredLineLevel( MONITORED_LINE_5V_SENSORS ); + data.adc5VPSGateDriver = getMonitoredLineLevel( MONITORED_LINE_PS_GATE_DRIVER_V ); + data.adc24V = getMonitoredLineLevel( MONITORED_LINE_24V_MAIN ); + data.adc24VPrimaryHtr = getMonitoredLineLevel( MONITORED_LINE_24V_PRIM_HTR_V ); + data.adc24VPrimaryHtrGnd = getMonitoredLineLevel( MONITORED_LINE_24V_PRIM_HTR_GND_V ); + data.adc24VSecondaryHtr = getMonitoredLineLevel( MONITORED_LINE_24V_SEC_HTR_V ); + data.adc24VTrimmerHtr = getMonitoredLineLevel( MONITORED_LINE_24V_TRIM_HTR_V ); broadcastData( MSG_ID_DG_VOLTAGES_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( VOLTAGES_DATA_PAYLOAD_T ) ); voltagesDataPublicationTimerCounter = 0; Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rae2b7f296dcd0247814356a28380b3ac582a8551 -rcd3f58205f4dab89291b29ee73b7fa9c31773abc --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision ae2b7f296dcd0247814356a28380b3ac582a8551) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision cd3f58205f4dab89291b29ee73b7fa9c31773abc) @@ -2099,6 +2099,14 @@ return fpgaSensorReadings.fpgaBaroErrorCount; } +/*********************************************************************//** + * @brief + * The getFPGABaroMfgInfo function gets the FPGA barometric pressure + * sensor manufacturing information. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return barometric pressure sensor manufacturing information + *************************************************************************/ U16 getFPGABaroMfgInfo( void ) { return fpgaSensorReadings.fpgaBaroManufacInfo;