Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
HEV - High Energy Ventilator
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
HEV - High Energy Ventilator
Commits
81c823ca
Commit
81c823ca
authored
Aug 12, 2020
by
Peter Švihra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added new flow calculation
parent
8ad0e797
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
7 deletions
+50
-7
BreathingLoop.cpp
arduino/hev_prototype_v1/src/BreathingLoop.cpp
+23
-1
BreathingLoop.h
arduino/hev_prototype_v1/src/BreathingLoop.h
+6
-0
LinearFitter.h
arduino/hev_prototype_v1/src/LinearFitter.h
+1
-1
UILoop.cpp
arduino/hev_prototype_v1/src/UILoop.cpp
+6
-3
common.h
arduino/hev_prototype_v1/src/common.h
+10
-0
main.cpp
arduino/hev_prototype_v1/src/main.cpp
+1
-0
CommsCommon.py
raspberry-dataserver/CommsCommon.py
+3
-2
No files found.
arduino/hev_prototype_v1/src/BreathingLoop.cpp
View file @
81c823ca
...
...
@@ -315,6 +315,15 @@ void BreathingLoop::updateCycleReadings()
}
void
BreathingLoop
::
updateCalculations
()
{
uint32_t
tnow
=
static_cast
<
uint32_t
>
(
millis
());
_calculations
.
flow
=
getFlow
();
_calculations
.
flow_calc
=
calculateFlow
(
tnow
,
_readings_raw
.
pressure_patient
,
_readings_raw
.
pressure_buffer
);
_calculations
.
volume
=
getVolume
();
_calculations
.
pressure_airway
=
getAirwayPressure
();
}
void
BreathingLoop
::
setVentilationMode
(
VENTILATION_MODE
mode
)
{
_ventilation_mode
=
mode
;
...
...
@@ -358,7 +367,7 @@ VENTILATION_MODE BreathingLoop::getVentilationMode() { return _ventilation_mode;
readings
<
float
>
BreathingLoop
::
getReadingAverages
()
{
return
_readings_avgs
;
}
readings
<
float
>
BreathingLoop
::
getRawReadings
()
{
return
_readings_raw
;
}
calculations
<
float
>
BreathingLoop
::
getCalculations
()
{
return
_calculations
;
}
float
BreathingLoop
::
getPEEP
()
{
...
...
@@ -878,6 +887,19 @@ ValvesController* BreathingLoop::getValvesController()
// _total_cycle_duration[N-1] = newtotal;
// }
float
BreathingLoop
::
calculateFlow
(
const
uint32_t
&
current_time
,
const
float
&
pressure_patient
,
const
float
&
pressure_buffer
,
float
volume_tube
,
float
volume_buffer
)
{
float
dp_tube
,
dp_buffer
,
offset
;
uint8_t
linreg
;
_pressure_buffer_fitter
.
appendPoints
(
current_time
,
pressure_buffer
+
1013.
);
_pressure_patient_fitter
.
appendPoints
(
current_time
,
pressure_patient
+
1013.
);
linreg
=
_pressure_buffer_fitter
.
linearRegression
(
dp_buffer
,
offset
);
linreg
=
_pressure_patient_fitter
.
linearRegression
(
dp_tube
,
offset
);
return
(((
-
1.
/
pressure_patient
)
*
((
dp_tube
*
volume_tube
)
+
(
dp_buffer
*
volume_buffer
)))
-
(
1.
*
4
*
dp_tube
));
}
float
BreathingLoop
::
getFlow
(){
const
float
temperature
=
298.0
;
const
float
pressure
=
1030.0
;
...
...
arduino/hev_prototype_v1/src/BreathingLoop.h
View file @
81c823ca
...
...
@@ -30,8 +30,10 @@ public:
void
updateReadings
();
void
updateRawReadings
();
void
updateCycleReadings
();
void
updateCalculations
();
readings
<
float
>
getReadingAverages
();
readings
<
float
>
getRawReadings
();
calculations
<
float
>
getCalculations
();
// float getRespiratoryRate();
float
getTargetRespiratoryRate
();
float
getIERatio
();
...
...
@@ -50,6 +52,7 @@ public:
void
setVentilationMode
(
VENTILATION_MODE
mode
);
VENTILATION_MODE
getVentilationMode
();
float
calculateFlow
(
const
uint32_t
&
current_time
,
const
float
&
pressure_patient
,
const
float
&
pressure_buffer
,
float
volume_tube
=
1600
,
float
volume_buffer
=
10000
);
float
getFlow
();
float
getVolume
();
float
getAirwayPressure
();
...
...
@@ -130,6 +133,7 @@ private:
readings
<
float
>
_readings_sums
;
// 32 bit due to possible analog read overflow
readings
<
float
>
_readings_avgs
;
readings
<
float
>
_readings_raw
;
calculations
<
float
>
_calculations
;
bool
_readings_reset
;
uint32_t
_readings_N
;
uint32_t
_readings_time
;
...
...
@@ -177,6 +181,8 @@ private:
//float _pid_integral; // moved to pid_variable struct
LinearFitter
_flow_fitter
=
LinearFitter
(
300
,
100
);
LinearFitter
_pressure_buffer_fitter
=
LinearFitter
(
20
,
0
);
LinearFitter
_pressure_patient_fitter
=
LinearFitter
(
20
,
0
);
// triggers
void
runningAvgs
();
bool
inhaleTrigger
();
...
...
arduino/hev_prototype_v1/src/LinearFitter.h
View file @
81c823ca
...
...
@@ -65,7 +65,7 @@ public:
float
extrapolate
(
uint32_t
x
)
{
x
-=
_x_zero
;
float
slope
,
offset
;
uint8_t
linreg
=
linearRegression
(
slope
,
offset
);
uint8_t
linreg
=
linearRegression
(
slope
,
offset
);
if
(
0
==
linreg
){
return
(
x
*
slope
+
offset
);
}
...
...
arduino/hev_prototype_v1/src/UILoop.cpp
View file @
81c823ca
...
...
@@ -105,9 +105,12 @@ void UILoop::reportFastReadings()
_fast_data
.
process_pressure
=
pid
.
process_pressure
;
_fast_data
.
valve_duty_cycle
=
pid
.
valve_duty_cycle
;
_fast_data
.
flow
=
_breathing_loop
->
getFlow
();
_fast_data
.
volume
=
_breathing_loop
->
getVolume
();
_fast_data
.
airway_pressure
=
_breathing_loop
->
getAirwayPressure
();
calculations
<
float
>
calc
=
_breathing_loop
->
getCalculations
();
_fast_data
.
flow
=
calc
.
flow
;
_fast_data
.
flow_calc
=
calc
.
flow_calc
;
_fast_data
.
volume
=
calc
.
volume
;
_fast_data
.
airway_pressure
=
calc
.
pressure_airway
;
_pl_send
.
setPayload
(
PRIORITY
::
DATA_ADDR
,
reinterpret_cast
<
void
*>
(
&
_fast_data
),
sizeof
(
_fast_data
));
_comms
->
writePayload
(
_pl_send
);
...
...
arduino/hev_prototype_v1/src/common.h
View file @
81c823ca
...
...
@@ -229,6 +229,7 @@ struct fast_data_format {
uint16_t
ambient_temperature
=
0
;
float
airway_pressure
=
0
.
0
;
float
flow
=
0
.
0
;
float
flow_calc
=
0
.
0
;
float
volume
=
0
.
0
;
float
target_pressure
=
0
.
0
;
//
float
process_pressure
=
0
.
0
;
...
...
@@ -664,6 +665,15 @@ template <typename T> struct readings{
T
o2_percent
=
0
;
};
template
<
typename
T
>
struct
calculations
{
uint32_t
timestamp
=
0
;
T
flow
=
0
;
T
flow_calc
=
0
;
T
volume
=
0
;
T
pressure_airway
=
0
;
};
template
<
typename
T
>
struct
IV_readings
{
uint64_t
timestamp
=
0
;
//
T
inhale_current
=
0
;
...
...
arduino/hev_prototype_v1/src/main.cpp
View file @
81c823ca
...
...
@@ -138,6 +138,7 @@ void loop()
breathing_loop
.
updateReadings
();
breathing_loop
.
updateRawReadings
();
breathing_loop
.
updateCycleReadings
();
breathing_loop
.
updateCalculations
();
// update alarm values
// TODO assign more values
alarm_loop
.
updateValues
(
breathing_loop
.
getReadingAverages
(),
breathing_loop
.
getCycleReadings
());
...
...
raspberry-dataserver/CommsCommon.py
View file @
81c823ca
...
...
@@ -279,7 +279,7 @@ class PayloadFormat():
@
dataclass
class
DataFormat
(
PayloadFormat
):
# subclass dataformat
_dataStruct
=
Struct
(
"<BIBBHfHffffHfHHfffffffff"
)
_dataStruct
=
Struct
(
"<BIBBHfHffffHfHHfffffffff
f
"
)
payload_type
:
PAYLOAD_TYPE
=
PAYLOAD_TYPE
.
DATA
# subclass member variables
fsm_state
:
BL_STATES
=
BL_STATES
.
IDLE
...
...
@@ -296,7 +296,8 @@ class DataFormat(PayloadFormat):
ambient_temperature
:
int
=
0
airway_pressure
:
float
=
0.0
flow
:
float
=
0.0
volume
:
float
=
0.0
flow_calc
:
float
=
0.0
volume
:
float
=
0.0
target_pressure
:
float
=
0.0
##
process_pressure
:
float
=
0.0
valve_duty_cycle
:
float
=
0.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment