Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -rdc0d9b087c609e71cacdb7f0395cccf29d749c00 -r5a882c7292cea58e74b5a28d4e85dd60e741b834 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision dc0d9b087c609e71cacdb7f0395cccf29d749c00) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 5a882c7292cea58e74b5a28d4e85dd60e741b834) @@ -15,9 +15,9 @@ * ***************************************************************************/ +#include "FPGA.h" #include "LoadCell.h" #include "SystemCommMessages.h" -#include "FPGA.h" #include "TaskPriority.h" /** @@ -27,21 +27,22 @@ // ********** private definitions ********** -#define LOAD_CELL_REPORT_PERIOD (100 / TASK_PRIORITY_INTERVAL) ///< Broadcast load cell values message every 100 ms. -#define LOAD_CELL_SAMPLES_TO_AVERAGE LOAD_CELL_REPORT_PERIOD ///< Averaging load cell data over the reporting interval. -#define LOAD_CELL_AVERAGE_MULTIPLIER (1.0 / (F32)LOAD_CELL_SAMPLES_TO_AVERAGE) ///< Optimization - multiplying is faster than dividing. +#define LOAD_CELL_REPORT_PERIOD (100 / TASK_PRIORITY_INTERVAL) ///< Broadcast load cell values message every 100 ms. +#define LOAD_CELL_SAMPLES_TO_AVERAGE (100 / TASK_PRIORITY_INTERVAL) ///< Averaging load cell data over the reporting interval. +#define LOAD_CELL_AVERAGE_MULTIPLIER (1.0 / (F32)LOAD_CELL_SAMPLES_TO_AVERAGE) ///< Optimization - multiplying is faster than dividing. // TODO - gain and offset for load cells should be read from NV Data calibration record. -#define ADC2GRAM (0.0894 * 1.1338) ///< Conversion factor from ADC counts to grams. -#define LOAD_CELL_ZERO_OFFSET -1215.0 ///< Zero offset (in grams). TODO - right now, this is empty reservoir weight. +#define ADC2GRAM (0.0894 * 1.1338) ///< Conversion factor from ADC counts to grams. +#define LOAD_CELL_ZERO_OFFSET -1215.0 ///< Zero offset (in grams). TODO - right now, this is empty reservoir weight. // ********** private data ********** -static OVERRIDE_U32_T loadCellDataPublishInterval = { LOAD_CELL_REPORT_PERIOD, LOAD_CELL_REPORT_PERIOD, 0, 0 }; ///< Broadcast load cell data interval in ms/task interval. -static U32 measuredLoadCellReadingsRaw[ NUM_OF_LOAD_CELLS ]; ///< Latest measured raw load cell readings. -static U32 measuredLoadCellReadingsSum[ NUM_OF_LOAD_CELLS ]; ///< Raw load cell sums for averaging. -static OVERRIDE_F32_T filteredLoadCellWeights[ NUM_OF_LOAD_CELLS ]; ///< Latest filtered load cell weights. -static U32 loadCellFilterTimerCount = 0; ///< used to schedule load cell filtering. -static U32 loadCellDataPublicationTimerCounter = 0; ///< used to schedule load cell data publication to CAN bus. +static OVERRIDE_U32_T loadCellDataPublishInterval = { LOAD_CELL_REPORT_PERIOD, + LOAD_CELL_REPORT_PERIOD, 0, 0 }; ///< Broadcast load cell data publish interval. +static U32 measuredLoadCellReadingsRaw[ NUM_OF_LOAD_CELLS ]; ///< Latest measured raw load cell readings. +static U32 measuredLoadCellReadingsSum[ NUM_OF_LOAD_CELLS ]; ///< Raw load cell sums for averaging. +static OVERRIDE_F32_T filteredLoadCellWeights[ NUM_OF_LOAD_CELLS ]; ///< Latest filtered load cell weights. +static U32 loadCellFilterTimerCount = 0; ///< Load cell filtering timer count. +static U32 loadCellDataPublicationTimerCounter = 0; ///< Load cell data publication timer counter to CAN bus. // ********** private function prototypes ********** @@ -73,13 +74,14 @@ /*********************************************************************//** * @brief - * The execLoadCell function gets load cell data from FPGA and advertises them over CAN. + * The execLoadCell function gets load cell data from FPGA, applies filters, + * and advertises them over CAN. * @details * Inputs : none - * Outputs : Advertising load call data. + * Outputs : Filtered and advertised load cell data. * @return none *************************************************************************/ -void execLoadCell(void) +void execLoadCell( void ) { // get latest raw load cell readings measuredLoadCellReadingsRaw[ LOAD_CELL_A1 ] = getFPGALoadCellA1(); @@ -127,7 +129,7 @@ /*********************************************************************//** * @brief - * The getLoadCellFilteredWeight function gets the measured filtered load cell \n + * The getLoadCellFilteredWeight function gets the measured filtered load cell * weight for a given load cell ID. * @details * Inputs : filteredLoadCellWeights[] @@ -160,8 +162,7 @@ /*********************************************************************//** * @brief - * The getLoadCellDataPublishInterval function gets the load cell data \n - * publication interval. + * The getLoadCellDataPublishInterval function gets the load cell data publish interval. * @details * Inputs : loadCellDataPublishInterval * Outputs : none @@ -184,11 +185,9 @@ * TEST SUPPORT FUNCTIONS *************************************************************************/ - /*********************************************************************//** * @brief - * The testSetLoadCellOverride function overrides the measured \n - * load cell A1. + * The testSetLoadCellOverride function overrides the measured load cell data. * @details * Inputs : none * Outputs : filteredLoadCellWeights[] @@ -205,7 +204,7 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - filteredLoadCellWeights[ loadCellID ].ovData = value; + filteredLoadCellWeights[ loadCellID ].ovData = value; filteredLoadCellWeights[ loadCellID ].override = OVERRIDE_KEY; } } @@ -215,8 +214,7 @@ /*********************************************************************//** * @brief - * The testResetLoadCellOverride function resets the override of the \n - * load cell A1. + * The testResetLoadCellOverride function resets the override of the load cell. * @details * Inputs : none * Outputs : filteredLoadCellWeights[] @@ -233,7 +231,7 @@ { result = TRUE; filteredLoadCellWeights[ loadCellID ].override = OVERRIDE_RESET; - filteredLoadCellWeights[ loadCellID ].ovData = filteredLoadCellWeights[ loadCellID ].ovInitData; + filteredLoadCellWeights[ loadCellID ].ovData = filteredLoadCellWeights[ loadCellID ].ovInitData; } } @@ -242,7 +240,7 @@ /*********************************************************************//** * @brief - * The testSetLoadCellDataPublishIntervalOverride function overrides the \n + * The testSetLoadCellDataPublishIntervalOverride function overrides the * load cell data publish interval. * @details * Inputs : none @@ -268,7 +266,7 @@ /*********************************************************************//** * @brief - * The testResetLoadCellDataPublishIntervalOverride function resets the override \n + * The testResetLoadCellDataPublishIntervalOverride function resets the override * of the load cell data publish interval. * @details * Inputs : none