Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r76f413c7bde4ca9d12cc61e0191daddb1e86e9f1 -r7b6b599a6f98241bc51bbee65b736b92cb881f01 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 76f413c7bde4ca9d12cc61e0191daddb1e86e9f1) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 7b6b599a6f98241bc51bbee65b736b92cb881f01) @@ -51,6 +51,7 @@ U32 rawReading; ///< Latest raw load cell reading OVERRIDE_F32_T weight; ///< Latest load cell weight F32 autoCalOffset; ///< Load cell auto-calibration offset + F32 loadCellVelocity_g_min; ///< Velocity (in g/min) of load cell. F32 smallFilterReadings[ SIZE_OF_SMALL_LOAD_CELL_AVG ]; ///< Load cell samples for small load cell moving average F32 smallFilterTotal; ///< Small filter rolling total - used to calc small load cell moving average @@ -122,6 +123,8 @@ { loadcells[ i ].largeFilterReadings[ j ] = 0.0; } + + loadcells[ i ].loadCellVelocity_g_min = 0.0; } // Set all the load cells' calibration values to benign values @@ -175,6 +178,7 @@ for ( ii = 0; ii < NUM_OF_LOAD_CELLS; ++ii ) { loadcells[ ii ].weight.data = (F32)loadcells[ ii ].rawReading * ADC2GRAM + LOAD_CELL_ZERO_OFFSET - loadcells[ ii ].autoCalOffset; + loadcells[ ii ].loadCellVelocity_g_min = ( getLoadCellWeight( (LOAD_CELL_ID_T)ii ) - loadcells[ ii ].smallFilterReadings[ smallReadingsIdx ] ) * (F32)SEC_PER_MIN; // Update small filter with new weight sample loadcells[ ii ].smallFilterTotal -= loadcells[ ii ].smallFilterReadings[ smallReadingsIdx ]; @@ -294,7 +298,7 @@ } else { - activateAlarmNoData( ALARM_ID_DG_SOFTWARE_FAULT ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_LOAD_CELL_ID, (U32)loadCellID ) } return result; @@ -319,7 +323,7 @@ } else { - activateAlarmNoData( ALARM_ID_DG_SOFTWARE_FAULT ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_LOAD_CELL_ID, (U32)loadCellID ) } return result; @@ -336,22 +340,47 @@ *************************************************************************/ F32 getLoadCellLargeFilteredWeight( LOAD_CELL_ID_T loadCellID ) { - F32 result = 0; + F32 result = 0.0; if ( loadCellID < NUM_OF_LOAD_CELLS ) { result = loadcells[ loadCellID ].largeFilteredWeight; } else { - activateAlarmNoData( ALARM_ID_DG_SOFTWARE_FAULT ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_LOAD_CELL_ID, (U32)loadCellID ) } return result; } /*********************************************************************//** * @brief + * The getLoadCellVelocity function gets the current velocity (in g/min) + * for the given load cell. + * @details Inputs: loadcells[] + * @details Outputs: none + * @param loadCellID ID of load cell to get velocity + * @return the velocity (in g/min) for the given load cell ID. + *************************************************************************/ +F32 getLoadCellVelocity( LOAD_CELL_ID_T loadCellID ) +{ + F32 result = 0.0; + + if ( loadCellID < NUM_OF_LOAD_CELLS ) + { + result = loadcells[ loadCellID ].loadCellVelocity_g_min; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_LOAD_CELL_ID, (U32)loadCellID ) + } + + return result; +} + +/*********************************************************************//** + * @brief * The getLoadCellDataPublishInterval function gets the load cell data publish interval. * @details Inputs: loadCellDataPublishInterval * @details Outputs: none