Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -rc9b434898a8bbe9143b243627ea081e5e0f7a861 -r8ac6dbd310f7408760e5cad232b1e9834882f739 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision c9b434898a8bbe9143b243627ea081e5e0f7a861) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 8ac6dbd310f7408760e5cad232b1e9834882f739) @@ -863,7 +863,7 @@ if ( commandedPositionEnum == VALVE_POSITION_B_OPEN ) { // Enable current relaxation - setFPGAValveSetPoint( valve, currentPosition, TRUE ); + setFPGAValveSetPoint( valve, targetPosition, TRUE ); } // Go back to Idle state @@ -1290,22 +1290,22 @@ // Subtract the defined number of steps for the next transition if ( commandedPositionEnum == VALVE_POSITION_B_OPEN ) { - valvesStatus[ valve ].targetPositionInCounts = getValvePositionCounts( valve ) + nextStep; + valvesStatus[ valve ].targetPositionInCounts = currentPosition + nextStep; } if ( commandedPositionEnum == VALVE_POSITION_C_CLOSE ) { - valvesStatus[ valve ].targetPositionInCounts = getValvePositionCounts( valve ) - nextStep; + valvesStatus[ valve ].targetPositionInCounts = currentPosition - nextStep; } break; case VALVE_POSITION_B_OPEN: // If the valve is currently in position B, subtract the defined number of steps for the next transition - valvesStatus[ valve ].targetPositionInCounts = getValvePositionCounts( valve ) - nextStep; + valvesStatus[ valve ].targetPositionInCounts = currentPosition - nextStep; break; case VALVE_POSITION_C_CLOSE: // If the valve is currently in position C, add the defined number of steps for the next transition - valvesStatus[ valve ].targetPositionInCounts = getValvePositionCounts( valve ) + nextStep; + valvesStatus[ valve ].targetPositionInCounts = currentPosition + nextStep; break; default: Index: firmware/App/Controllers/Voltages.c =================================================================== diff -u -r37a9fd8f15e413db5337371a7d1a1cb65567af7c -r8ac6dbd310f7408760e5cad232b1e9834882f739 --- firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision 37a9fd8f15e413db5337371a7d1a1cb65567af7c) +++ firmware/App/Controllers/Voltages.c (.../Voltages.c) (revision 8ac6dbd310f7408760e5cad232b1e9834882f739) @@ -17,7 +17,8 @@ #include "AlarmMgmt.h" #include "FPGA.h" -#include "InternalADC.h" +#include "InternalADC.h" +#include "PersistentAlarm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Timers.h" @@ -30,8 +31,10 @@ // ********** private definitions ********** -#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 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 ( 1 * MS_PER_SECOND ) ///< Alarm persistence period for voltage monitor alarms in milliseconds. +#define POWER_LOSS_VOLTAGE_PERSISTENCE_MS ( 0.15 * MS_PER_SECOND ) ///< Power supply voltage out of range persistence in milliseconds. +#define POWER_LOSS_VOLTAGE_THRESHOLD_V 1.0F ///< Power loss voltage threshold #define DATA_PUBLISH_COUNTER_START_COUNT 14 ///< Data publish counter start count. /// Defined states for the voltage monitor state machine. @@ -111,9 +114,11 @@ voltages[i].ovData = 0.0; voltages[i].ovInitData = 0.0; voltages[i].override = OVERRIDE_RESET; - voltageAlarmPersistenceCtr[i] = 0; - } + } + + initPersistentAlarm( ALARM_ID_HD_VOLTAGE_OUT_OF_RANGE, VOLTAGES_ALARM_PERSISTENCE_MS, VOLTAGES_ALARM_PERSISTENCE_MS ); + initPersistentAlarm( ALARM_ID_HD_AC_POWER_LOST, POWER_LOSS_VOLTAGE_PERSISTENCE_MS, POWER_LOSS_VOLTAGE_PERSISTENCE_MS ); } /*********************************************************************//** @@ -202,16 +207,28 @@ static void checkVoltageRanges( void ) { U32 i; + BOOL hasPowerBeenLost = FALSE; // Check range for ( i = 0; i < NUM_OF_MONITORED_LINES; i++ ) { - F32 volts = getMonitoredLineLevel( (MONITORED_VOLTAGES_T)i ); + F32 volts = getMonitoredLineLevel( (MONITORED_VOLTAGES_T)i ); + BOOL isVoltageOutOfRange = ( ( volts > MAX_VOLTAGES[ i ] ) || ( volts < MIN_VOLTAGES[ i ] ) ? TRUE : FALSE ); - if ( volts > MAX_VOLTAGES[ i ] ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_VOLTAGES_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - if ( ++voltageAlarmPersistenceCtr[ i ] >= VOLTAGES_ALARM_PERSISTENCE ) + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_VOLTAGE_OUT_OF_RANGE, isVoltageOutOfRange ) ) { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_VOLTAGE_OUT_OF_RANGE, i, isVoltageOutOfRange ); + } + } + + /*if ( volts > MAX_VOLTAGES[ i ] ) + { + if ( ++voltageAlarmPersistenceCtr[ i ] >= VOLTAGES_ALARM_PERSISTENCE_MS ) + { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_VOLTAGES_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif @@ -222,8 +239,15 @@ } else if ( volts < MIN_VOLTAGES[ i ] ) { - if ( ++voltageAlarmPersistenceCtr[ i ] >= VOLTAGES_ALARM_PERSISTENCE ) + BOOL isAlarmValid = TRUE; + + if ( ( ( MONITORED_LINE_24V == i ) || ( MONITORED_LINE_24V_REGEN == i ) ) && ( TRUE == isAlarmActive( ALARM_ID_HD_AC_POWER_LOST ) ) ) { + isAlarmValid = FALSE; + } + + if ( ++voltageAlarmPersistenceCtr[ i ] >= VOLTAGES_ALARM_PERSISTENCE_MS ) + { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_VOLTAGES_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif @@ -235,8 +259,19 @@ else { voltageAlarmPersistenceCtr[ i ] = 0; - } + }*/ } + + if ( ( getMonitoredLineLevel( MONITORED_LINE_24V ) < POWER_LOSS_VOLTAGE_THRESHOLD_V ) || + ( getMonitoredLineLevel( MONITORED_LINE_24V_REGEN ) < POWER_LOSS_VOLTAGE_THRESHOLD_V ) ) + { + hasPowerBeenLost = TRUE; + } + + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_AC_POWER_LOST, hasPowerBeenLost ) ) + { + activateAlarmNoData( ALARM_ID_HD_AC_POWER_LOST ); + } } /*********************************************************************//** Index: firmware/App/HDCommon.h =================================================================== diff -u -r6c8f578be87fc6d9534d27e15973cd1ef4367449 -r8ac6dbd310f7408760e5cad232b1e9834882f739 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision 6c8f578be87fc6d9534d27e15973cd1ef4367449) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision 8ac6dbd310f7408760e5cad232b1e9834882f739) @@ -38,7 +38,7 @@ // #define RUN_WITHOUT_DG 1 // Run HD w/o DG // #define SIMULATE_UI 1 // Build w/o requirement that UI be there // #define TASK_TIMING_OUTPUT_ENABLED 1 // Re-purposes alarm lamp pins for task timing - #define DISABLE_BATT_COMM 1 // Disable battery communication +// #define DISABLE_BATT_COMM 1 // Disable battery communication // TODO soft switch // #define READ_FPGA_ASYNC_DATA 1 // Test build reads non-priority register page every other time // #define DISABLE_FPGA_COUNTER_CHECKS 1 // Disable alarms associated with FPGA read/error counters // #define EMC_TEST_BUILD 1 // EMC test build - HD/DG run separately but connected, HD pumps toggle on/off w/ stop button