Index: firmware/App/Controllers/Voltages.c =================================================================== diff -u -r25ede6f944eb53b68c8073404663c99d3ce158b0 -r6d61f5b0781ed52b2af2998e92410e6105cf755b --- firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision 25ede6f944eb53b68c8073404663c99d3ce158b0) +++ firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision 6d61f5b0781ed52b2af2998e92410e6105cf755b) @@ -204,8 +204,12 @@ *************************************************************************/ static void checkVoltageRanges( void ) { - U32 i; - BOOL hasPowerBeenLost = FALSE; + MONITORED_VOLTAGES_T channel; + MONITORED_VOLTAGES_T channelInAlarm; + BOOL hasPowerBeenLost = FALSE; + BOOL isVoltageOutOfRange = FALSE; + F32 volts = 0.0F; + F32 alarmVoltage = 0.0F; // Have we lost AC power? TODO - replace with CPLD status check if ( getMonitoredLineLevel( MONITORED_LINE_24V ) < POWER_LOSS_VOLTAGE_THRESHOLD_V ) @@ -217,36 +221,31 @@ } // Check range - for ( i = 0; i < NUM_OF_MONITORED_LINES; i++ ) + for ( channel = MONITORED_LINE_FIRST_VOLTAGE; channel < NUM_OF_MONITORED_LINES; channel++ ) { - F32 volts = getMonitoredLineLevel( (MONITORED_VOLTAGES_T)i ); - BOOL isVoltageOutOfRange = ( ( volts > MAX_VOLTAGES[ i ] ) || ( volts < MIN_VOLTAGES[ i ] ) ? TRUE : FALSE ); - if ( ( ( isSafetyShutdownActivated() != TRUE ) && ( hasPowerBeenLost != TRUE ) ) || - ( ( i != MONITORED_LINE_24V ) && ( i != MONITORED_LINE_24V_REGEN ) ) ) + ( ( channel != MONITORED_LINE_24V ) && ( channel != MONITORED_LINE_24V_REGEN ) ) ) { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_VOLTAGES_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_VOLTAGE_OUT_OF_RANGE, isVoltageOutOfRange ) ) + volts = getMonitoredLineLevel( channel ); + if ( ( volts > MAX_VOLTAGES[ channel ] ) || ( volts < MIN_VOLTAGES[ channel] ) ) { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_VOLTAGE_OUT_OF_RANGE, i, isVoltageOutOfRange ); + isVoltageOutOfRange = TRUE; + channelInAlarm = channel; + alarmVoltage = volts; + break; // once a channel is out of range there is + // no need to continue } } -#ifndef _RELEASE_ - else - { - isPersistentAlarmTriggered( ALARM_ID_HD_VOLTAGE_OUT_OF_RANGE, FALSE ); - } -#endif } - else - { - isPersistentAlarmTriggered( ALARM_ID_HD_VOLTAGE_OUT_OF_RANGE, FALSE ); - } } + // Check the persistence alarm + checkPersistentAlarm ( ALARM_ID_HD_VOLTAGE_OUT_OF_RANGE, isVoltageOutOfRange, channelInAlarm, alarmVoltage ); + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_AC_POWER_LOST, hasPowerBeenLost ) ) { HD_OP_MODE_T opMode = getCurrentOperationMode(); Index: firmware/App/Controllers/Voltages.h =================================================================== diff -u -r0a4dcd288d4347b85baaa0b07da568b6add5eac7 -r6d61f5b0781ed52b2af2998e92410e6105cf755b --- firmware/App/Controllers/Voltages.h (.../Voltages.h) (revision 0a4dcd288d4347b85baaa0b07da568b6add5eac7) +++ firmware/App/Controllers/Voltages.h (.../Voltages.h) (revision 6d61f5b0781ed52b2af2998e92410e6105cf755b) @@ -36,7 +36,8 @@ /// Enumeration of voltages monitored by this module. typedef enum Voltages { - MONITORED_LINE_1_2V = 0, ///< Processor voltage (1.2V) + MONITORED_LINE_1_2V = 0, ///< First voltage in list + MONITORED_LINE_FIRST_VOLTAGE = MONITORED_LINE_1_2V, ///< MONITORED_LINE_1_2V MONITORED_LINE_3_3V, ///< Logic voltage (3.3V) MONITORED_LINE_5V_LOGIC, ///< Logic voltage (5V) MONITORED_LINE_5V_SENSORS, ///< Sensors voltage (5V)