PID Controller Design for Ventilator (2023 Update)

e:

icketty C

triggered

air in

no registration

oss

ter

he blood.

your lungs

ut you

but

Yeah well I just replace 's' with 'i*w' (omega.. angular frequency) and Laplace transforms are fine. My problem is that it's easy to dig down into the math (algebra) and lose a sense of what is going on. I sorta need the math after I understand it.

George H.

Reply to
George Herold
Loading thread data ...

je:

Ricketty C

e triggered

w air in

no registration

cross

tter

.

the blood.

your lungs

out you

ut

s by Brogan, Kou, Ogata, Diazzo & Haupis and Astrom. All are fairly theore tical, but Astroms book "Computer Controlled System: Theory and Design - 3r d edition was one that rolled in the use of Matlab & Simulink, as well as a chapter on 'implementation details' . There may be more applications orie nted "how to' books around as of late, I just don't know about them. The W estcott book seems to be a valuable collection of 'things I learned when im plementing control systems' Anyone who lived in the trenches can identify with having learned those lessons.

quite good, and they have a example on how to use their code generator whic h is helpful. Getting it set up for your target machine can be a little tr icky.

Thanks, I'll give 'em a look see.

George H.

Reply to
George Herold

Right. Being able to push some equations around doesn't mean you understand it.

--

John Larkin         Highland Technology, Inc 

Science teaches us to doubt. 

  Claude Bernard
Reply to
jlarkin

tje:

Ricketty C

e triggered

w air in

h no registration

cross

etter

r.

the blood.

n your lungs

hout you

, but

l

That seems a bit backwards to me. The math is what ultimately explains thi ngs. You just need to understand the math. Math is hard, so people often take short cuts. I don't want to wade through a bunch of math of a PID con troller that might not be completely correct, but I can use the math to exp lore the nature of the beast. The lung has a dissipative element and an in tegral element. That tells me what the waveforms of pressure, flow and vol ume should look like and how the controller should function. Until I get s ome idea of the math, I don't know what to expect.

I was just looking a the waveforms of our controller. I was being told our graphs are near, but not quite the same as the example case. I realized v ery quickly the differences are not from the controller. They are from dif ferences in the lung model. With constant pressure, the spring constant cr eates a curve in the volume and a sloping curve in the flow. The dissipati ve element (like resistance) gives a pressure directly proportional to flow , so the flow would be flat like the pressure and volume would be a triangl e. The example shows more influence from the dissipative element and less from the spring constant. The controller is working fine. The test case ha s a slower pressure release on the exhale side indicating the exhalation pa th is more obstructed than the example. If our test case were on a real pa tient the flow rate dropping near zero means the lungs are nearly full whic h I expect would make injury more likely and the volume needs to be reduced .

Maybe I am making your case because I didn't do any math to dig out this in fo, but it is because I have seen the math and understand what the math tel ls me.

--

  Rick C. 

  -++ Get 1,000 miles of free Supercharging 
  -++ Tesla referral code - https://ts.la/richard11209
Reply to
Ricketty C

g being controlled, how can you design the controller other than trial and error?

at presses on a bag producing an air flow with the loop controlled by a pre ssure measurement.

equency. Presently they are using 3.6 kHz with 8 bit PWM control. I kinda wonder if a sigma-delta might be better, but that might require some exter nal logic. They seem to be shy of pushing the CPU too much even after chan ging from an Arduino CPU at 20 MHz to an ARM CM4F at 80 MHz.

ale and inhale. In general, would it be better to simply jump the pressure set point at once and let the PID controller do its thing, optimizing the response time as best as possible controlling overshoot -or- would it be be tter to run up the pressure set point over a period of time which would see m to place less demand on the PID controller?

as a capacitor) in parallel with a dissipative element (a dashpot or resis tor in electronics). The motor is highly geared to a relatively lightweigh t arm pushing on a bag with air passing through a tube of relatively low re striction. So initially the dominate opposition to flow will be the dissip ation/resistor, i.e. proportional to the rate of airflow. This in turn is proportional to the arm speed (although not constant through the stroke due to the bag geometry). The arm speed is what is controlled by the PWM (app roximately).

that's appropriate. The response to air entering the lung will be the sum of the airway resistance (dashpot) and the lung compliance (spring) which would be a series combination to obtain the resulting air pressure. Well, maybe that is right for the mechanical model, but in the electrical equival ent if pressure is the same as voltage it would be a series arrangement.

en by a P only controller, is there any way it could ring? I was shown dat a measured that showed huge ringing from an initial step function in the se t point.

low regulated cycles. I expect to see similar results with either method.

What you might want to think about is breaking the cycle up into chunks, to remove some of the mechanical geometry from the equation. Then do PID on e ach of those. The arduino libraries include PID and FastPID, which as anoth er poster mentioned, can be tuned on the fly.

My thinking is that by removing mechanical variables, you've really simplif ied things. I would start with a sketched curve of pressure (or volume)/tim e. Mark on the curve the points where the geometry changes significantly. N ow try to tune the PID for the leftmost segment. When that's behaving OK, t une the PID for the next segment, leaving the first settings alone. Repeat until the whole thing is working.

Note - I have never done this sort of segment system, but that's where I wo uld start.

I'm a little concerned that "they" are running out of CPU with something as slow as human breathing. In fact, it's slow enough that you might consider a different approach: Map the rotation of the shaft to the volume of expel led air. Set many target points along that curve and then positively contro l the motor to hit those points of rotation at the proper times. This shoul d also be easy to set up with Arduino PID controls (which will also work on higher end boards like ARM, ESP or the like). A tiny & cheap shaft encoder would make it really simple.

Reply to
rangerssuck

ing being controlled, how can you design the controller other than trial an d error?

that presses on a bag producing an air flow with the loop controlled by a p ressure measurement.

frequency. Presently they are using 3.6 kHz with 8 bit PWM control. I kin da wonder if a sigma-delta might be better, but that might require some ext ernal logic. They seem to be shy of pushing the CPU too much even after ch anging from an Arduino CPU at 20 MHz to an ARM CM4F at 80 MHz.

xhale and inhale. In general, would it be better to simply jump the pressu re set point at once and let the PID controller do its thing, optimizing th e response time as best as possible controlling overshoot -or- would it be better to run up the pressure set point over a period of time which would s eem to place less demand on the PID controller?

is as a capacitor) in parallel with a dissipative element (a dashpot or res istor in electronics). The motor is highly geared to a relatively lightwei ght arm pushing on a bag with air passing through a tube of relatively low restriction. So initially the dominate opposition to flow will be the diss ipation/resistor, i.e. proportional to the rate of airflow. This in turn i s proportional to the arm speed (although not constant through the stroke d ue to the bag geometry). The arm speed is what is controlled by the PWM (a pproximately).

re that's appropriate. The response to air entering the lung will be the s um of the airway resistance (dashpot) and the lung compliance (spring) whic h would be a series combination to obtain the resulting air pressure. Well , maybe that is right for the mechanical model, but in the electrical equiv alent if pressure is the same as voltage it would be a series arrangement.

iven by a P only controller, is there any way it could ring? I was shown d ata measured that showed huge ringing from an initial step function in the set point.

flow regulated cycles. I expect to see similar results with either method .

to remove some of the mechanical geometry from the equation. Then do PID on each of those. The arduino libraries include PID and FastPID, which as ano ther poster mentioned, can be tuned on the fly.

ified things. I would start with a sketched curve of pressure (or volume)/t ime. Mark on the curve the points where the geometry changes significantly. Now try to tune the PID for the leftmost segment. When that's behaving OK, tune the PID for the next segment, leaving the first settings alone. Repea t until the whole thing is working.

The only changes in "geometry" (which I assume you mean the shape of the cu rve) is at the points were we change our set point. The ideal curve would be a square wave for which ever variable is being controlled. The rate of the leading edge will be limited by the details of the control loop. The t railing edge is not in control since that is simply the patient exhaling.

Nothing much is needed really. I think the ringing curve they showed me wa s pure P with no I or D terms in the control loop, but the gain was set far too high. Without the I term the P term requires an error to maintain a n on-zero output. To minimize the error the gain is set way high resulting i n excessive acceleration and ultimately ringing in the controlled parameter .

The other day they showed me working graphs where the exact shape is slight ly different from the examples, but not in any way I would not attribute to the details of the lung model. I don't know what they did, but it is work ing.

would start.

as slow as human breathing.

I don't recall saying they had run out of CPU. Some weeks ago we switched from an Arduino CPU to an ARM CM4F when we needed more I/Os. No one object ed to switching to a better CPU, but it has lots of room for growth in the project... except for I/Os. We are nearly out and they've decided to add m ore LEDs.

ap the rotation of the shaft to the volume of expelled air. Set many target points along that curve and then positively control the motor to hit those points of rotation at the proper times. This should also be easy to set up with Arduino PID controls (which will also work on higher end boards like ARM, ESP or the like). A tiny & cheap shaft encoder would make it really si mple.

That would work for flow rate control, but the pressure depends on the pati ent and they are not all the same. It also depends on all the mechanical p arts being the same with the same friction and the same resilience, etc. T hey have gone to great lengths to design a flow meter and we have a pressur e gauge, so they are going to be used!

The more I think about the control loop, the simpler I think it will be. W e have so much time to deal with the changes that it would require effort t o muck it up.

--

  Rick C. 

  +-- Get 1,000 miles of free Supercharging 
  +-- Tesla referral code - https://ts.la/richard11209
Reply to
Ricketty C

What level of abstraction one needs to use at a particular time is a skill.

It's rare that there are interesting problems that one can intuitively understand all the way up and down thru the levels and have some God's-eye knowledge of everything without from time to time resorting to faith in the idea that the process of pushing equations often provides answers that are correct regardless if you "grok" every piece of it.

That is to say some people can read machine's "mind" I don't have this ability.

Reply to
bitrex

Do you have a particular example of what in the process of "understanding" is a sticking-point?

All that's happening is that the integro-differential equations of LTI circuits or systems in the time domain are being converted to algebraic ones. And then once the equation is solved in the s domain you can run the machine backwards and get the solution in the time domain again, if you want.

The reason you can "read" the frequency response in the s domain by making that substitution and taking the magnitude is because convolution is the same as multiplication there, and the Laplace transform of the unit impulse is 1.

In the time domain you'd get the frequency response by convolution of the time-domain equation with the unit impulse, in the s domain that work is mostly already done for you as-is just by virtue of the transformation process.

Both functions in both domains must have equal power spectral densities so it's still the same system except the implicit convolution acting on an s-domain transfer function has made the variable "s" equivalent to complex frequency. hence you can make that substitution and it works out.

Sometimes you have to do algebra to get equations in the s domain in the form of a transfer function between input and output and find magnitudes and phases, but there's nothing really interesting in the algebra of that itself, it's just a mechanical process.

Reply to
bitrex

Wes Hayward's book "Introduction to RF Design" has a section about how to apply it to designing a PLL. The intuition comes in via knowing a PLL should have certain parts with certain characteristics. There's a VCO. A phase detector. Loop filter. Feedback loop around.

And you figure out what the transfer functions of those are in general, and the whole loop in combination. and you construct an equation for the loop transfer function, with some unknown coefficients. What values the coefficient have to take to make the loop stable and do what you want is where the math/engineering comes in, you have to analyze the equation, make plots of various values to figure out what the coefficients should be to get the result you want.

Doesn't require a lot more "understanding" than that! "it is what it is"

Reply to
bitrex

tje:

Ricketty C

e triggered

w air in

h no registration

cross

etter

r.

the blood.

n your lungs

hout you

, but

al

Not at the moment. I've done mostly thermal loops, which are easy (no thermal 'momentum/ inductance'). I guess the perennial question in a thermal loop is where to put the heater/ TEC / cooler (plant) and where to put the temperature sensor.

George H.

Reply to
George Herold

en

eltje:

ed Ricketty C

ine triggered

raw air in

ith no registration

across

better

eer.

in the blood.

in your lungs

ithout you

ew, but

tial

nd

n

Earlier it was pointed out that delays in the system can impact loop stabil ity. I believe thermal systems can have such delays, for example, when the heater itself has significant thermal mass and the object being heated als o has thermal mass with some thermal impedance between.

Such a system can be stabilized by using multiple loops. A fast loop to co ntrol the temperature of the first thermal mass and a second, slower loop t o adjust the set point of the first loop ultimately managing the temperatur e of the second thermal mass.

I suppose a single loop with a slow response would work, but I expect it wi ll require a slower response than the two loop design to deal with integrat or wind up because the inner loop would allow the set point to ramp up more quickly without ramping up the outer loop integrator. Yes, no?

Today in the conference call I explained the idea of reducing the overshoot by instead of limiting the slew rate of the PID controller, not driving it with an abrupt step function. Rather a slope can be used appropriate for the desired ramp up of the controlled variable. Rather than focus on makin g the controller manage the rate, give it the rate it should follow.

--

  Rick C. 

  +-+ Get 1,000 miles of free Supercharging 
  +-+ Tesla referral code - https://ts.la/richard11209
Reply to
Ricketty C

There will be step changes when ventilating a patient. Obvious ones are when the patient stops or starts trying to breath.

Gently reacting to a patient that no longer inspires and expires is likely to lead to a long-lasting expiration.

Ditto inflating a patient that is trying to take control of their life.

Reply to
Tom Gardner

d

g

e to

, when

ted

o

loop

rature

t will

tor

e

hoot

it

or the

g the

You seem to not understand the issue. Everything has a spec. There is no need for an abrupt spec on any of the parameters. Humans typically don't r espond to sub-millisecond stimuli other than perhaps light and then just ba rely. I guess sub-millisecond pressure changes can be noticed when they ar e in the form of explosions.

Why do people make silly statements about topics they don't actually know a nything about?

--

  Rick C. 

  ++- Get 1,000 miles of free Supercharging 
  ++- Tesla referral code - https://ts.la/richard11209
Reply to
Ricketty C

He shows the only difference between patient triggered and

Quoting such numbers indicates you clearly don't understand the issues.

I built a commercial lung ventilator, a long time ago. How many have you built?

I suspect I have more of a clue about that than you.

Reply to
Tom Gardner

:

no

a

ere

le,

ing

to

r
e

it

o

es,

not

er

it

e

kely

.

no

't

st

hey

ow

built?

If you understood the issues you would not make the silly, technically vagu e, alarmist comments you have made here. The issues have to do with contro l theory, not medical. There is no medical requirement to drive pressure o r air flow in microseconds. What was the step response of the ventilator y ou designed? I will have to say I'm impressed that one person can design s uch a complex device. There are many, many facets to it and typically it w ould involve many engineers.

This is a perfect example of "if you're not part of the solution, you are p art of the problem". Why are you going on about this? If you want to cont ribute, why not actually make a contribution. If you just want to rag on t hings, please go elsewhere.

There are plenty of threads here where people are just ragging on one anoth er ad infinitum. It would be nice to keep the technical threads free of th at.

--

  Rick C. 

  +++ Get 1,000 miles of free Supercharging 
  +++ Tesla referral code - https://ts.la/richard11209
Reply to
Ricketty C

He shows the only difference between patient triggered and

Wow. So many misconceptions in one paragraph. Let's keep it simple.

1) I made no such statement about driving/measuring in microseconds. 2) I made no such statement about being the only person involved, nor even the only company involved.

You really ought to learn to read only that which is stated, and not allow your preconceptions to blind you

For the record, the step is the event that a patient has died or been resurrected. (There are many others, of course) The event is instantaneous, of course, and flips operation to

*completely* different behavioural *modes*. Determining the trigger conditions and ensuring appropriate future behaviour is not trivial.

It took 3 engineers in my company (RTOS infrastructure, front panel, ventilator control), and several in another company. The latter knew the ventilation requirements but not how to design and implement them.

I was the PM, and designed and implemented the ventilator control.

I'm going to decline in this case; it would be a waste of my time in two ways:

1) I have tried to educate you before, and found it notably difficult to get you to think away from your preconceptions. (cf with the above) 2) this whole effort is doomed to failure, for the non-technical reasons others have stated.

Yes, we've noticed.

Reply to
Tom Gardner

On a sunny day (Fri, 21 Aug 2020 08:36:27 -0700 (PDT)) it happened Ricketty C wrote in :

Rick stt

Maybe YOU should simply build the thing, and not get lost in PID control theory. One can easily measure air pressure and adjust the speed of a motor drive, especially if it is a stepper, in milliseconds. Now all you need is knowledge about the human interface to make it follow a curve. No PID stuff, just millisecond by millisecond adjustment against a known curve. No long delays as in thermal heating and overshoot or big flywheels speeding up or whatever. Build something, test it on yourself. Best way to get feedback and FEEL where it needs improvement. You seem to think you are the only one in the universe who knows how to do things you have nothing yet, not even a prototype, math is useless in phantasy. There is an old joke here: How many guys does it take to screw in a light bulb? Answer:

5 one to hold the bulb, and 4 to turn the ceiling.

I have been with a big company that actually now makes ventilators for the US, and the time from idea to production I was told there was 2 weeks. This thread has been going on and on, where is your prototype?

No use trying to write code for a control system for a thing you do not even have. Untestable, Cool it man.

:-)

Reply to
Jan Panteltje

r
p
e

ce

op

ct

r,

.

is

y
.

ou

vague,

ol

or

you

such a

ld

I did and then you replied that I didn't understand "the issues". That is the issue you initially responded to. I pointed out the difficulty of desi gning a controller to provide an adequate step response without overshoot c an be mitigated by not feeding the controller an abrupt step function. Fro m there on you disagreed with everything I wrote to clarify the issue. You are just wrong about this. It's time to stop back peddling and accept tha t.

Here is what you posted....

"I built a commercial lung ventilator, a long time ago."

Where do you indicate you were not the only person involved? "I built" imp lies you and you alone. My response was a prod because I knew it was not y ou alone. Do I really need to explain the subtleties of the English langua ge to you?

Now you are being silly. The step input is asking the machine to provide 0 pressure, then raising it to the set value for the next sample. Expecting it to respond without overshoot is a tall request when the thing being con trolled (the system of machine and patient) varies from case to case. Aski ng an operator to tune the PID parameters is a bit much when it is not need ed. The rise time and overshoot specs can be met more easily by feeding th e control loop a set of steps of initially high, but sequentially decreasin g value allowing the control loop to follow the request without excessive w ind up of the I term and minimal overshoot for a wider range of patient par ameters.

Excellent. Then you should understand everything I've posted.

re

rag on

Obviously it is not a complete waste of your time or you would not be makin g these lengthy posts. I suspect it is more a matter of recognizing that y our useful contributions are limited. So instead you are blustering. You could contribute to the project without ever dealing with me and my limited abilities to learn.

nother

hat.

And yet you continue to use bandwidth to continue the conversation just so you can tell me how defective I am, but never actually making any technical points. None at all - in spite of your claims of superior knowledge. I s till gain something from these discussions. They help me clarify my positi on by learning from your mistakes.

Thank you.

--

  Rick C. 

  ---- Get 1,000 miles of free Supercharging 
  ---- Tesla referral code - https://ts.la/richard11209
Reply to
Ricketty C

You are a trip. You literally know nothing about the project and yet you talk about there being no prototype, etc, etc, etc.

What type of acid are you on today???

This group is largely as Larkin describes it. There are on occasion a few who are willing to consider a thought. Many more here are just a scene from 2001.

formatting link

If you have nothing to contribute to the discussion, why post?

--

  Rick C. 

  ---+ Get 1,000 miles of free Supercharging 
  ---+ Tesla referral code - https://ts.la/richard11209
Reply to
Ricketty C

On a sunny day (Fri, 21 Aug 2020 10:01:43 -0700 (PDT)) it happened Ricketty C wrote in :

Yea, you keep telling that to every body. Consider visiting a shrink.

Reply to
Jan Panteltje

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.