The PID control schema is a good general purpose approach for controlling nearly anything. It would be a natural starting place for investigating the closed loop between the insulin pump and CGMS. But it lacks in one fundamental area: it won't work better than the old way when a diabetic person starts eating. The closed loop works great in terms of adjusting the basal delivery from the insulin pump in response to measured blood glucose values. You can even use temporary basal changes to adjust for meal boluses and correction boluses after they have been administered. But when eating, the performance of that PID schema does not beat the baseline performance of today's insulin pump with a pre-bolus based on carb counting.

"Strike the Spike"Edit

After eating a meal , naturally there will be a temporary increase in the BG level (i.e. postprandial hyperglycemia) that occurs as glucose enters the bloodstream before the insulin acts to reduce the glucose level back to normal . Graphing that concept, we see a sudden rise from normal BG to higher levels (the “spike”) and then a long slope back down to normal BG levels. This would be a typical metabolic response to a type 1 diabetic person who eats a meal with “fast” carbs (low on the glycemic index) and administers insulin simultaneously. This happens because of the 15 minute delay for injected or infused insulin to reach the blood stream. Let’s assume that the carbs are measured carefully and the correct amount of insulin to “cover” the carbs is administered (i.e. a controlled experiment) such that we can focus only on the “timing” of the insulin.

Consider a pancreatic release of insulin which is in proportional response to actual blood glucose levels, is also integral as it spurts insulin over the duration of high blood glucose levels, and is given directly into the portal vein which flows almost directly to the liver where much of the excess blood sugar will be taken up and stored. Now compare to the typical insulin pump infusion: 15 minutes go by, with glucose entering the bloodstream from digestion, before the insulin reaches the bloodstream. Often it makes more sense to give the insulin 15 minutes before eating rather than simultaneously. Gary Scheiner, a Certified Diabetes Educator and consultant, is teaching the importance of thinking about this “spike” after meals, particularly in regards to how that hyperglycemic response contributes to higher measured HbA1c test levels and the associated impact to the avoidance of long term diabetic complications. Awareness to the “spike” phenomena is growing as a result of its visibility in data from continuous glucose monitoring systems (CGMS), and to the realization that in children the “spike” is greater than was previously thought. This is the likely difference between the HbA1c levels that can be predicted when looking only at pre-meal BG data points downloaded from finger stick meters versus the actual HbA1c test levels that were determined at the 3 month endocrinology clinic appointment. To address the trend, Gary developed an educational philosophy and action plan detailing how to “strike the spike” and take better control of post-prandial hyperglycemia.

Administering insulin 10-15 minutes before eating, when appropriate, is the general concept. Gary calls this a “pre-bolus” because you would generally bolus before eating. A key feature of Gary’s concept is to adjust the pre-bolus time as a function of the pre-meal BG test value and also as a function of the kinds of food that are about to be eaten. If pre-meal BG is low, then a pre-bolus is not appropriate. However if pre-meal BG is high, then it is better to administer a meal-plus-correction dose and wait a half hour (with perhaps some physical activity) to allow blood glucose levels to come down before eating. This reduces both the maximum BG levels that would have spiked as well as reduced the time duration of the hyperglycemia. The glycemic index of foods is also important to an appropriate pre-bolus. Fast carbs (cheerios and juice for breakfast) make a longer pre-bolus time appropriate. Fresh fruit make for a more typical pre-bolus, and slow foods (proteins and carbs together with fat) make no pre-bolus appropriate. These two considerations can also be combined (doubling the pre-bolus time, or even canceling each other out) as shown in the table below:

Bolus Timing: the ideal time to pre-bolus depends upon the blood glucose level and the glycemic index.
If The Blood Glucose Level Before Eating Is:
High GI Foods Moderate GI Foods Low GI Foods
Above Target Range 30-40 min before eating 15-20 min before eating 0-5 min before eating
Within Target Range 15-20 min before eating 0-5 min before eating 15-20 min after eating
Below Target Range 0-5 min before eating 15-20 min after eating 30-40 min after eating

The pre-bolus is not for everyone. Gary suggests if your HbA1C is higher than you think it should be when you look at your well controlled pre-meal BG test data, then it's time to “strike the spike.”


Now, what does this have to do with PID control? Actually, it is a key point in this artificial pancreas algorithm to close the loop between CGMS and the insulin pump: because of the 15 minute delay, there will NEVER be a PID algorithm that outperforms a pre-bolus from the insulin pump. Period. So why is all of the academic research for the artificial pancreas focusing on the PID schema? Simple: it's because the researchers are not controls engineers.

The "PID" control scheme: example with an auto-focus cameraEdit

When control engineers close the loop, the purpose is to optimize the performance of the loop so that the control system finds its solution quickly and accurately. “Damping” is used to prevent oscillations and add stability to the control loop, but excessive damping can slow down the performance of the system. When optimized, the performance of the feedback control system is known as “critically damped.” The PID control scheme is one way to achieve this.


The PID controller a is an acceptable way for an artificial pancreas to control the insulin pump basal rate at night, when not eating, but it will never control postprandial hyperglycemia better than a pre-bolus of insulin given 15 minutes before eating.

Consider the design of an auto-focus camera. It uses a control system to drive a motor that turns the lens and focus the image. When a focus button is pressed on the camera, the control system will move the lens in the direction needed for focus, and then stop when focus is achieved. It would not be a very good control system if the lens overshoots the focus, backs up but goes to far again, focuses forward again and gets closer this time but still goes to far, backs up and tries again, each time getting closer, and after a few more tries the focus is perfect. That works, but it will be annoying. That control system is “under-damped. “ So damping is added to the focus control system. Now when the focus button is pressed, the dampened control system will slowly focus the lens, without overshooting the desired point (slowing down as it gets closer) and calmly takes you to the best focus on the first try. If you experienced this new camera for the first time, you would press the button and hear the motor “whiiiiiiirrrrrrrrrrrrrrrrrrrrrr” and after 2 seconds have a nice sharp focus. Pretty Cool! Your control system is well damped now (maybe a bit over-damped, but better than being under-damped). You are happy for a while, but then some guy next to you turns on his new autofocus camera, presses his auto-focus button, and his focus motor goes “zip!” and is focused in half a second. You are not so impressed with your under-damped camera control system anymore. It works fine, but not as well compared to his. His control system is critically damped, focusing as fast as possible, overshooting barely a little but readjusting only once and then backing up to perfect focus.

Control system engineers use applied calculus to determine the optimal damping and model the best performance of their control system. Good performance is judged for both speed and accuracy. The feedback to close the loop on the focus motor is a first step. We will use a tachometer to measure the rate that our motor is driving, and use it as a feedback signal. A proportional gain to drive the motor toward the focus point is needed (i.e., if far away from the focus point, then focus faster, but slow down as you get closer to the final point) but this will result in an over-damped system. If we take the derivative of the feedback signal (the calculation gives us the acceleration of the motor drive), then we can add this to the proportional term and speed up large corrections in the control system. It also helps to take the integral of the feedback signal (this calculates the relative position of the focus, telling us how far we have moved the motor so far) and that helps us drive the motor hard in the proportional term and then slow down as we predict we are close to the final position. So you can see how the “PID controller” could be used to control the auto-focus of the camera lens. By tuning the individual proportional gain, integral gain, and derivative gain of the PID algorithm, we can see how this will be useful in achieving a critically damped system and optimally fast and sharp focus.

The "Pre-bolus" with closed loop correctionEdit

How does this apply to the artificial pancreas algorithm? We want to give enough insulin to bring down the blood glucose values measured in the CGMS data, which is the feedback signal used to close the loop. Do we want to give to much insulin, overshoot the lower BG value we are shooting for, and then back off the insulin to let the BG come back up? No, obviously. We want to give the right amount of insulin the first time, and since the insulin response is slow (3 and a half hours) we can make small adjustments (adding or taking away from the basal rate) as we go. Sounds good? Of course it does, which is exactly the problem. Upon first consideration, it sounds like a PID algorithm is the way to optimize the use of feedback from the CGMS to control the insulin pump. But it is not.

Artificial Pancreas

Best performance of the artificial pancreas algorithm will be observed after giving a pre-bolus (15 minutes before eating carbohydrates), then correcting the insulin balance 2 hours later using BG feedback with compensation for "insulin on board," and then later closing the loop in the classical way after the insulin tail has passed.

Why? Because we want to match the actual insulin need as fast as we can. The PID algorithm would add insulin continuously, spread out over time as a "driving" signal. An insulin pump gives all of the bolus insulin in one push, but continues to give a low continuous dose of basal insulin. Existing insulin pump algorithms use a variable known as "insulin on board" or IOB. The 'insulin need" is the key variable to optimize, and IOB is a key element to that optimization. When a bolus is performed and the resulting 4 hour insulin tail is passed, then the insulin need is proportional to the difference between the actual BG and the target BG. The PID approach works great in this mode. But after bolusing, when the insulin tail is still in effect, then the insulin need must take into account both the difference in BG from target as well as the IOB. The control loop to add more insulin MUST ONLY INCREASE CLOSED LOOP DELIVERY OF INSULIN WHEN THE INSULIN ON BOARD IS PREDICTED TO BE INSUFFICIENT. A linear model for prediction of the insulin tail is adequate to calculate the insulin need. For example, Novolog insulin follows the "7-4-1 model" which is simply that 70% of the insulin is yet to impact BG values at 1 hour, 40% remaining at 2 hours, and 10% at 3 hours. Humulog is slower. The 7-4-1 model for Novolog is equivalent to IOB = -(100/210) t + 100 where IOB is in percent, t is minutes since start of bolus, and the model is only non-zero from t = 0 to t = 210. It helps to think of "modes" to control the insulin as best to optimize the performance. When the bolus insulin tail is complete, the mode is to calculate the insulin need based only on BG feedback. The time during the bolus is broken into two other modes, The first half if the insulin bolus is unpredictable, so it is best to wait and see and not adjust the insulin delivery. The second half of the insulin bolus is quite predictable, such that in this mode the insulin need is the difference between the correction dose predicted from BG feedback and the insulin that is still on board. At a minimum, three states would do: waiting after bolus, correcting bolus with the closed loop, and controlling basal rate with the closed loop. As additional capabilities are brought to the algorithm, then additional states will be useful.

The second shortcoming with the PID schema is that we want the closed loop system to work better than the open loop insulin pump system: if we wait for BG to rise after eating, and then inject insulin, and then wait 15 minutes for the insulin to reach the bloodstream, then we will never “strike the spike.” A PID control loop will never overcome the 15 minute delay, and therefore will never control hyperglycemia as well as an expertly calibrated insulin pump which predicts the insulin need (insulin to carb ratios and insulin sensitivities carefully dialed in) and then used to pre-bolus insulin at the appropriate time before eating a meal.

A similar argument can be made for a correction dose of insulin. There is no PID algorithm that will perform better than giving the whole correction dose immediately upon detection of the high blood sugar value, and then using adjustments to the basal rate to balance any small errors in the predicted correction dose.

What next? Read the article: How will states and modes be used to control the insulin pump?

Community content is available under CC-BY-SA unless otherwise noted.