Index: Accel.c =================================================================== diff -u -r8fe83d389f46bd5381c1d1f78eb8b39178672e01 -r46a80c6b5bddd2f4c438a5c4d1b3bb53a717944f --- Accel.c (.../Accel.c) (revision 8fe83d389f46bd5381c1d1f78eb8b39178672e01) +++ Accel.c (.../Accel.c) (revision 46a80c6b5bddd2f4c438a5c4d1b3bb53a717944f) @@ -49,6 +49,9 @@ #define MAX_TILT_G ( 1.0F ) ///< Maximum tilt (in g). #define MAX_TILT_ANGLE_DEG ( 90.0F ) ///< Maximum tilt angle (in degrees). #define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. +// POST test +#define ACCEL_POST_TEST_COUNT 5 ///< Number of times to repeat POST test +#define ACCEL_POST_TEST_FAIL_MAX 3 ///< Maximum number of times POST test may fail (<= ACCEl_POST_TEST_COUNT) /// Enumeration of accelerometer monitor states. typedef enum Accelerometer_States @@ -88,6 +91,8 @@ static F32 accelTilt[ NUM_OF_ACCEL_AXES ]; ///< Axis angles for tilt determination (filtered and converted to degrees). static U32 accelTiltErrorTimerCounter = 0; ///< used for persistence requirement on tilt error. static ACCELEROMETER_SELF_TEST_STATE_T accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_START; ///< current accelerometer self-test state. +static U08 postTestCounter = 0; ///< POST test repeat counter +static U08 postFailCounter = 0; ///< POST test fail counter static BOOL tiltErrorDetected; ///< Flag indicates a tilt error has been detected and tilt must now come below alarm clear threshold to clear alarm. static BOOL shockErrorDetected; ///< Flag indicates a shock error has been detected and g-force must now come below alarm clear threshold to clear alarm. @@ -594,14 +599,17 @@ /*********************************************************************//** * @brief * The execAccelTest function executes the state machine for the - * accelerometer self-test. + * accelerometer power on self-test (POST). Verifies Accelerometer + * reading is within tolerance. 5 Repeats on 50ms interval with + * maximum of 3 fails is intended to mitigate a false fail from + * moving or bumping the machine during test. * @details Inputs: accelSelfTestState, accelCalOffsets * @details Outputs: accelSelfTestState, accelCalOffsets, Alarm is * self-test failed * @return the current state of the accelerometer self-test. *************************************************************************/ SELF_TEST_STATUS_T execAccelTest( void ) -{ +{ SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; switch ( accelSelfTestState ) @@ -619,6 +627,8 @@ { accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_IN_PROGRESS; } + postTestCounter = 0; + postFailCounter = 0; } break; @@ -628,21 +638,38 @@ getMeasuredAccelAxis( ACCEL_AXIS_Y ), getMeasuredAccelAxis( ACCEL_AXIS_Z ) ); - if ( fabs( NOMINAL_ACCEL_VECTOR_LENGTH - vectorLen ) < MAX_ACCEL_VECTOR_LENGTH_ERROR ) + if ( fabs( NOMINAL_ACCEL_VECTOR_LENGTH - vectorLen ) >= MAX_ACCEL_VECTOR_LENGTH_ERROR ) { - result = SELF_TEST_STATUS_PASSED; - } - else - { - result = SELF_TEST_STATUS_FAILED; + // count the failures + postFailCounter++; + if ( postFailCounter >= ACCEL_POST_TEST_FAIL_MAX ) + { + result = SELF_TEST_STATUS_FAILED; + // Already failed, no need to repeat test + postTestCounter = ACCEL_POST_TEST_COUNT; #ifdef _DG_ - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_ACCELEROMETER_SELF_TEST_FAILURE, vectorLen ) + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_ACCELEROMETER_SELF_TEST_FAILURE, vectorLen ) #else - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_ACCELEROMETER_SELF_TEST_FAILURE, vectorLen ) + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_ACCELEROMETER_SELF_TEST_FAILURE, vectorLen ) #endif + } } - accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_COMPLETE; + if ( postTestCounter < ACCEL_POST_TEST_COUNT ) + { + // Repeat the test + postTestCounter++; + result = SELF_TEST_STATUS_IN_PROGRESS; + } + else + { + // Test complete, return Pass / Fail. + if ( SELF_TEST_STATUS_FAILED != result ) + { + result = SELF_TEST_STATUS_PASSED; + } + accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_COMPLETE; + } } break; @@ -655,7 +682,7 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_ACCEL_INVALID_SELF_TEST_STATE, accelSelfTestState ) #endif break; - } + } return result; }