Hardware-Inthe-Loop Simulation System In the Development of Temperature Controller of Blood Glucose Meter

You should leave 8 mm of space above the abstract and 10 mm after the abstract. The heading Abstract should be typed in bold 8,5-point Times. The body of the abstract should be typed in normal 8,5-point Times in a single paragraph, immediately following the heading. The text should be set to 1.15 line spacing. The abstract should be centred across the page, indented 15 mm from the left and right page margins and justified. It should not normally exceed 200 words.


Introduction
In recent years, patients with diabetes are increasing as people's living standards improve.According to incomplete statistics, the incidence of this disease is between 2% to 3%, with the growth rate of 1/1000, diabetes has become one of the four major diseases that endanger human health.Patients need to use hypoglycemic drugs over a long period of time, and observation on the patient's condition and the therapeutic effect mainly rely on blood glucose monitoring.The blood glucose meter is a kind of blood glucose concentration detection instrument, usually using DSP or ARM embedded chips as its core processor.With the advantages of simple operation, convenience etc., it has entered many families having patients with diabetes.Currently, the glucose oxidase biosensor is adopted in the majority of blood glucose meters, while the temperature has some effects on the activity of glucose oxidase, and there is a certain deviation in blood glucose concentration under different temperature [1].So in order to eliminate the deviation, it must design and develop a good temperature controller of the blood glucose meter.However, the blood glucose meter temperature system is complicated, and it is difficult to build the accurate mathematical model in pure numerical simulation.
HIL simulation is a semi-physical simulation method, as a role of the bridge between traditionally isolated simulation/emulation and physical prototyping [2,3].Before HIL simulation, simulation and prototyping coexisted as disjointed iterative steps.The simulation/emulation quality highly depends on the model accuracy.In some cases, the controlled objects may be hard to be numerically modeled.In other cases, a highly complex control system cannot be fully validated until it is tested against a 100 percent accurate model.
Prototyping, although capable of producing a realistic model and providing more accurate outcomes, results in longer development time, higher engineering cost, less efficiency, and it won't be reused if damaged.HIL simulation efficiently combines the isolated traditional simulation/emulation with the physical prototyping to meet the current needs of product design.It provides the scalability and cost benefits that come with simulation/emulation while maintaining physical realism at a high level.
So in this paper, a HIL simulation system for temperature control of the blood glucose meter is designed and developed based on Matlab/Simulink and CCSLink tools [4].The temperature controller and its accessorial parts are constructed as the simulation model in Simulink environment, and the executable C codes of the simulation model are generated, compiled and downloaded to the DSP development system to run.In the computer, the model running state can be shown in real time and the parameters can be adjusted on line.In this system, off-line simulation and on-line simulation are integrated in a platform, and it provides an integrated way for analysis, design and verification to the embedded system.

Design of the temperature controller
The temperature control system of the blood glucose mater is a complex multi-variable control system, which not only has unidirectional temperature rising, but also has large inertia, large time-delay, and time varying.Good dynamic performance and static performance are difficult to obtain by the traditional PID control method [5].So in this paper, we use a segment control algorithm to design the temperature controller.When the temperature error E is [-1, 1], the adaptive fuzzy PID control algorithm is started, so that the temperature will be stable near the target temperature.When E is (-∞ ,-1) or (1,+∞ ), a switching control algorithm is started to rapidly decrease E and reduce the adjustment time.So by the above method, the control system will have the smallest steady-state error and the optimal dynamic process.What's more, the fuzzy controller with two inputs and three outputs is used.The temperature error E and the temperature error change rate C are taken as inputs.The three adjusted values of PID coefficients △ Kp, △ Ki and△ Kd are taken as outputs.

System Configuration.
In order to verify the performance of the designed temperature controller for the blood glucose meter, we developed a HIL simulation system.The whole system includes mainly two parts, one is the virtual simulation environment comprised by the computer, the DSP emulator, the DSP development system, and the related softwares, the other is the factual environment composed of the controlled object and the other peripheral circuits.
The system configuration is shown in Fig. 1.Matlab/Simulink, CCStudio integrated development environment and DSP development system are combined together in bidirectional way with the Matlab CCSLink tools.The temperature controller and its accessorial parts are constructed in the Matlab/Simulink environment, and the parameters of the temperature controller can be adjusted and transmitted to the running DSP development system, then the processing results from the DSP development system can be output to control the running state of the controlled object and returned to Matlab/Simulink for improving the control algorithm.The hardwares of system are mainly composed of the computer, the DSP emulator, the DSP development system, the digital temperature sensor, the voltagecontrolled source, the digital potentiometer, and the electric heater, as shown in Fig. 2. The DSP development system constitutes a closed simulation loop with the digital potentiometer, the voltage-controlled source, the digital temperature sensor, and the electric heater.The temperature controller and its accessorial parts are constructed as the simulation model in Simulink environment, and the executable C codes of the simulation model are generated, compiled and downloaded to the DSP development system to run [6].The DSP development system supports the real-time running of the simulation model, and it transmits the digital temperature signal to the computer via the DSP emulator, and then inputs the processed data to the digital potentiometer, and we use the DSP development system SEED-DEC 28335 and the TI DSP emulator XDS510-USB2.0[7].
Digital Temperature Sensor.The sensor adjusts the temperature of the electric heater into digital signal, and transmits it to the DSP development system.It's the digital temperature sensor DS18B20 that the temperature range is between -55°C to 125°C, and the precision is 0.5°C when the testing temperature is between -10°C to 85°C.
Digital Potentiometer and Voltage-Controlled Source.We use the designed temperature control algorithm to control the digital potentiometer, and then the adjusted voltage is output through voltage-controlled source to control the electric heater.The digital potentiometer X9111 is adopted.Electric Heater.The electric heater is the controlled object in this HIL simulation system.We use it instead of the mathematics model established by computer to simulate the conditions of the temperature control system in the blood glucose meter.

3.3Software.
The software of system mainly refers to the simulation model, it is running in the DSP development system, and is comprised by two parts, the interface layer and the control layer.The interface layer includes the signal acquisition module, the signal processing module, and the signal output module.It is developed based on the Matlab/Simulink environment.The signal acquisition module is created by using the C28x3x GPIO DI block and the signal output module is created by using the C280x/C28x3x SPI Transmit block, they are used to collect important parameters and output the control signals.The signal processing module is created by using the low-pass filter block, and it is used to filter the input signal.The control layer includes the designed temperature controller module.It is also developed based on the Matlab/Simulink environment.The temperature controller module uses the segment control algorithm designed above, and the program flow chart is shown in Fig. 3.

Experiment and result analysis
In the simulation experiment, the sampling time is 0.3 seconds, the initial temperature is 20°C and the set temperature is 37°C.Real-time simulation curve is shown in Fig. 4. We find that when the system is stable, the temperature error is between -0. 3 °C and +0. 3 °C, and good performance can be obtained in the real-time control experiment for the blood glucose meter temperature system based on the segment control method 10007-p.3 which combines the fuzzy control algorithm with the switching control algorithm.And in the end, we test the designed controller in the actual blood glucose meter, the test results are shown in Fig. 5, we can see that our algorithm can meet the requirements of the temperature control precision and dynamic performance, and comparing with the original used algorithm in the blood glucose meter, our algorithm has less oscillation.

Conclusions
The designed scheme of semi-physical real-time simulation system for temperature control of the blood glucose meter was proposed in this paper based on Matlab/Simulink and CCSLink tools.The experiment showed that the HIL simulation method and our designed temperature control algorithm had excellent effect even finally tested in the actual blood glucose meters.What's more, the simulation system can be widely used in the embedded systems needing real-time processing, and it can not only shorten the development cycle and cost, improve the design level of the control system, but also provide a solution to the demonstration of the controller in a real-time mode.

2
Determination of fuzzy control rule table.

Fig. 2
Fig. 2 System hardwareComputer, DSP Eemulator and DSP Development System.The computer is based on Matlab R2010b and CCStudio integrated development environment V3.3, it supports the running of the monitoring program, and displays the simulation process in real time.The temperature controller and its accessorial parts are constructed as the simulation model in Simulink environment, and the executable C codes of the simulation model are generated, compiled and downloaded to the DSP development system to run[6].The DSP development system supports the real-time running of the simulation model, and it transmits the digital temperature signal to the computer via the DSP emulator, and then inputs the processed data to the digital potentiometer, and we use the DSP development system SEED-DEC 28335 and the TI DSP emulator XDS510-USB2.0[7].Digital Temperature Sensor.The sensor adjusts the temperature of the electric heater into digital signal, and transmits it to the DSP development system.It's the digital temperature sensor DS18B20 that the temperature range is between -55°C to 125°C, and the precision is 0.5°C when the testing temperature is between -10°C to 85°C.Digital Potentiometer and Voltage-Controlled Source.We use the designed temperature control algorithm to control the digital potentiometer, and then the adjusted voltage is output through voltage-controlled source to control the electric heater.The digital potentiometer X9111 is adopted.

Fig. 3
Fig. 3 Program flow chart of the temperature controller

Table 2
table method to do the fuzzy inference operation.The fuzzy inference decision uses the dual-input and single-output mode, and the fuzzy control rules are composed of the following inference languages.If E is Ai and C is Bi then △ Kj is Ci.Ai, Bi, Ci are the fuzzy subsets of E, C and △ Kj (j=p, i, d).According to the process operation and the operator's experience, we can obtain the fuzzy control rule tables of △ Kp, △ Ki and △ Kd.The fuzzy control rule table of △ Kp is shown in Table2.Then we use the algorithm of maximum degree of membership to obtain the optimal fuzzy control rule table of △ Kp, △ Ki and △ Kd, the optimal fuzzy control table of △ Kp is shown in Table3.Fuzzy control rule table of Kp

Table 3
Optimal fuzzy control rule table of Kp Finally, according to the fuzzy control rules, fuzzy synthetic inference is applied to obtain the adjusted values of PID coefficients, and then the new PID coefficients can be computed by Eq. 1, Eq. 2 and Eq. 3. Kp', Ki', Kd' are the pre-set values obtained by using the conventional tuning method.