Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r40959111de79e7cc3b1dfed5d244d5038e3c375c -r754427f339e660b7fa688e5e3becc587b30518a8 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 40959111de79e7cc3b1dfed5d244d5038e3c375c) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 754427f339e660b7fa688e5e3becc587b30518a8) @@ -1743,7 +1743,7 @@ /*********************************************************************//** * @brief * The calcMeasRate function calculates the measured rate from a given delta - * position in last 1 sedond. + * position in last 1 second. * @details Inputs: syringePumpLastPositions[], syringePumpSpeedCalcTimerCounter * @details Outputs: syringePumpMeasRate, syringePumpSpeedCalcTimerCounter * @return none @@ -1754,15 +1754,15 @@ { S32 pos = getSyringePumpPosition(); U32 nextIdx = INC_WRAP( syringePumpMotorSpeedCalcIdx, 0, SYRINGE_PUMP_SPEED_CALC_BUFFER_LEN - 1 ); - S32 countsPerSec = pos - syringePumpLastPositions[ nextIdx ]; // Calc delta between pos 1 second ago and pos now + S32 countsPerSec = pos - syringePumpLastPositions[ syringePumpMotorSpeedCalcIdx ]; // Calc delta between pos 1 second ago and pos now S32 countsPerHr = countsPerSec * ( MIN_PER_HOUR * SEC_PER_MIN); F32 mLPerHr = (F32)((double)countsPerHr / (double)SYRINGE_ENCODER_COUNTS_PER_ML); // Set latest measured rate syringePumpMeasRate.data = mLPerHr; // Update last position for next time - syringePumpLastPositions[ nextIdx ] = pos; + syringePumpLastPositions[ syringePumpMotorSpeedCalcIdx ] = pos; syringePumpMotorSpeedCalcIdx = nextIdx; syringePumpSpeedCalcTimerCounter = 0; }