Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r90ac1467b8d858ec3c690f50d87893f3b1778a33 -r722eb364d9b8d1fa9cc98da41f09c5fd73a8be39 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 90ac1467b8d858ec3c690f50d87893f3b1778a33) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 722eb364d9b8d1fa9cc98da41f09c5fd73a8be39) @@ -994,6 +994,7 @@ syringePumpVolumeStartPosition = 0; syringePumpPositionKnown = TRUE; syringePumpVolumeDelivered.data = 0.0; + syringePumpSafetyVolumeDelivered = 0.0; syringePumpPlungerFound = FALSE; syringePumpPrimeCompleted = FALSE; result = SYRINGE_PUMP_OFF_STATE; @@ -1031,6 +1032,7 @@ stopPump = TRUE; syringePumpPlungerFound = TRUE; syringePumpVolumeDelivered.data = 0.0; + syringePumpSafetyVolumeDelivered = 0.0; syringePumpVolumeStartPosition = syringePumpPosition.data; } @@ -1072,6 +1074,7 @@ stopPump = TRUE; syringePumpPrimeCompleted = TRUE; syringePumpVolumeDelivered.data = 0.0; + syringePumpSafetyVolumeDelivered = 0.0; syringePumpVolumeStartPosition = syringePumpPosition.data; } @@ -1341,9 +1344,9 @@ { BOOL result = stopPump; F32 vol = getSyringePumpVolumeDelivered(); - F32 delta = fabs( vol - syringePumpSafetyVolumeDelivered ); F32 max = MAX( vol, syringePumpSafetyVolumeDelivered ); - F32 error = ( fabs( max ) < NEARLY_ZERO ? 0.0 : ( 1.0 - ( delta / max ) ) ); + F32 min = MIN( vol, syringePumpSafetyVolumeDelivered ); + F32 error = ( fabs( max ) < NEARLY_ZERO ? 0.0 : ( 1.0 - fabs( min / max ) ) ); if ( error > pctMargin ) { @@ -1462,6 +1465,7 @@ data.syringePumpState = (U32)syringePumpState; data.heparinDeliveryState = (U32)heparinDeliveryState; data.syringePumpVolumeDelivered = getSyringePumpVolumeDelivered(); + data.syringePumpSafetyVolume = syringePumpSafetyVolumeDelivered; broadcastSyringePumpData( data ); broadcastHeparinData( data.syringePumpVolumeDelivered );