diff --git a/arduino/hev_prototype_v1/src/AlarmLoop.cpp b/arduino/hev_prototype_v1/src/AlarmLoop.cpp index 232f0d76c74a2dbc6f65164c25ab36c5f5740fb1..5df5f1558efa00e404e4a09fca4b4b8197d1f921 100644 --- a/arduino/hev_prototype_v1/src/AlarmLoop.cpp +++ b/arduino/hev_prototype_v1/src/AlarmLoop.cpp @@ -57,6 +57,7 @@ void AlarmLoop::updateValues(readings<float> fast_data, cycle_readings cr) { _alarms.values[ALARM_CODES::HIGH_VTI] = static_cast<float>(cr.inhaled_tidal_volume); _alarms.values[ALARM_CODES::LOW_VTE] = static_cast<float>(cr.exhaled_tidal_volume); _alarms.values[ALARM_CODES::LOW_VTI] = static_cast<float>(cr.inhaled_tidal_volume); +// _alarms.values[ALARM_CODES::LOW_PEEP] = static_cast<float>(cr.peep); _alarms.values[ALARM_CODES::AIR_FAIL] = static_cast<float>(fast_data.pressure_air_regulated); _alarms.values[ALARM_CODES::O2_FAIL] = static_cast<float>(fast_data.pressure_o2_regulated); } @@ -91,4 +92,4 @@ void AlarmLoop::setBatteryAlarms(battery_data_format &bat) setAlarm<float>(ALARM_CODES::BATTERY_CHARGE, _alarms.values, battery_charge); setAlarm<float>(ALARM_CODES::BATTERY_FAULT_SRVC, _alarms.values, battery_fault_svc); setAlarm<float>(ALARM_CODES::LOW_BATTERY, _alarms.values, low_battery); -} \ No newline at end of file +} diff --git a/arduino/hev_prototype_v1/src/BreathingLoop.cpp b/arduino/hev_prototype_v1/src/BreathingLoop.cpp index 1908d0935e745f15ccc1e0f8a5baa01d98057102..0f9fcfb68662a7c60e7a0c6d120beb7efe615c5e 100644 --- a/arduino/hev_prototype_v1/src/BreathingLoop.cpp +++ b/arduino/hev_prototype_v1/src/BreathingLoop.cpp @@ -32,10 +32,10 @@ BreathingLoop::BreathingLoop() _mandatory_inhale = false; _mandatory_exhale = false; - _pid.Kp = 0.004; // proportional factor - _pid.Ki = 0.0010; // integral factor - _pid.Kd = 0.; // derivative factor - _pid.pid_gain = 1; + _pid.Kp = 0.001; // proportional factor + _pid.Ki = 0.0005; // integral factor + _pid.Kd = 0.001; // derivative factor + _pid.pid_gain = 2; _pid.max_patient_pressure = 45; _pid.integral = 0.; @@ -88,16 +88,16 @@ BreathingLoop::BreathingLoop() void BreathingLoop::initTargets() { - _targets_pcac.respiratory_rate = 20.0; + _targets_pcac.respiratory_rate = 15.0; _targets_pcac.ie_ratio = 0.5; _targets_pcac.ie_selected = false; - _targets_pcac.inspiratory_pressure = 15; + _targets_pcac.inspiratory_pressure = 17; _targets_pcac.volume = 400; _targets_pcac.inhale_time= 1000; _targets_pcac.peep = 5; _targets_pcac.fiO2_percent = 21; - _targets_pcac.inhale_trigger_threshold = 0.0005; // abs flow ? unit / + _targets_pcac.inhale_trigger_threshold = 1; // abs flow ? unit / _targets_pcac.exhale_trigger_threshold = 0.25; // 25% of the peak flow _targets_pcac.buffer_lower_pressure = 285.0; @@ -670,7 +670,7 @@ void BreathingLoop::measureDurations( ) { void BreathingLoop::measurePEEP() { - if(fabs(_flow) < 0.1){ + if(fabs(_flow) < 1){ // _peep = _readings_avgs.pressure_patient; float sum_peep = 0; _running_peep[_running_index_peep] = _readings_avgs.pressure_patient; @@ -678,11 +678,13 @@ void BreathingLoop::measurePEEP() for(int i=0; i<RUNNING_AVG_READINGS-1; i++){ sum_peep += static_cast<float>(fabs(_running_peep[i])); } - _running_avg_peep = sum_peep/RUNNING_AVG_READINGS; + //_running_avg_peep = sum_peep/RUNNING_AVG_READINGS; _running_index_peep = (_running_index_peep == RUNNING_AVG_READINGS-1 ) ? 0 : _running_index_peep+1; } + //KH + _running_avg_peep = _readings_avgs.pressure_patient; } diff --git a/arduino/hev_prototype_v1/src/common.h b/arduino/hev_prototype_v1/src/common.h index 647d24d2a2abc5e23d30691f7b99b8068bc47366..f72c8f99adfd9d2dc3634ed1df39e934c9020f00 100644 --- a/arduino/hev_prototype_v1/src/common.h +++ b/arduino/hev_prototype_v1/src/common.h @@ -548,58 +548,58 @@ struct alarms { float thresholds_min [ALARM_CODES::ALARMS_COUNT] = { std::numeric_limits<float>::lowest(), // TEMPORARY VALUE DUE TO START FROM 1 -1, // APNEA - std::numeric_limits<float>::lowest(), // CHECK_VALVE_EXHALE - std::numeric_limits<float>::lowest(), // CHECK_P_PATIENT - std::numeric_limits<float>::lowest(), // EXPIRATION_SENSE_FAULT_OR_LEAK - std::numeric_limits<float>::lowest(), // EXPIRATION_VALVE_Leak - 0, // HIGH_FIO2 - 0, // HIGH_PRESSURE - 0, // HIGH_RR - 0, // HIGH_VTE + -1000, // CHECK_VALVE_EXHALE + 0, // CHECK_P_PATIENT + -1000, // EXPIRATION_SENSE_FAULT_OR_LEAK + -1000, // EXPIRATION_VALVE_Leak + -1000, // HIGH_FIO2 + -1000, // HIGH_PRESSURE + -1000, // HIGH_RR + -1000, // HIGH_VTE 300, // LOW_VTE - 0, // HIGH_VTI + -1000, // HIGH_VTI 300, // LOW_VTI - std::numeric_limits<float>::lowest(), // INTENTIONAL_STOP + -1, // INTENTIONAL_STOP -1.0, // LOW_BATTERY 19.5, // LOW_FIO2 // 19.5 % - std::numeric_limits<float>::lowest(), // OCCLUSION - 0, // HIGH_PEEP + -1000, // OCCLUSION + -1000, // HIGH_PEEP 0, // LOW_PEEP -1.0, // AC_POWER_DISCONNECTION -1.0, // BATTERY_FAULT_SRVC -1.0, // BATTERY_CHARGE - 400, // AIR_FAIL + -1000, // AIR_FAIL 400, // O2_FAIL - -0.5, // PRESSURE_SENSOR_FAULT - std::numeric_limits<float>::lowest() // ARDUINO_FAIL + -1000, // PRESSURE_SENSOR_FAULT + -1000 // ARDUINO_FAIL }; float thresholds_max [ALARM_CODES::ALARMS_COUNT] = { std::numeric_limits<float>::max() , // TEMPORARY VALUE DUE TO START FROM 1 3, // APNEA - std::numeric_limits<float>::max() , // CHECK_VALVE_EXHALE - std::numeric_limits<float>::max() , // CHECK_P_PATIENT - std::numeric_limits<float>::max() , // EXPIRATION_SENSE_FAULT_OR_LEAK - std::numeric_limits<float>::max() , // EXPIRATION_VALVE_Leak + 1000, // CHECK_VALVE_EXHALE + 45, // CHECK_P_PATIENT + 1000, // EXPIRATION_SENSE_FAULT_OR_LEAK + 1000, // EXPIRATION_VALVE_Leak 90.0, // HIGH_FIO2 // 90% 45, // HIGH_PRESSURE 30, // HIGH_RR 700, // HIGH_VTE - 0, // LOW_VTE + 10000, // LOW_VTE 700, // HIGH_VTI - 0, // LOW_VTI - std::numeric_limits<float>::max() , // INTENTIONAL_STOP + 10000, // LOW_VTI + 1, // INTENTIONAL_STOP 0.5, // LOW_BATTERY 100, // LOW_FIO2 - std::numeric_limits<float>::max() , // OCCLUSION + 1000, // OCCLUSION 15, // HIGH_PEEP - 0, // LOW_PEEP + -1000, // LOW_PEEP 0.5, // AC_POWER_DISCONNECTION 0.5, // BATTERY_FAULT_SRVC 0.5, // BATTERY_CHARGE - 550, // AIR_FAIL - 550, // O2_FAIL - std::numeric_limits<float>::max() , // PRESSURE_SENSOR_FAULT - std::numeric_limits<float>::max() // ARDUINO_FAIL + 10000, // AIR_FAIL + 650, // O2_FAIL + 1000 , // PRESSURE_SENSOR_FAULT + 1000, // ARDUINO_FAIL }; float values [ALARM_CODES::ALARMS_COUNT]; }; diff --git a/raspberry-dataserver/CommsLLI.py b/raspberry-dataserver/CommsLLI.py index 4f1586f0480e1d3be415a2f02748c2dd0358cc0f..4b4ffdbab6eb57a74e8a2f8f70638cbb69cdf7dc 100755 --- a/raspberry-dataserver/CommsLLI.py +++ b/raspberry-dataserver/CommsLLI.py @@ -53,7 +53,7 @@ class CommsLLI: self._acklist = {0xC0: self._dv_alarms, 0x80: self._dv_commands, 0x40: self._dv_data} # receive - self._payloadrecv = asyncio.Queue() + self._payloadrecv = asyncio.Queue(maxsize=5) # for reducing the rate for use in the lab self._packet_count = 0 self._throttle = throttle