I've made a first pilot effort at adding "assisted ventilation" to my little ventilator at home, with a bit of code added to vent_slice()? (see below)
It is pretty crude, but it does indeed initiate an assisted breath (of sorts).
Here is how it works:? ?When measuring the pressure (only done at the end of a "slice" -- there are 20 of them in each respiratory cycle in my code) -- if that pressure goes below 2cm below atmospheric (and inspiratory_pause isn't active, just for simplicity of my code for this test) -- the code jumps the variable current_phase up all the way to the ending phase of the respiratory cycle.? ?This causes the code to complete end-of-cycle calculations & displays, and move right into an INSPIRE sequence, forcing fresh gas into the patient.??
qui
It worked -- I was easily able to intiate an assisted breath--- by doing the following.
(CAUTION:? many of us are using air compressors that literally are like little engines, with pistons and cylinders and rings and oil lubrication -- and the air coming out may have OIL etc in it -- you don't want to breathe that stuff if you can help it!!)
Because I still have a breathing bag attached to my system (to simulate a patient) and I wasn't yet willing to take that off and breathe from that connection, I just quickly used a hand to occlude the bag entrance during an exhalation phase (I slowed the BPM to 10 to make my timing easier) and then sucked air out of the expiratory (pen) lawn sprinkler -- and got the system to recognize it, giving me a Serial.print? of ***ASSISTED BREATH****? and moving right to the beginning of the respoiratory cycle and initiating an inspiration.
Problems:? it was too slow.? ?I have a lot of code doing a lot of things AFTER the point at which I measured this, so the move toward assisting took >100 mSec.? ?That could be speeded up I suspect to make this more useful!
But it was a start and wanted to point out this possibility for the hardware that we now have.?
Gordon
Full current code attached.??
void vent_slice(){
? long now;
? float diffpressure[MAX_PHASES];
? long differentialpressure;
??
?
? if (!vent_running){
? ? alarm(ALARM_OFF);
? ? return;
? }
?
? now = millis();
? if (next_slice > now){
? ? //? Serial.print(".");
? ? //? With MAX_PHASES (number of slices to a ventilatory cycle) at 20, system printed 8 dots at resp rate of 28?
? ? //? With MAX_PHASES (number of slices to a ventilatory cycle at 60....? did not print any dots MA -- unable to keep up.
? ? //? So the maximum MAX_PHASES isn't that much....
? ? ? ? return;
? ? }
? ?
?
?// Note that it may go through many times before it ever goes any further.
?
? // Zero the peak inspiratory pressure if this is our very first time
? // in this cycle.?
??
? if(current_phase==0)peakinspiratorypressure=0;
??
? cut_off = MAX_PHASES - (MAX_PHASES * (ie_ratio))/(ie_ratio + 1);
?
? check_pressure_limits();? // check this at the end of every slice??
? ??
? //we move to the next slice
? if (current_phase < cut_off){
? ? ? pressure_on();
? ? ? exLitersPerCycle = 0 ; // initalize for? computations next exhalation?
? ? ? }
? //? During the expiratory phase we need to measure?
? //? 1)? differential pressure across an obstruction
? //? 2)? compute the flow rate
? //? 3)? multiply by the time slice to get volume in that breath
? //? 4)? keep accumulating it.
? //? 5)? zero it out during inspirations.
??
? if (current_phase > cut_off){
? ? pressure_off();
? ? ?// we are in EXHALATIION
? ? ?
? ? // I have no idea what the proper constants are here.....
? ? diffpressure[current_phase] =? ReadFlowPressureSensor();
?
#ifdef DELP-DISPLAY? ??
? ? Serial.print ("Differential pressure:? ?");
? ? Serial.print (delP);
? ? Serial.print ("\n");
#endif
? ? // Now calculate the FLOW for that pressure difference:
? ? // The mlliseconds assigned to each slice is 60000l / ((long)beats_per_minute * (long)MAX_PHASES)
? ? // where 60000 l? is (long) 60000??
? ? // so the SECONDS of each slice is? ?float? 60/(? (float)beats_per_minute? * (float)MAX_PHASES )?
? ? // and we use exLitersPerCycle to build up the expiredLiters per cycle as follows:?
? ? exLitersPerCycle = exLitersPerCycle? +? ?(? CalculateInstantFlow() * 60 / ( (float) (beats_per_minute *? MAX_PHASES))? )? ;
? ? // GLG -- Marcelo caught the erroneous PLUS sign where beats_per_minute wa supposed to be multiplied by MAX_PHASES.... fixed now.
? ??
#ifdef? ACCUMULATIONDISPLAY
? ? Serial.print("Accumuating exLitersPerCycle");
? ? Serial.print((long) exLitersPerCycle );
? ? Serial.print( "\n");
#endif? ??
? ? ? ?}? // end of things to do AFTER cut_off (hence in exhalation)
? ?
?
? // this is what sets the TIME WIDTH of a slice --? ?
? // the 60 000 l? ?is 60 thousand (LONG)? milliseconds
? // at 10 breatghs per minute and MAX_PHASES = 40, each slide is 150ms
? // at 30 breaths per minute, it would be 50 msec
??
? next_slice = now + 60000l / ((long)beats_per_minute * (long)MAX_PHASES);
?
#ifdef TIMESLICE-DISPLAY
Serial.print("Now, nextslice: ");
Serial.print(now);
Serial.print("? ");
Serial.print(next_slice);
Serial.print("\n");
#endif
?
? int p = measure_pressure();??
?
//---------------------ASSISTED VENTILATION EXPERIMENT---------------------
? // Lets try to add assisted ventilation
? if( (current_phase>cut_off) & (inspiratory_pause==0) & (p+1<atmospheric_pressure) )
? {
? ? // slam us to the end of the expiratory phase
? ? current_phase= MAX_PHASES +1;
? ? Serial.print("\n\n**ASSISTED BREATH**\n\n");?
? }
// ---------------------END OF ASSISTED VENT EXPErIMENT-----------------------
?
?
? bargraph[current_phase] = (int)(p - atmospheric_pressure);
? current_pressure = bargraph[current_phase];
? pressure_total += current_pressure;
? if (use_tft)
? ? tft_graph_update();
? else?
? ? lcd_graph_update();
? current_phase++;
??
? if (current_phase >= MAX_PHASES){ // end of the entire respiratory cycle
? exmLPerCycle=(int) exLitersPerCycle;? // note exmLPerCycle= INT
? if(exmLPerCycle<0) exmLPerCycle=0;? // dont allow negative numbers
?
// Check tidal volume limits
? if(exmLPerCycle>TVhighlimit){
? ? ? ? ? alarm(ALARM_SLOW);
? ? ? ? ? update_status2("V^");
? }
? if(exmLPerCycle<TVlowlimit) {
? ? ? ? ? alarm(ALARM_FAST);
? ? ? ? ? update_status2("Vv");
? ?
? }
??
#ifdef TOTALTIDAL-DISPLAY
? Serial.print("Tidal Vol This Breath: ");
? Serial.print("exLitersPerCycle");
? Serial.print("? ");
? Serial.println((int) exLitersPerCycle);
? Serial.print("exmLPerCycle: " );
? Serial.print(exmLPerCycle);
? Serial.print("\n\n");
??
?
#endif
?
// Now WRITE IT OUT To THE DISPLAY!!!
// try callng this update directly:
?
// lcd_graph_update();? ?// that SHOULD print it out
?
?
? ?if (use_tft)
? ? ? tft_graph_clear();
? ? else
? ? ? lcd_graph_clear();
? ? current_phase = 0;? ??
? }
?}
?