Artificial Pancreas System

I coded the first version of an Artificial Pancreas System in C# in October of 2011 while working for the University of California Santa Barbara (UCSB) and the Sansum Diabetic Research Institute.

Concept
Connect a Continuous Glucose Monitor (GCM) device with an Insulin Pump in a feedback control loop.


Artificial Pancreas System

Feedback Control Loop for Artificial Pancreas System

This Windows Forms application I wrote includes:

Communication with external Devices and External Controller Program
The program communicated with two external devices, one emulating and insulin pump, the other emulating a Continuous Glucose Meter (CGM) device.

Port Sniffer
On the first day I wasn’t getting any reply from the external device. I double checked all the settings: baud rate, stop bits, no flow control, etc. Still no reply. Downloaded some Port Sniffer software to see what was going on. Port Sniffer was able to communicate with the device, but C# program still would not. I took a snapshot of what was being sent by the C# program and compared that to what was being sent by the Port Sniffer. Discovered C# was using Xon/Xoff flow control even though I specified "none". Switched to using DTR flow control (which the device ignored) and it started working fine.

Obfuscator
We had to obfuscate the final executable, because we were sending it to our competitor (why?) so I spent a couple days researching and testing over a dozen different obfusactor programs. I finally settled on a good one which didn’t cost much. I recommend Obfusasm at http://www.devextras.com/ which did an excellent job.

Feedback Control Algorithm
I majored in Signals and Systems. My Master’s thesis was on feedback control systems. My father’s PhD dissertation was on feedback control systems. My father was a control systems engineer, and he wrote: A Control Systems Engineer Looks At Controlling Type I Diabetes (.pdf file). I did this as a tribute to my father, who was a type 1 diabetic for 53 years.

CRC Checksums
If any programmers out there are reading this please read up on using CRC Checksums when transferring data over noisy channels. CRC Checksums detect all single and double bit errors, all errors involving an odd number of bits, all burst errors of length 16 or less, 99.997% of 17-bit error bursts, and 99.998% of 18-bit and longer bursts. See my essay XMODEM CRC Error Checking Protocols, and read this article: Peterson, W.W., and D.T. Brown.: "Cyclic Codes for Error Detection". Proc. IRE, vol. 49, pp. 228-235, Jan. 1961.



1 Idea and photo from http://www.instructables.com/id/Make-a-battery-substitute-power-connector/

2 The Effectiveness of Checksums for Embedded Control Networks by Theresa C. Maxino, Member, IEEE, and Philip J. Koopman, Senior Member, IEEE. (2009) http://www.ece.cmu.edu/~koopman/pubs/maxino09_checksums.pdf

back arrow Back


Last Update: June 6, 2016