# Need help designing a simple control system

• posted

This problem probably amounts to determining the constants of a curve. Furthermore, the "curve" is most likely a line:

Y = mX + K

Now, the fun part. I am trying to synthesize/derive a formula that will tell me how much insulin should a diabetic patient use: the OPTIMAL dosage.

Let's say that the person measures his glucose level every night and depending on its value, he injects himself some units of insulin. The target output is that the following morning the glucose should be between 100-120 mg/dl.

The more insulin the person uses, the lower the glucose BUT we don't want him to go into hypoglycemia.

I took a Control System class and recall that when some output is simultaneously input, we have a feedback control system. This seems to be the case here, as the sugar level is measured (input) in order to achieve a desired level (output).

I would like to start with the simplest case, with 3 parameters:

(1) The glucose level, G (2) The injected insulin, I (3) The time, t.

After taking many measurements (the number of them is fortunately not a constraint, can take them for weeks or months, for improved accuracy) a formula is derived, and we have reverse-engineered the glucose Control System.

That is all I have so far. Can you folks give me a hand?

TIA,

-RFH

• posted

So we have a value of I(t) that depends on G(t-1).

I will allow you to take a peek at the future (more complex) problem.

In reality the patient administers the insulin TWICE a day: before going to bed and first thing in the morning. Pinching himself is a pain (not in the butt :-) and therefore there are times in which a default dose is applied (specially in the night).

The doctor simply prescribed "50 units at night and 60 in the morning" but this is terribly inaccurate! An airplane (*) would crash with this kind of "rule of thumb!" If we can place "Curiosity" on the surface of Mars, we can certainly come up with a better system.

Thanks again,

-Ramon

(*) When I took the Analog Control Systems and Digital Control Systems courses, my professors worked across the street in McDonnell-Douglas, designing the F-18 Hornet, Tomahawks, etc.

• posted

Are you certain that your "curve" is linear? I would expect either an exponential or logarithmic curve for these kinds of situations. Also, I hope you are talking about a hypothetical patient here. I wouldn't use a living being to experiment with this.

And finally, this doesn't seem like an Electronics problem, but a math and biology problem.

• posted

I figured I would start with a straight line. The range is actually pretty short and the dosages are not critical at all.

That would be yours truly. We are not talking Marie Curie type of experiments here. Insulin is over an the counter medication and the doc authorized me to do trial and error. I am trying to come up with a better method than his constants.

If a person injects himself too much, he feels weak and all he has to do is drink orange juice or something. If too little, there is no short-term effect.

This is definitely a control system.

-Ramon

• posted

There is some discussion relevant to your question here:

Insulin may be an 'over the counter' medicine where you live but I would consider it to be fairly dangerous stuff. Try not to kill yourself.

C.

• posted

Thanks for your interest, Daniel.

A big issue here is the period, P: the time between the measurement and the correction. In the F-18 examples my professor used, it was measured in milliseconds (flap angle). A human being cannot possibly respond fast enough and fly-by-wire is required.

In the diabetes case the period is about 6 months! The doctor measures your Hb A1C (*) level and says: "Ramon, instead of 50/60 units go up to

60/70" and 6 months later he checks again.

Many people don't even bother measuring anything. All measures are done at the doctor's place, and they simply inject merrily.

For people who can afford it, there is some pancreas clone gizmo: a device that is permanently attached to your body, measures the glucose levels and emits the necessary insulin. It checks every half hour or something.

Those are the 2 extremes of P. Since I have this little glocumeter gadget that allows home measurement of glucose, I figure I can come up with something in between: a period less than 6 months and more than 1/2 hour. About 24 hours would be nice.

-Ramon

(*) Glycated hemoglobin which measures the average insulin level. I was floored when I found out how similar it is to a man-made circuit: God imitates humans!.

• posted

There are many dosage calculators available on the google app store that use just this type of equation BUT it is more complex than that. A persons insulin sensitivity changes according to the amount of glycogen/glucose already stored in the muscles and liver.

• posted

"Insulin may be an 'over the counter' medicine where you live"

That would be in the US. Untold millions of people have been injecting themselves for a long time. Before the invention of affordable home meters, people simply estimated: Let's say you went to a party and indulged yourself: you simply inject a little more than usual.

After a while you BECOME your own Control System (in the immortal words of Socrates: "Know Thyself")

OTOH, the negative effect of underdosage takes about 20 years to happen: people may go blind, have kidney failures, etc. Then again you have almost a quarter of a century to do something about it.

Yes, you can kill yourself with insulin and with a hammer as well.

-Ramon

• posted

There are newsgroups for diabetics.

```--
Anyone wanting to run for any political office in the US should have to
have a DD214, and a honorable discharge.```
• posted

Unlikely that you could add anything significant to the established wisdom, this is one of the most studied control problems around. Look for existing guidelines.

• posted

To op re control systems

sounds like you want to read up on PID controllers... P= proportional I = Integral D= Derivative

these three terms are the basis for most control systems

For your case I'd keep the I and D terms = 0 and adjust only the P term

Mark

• posted

So. You are your own test subject. That is very dangerous. Simple measuring a bit more often may help you understand better the less than a day, daily, monthly, and the yearly cycles. Of course if you have not been logging the data you have some logging to do. Party and other irregular (and a few annual) disruptions are up to you, but understanding the cycles better will help you deal with them.

Most of this stuff is second order ODE and a few second order heterogeneous non-linear PDE.

?-)

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.