Commit ff5f5074 authored by Derick's avatar Derick

changed calculation of MAINTAIN_O2 state according to documentation, display…

changed calculation of MAINTAIN_O2 state according to documentation, display calculated fio2 instead of measured
parent f24f19de
Pipeline #992 failed
......@@ -254,7 +254,7 @@ void BreathingLoop::updateReadings()
resetReadingSums();
updateFromTargets();
// logging to cross check fio2 with TestChest
logMsg(String(_targets_current->fiO2_percent)+","+String( _readings_avgs.o2_percent)+","+String(_fiO2_est));
// logMsg(String(_targets_current->fiO2_percent)+","+String( _readings_avgs.o2_percent)+","+String(_fiO2_est * 100.f));
}
}
......@@ -293,7 +293,7 @@ void BreathingLoop::updateCycleReadings()
_cycle_index = (_cycle_index == CYCLE_AVG_READINGS-1 ) ? 0 : _cycle_index+1;
_cycle_readings.timestamp = tnow;
_cycle_readings.fiO2_percent = _readings_avgs.o2_percent;// FIXME
_cycle_readings.fiO2_percent = _fiO2_est * 100.f; //_readings_avgs.o2_percent;// FIXME
_running_inhale_minute_volume[_cycle_index] = _volume_inhale ;
_running_exhale_minute_volume[_cycle_index] = _volume_exhale ;
_total_cycle_duration[_cycle_index] = (
......@@ -1429,9 +1429,10 @@ void BreathingLoop::updateO2Concentration()
// O2 valve from open->closed
_time_valve_closure = millis();
if (delta_p < 0){
_fill_state = FILL_STATES::AIR_FILL;
_fill_state = FILL_STATES::AIR_FILL; // safety precaution: when during O2 filling not enough pressure is provided, fill with air
}else{
_fiO2_est = (delta_p + _fiO2_est * _pressure_before_filling) / p_buff_now;
// _fiO2_est = (delta_p + _fiO2_est * _pressure_before_filling) / p_buff_now; //old
_fiO2_est = _fiO2_est + (1 - _fiO2_est) * (delta_p / p_buff_now);
}
}
}else if (vin_air != _valve_air_last_state){
......@@ -1445,7 +1446,8 @@ void BreathingLoop::updateO2Concentration()
if (delta_p < 0){
_fill_state = FILL_STATES::AIR_FILL;
}else{
_fiO2_est = 1 - (delta_p * 0.79 +(1 - _fiO2_est) * _pressure_before_filling) / p_buff_now;
// _fiO2_est = 1 - (delta_p * 0.79 +(1 - _fiO2_est) * _pressure_before_filling) / p_buff_now;
_fiO2_est = 0.21 + (_fiO2_est - 0.21) * (p_buff_now - delta_p) / p_buff_now;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment