Improving a Heart Rate Controller for a Cardiac Pacemaker Connor Morrow 03/13/2018
1 In the paper Intelligent Heart Rate Controller for a Cardiac Pacemaker, J. Yadav, A. Rani, and G. Garg detail different control methods for coming up with a controller to improve on the response of a pacemaker. Using a previously established transfer function for the heart and pacemaker mechanics, they design a controller through three different methods: Ziegler-Nechols tuning, Tyreus-Luyben tuning, and fuzzy logic. This example will look into how they developed their controllers while also putting forth a few state space controllers that will improve upon their methods. 1 Pacemaker System To start, let s look at the system that the controller will be integrated into. S. C. Biswas et al came up with a transfer function to model the cardiovascular system in the paper Mathematical Model of Cardiovascular System by Transfer Function Method. The transfer functions that model the heart and the pacemaker are: 169 G H = s 2 + 20.8s G P = 8 s + 8 The block diagram that includes those transfer functions as well as the controller looks like: 2 Their Controllers Before building our own state space controller, lets first look at how they built their controllers. This will be a quick overview on the methods that they used, as well as looking at the results that they came up with. 2.1 Ziegler-Nichols and Tyreus-Luyben Tuning Ziegler-Nichols and Tyresus-Luyben tuning are ways of forming a PID controller by looking at the critical gain and period of the open loop system. One way to find critical gain would be to use the root locus of the open loop system to find the K value that lies at s = 0 on the real axis. Once that is found, we look at the system after being excited and find the period between the peaks of its continual oscilation.
2 From the root locus, we see that the gain associated with marginal stability is: K cr = 3.5446155 Now looking at the response we can find the period of the oscillations. P cr = 0.49 sec
3 The controller formula for a PID controller is as follows: G c (s) = K p + K i s + K ds It can also be written in a form using time constants as opposed to gains. G c (s) = K p (1 + 1 T i s + T ds) Both the Ziegler-Nichols and Tyreus-Luyben tuning methods use the critical gain and the period to come up with the time constants. The formulas for the time constants are listed in the following table. This gives us the controllers Table 1: Tuning Method Gains Method K p T i T d Ziegler-Nichols PID 0.6K cr 0.5P cr 0.125P cr Tyreus-Luyben PID K cr /2.2 2.2P cr P cr /6.3 G ZN = 0.032s2 + 0.52s + 2.127 0.25s G T L = 0.14s2 + 1.7s + 1.6 1.1s We can now see what the step response of the closed loop system would look like when implementing these controllers. We will be looking at trying to achieve a heart rate beats per minute of 65, 75, and 85.
4 These responses are not identical to the ones generated in the paper, as the paper did not explicitly declare their gains. However, they do list what rise time, settling time, and percent maximum overshoot they were able to achieve, which is what we will be designing our controller to do better than. Table 2: Ziegler-Nichols Results Heart Rate Settling Time Rise Time PMO 65 0.0714 1.02 23.5% 75 0.0714 1.02 23.5% 85 0.0711 1.02 24.1% Table 3: Tyreus-Luyben Results Heart Rate Settling Time Rise Time PMO 65 0.0860 0.410 11.7% 75 0.0856 0.410 11.4% 85 0.0853 0.410 10.9% 2.2 Fuzzy Logic Controller Fuzzy logic controllers are built on the fuzzy logic mathematical system. This refers to the ability of logic control that can interpret more than true and false. It is also able to handle partially true. Creating a fuzzy logic controller involves a process of fuzzification of the data, processing that data through a fuzzy logic engine, and finally defuzzifying that information. The paper briefly goes over this process, but doesn t explicitly say how it was performed. Once again, however, they detail the response characteristics of this method, which we will compare our controller to. Heart Rate Settling Time Rise Time PMO 65 0.344 0.757 2.09% 75 0.292 0.748 2.51% 85 0.272 0.763 3.59% 3 State Space Controller Now that we have had an opportunity to look at how they designed their controller, let s begin building a state space controller. In order to do so, we will first create the state space equations. 3.1 State Space Equations Our state variables will come from open loop transfer function of G H and G P. ( G = G = G = G H G P 169 s 2 + 20.8s ) ( 8 s + 8 1352 s 3 + 20.8s 2 + 166.4 )
5 Looking at G as the transfer function between the input, R, and the output, Y, we get: We can now set up our state variables Y R = 1352 s 3 + 20.8s 2 + 166.4... Y + 20.8Ÿ + 166.4Ẏ = 1352R... Y = 166.4Ẏ 20.8Ÿ + 1352R x 1 = Y x 2 = Ẏ = x 1 x 3 = Ÿ = x 2 This gives us the state matrix equation x 1 0 1 0 x 1 0 x 2 = 0 0 1 x 2 + 0 R x 3 0 166.4 20.8 x 3 1352 Y = [ 1 0 0 ] x 1 x 2 This gives us our state space matrices that we will enter into Matlab 0 1 0 0 A = 0 0 1, B = 0, C = [ 1 0 0 ], D = 0 0 166.4 20.8 1352 Before going too much further, we should also realize that state space controllers generally include a steady state error. In order to rectify that, we will include an integrator loop outside of the main control loop. This will produce new state space matrices that look like the following: [A i ] = [ ] [A] {0}, [B [C] 0 i ] = x 3 { } [B], [C 0 i ] = [[C] 0] We will also need the closed loop A and B matrices. They will include the controller matrix, K, that we will derive in the next sections, with K i being the controller gain added because of the integrator loop. [A icl ] = [ ] [A] [B][K] [B]Ki, [B [C] 0 icl ] = { } {0} 1 Those matrices can all be entered into Matlab to handle the calculations. The closed loop matrices should be included in the Matlab code after the controller K is made. With that out of the way, we can begin the actual design process of the controller.
6 3.2 Designing a Controller to Outperform the Tuning Methods The controller will be designed in order to model a second order system. That means we can find a ζ and ω n that will meet our design criteria to come up with the controller. This controller will be designed to outperform the the previously discussed tuning methods. The stated PMO and rise time for the Ziegler-Nichols controller was about 23% and 0.071 sec respectively, whereas the Tyreus-Luyben method achieved a PMO of 10.9% and a rise time of 0.086 sec. To out perform both controllers, we will design one that will achieve a PMO below 10% and have a rise time below 0.07 sec. From our graphs detailing the relationship between PMO and ζ, for a PMO below 10% we are going to want ζ = 0.6. From there we can calculate ω n from the following equations. ζ = 0.6 t r = 0.8 + 2.5ζ ω n ω n = 32.9 We can find the roots for the second order system created with these parameters to be used to determine our controller matrix s 2 + 2ζω n s + ω 2 n = 0 s = 19.7 ± 26.3i Since the the actual system is third order, we will add another arbitrary root for our matrix. This root must be at least five times greater than the second order roots, in order to not have an impact on the system. We will choose -100. Also, as established earlier, we will need a root to compensate for the integrator, which we will choose to be -101. The K matrix is determined by using the place command in Matlab, placing the four roots in A i and B i. One thing to remember is that we will need the gain for the integrator to be the negative of the one that Matlab generates. This gives us the controller matrix: K = [455 14.0 0.162 8065] Creating the closed loop A and B matrices through the method discussed in the previous section, and using the ss command in Matlab to generate the state space closed loop equation, we can view the step response of the system. We will only looking at 65bpm to make sure we have achieved our goal.
7 This step response yields a PMO of 8.27% and a rise time of 0.064 sec, which means we ve achieved our goal. 3.3 Designing a Controller to Outperform the Fuzzy Logic Controller Designing our second controller will be nearly identical to the previous method, just with different PMO and rise time goals. For this one, we want to beat a PMO of 2.1% and a rise time of 0.27 sec, which was achieved by the fuzzy logic controller. We will use a PMO of 2% and a rise time of 0.25 sec, which yields the following The step response to that system looks like ζ = 0.9 ω n = 12.2 K = [186 10.7 0.149 1110]
8 This response has no overshoot and has a rise time of 0.239 sec, which is once again successful. 3.4 Designing the Optimal Controller For fun, let s now design a controller to beat the tuning methods and the fuzzy logic method at once. We will be trying to achieve a PMO less than 2.1% and a rise time of 0.071 sec. ζ = 0.8 ω n = 40 K = [716 18.0 0.181 11900]
9 Once again, state space controllers make it easy to achieve the characteristics that we are looking for. The PMO for this system is 1.18% and the rise time is 0.07 sec. 4 Matlab Code Working with state space matrices can be very tedious, however Matlab makes things a lot easier. The following is the Matlab code, which shows how the tuned controllers were recreated and how the state space controllers were made.
13 References [1] S. C. Biswas, A. Das, P. Guha Mathematical Model of Cardiovascular System by Transfer Function Method Calcutta Medical Journal, 4, 2006 [2] J. Yadav, A. Rani, G. Garg Intelligent Heart Rate Controller for Cardiac Pacemaker International Journal of Computer Applications, 7, 2011