Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -rb5e25e2bf3b87f12f9d1beedf460b5884c8816e9 -ra721c4feab8c89880314070d56224e28d502ac5e --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision b5e25e2bf3b87f12f9d1beedf460b5884c8816e9) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision a721c4feab8c89880314070d56224e28d502ac5e) @@ -28,8 +28,10 @@ #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 ADC2GRAM (0.0894 / LOAD_CELL_SAMPLES_TO_AVERAGE) ///< Conversion factor from ADC counts to grams. Division for averaging is folded into this value. -#define ADC2GRAM (0.01183 / LOAD_CELL_SAMPLES_TO_AVERAGE) ///< Conversion factor from ADC counts to grams. Division for averaging is folded into this value. +#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.01126 // Conversion factor from ADC counts to grams. Division for averaging is folded into this value. +#define LOAD_CELL_ZERO_OFFSET -237.16 // Zero offset (in grams). // ********** private data ********** @@ -94,10 +96,14 @@ { loadCellDataPublicationTimerCounter = 0; // calculate load cell average weights - filteredLoadCellWeights[ LOAD_CELL_A1 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_A1 ]) * ADC2GRAM; // division for averaging folded into ADC2GRAM - filteredLoadCellWeights[ LOAD_CELL_A2 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_A2 ]) * ADC2GRAM; - filteredLoadCellWeights[ LOAD_CELL_B1 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_B1 ]) * ADC2GRAM; - filteredLoadCellWeights[ LOAD_CELL_B2 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_B2 ]) * ADC2GRAM; + filteredLoadCellWeights[ LOAD_CELL_A1 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_A1 ]) * + LOAD_CELL_AVERAGE_MULTIPLIER * ADC2GRAM + LOAD_CELL_ZERO_OFFSET; // division for averaging folded into ADC2GRAM + filteredLoadCellWeights[ LOAD_CELL_A2 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_A2 ]) * + LOAD_CELL_AVERAGE_MULTIPLIER * ADC2GRAM + LOAD_CELL_ZERO_OFFSET; + filteredLoadCellWeights[ LOAD_CELL_B1 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_B1 ]) * + LOAD_CELL_AVERAGE_MULTIPLIER * ADC2GRAM + LOAD_CELL_ZERO_OFFSET; + filteredLoadCellWeights[ LOAD_CELL_B2 ].data = (F32)(measuredLoadCellReadingsSum[ LOAD_CELL_B2 ]) * + LOAD_CELL_AVERAGE_MULTIPLIER * ADC2GRAM + LOAD_CELL_ZERO_OFFSET; // broadcast load cell data broadcastLoadCellData( getLoadCellFilteredWeight( LOAD_CELL_A1 ), getLoadCellFilteredWeight( LOAD_CELL_A2 ), getLoadCellFilteredWeight( LOAD_CELL_B1 ), getLoadCellFilteredWeight( LOAD_CELL_B2 ) ); Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -ra75923f40bea362b44fc082ce8eebde7bfa97c9a -ra721c4feab8c89880314070d56224e28d502ac5e --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision a75923f40bea362b44fc082ce8eebde7bfa97c9a) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision a721c4feab8c89880314070d56224e28d502ac5e) @@ -108,7 +108,6 @@ * @details * Inputs : none * Outputs : ROPump module initialized. - * @param none * @return none *************************************************************************/ void initROPump( void ) @@ -160,7 +159,6 @@ * @details * Inputs : none * Outputs : RO pump stopped, set point reset, state changed to off - * @param none * @return none *************************************************************************/ void signalROPumpHardStop( void ) @@ -179,7 +177,6 @@ * @details * Inputs : none * Outputs : measuredROPumpPressure, measuredROFlowRateLPM - * @param none * @return none *************************************************************************/ void execROPumpMonitor( void ) @@ -211,7 +208,6 @@ * @details * Inputs : roPumpState * Outputs : roPumpState - * @param none * @return none *************************************************************************/ void execROPumpController( void ) @@ -239,18 +235,19 @@ * @details * Inputs : targetROPumpPressure * Outputs : roPumpPWMDutyCyclePctSet, isROPumpOn - * @param none * @return next state *************************************************************************/ static RO_PUMP_STATE_T handleROPumpOffState( void ) { RO_PUMP_STATE_T result = RO_PUMP_OFF_STATE; +#ifdef DEBUG_ENABLED // TODO - test code - remove later if ( GET_DIP_SW0_TEST() ) { setROPumpTargetPressure( 120, PUMP_CONTROL_MODE_CLOSED_LOOP ); } +#endif // if we've been given a pressure, transition to control to target state if ( getTargetROPumpPressure() > 0 ) @@ -260,7 +257,7 @@ roPumpPWMDutyCyclePctSet = roPumpPWMDutyCyclePct; setROPumpControlSignalPWM( roPumpPWMDutyCyclePctSet ); // reset controller - resetPIController( PI_CONTROLLER_ID_RO_PUMP, MIN_RO_PUMP_PWM_DUTY_CYCLE ); + resetPIController( PI_CONTROLLER_ID_RO_PUMP, roPumpPWMDutyCyclePctSet ); // set pump to on isROPumpOn = TRUE; result = RO_PUMP_CONTROL_TO_TARGET_STATE; @@ -276,7 +273,6 @@ * @details * Inputs : none * Outputs : roPumpState - * @param none * @return next state *************************************************************************/ static RO_PUMP_STATE_T handleROPumpControlToTargetState( void ) @@ -299,12 +295,14 @@ roControlTimerCounter = 0; } +#ifdef DEBUG_ENABLED // TODO - test code - remove later if ( !GET_DIP_SW0_TEST() ) { signalROPumpHardStop(); result = RO_PUMP_OFF_STATE; } +#endif return result; } @@ -330,7 +328,6 @@ * @details * Inputs : none * Outputs : PWM duty cycle zeroed - * @param none * @return none *************************************************************************/ static void stopROPump( void ) @@ -347,7 +344,6 @@ * @details * Inputs : roPumpDataPublishInterval * Outputs : none - * @param none * @return the current RO pump data publication interval (in ms). *************************************************************************/ U32 getPublishROPumpDataInterval( void ) @@ -369,7 +365,6 @@ * @details * Inputs : targetROPumpPressure * Outputs : none - * @param none * @return the current target RO pressure (in PSI). *************************************************************************/ U32 getTargetROPumpPressure( void ) @@ -389,10 +384,9 @@ * The getMeasuredROFlowRate function gets the measured RO pump \n * flow rate. * @details - * Inputs : roPumpSpeedRPM + * Inputs : measuredROFlowRateLPM * Outputs : none - * @param none - * @return the current RO pump speed (in RPM). + * @return the current RO pump flow rate (in LPM). *************************************************************************/ F32 getMeasuredROFlowRate( void ) { Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rc48a99d2d1c852adcc986253b6c420a90dab7bfe -ra721c4feab8c89880314070d56224e28d502ac5e --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision a721c4feab8c89880314070d56224e28d502ac5e) @@ -142,14 +142,6 @@ U16 fpgaCPoProbeType; U16 fpgaDrainPumpSetSpeed; U16 fpgaValveStates; - U08 fpgaID; - U08 fpgaRev; - //U08 fpgaADC1Control; - //U08 fpgaDiag; - //U08 fpgaADC2Control; - //U08 fpgaRTDControl; - //U08 fpgaTHDoControl; - //U08 fpgaTDiControl; } FPGA_ACTUATORS_T; #pragma pack(pop)