Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -rb1fa52faec7b2bd1ed45eb58e2f7dfa7b03ea848 -r0c821ccea762672476834fa0a0926c9aba64c47b --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision b1fa52faec7b2bd1ed45eb58e2f7dfa7b03ea848) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 0c821ccea762672476834fa0a0926c9aba64c47b) @@ -198,6 +198,7 @@ static OVERRIDE_U32_T syringePumpADCReadCtr = {0, 0, 0, 0}; ///< Syringe pump ADC read counter reported by FPGA. static BOOL requireSyringeDetection; ///< Flag indicating whether syringe detection is required in the current state. +static BOOL prevSyringeDetected; ///< Flag saving last state of syringe detection static F32 syringePumpSetRate; ///< Set rate for syringe pump (in mL/hr). static F32 forceAtEndOfSeek; ///< Force sensor reading in Volts at the end of seek. @@ -291,6 +292,7 @@ syringePumpState = SYRINGE_PUMP_INIT_STATE; heparinDeliveryState = HEPARIN_STATE_OFF; requireSyringeDetection = FALSE; + prevSyringeDetected = FALSE; syringePumpSetRate = 0.0; syringePumpSetToggleTime = 0; syringePumpSafetyVolumeDelivered = 0.0; @@ -1024,8 +1026,6 @@ *************************************************************************/ static void execSyringePumpMonitor( void ) { - BOOL prevSyringeDetected = isSyringeDetected(); - // Check if a new calibration is available if ( TRUE == isNewCalibrationRecordAvailable() ) { @@ -1102,7 +1102,6 @@ syringePumpMeasForce.data = ( (F32)getFPGASyringePumpADCChannel0() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS; // Apply home offset to encoder position - syringePumpLastPosition = getSyringePumpPosition(); syringePumpPosition.data = encPosition - syringePumpHomePositionOffset; // Calculate volume delivered from position syringePumpVolumeDelivered.data = (F32)( syringePumpPosition.data - syringePumpVolumeStartPosition ) / SYRINGE_ENCODER_COUNTS_PER_ML; @@ -1216,6 +1215,10 @@ resetSyringePumpRequestFlags(); + // Save syringe pump info for next time + syringePumpLastPosition = getSyringePumpPosition(); + prevSyringeDetected = isSyringeDetected(); + // Publish syringe pump data on interval publishSyringePumpData(); }