the two embodiments to be described are ventilators that operate in a manner that seeks to simultaneously achieve the three goals stated above . apparatus to give effect to a first embodiment of the apparatus is shown in fig1 a . a blower 10 supplies a breathable gas to mask 11 in communication with the subject &# 39 ; s airway via a delivery tube 12 and exhausted via a exhaust diffuser 13 . airflow to the mask 11 is measured using a pneumotachograph 14 and a differential pressure transducer 15 . the mask flow signal from the transducer 15 is then sampled by a microprocessor 16 . mask pressure is measured at the port 17 using a pressure transducer 18 . the pressure signal from the transducer 18 is then sampled by the microprocessor 16 . the microprocessor 16 sends an instantaneous mask pressure request signal to the servo 19 , which compares said pressure request signal with actual pressure signal from the transducer 18 to the control fan motor 20 . the microprocessor settings can be adjusted via a serial port 21 . it is to be understood that the mask could equally be replaced with a tracheotomy tube , endotracheal tube , nasal pillows , or other means of making a sealed connection between the air delivery means and the subject &# 39 ; s airway . the microprocessor 16 is programmed to perform the following steps , to be considered in conjunction with tables 1 and 2 . 1 . set desired target values for the duration of inspiration ti tgt , duration of expiration te tgt , and minute ventilation v tgt . choose suitable constants p 0 and a std where p 0 is the desired end expiratory pressure , and a std is the desired increase in pressure above p 0 at end inspiration for a breath of duration tt tgt = ti tgt + te tgt . 2 . choose a suitable pressure waveform function π ( φ ), such as that shown in fig2 , such that the desired delivery pressure at phase φ will be given by : where the amplitude a equals the difference between the end inspiratory pressure and end expiratory pressure . however , other waveforms may be suitable for subjects with particular needs . 3 . initialize the phase φ in the respiratory cycle to zero , and initialize the current estimates of actual inspiratory and expiratory duration ti and te to ti tgt and te tgt respectively . 4 . initialize the rate of change of phase during inspiration δφ i between sampling intervals of length t to : 5 . initialize the rate of change of phase during expiration δφ e to : 6 . measure the instantaneous respiratory airflow f resp . 7 . calculate the average total breath duration tt = ti + te 8 . low pass filter the respiratory airflow with an adjustable time constant τf , where τf is a fixed small fraction of tt . 9 . calculate the instantaneous ventilation v , as half the absolute value of the respiratory airflow : v = 0 . 5 | f resp | 10 . from the target ventilation v tgt and the measured minute ventilation v , derive an error term v err , such that large values of v err indicate inadequate ventilation : 11 . takev bar as the result of low pass filtering v with a time constant τv bar which is long compared with tt . 12 . calculate a normalized airflow f norm , where f norm = f resp / v bar . 13 . from f norm , calculate the degree of membership in each of the fuzzy sets whose membership functions are shown in fig3 . 14 . calculate a normalized rate of change df norm / dφ , equal to df norm / dt divided by the current estimate of the average respiratory cycle time tt . 15 . from the normalized rate of change , calculate the degree of membership in each of the fuzzy sets shown in fig4 . 16 . for each row n in table 1 , calculate the degree of membership g n in the fuzzy set shown in the column labelled fuzzy phase , by applying the fuzzy inference rules shown . 17 . associate with the result of each of the n rules a phase φ n as shown in table 2 , noting that φ 10 is the current phase φ . 18 . increase each of the φ n excepting φ 10 by 0 . 89 τ / tt , to compensate for the previous low pass filtering step . 19 . calculate a new instantaneous phase φ inst as the angle to the center of gravity of n unit masses at polar coordinates of radius g n and angle φ n revolutions . 20 . calculate the smallest signed difference δφ inst between the phase estimated in the previous step and the current phase . 21 . derive a revised estimate δφ rev equal to a weighted mean of the value calculated in the previous step and the average value ( δφ i or δφ e as appropriate ). smaller values of w will cause better tracking of phase if the subject is breathing regularly , and larger values will cause better tracking of phase if the subject is breathing irregularly . 22 . derive a blending fraction b , such that the blending fraction is unity if the subject &# 39 ; s ventilation is well above v tgt , zero if the subject is breathing near or below v tgt , and increasing proportionally from zero to unity as the subject &# 39 ; s ventilation increases through an intermediate range . 23 . calculate δφ blend influenced chiefly by δφ calculated in step 21 from the subject &# 39 ; s respiratory activity if the subject &# 39 ; s ventilation is well above v tgt ; influenced chiefly by the target respiratory duration if the subject is breathing near or below v tgt ; and proportionally between these two amounts if ventilation is in an intermediate range : 24 . increment φ by δφ blend 25 . update the average rate of change of phase ( δφ i or δφ e as appropriate ). 26 . recalculate the approximate duration of inspiration ti and expiration te : te = 0 . 5 t / δφ e 27 . calculate the desired mask pressure modulation amplitude a d : a d = 2 · a std ( tt & gt ; 2 · tt std ) a d = a std · tt / tt std ( otherwise ) 28 . from the error term v err , calculate an additional mask pressure modulation amplitude a e : where larger values of k will produce a faster but less stable control of the degree of assistance , and smaller values of k will produce slower but more stable control of the degree of assistance . p mask = p 0 +( a d + a e ) π ( φ ) 30 . wait for a sampling interval t , short compared with the duration of a respiratory cycle , and then continue at the step of measuring respiratory airflow . as follows from above , it is necessary to respiratory airflow , which is a standard procedure to one skilled in the art . in the absence of leak , respiratory airflow can be measured directly with a pneumotachograph placed between the mask and the exhaust . in the presence of a possible leak , one method disclosed in european publication no 0 651 971 incorporated herein by cross - reference is to calculate the mean flow through the leak , and thence calculate the amount of modulation of the pneumotachograph flow signal due to modulation of the flow through the leak induced by changing mask pressure , using the following steps : 1 . measure the airflow at the mask f mask using a pneumotachograph 2 . measure the pressure at the mask p mask 3 . calculate the mean leak as the low pass filtered airflow , with a time constant long compared with a breath . 4 . calculate the mean mask pressure as the low pass filtered mask pressure , with a time constant long compared with a breath . 5 . calculate the modulation of the flow through the leak as : a convenient extension as further disclosed in ep 0 651 971 ( incorporated herein by cross - reference ) is to measure airflow f turbine and pressure p turbine at the outlet of the turbine , and thence calculate p mask and f mask by allowing for the pressure drop down the air delivery hose , and the airflow lost via the exhaust : δ p hos e = k 1 ( f turbine )− k 2 ( f turbine ) 2 1 . the following embodiment is particularly applicable to subjects with varying respiratory mechanics , insufficient respiratory drive , abnormal chemoreceptor reflexes , hypoventilation syndromes , or cheyne stokes breathing , or to subjects with abnormalities of the upper or lower airways , lungs , chest wall , or neuromuscular system . many patients with severe lung disease cannot easily be treated using a smooth physiological pressure waveform , because the peak pressure required is unacceptably high , or unachievable with for example a nose - mask . such patients may prefer a square pressure waveform , in which pressure rises explosively fast at the moment of commencement of inspiratory effort . this may be particularly important in patients with high intrinsic peep , in which it is not practicable to overcome the intrinsic peep by the use of high levels of extrinsic peep or cpap , due to the risk of hyperinflation . in such subjects , any delay in triggering is perceived as very distressing , because of the enormous mis - match between expected and observed support . smooth waveforms exaggerate the perceived delay , because of the time taken for the administered pressure to exceed the intrinsic peep . this embodiment permits the use of waveforms varying continuously from square ( suitable for patients with for example severe lung or chest wall disease or high intrinsic peep ) to very smooth , suitable for patients with normal lungs and chest wall , but abnormal respiratory control , or neuromuscular abnormalities . this waveform is combined either with or without elements of proportional assist ventilation ( corrected for sudden changes in leak ), with servo - control of the minute ventilation to equal or exceed a target ventilation . the latter servo - control has an adjustable gain , so that subjects with for example cheyne stokes breathing can be treated using a very high servo gain to over - ride their own waxing and waning patterns ; subjects with various central hypoventilation syndromes can be treated with a low servo gain , so that short central apneas are permitted , for example to cough , clear the throat , talk , or roll over in bed , but only if they follow a previous period of high ventilation ; and normal subjects are treated with an intermediate gain . the integral gain of the servo - control of the degree of assistance is adjustable from very fast ( 0 . 3 cmh 2 o / l / sec / sec ) to very slow . patients with cheyne - stokes breathing have a very high ventilatory control loop gain , but a long control loop delay , leading to hunting . by setting the loop gain even higher , the patient &# 39 ; s controller is stabilized . this prevents the extreme breathlessness that normally occurs during each cycle of cheyne - stokes breathing , and this is very reassuring to the patient . it is impossible for them to have a central apnea . conversely , subjects with obesity - hypoventilation syndrome have low or zero loop gain . they will not feel breathless during a central apnea . however , they have much mucus and need to cough , and are also often very fidgety , needing to roll about in bed . this requires that they have central apneas which the machine does not attempt to treat . by setting the loop gain very low , the patient is permitted to take a couple of deep breaths and then have a moderate - length central apnea while coughing , rolling to over , etc , but prolonged sustained apneas or hypopneas are prevented . sudden changes in leakage flow are detected and handled using a fuzzy logic algorithm . the principle of the algorithm is that the leak filter time constant is reduced dynamically to the fuzzy extent that the apparent respiratory airflow is a long way from zero for a long time compared with the patient &# 39 ; s expected respiratory cycle length . rather than simply triggering between two states ( ipap , epap ), the device uses a fuzzy logic algorithm to estimate the position in the respiratory cycle as a continuous variable . the algorithm permits the smooth pressure waveform to adjust it &# 39 ; s rise time automatically to the patient &# 39 ; s instantaneous respiratory pattern . the fuzzy phase detection algorithm under normal conditions closely tracks the patient &# 39 ; s breathing . to the extent that there is a high or suddenly changing leak , or the patient &# 39 ; s ventilation is low , the rate of change of phase ( respiratory rate ) smoothly reverts to the specified target respiratory rate . longer or deeper hypopneas are permitted to the extent that ventilation is on average adequate . to the extent that the servo gain is set high to prevent cheyne stokes breathing , shorter and shallower pauses are permitted . airflow filtering uses an adaptive filter , which shortens it &# 39 ; s time constant if the subject is breathing rapidly , to give very fast response times , and lenthens if the subject is breathing slowly , to help eliminate cardiogenic artifact . the fuzzy changing leak detection algorithm , the fuzzy phase detection algorithm with its differential handling of brief expiratory pauses , and handling of changing leak , together with the smooth waveform severally and cooperatively make the system relatively immune to the effects of sudden leaks . by suitably setting various parameters , the system can operate in cpap , bilevel spontaneous , bilevel timed , proportional assist ventilation , volume cycled ventilation , and volume cycled servo - ventilation , and therefore all these modes are subsets of the present embodiment . however , the present embodiment permits states of operation that can not be achieved by any of the above states , and is therefore distinct from them . note 1 : in this second embodiment , the names and symbols used for various quantities may be different to those used in the first embodiment . note 2 : the term “ swing ” is used to refer to the difference between desired instantaneous pressure at end inspiration and the desired instantaneous pressure at end expiration . note 3 : a fuzzy membership function is taken as returning a value between zero for complete nonmembership and unity for complete membership . fuzzy intersection a and b is the lesser of a and b , fuzzy union a or b is the larger of a and b , and fuzzy negation not a is 1 − a . note 4 : root ( x ) is the square root of x , abs ( x ) is the absolute value of x , sign ( x ) is − 1 if x is negative , and + 1 otherwise . an asterisk (*) is used to explicitly indicate multiplication where this might not be obvious from context . the apparatus for the second embodiment is shown in fig1 b . the blower 110 delivers air under pressure to the mask 111 via the air delivery hose 112 . exhaled air is exhausted via the exhaust 113 in the mask 111 . the pneumotachograph 114 and a differential pressure transducer 115 measure the airflow in the nose 112 . the flow signal is delivered to the microprocessor 116 . pressure at any convenient point 117 along the nose 112 is measured using a pressure transducer 118 . the output from the pressure transducer 118 is delivered to the microcontroller 116 and also to a motor servo 119 . the microprocessor 116 supplies the motor servo 119 with a pressure request signal , which is then compared with the signal from the pressure transducer 118 to control the blower motor 120 . user configurable parameters are loaded into the microprocessor 116 via a communications port 121 , and the computed mask pressure and flow can if desired be output via the communications port 121 . the expected duration of a respiratory cycle , of an inspiration , and of an expiration are set respectively to : the standard rates of change of phase ( revolutions per sec ) during inspiration and expiration are set respectively to : the instantaneous elastic support at any phase φ in the respiratory cycle is given by : if τ = 0 , then π ( φ ) is a square wave . the maximum implemented value for τ = 0 . 3 , producing a waveform approximately as shown in fig5 . the following is an overview of routine processing done at 50 hz : measure flow at flow sensor and pressure at pressure sensing port calculate mask pressure and flow from sensor pressure and flow calculate conductance of mask leak calculate instantaneous airflow through leak calculate respiratory airflow and low pass filtered respiratory airflow calculate mask on - off status and lead - in calculate instantaneous and recent peak jamming calculate time constant for leak conductance calculations calculate phase in respiratory cycle update mean rates of change of phase for inspiration and expiration , lengths of inspiratory and expiratory times , and respiratory rate add hose pressure loss to epap pressure add resistive unloading calculate instantaneous elastic assistance required to servo - control ventilation estimate instantaneous elastic recoil pressure using various assumptions weight and combine estimates add servo pressure to yield desired sensor pressure servo - control motor speed to achieve desired sensor pressure flow is measured at the outlet of the blower using a pneumotachograph and differential pressure transducer . pressure is measured at any convenient point between the blower outlet and the mask . a humidifier and / or anti - bacterial filter may be inserted between the pressure sensing port and the blower . flow and pressure are digitized at 50 hz using an a / d converter . the pressure loss from pressure measuring point to mask is calculated from the flow at the blower and the ( quadratic ) resistance from measuring point to mask . where sign ( x )=− 1 for x & lt ; 0 , + 1 otherwise . the mask pressure is then calculated by subtracting the hose pressure loss from the measured sensor pressure : the flow through the mask exhaust diffuser is calculated from the known parabolic resistance of the diffuser holes , and the square root of the mask pressure : the foregoing describes calculation of mask pressure and flow in the various treatment modes . in diagnostic mode , the patient is wearing only nasal cannulae , not a mask . the cannula is plugged into the pressure sensing port . the nasal airflow is calculated from the pressure , after a linearization step , and the mask pressure is set to zero by definition . root mask pressure = sign ( p mask )√{ right arrow over ( abs ( p mask ))} the time constant for the two low pass filtering steps is initialized to 10 seconds and adjusted dynamically thereafter ( see below ). the instantaneous flow through the leak is calculated from the instantaneous mask pressure and the conductance of the leak : the respiratory airflow is the difference between the flow at the mask and the instantaneous leak : low pass filter the respiratory airflow to remove cardiogenic airflow and other noise . the time constant is dynamically adjusted to be 1 / 40 of the current estimated length of the respiratory cycle t tot ( initialized to std_t tot and updated below ). this means that at high respiratory rates , there is only a short phase delay introduced by the filter , but at low respiratory rates , there is good rejection of cardiogenic airflow . the mask is assumed to initially be off . an off - on transition is taken as occurring when the respiratory airflow first goes above 0 . 2 l / sec , and an on - off transition is taken as occurring if the mask pressure is less than 2 cmh 2 o for more than 1 . 5 seconds . lead - in is a quantity that runs from zero if the mask is off , or has just been donned , to 1 . 0 if the mask has been on for 20 seconds or more , as shown in fig6 . j is the fuzzy extent to which the impedance of the leak has suddenly changed . it is calculated as the fuzzy extent to which the absolute magnitude of the respiratory airflow is large for longer than expected . the fuzzy extent a i to which the airflow has been positive for longer than expected is calculated from the time t zi since the last positive - going zero crossing of the calculated respiratory airflow signal , and the expected duration std t i of a normal inspiration for the particular subject , using the fuzzy membership function shown in fig7 . the fuzzy extent b i to which the airflow is large and positive is calculated from the instantaneous respiratory airflow using the fuzzy membership function shown in fig8 . the fuzzy extent i i to which the leak has suddenly increased is calculated by calculating the fuzzy intersection ( lesser ) of a i and b i . precisely symmetrical calculations are performed for expiration , deriving i e . as the fuzzy extent to which the leak has suddenly decreased . a e is calculated from t ze and t e , b e is calculated from minus f resp , and i e is the fuzzy intersection of a e and b e . the instantaneous jamming index j is calculated as the fuzzy union ( larger ) of indices i i and i e . if the instantaneous jamming index is larger than the current value of the recent peak jamming index , then the recent peak jamming index is set to equal the instantaneous jamming index . otherwise , the recent peak jamming index is set to equal the instantaneous jamming index low pass filtered with a time constant of 10 seconds . an electrical analogy of the calculation is shown in fig9 . if the conductance of the leak suddenly changes , then the calculated conductance will initially be incorrect , and will gradually approach the correct value at a rate which will be slow if the time constant of the low pass filters is long , and fast if the time constant is short . conversely , if the impedance of the leak is steady , the longer the time constant the more accurate the calculation of the instantaneous leak . therefore , it is desirable to lengthen the time constant to the extent that the leak is steady , reduce the time constant to the extent that the leak has suddenly changed , and to use intermediately longer or shorter time constants if it is intermediately the case that the leak is steady . if there is a large and sudden increase in the conductance of the leak , then the calculated respiratory airflow will be incorrect . in particular , during apparent inspiration , the calculated respiratory airflow will be large positive for a time that is large compared with the expected duration of a normal inspiration . conversely , if there is a sudden decrease in conductance of the leak , then during apparent expiration the calculated respiratory airflow will be large negative for a time that is large compared with the duration of normal expiration . therefore , the time constant for the calculation of the conductance of the leak is adjusted depending on j peak , which is a measure of the fuzzy extent that the leak has recently suddenly changed , as shown in fig1 . in operation , to the extent that there has recently been a sudden and large change in the leak , j peak will be large , and the time constant for the calculation of the conductance of the leak will be small , allowing rapid convergence on the new value of the leakage conductance . conversely , if the leak is steady for a long time , j peak will be small , and the time constant for calculation of the leakage conductance will be large , enabling accurate calculation of the instantaneous respiratory airflow . in the spectrum of intermediate situations , where the calculated instantaneous respiratory airflow is larger and for longer periods , j peak will be progressively larger , and the time constant for the calculation of the leak will progressively reduce . for example , at a moment in time where it is uncertain whether the leak is in fact constant , and the subject has merely commenced a large sigh , or whether in fact there has been a sudden increase in the leak , the index will be of an intermediate value , and the time constant for calculation of the impedance of the leak will also be of an intermediate value . the advantage is that some corrective action will occur very early , but without momentary total loss of knowledge of the impedance of the leak . the current phase φ runs from 0 for start of inspiration to 0 . 5 for start of expiration to 1 . 0 for end expiration = start of next inspiration . nine separate features ( peaks , zero crossings , plateaux , and some intermediate points ) are identified on the waveform , as shown in fig1 . the filtered respiratory airflow is normalized with respect to the user specified target ventilation as follows : next , the fuzzy membership in fuzzy sets large negative , small negative , zero , small positive , and large positive , describing the instantaneous airflow is calculated using the membership functions shown in fig1 . for example , if the normalized airflow is 0 . 25 , then the airflow is large negative to extent 0 . 0 , small negative to extent 0 . 0 , zero to extent 0 . 5 , small positive to extent 0 . 5 , large positive to extent 0 . 00 . the rate of change of filtered respiratory airflow is calculated and normalized to a target ventilation of 7 . 5 l / min at 15 breaths / min as follows : standard df / dt = standard airflow * target frequency / 15 calculate d ( filtered airflow )/ dt low pass filter with a time constant of 8 / 50 seconds normalize by dividing by standard df / dt now evaluate the membership of normalized df / dt in the fuzzy sets falling , steady , and rising , whose membership functions are shown in fig1 . low pass filtered with a time constant of std t tot . hypopnea is the fuzzy extent to which the normalized ventilation is zero . the membership function for hypopnea is shown in fig1 . recent ventilation is also a low pass filtered abs ( respiratory airflow ), but filtered with an adjustable time constant , calculated from servo gain ( specified by the user ) as shown in fig1 . for example , if the servo gain is set to the maximum value of 0 . 3 , the time constant is zero , and recent ventilation equals instantaneous abs ( respiratory airflow ). conversely , if servo gain is zero , the time constant is twice std t tot , the expected length of a typical breath . hyperpnea is the fuzzy extent to which the recent ventilation is large . the membership function for hyperpnea is shown in fig1 . the fuzzy extent to which there is a big leak is calculated from the membership function shown in fig1 . membership in fuzzy sets switch negative and switch positive are calculated from the normalized respiratory airflow using the membership functions shown in fig1 , and membership in fuzzy sets insp_phase and exp_phase are calculated from the current phase f using the membership functions shown in fig1 . procedure w ( y ) calculates the area of an isosceles triangle of unit height and unit base , truncated at height y as shown in fig2 . in the calculations that follow , recall that fuzzy intersection a and b is the smaller of a and b , fuzzy union a or b is the larger of a and b , and fuzzy negation not a is 1 − a . the first fuzzy rule indicates that lacking any other information the phase is to increase at a standard rate . this rule is unconditionally true , and has a very heavy weighting , especially if there is a large leak , or there has recently been a sudden change in the leak , or there is a hypopnea . the next batch of fuzzy rules correspond to the detection of various features of a typical flow - vs - time curve . these rules all have unit weighting , and are conditional upon the fuzzy membership in the indicated sets : w early insp = w ( rise and small positive ) w peak insp = w ( large positive and steady and not recent peak jamming ) w early exp = w ( fall and small negative ) w peak exp = w ( large negative and steady ) w late exp = w ( rise and small negative ) the next rule indicates that there is a legitimate expiratory pause ( as opposed to an apnea ) if there has been a recent hyperpnea and the leak has not recently changed : w pause =( hyperpnea and not j peak )* w ( steady and zero ) recalling that the time constant for hyperpnea gets shorter as servo gain increases , the permitted length of expiratory pause gets shorter and shorter as the servo gain increases , and becomes zero at maximum servo gain . the rationale for this is that ( i ) high servo gain plus long pauses in breathing will result in “ hunting ” of the servo - as controller , and ( ii ) in general high servo gain is used if the subject &# 39 ; s chemoreceptor responses are very brisk , and suppression of long apneas or hypopneas will help prevent the subject &# 39 ; s own internal servo - control from hunting , thereby helping prevent cheyne - stokes breathing . finally , there are two phase - switching rules . during regular quiet breathing at roughly the expected rate , these rules should not strongly activate , but they are there to handle irregular breathing or breathing at unusual rates . they have very heavy weightings . for each of the ten fuzzy rules above , we attach phase angles φn , as shown in table zzz . note that φn are in revolutions , not radians . we now place the ten masses w ( n ) calculated above at the appropriate phase angles φ n around the unit circle , and take the centroid . note that if the user has entered very short duty cycle , k will be small . for example a normal duty cycle is 40 %, giving k = 40 / 60 = 0 . 67 . thus the expiratory peak will be associated with a phase angle of 0 . 5 + 0 . 2 * 0 . 67 = 0 . 63 , corresponding 26 % of the way into expiratory time , and the expiratory pause would start at 0 . 5 + 0 . 5 * 0 . 67 = 0 . 83 , corresponding to 67 % of the way into expiratory time . conversely , if the duty cycle is set to 20 % in a patient with severe obstructive lung disease , features 6 through 10 will be skewed or compressed into early expiration , generating an appropriately longer expiratory pause . the new estimate of the phase is the centroid , in polar coordinates , of the above ten rules : the change in phase dφ from the current phase φ to the centroid is calculated in polar coordinates . thus if the centroid is 0 . 01 and the current phase is 0 . 99 , the change in phase is dφ = 0 . 02 . conversely , if the centroid is 0 . 99 and the current phase is 0 . 01 , then dφ =− 0 . 02 . the new phase is then set to the centroid : this concludes the calculation of the instantaneous phase in the respiratory cycle φ . estimated mean duration of inspiration , expiration , cycle time , and respiratory rate if the current phase is inspiratory ( φ & lt ; 0 . 5 ) the estimated duration of inspiration t i is updated : lp ( dφ i )= low pass filtered dφ with a time constant of 4 * std t tot clip lp ( dφ i ) to the range ( 0 . 5 / std t i )/ 2 to 4 ( 0 . 5 / std t i ) t i = 0 . 5 / clipped lp ( dφi ) conversely , if the current phase is expiratory , ( φ & gt ;= 0 . 5 ) the estimated duration of expiration t e is updated : lp ( dφ e )= low pass filtered dφ with a time constant of 4 * std t tot clip lp ( dφe ) to the range ( 0 . 5 / std t e )/ 2 to 4 ( 0 . 5 / std t e ) te = 0 . 5 / clipped lp ( dφ e ) the purpose of the clipping is firstly to prevent division by zero , and also so that the calculated t i and t e are never more than a factor of 4 shorter or a factor of 2 longer than expected . finally , the observed mean duration of a breath t tot and respiratory rate rr are : the resistive unloading is the pressure drop across the patient &# 39 ; s upper and lower airways , calculated from the respiratory airflow and resistance values stored in sram f = respiratory airflow truncated to +/− 2 l / sec resistive unloading = airway resistance * f + upper airway resistance * f 2 * sign ( f ) the purpose of the instantaneous elastic assistance is to provide a pressure which balances some or all of the elastic deflating pressure supplied by the springiness of the lungs and chest wall ( instantaneous elastic pressure ), plus an additional component required to servo - control the minute ventilation to at least exceed on average a pre - set target ventilation . in addition , a minimum swing , always present , is added to the total . the user - specified parameter elastance is preset to say 50 - 75 % of the known or estimated elastance of the patient &# 39 ; s lung and chest wall . the various components are calculated as follows : the quantity servo swing is the additional pressure modulation amplitude required to servo - control the minute ventilation to at least equal on average a pre - set target ventilation . minute ventilation is defined as the total number of litres inspired or expired per minute . however , we can &# 39 ; t wait for a whole minute , or even several seconds , to calculate it , because we wish to be able to prevent apneas or hypopneas lasting even a few seconds , and a pi controller based on an average ventilation over a few seconds would be either sluggish or unstable , the quantity actually servo - controlled is half the absolute value of the instantaneous respiratory airflow . a simple clipped integral controller with no damping works very satisfactorily . the controller gain and maximum output ramp up over the first few seconds after putting the mask on . if we have had a sudden increase in mouth leak , airflow will be nonzero for a long time . a side effect is that the ventilation will be falsely measured as well above target , and the amount of servo assistance will be falsely reduced to zero . to prevent this , to the extent that the fuzzy recent peak jamming index is large , we hold the degree of servo assistance at its recent average value , prior to the jamming . error = target ventilation − abs ( respiratory airflow )/ 2 servo swing = s error * servo gain * sample interval clip servo swing to range 0 to 20 cmh 2 o * lead - in set recent servo swing = servo swing low pass filtered with a time constant of 25 sec . the instantaneous servo assistance is calculated by multiplying servo swing by the previously calculated pressure waveform template : the instantaneous pressure required to unload the elastic work of inspiring against the user - specified elastance is the specified elastance times the instantaneous inspired volume . unfortunately , calculating instantaneous inspired volume simply by integrating respiratory airflow with respect to time does not work in practice for three reasons : firstly leaks cause explosive run - away of the integration . secondly , the integrator is reset at the start of each inspiration , and this point is difficult to detect reliably . thirdly , and crucially , if the patient is making no efforts , nothing will happen . therefore , four separate estimates are made , and a weighted average taken . estimate 1 : exact instantaneous elastic recoil calculated from instantaneous tidal volume , with a correction for sudden change in leak the first estimate is the instantaneous elastic recoil of a specified elastance at the estimated instantaneous inspired volume , calculated by multiplying the specified elastance by the integral of a weighted respiratory airflow with respect to time , reset to zero if the respiratory phase is expiratory . the respiratory airflow is weighted by the fuzzy negation of the recent peak jamming index j peak , to partly ameliorate an explosive run - away of the integral during brief periods of sudden increase in leak , before the leak detector has had time to adapt to the changing leak . in the case where the leak is very steady , j peak will be zero , the weighting will be unity , and the inspired volume will be calculated normally and correctly . in the case where the leak increases suddenly , j peak will rapidly increase , the weighting will decrease , and although typically the calculated inspired volume will be incorrect , the over - estimation of inspired volume will be ameliorated . calculations are as follows : instantaneous volume = integral of respiratory airflow *( 1 − j peak ) dt if phase is expiratory ( 0 . 5 & lt ; φ & lt ; 1 . 0 revolutions ) reset integral to zero estimate 1 = instantaneous volume * elastance estimate 2 : based on assumption that the tidal volume equals the target tidal volume the quantity standard swing is the additional pressure modulation amplitude that would unload the specified elastance for a breath of a preset target tidal volume . target tidal volume = target ventilation / target frequency standard swing = elastance * target tidal volume estimate 2 = standard swing * π ( φ ) estimate 3 : based on assumption that the tidal volume equals the target tidal volume divided by the observed mean respiratory rate rr calculated previously . estimate 4 : based on assumption that this breath is much like recent breaths the instantaneous assistance based on the assumption that the elastic work for this breath is similar to that for recent breaths is calculated as follows : low pass filtered with a time constant of 2 std t tot the above algorithm works correctly even if π ( φ ) is dynamically changed on - the - fly by the user , from square to a smooth or vice versa . for example , if an 8 cmh2o square wave ( π bar = 1 ) adequately assists the patient , then a sawtooth wave ( π bar = 0 . 5 ) will require 16 cmh 2 o swing to produce the same average assistance . next , calculate the pressure required to unload a best estimate of the actual elastic recoil pressure based on a weighted average of the above . if π ( φ ) is set to the smoothest setting , the estimate is based equally on all the above estimates of instantaneous elastic recoil . if π ( φ ) is a square wave , the estimate is based on all the above estimates except for estimate 1 , because a square wave is maximal at φ = 0 , whereas estimate 1 is zero at φ = 0 . intermediate waveforms are handled intermediately . quantity smoothness runs from zero for a square wave to 1 for a waveform time constant of 0 . 3 or above . now add the estimates based on minimum and servo swing , truncate so as not to exceed a maximum swing set by the user . reduce ( lead in gradually ) if the mask has only just been put on . i = instantaneous minimum assistance + instantaneous servo assistance + instantaneous recoil truncate i to be less than preset maximum permissible swing instantaneous elastic assistance = i * lead - in in the final step , the measured pressure at the sensor is servo - controlled to equal the desired sensor pressure , using for example a clipped pseudodifferential controller to adjust the motor current . reference can be made to fig1 in this regard . fig2 - 27 each show an actual 60 second recording displaying an aspect of the second embodiment . all recordings are from a normal subject trained to perform the required manoeuvres . calculated respiratory airflow , mask pressure , and respiratory phase are calculated using the algorithms disclosed above , output via a serial port , and plotted digitally . in fig2 - 26 respiratory airflow is shown as the darker tracing , the vertical scale for flow being ± l / sec , inspiration upwards . the vertical scale for the pressure ( light trace ) is 0 . 2 cmh 2 o . fig2 is recorded with the servo gain set to 0 . 1 cmh 2 o / l / sec / sec , which is suitable for subjects with normal chemoflexes . the subject is breathing well above the minimum ventilation , and a particularly deep breath ( sigh ) is taken at point ( a ). as is usual , respiratory effort ceases following the sigh , at point ( c ). the device correctly permits a short central apnea ( b ), as indicated by the device remaining at the end expiratory pressure during the period marked ( b ). conversely fig2 shows that if there is no preceding deep breath , when efforts cease at ( a ), the pressure correctly continues to cycle , thus preventing any hypoxia . fig2 is recorded with servo gain set high , as would be appropriate for a subject with abnormally high chemoreflexes such as is typically the case with cheyne - stokes breathing . now when effort ceases at arrow ( a ), pressure continues to cycle and a central apnea is no longer permitted , despite preceding deep breathing . this is advantageous for preventing the next cycle of cheyne - stokes breathing . the above correct behaviour is also exhibited by a time mode device , but is very different to that of a spontaneous mode bilevel device , or equally of proportional assist ventilation , both of which would fail to cycle after all central apneas , regardless of appropriateness . fig2 shows automatically increasing end - inspiratory pressure as the subject makes voluntarily deeper inspiratory efforts . the desirable behaviour is in common with pav , but is different to that of a simple bilevel device , which would maintain a constant level of support despite an increased patient requirement , or to a volume cycled device , which would actually decrease support at a time of increasing need . fig2 is recorded with a somewhat more square waveform selected . this figure shows automatically increasing pressure support when the subject voluntarily attempts to resist by stiffening the chest wall at point ( a ). this desirable behaviour is common with pav and volume cycled devices , with the expectation that pav cannot selectively deliver a squarer waveform . it is distinct from a simple bilevel device which would not augment the level of support with increasing need . fig2 shows that with sudden onset of a severe 1 . 4 l / sec leak at ( a ), the flow signal returns to baseline ( b ) within the span of a single breath , and pressure continues to cycle correctly throughout . although timed mode devices can also continue to cycle correctly in the face of sudden changing leak , the are unable to follow the subject &# 39 ; s respiratory rate when required ( as shown in fig2 ). other known bilevel devices and pav mis - trigger for longer or shorter periods following onset of a sudden sever leak , and pav can deliver greatly excessive pressures under these conditions . fig2 shows an actual 60 second tracing showing respiratory airflow ( heavy trace ± 1 l / sec full scale ) and respiratory phase as a continuous variable ( light trace , 0 to 1 revolution ), with high respiratory rate in the left half of the trace and low respiratory rate in the right half of the trace . this trace demonstrates that the invention can determine phase as a continuous variable . in the prior art , phase is taken as a categorical variable , with two values : inspiration and expiration . errors in the detection of start of inspiration and start of expiration produce categorical errors in delivered pressure . conversely , here , phase is treated as a continuous variable having values between zero and unity . thus categorical errors in measurement of phase are avoided . by using a short time constant when the subject is breathing rapidly , and a long time constant when the subject is breathing slowly , the filter introduces a fixed phase delay which is always a small fraction of a respiratory cycle . thus unnecessary phase delays can be avoided , but cardiogenic artifact can be rejected in subjects who are breathing slowly . furthermore , because phase is treated as a continuous variable , it is possible to largely compensate for the delay in the low pass filter . with all prior art there is an intrusive discontinuous change in pressure , either at the start of inspiration or at the start of expiration . here , the pressure change is continuous , and therefore more comfortable . with proportional assist ventilation , the instantaneous pressure is a function of instantaneous volume into the breath . this means that a sudden large leak can cause explosive pressure run - away . here , where instantaneous pressure is a function of instantaneous phase rather than tidal volume , this is avoided . average inspiratory duration is easier to calculate in the presence of leak than is tidal volume . by taking advantage of a correlation between average inspiratory duration and average tidal volume , it is possible to adjust the amplitude of modulation to suit the average tidal volume . provision of a pressure component for unloading turbulent upper airway resistance , and avoiding cardiogenic pressure instabilities . although younes describes the use of a component of pressure proportional to the square of respiratory airflow to unload the resistance of external apparatus , the resistance of the external apparatus in embodiments of the present invention is typically negligible . conversely , embodiments of the present invention describes two uses for such a component proportional to the square of respiratory airflow that were not anticipated by younes . firstly , sleeping subjects , and subjects with a blocked nose , have a large resistance proportional to the square of airflow , and a pressure component proportional to the square of airflow can be used to unload the anatomical upper airway resistance . secondly , small nonrespiratory airflow components due to heartbeat or other artifact , when squared , produces negligible pressure modulation , so that the use of such a component yields relative immunity to such nonrespiratory airflow . there is a smooth , seamless gradation from flexibly tracking the subject &# 39 ; s respiratory pattern during spontaneous breathing well above the target ventilation , to fully controlling the duration , depth , and phase of breathing if the subject is making no efforts , via a transitional period in which the subject can make progressively smaller changes to the timing and depth of breathing . a smooth transition avoids categorization errors when ventilation is near but not at the desired threshold . the advantage is that the transition from spontaneous to controlled ventilation occurs unobtrusively to the subject . this can be especially important in a subject attempting to go to sleep . a similar smooth transition can occur in the reverse direction , as a subject awakens and resumes spontaneous respiratory efforts .
the apparatus provides for the determination of the instantaneous phase in the respiratory cycle , subject &# 39 ; s average respiration rate and the provision of ventilatory assistance . a microprocessor receives an airflow signal from a pressure transducer coupled to a port at a mask . the microprocessor controls a servo , that in turn controls the fan motor and thus the pressure of air delivered by the blower . the blower is coupled to a subject &# 39 ; s mask by a conduit . the invention seeks to address the following goals : while the subject is awake and making substantial efforts the delivered assistance should be closely matched in phase with the subject &# 39 ; s efforts ; the machine should automatically adjust the degree of assistance to maintain at least a specified minimum ventilation without relying on the integrity of the subject &# 39 ; s chemoreflexes ; and it should continue to work correctly in the presence of large leaks .