Hello and welcome to the honors week of this course. I'm really pleased that you have chosen to study this optional material. This week, we're going to look at a few advanced methods for dealing with some real-world issues that relate to state of charge estimation. We begin by looking at methods to deal with current-sensors that have a DC bias. The Kalman filter theory that you learned about in this course assumes that all noises have zero mean, and if the current-sensor has a constant DC bias, especially one that's unknown, then this process noise that models the error in the current-sensor will not have zero mean, and the current-sensor reading then we'll introduce a permanent state of charge estimation error. Hall-effect type current-sensors are especially prone to producing estimates with a DC bias and that was why in the first course in this specialization I shared with you that I prefer using shut-style current-sensors instead. But even those can introduce a constant DC bias in the current-sensor reading if the measurement electronics are not carefully designed in order to balance all effects. So, what's the problem? We find that the accumulated ampere-hours of bias tend to move this state of charge estimate faster than the measurement update of the Kalman filter is able to correct. The result is that our state of charge estimate will have an offset with respect to the true state of charge, and that offset might actually grow without bound. So, how do we fix this? Well, the best solution would be to fix the sensor, that is, less design sensing hardware that eliminates all of the current-sensor bias. Some hall-effect type current-sensors include, special circuitry that attempts to eliminate the bias that's fundamentally caused by magnetic hysteresis components of the sensor itself. Shunt type sensing can also be designed to attempt to eliminate the bias by carefully matching component values and choosing tight tolerances on resistances, and capacitances, and so forth inside of the circuitry. However, despite our best attempts, there will always be some amount of bias and it would be good to have a solution that can help eliminate that bias using software. So, we will attempt to correct for this unknown and possibly time-varying bias algorithmically by estimating the value of the bias at each point in time, and then subtracting that out from the current-sensor reading. So, I stress that it's not the fact that we have bias that's the problem, it's the fact that we don't know the bias, and with hall-effect sensors in particular, this bias can change over time and due to temperature changes and so forth. We just don't know what the bias is and so we'd like to be able to estimate that value and subtract the bias from the current-sensor readings to give unbiased sensors. I will quickly share with you one approach that we can take. We desire to estimate the bias of the current-sensor and so we augment the state of our model with one additional component, that is, the current-sensor bias itself. We give this state vector component the name, i_b, where b stands for bias. Then we design the rest of our model appropriately. If we do that, the Kalman filter will automatically estimate the current-sensor bias at the same time it is estimating the rest of this state vector. Here, I produce the set of equations that illustrates what I mean. Notice that the bias equation is the one on the bottom and we'll talk about that in a moment, but the rest of the equations are essentially the same from the standard enhanced self-correcting model but with the small change that every time input current i_k occurred previously, we now have i_k minus i_kb. We're subtracting out the estimate of the current-sensor bias. So previously, the state of charge equation model, presence state of charge is equal to the prior state of charge minus the measured current plus the process noise all scaled by the sample interval and the capacity. But now, we subtract from the measured current the bias estimate. Similarly, the diffusion resistor currency equation, we're subtracting from the measured current the bias estimate, and in the hysteresis factor, we're subtracting the bias current, and also for the hysteresis input, we're subtracting the bias current from the measured current inside of that sine function. But we need a way for the Kalman Filter to adapt the bias. So, we really need a state equation that describes how the bias changes over time, and we don't have any idea how the bias changes over time. Maybe it's a constant, maybe it drifts over time due to temperature changes or unknown factors. So, the final equation on this slide says that the current bias is equal to the previous bias plus some noise factor, n_b. This is basically saying that the bias is a constant, present bias is equal to the prior bias. But it's not really a constant, it might change. This n_b is a fictitious noise. It doesn't really exist, but it's basically trying to model the uncertainty and how the bias truly changes. It might go up, it might go down. We don't know. So, we model this random noise source driving changes in bias, and the covariance value we give to n_b is giving the Kalman filter permission to adapt the bias state. If the covariance of n_b is zero, then the Kalman filter looks at this equation and thinks, "Oh, new bias equals old bias plus zero." Bias is a constant period, it doesn't change. In that case, the Kalman filter will never ever, ever change the bias estimate. But if I give the Kalman filter a covariance matrix for n_b that is greater than zero, then that allows the Kalman filter some freedom to update this bias state, and the larger the covariance, the more freedom the Kalman filter has to update the bias estimate over time. So overall, the set of equations really has two process noise inputs. One is the standard process noise, W, that we've talked about before, but the second process noise is n_b. The overall process noise is really a vector, I should probably give it a different name, but the vector of process noises contains both W and n_b in it, so it's a two vector. So, the covariance of process noise is a two-by-two matrix. Because we can pretty easily assume that the actual process noise and this fictitious noise are uncorrelated, we can have this two-by-two covariance matrix be diagonal, and so the diagonal elements are simply the individual variances of the different components. So, we've modified the state equation to augment it with a bias state and we also augment the output equation of our model to include this bias by subtracting it from the measured current and the augment voltage drop part of the equation. That's the idea. We estimate the bias using the Kalman filter. The Kalman filter will automatically adjust it's state estimate so that the input/output behavior of the model matches the observed input/output behavior, as well as, possible. In so doing, it's going to adapt the bias so that it causes the input/output mapping to work, as well as, possible and so forth. It's kind of magic, but it actually works. At this point, I'm not going to share with you code to implement a Kalman filter with this bias estimator, but later on this week I will show you some results of some code that includes a bias estimation, and for that example, I have code on the Coursera website that you can look at and experiment with yourself. Instead, I want to move on to the next topic which is what we will spend the rest of the week discussing, which is another real-world issue. After we develop a solution for this real-world issue, we will return to bias estimation, and again, you will see examples of solving both of these problems jointly, the bias problem and the problem that I will share with you now. This is a problem of computational complexity. Common filters appear to require a lot of floating point operations. Although I think that they might actually require less computation than most people think, especially as a fraction of the available computing power on modern even embedded processors. I think it's actually a pretty low fraction. But in any case, you've learned how to apply different types of Kalman filters to estimate state-of-charge of a single battery cell. But how about estimating state-of-charge for an entire battery pack for all of the cells and the battery pack? So, let's consider one more time a philosophical question that has some important practical implications. I redraw a simple two-cell battery pack on the right and we've talked about this before, even with similar conclusions, but I want to refresh your memory. The question is how should we think about the state-of-charge of this battery pack? What value should I report to the battery management system or to the vehicle or to the application? What is the state-of-charge of this battery pack? In this example, we have one cell that's completely empty and one cell is completely full and they're connected together in series. Maybe we should report zero percent because the cell drawn on the top is empty, but we really can't report that value because that implies that it's possible to charge the battery pack and the application says, "Oh, state-of-charge zero percent, I better charge the battery pack right now." But we can't do that because that would overcharge the cell shaded in green. So instead, we might report a value of 100 percent but the answer is we can't do that either because if I report to the load that the battery pack is a state-of-charge of 100 percent, it says "Great, I can use all of the capacity and I can discharge the pack and I can do wonderful things", and we can't do that either because that would overcharge the cell that is shaded red here on the top. So, how about the average? Maybe we can report the battery pack state-of-charge to be equal to 50 percent, but we can't do that either because that's almost worse than the other two. That tells the load as possible both to charge and discharge, but we can't do either one of them. So, I start the segment by repeating my earlier claim that battery pack state-of-charge is really a poorly defined, an ill-defined concept and we should never use the term, that's my opinion. A much more useful quantity as a computation of battery pack available energy or battery pack available power because we can do that for this example and say, "Well, the available energy is zero." So, the load doesn't discharge it. But then the available charging power is also zero and so the load understands it can't charge it. So, those are much more useful quantities, and you learned how to compute battery pack energy in the first course of this specialization, and you also learned a simple method to compute battery pack power at that point in time. In the fifth course of this specialization, I will share with you an even better way to compute battery pack power limits that can resolve the ambiguity, the issue of this particular case. This is an extreme example, it would only happen if our battery pack got severely out of balance. But I do think it's an important example because it illustrates the fact that really under all circumstances we must estimate the state-of-charge of every single cell in a lithium ion battery pack even when we believe the battery pack to be much better balanced than this is in order to avoid strange conditions where we would overcharge or undercharge by mistake. So, I claim that we should estimate the state-of-charge of every series connected cell in a battery pack. The problem with that is that any kind of Kalman filter estimating state-of-charge is computationally fairly complex. Maybe running a single Kalman filter for a single cell is okay, but running 100 Kalman filters to estimate 100 individual states-of-charge for a large battery pack is probably not okay. The degree of computation would be far too high. So, for most of the remainder of this week, you're going to learn about a different way to estimate the state-of-charge of all the cells in the battery pack in a very efficient way that reduces the total number of computations involved. This method takes advantage of a very simple observation. I hope that I've convinced you that the idea of battery pack state-of-charge is really ill posed. It's a quantity that does not make sense. But I'm going to insert one new word in that name to create a quantity that I believe does make sense. I will make the distinction between pack-state-of-charge which somehow tries to summarize the state of the battery pack in one quantity and I think that's meaningless, versus something that I will call pack-average state-of-charge which instead is a quantity that only partially describes the battery pack state and the word average tells you that. It doesn't describe everything that goes on, but it's the average of what's going on. So, I include the word average in this name to remind us it's not the same thing as a battery pack state-of-charge, instead it's the average of all individual cell states-of-charge. Now, maybe I'm being pedantic. You can decide that for yourself, but I am going to use this idea of pack-average state-of-charge and it's going to be a really helpful idea for finding a very efficient way to estimate all the states-of-charge of all the cells of a battery pack efficiently. For example, because every cell in a series connected battery pack experiences the same electrical current, the state-of-charge values for every cell will move in the same direction at every point in time. For example, if the pack is discharging, then all cells states of charge will decrease at that point in time or if the pack is charging, then all cell states have charge will increase at that point in time. So, there's something common between all cells that is something that might be helpful to think about. Further, the amount that the state-of-charge changes for individual cells is also going to be almost the same for every single cell in the battery pack. In fact, if every cell had identical total capacity, then the amount that the state-of-charge of one cell changes at any point in time is exactly equal to the amount that every other cell changes. In a physical battery pack, every cell is going to have slightly different total capacity, so the state-of- charge of every cell, the amount that it changes will be a little bit different every time step but mostly similar. So, if we can take advantage of these two things, computationally that would be really wonderful. And we're going to do that. What we're going to do is we are going to create one algorithm that determines the composite average state behavior of all cells in a battery pack and we'll create a second algorithm that determines the individual difference between one cell's behavior and this composite average behavior. We're going to define the composite average battery- pack state with the label x-bar, I use the symbol bar the overline because that's commonly used in the literature to talk about an average value. So, if the number of series connected battery cells in a battery pack is N subscript s, then the pack average state is equal to the summation of all the states of each individual battery cell divided by Ns, as we see here in this equation. Notice one nice feature of the pack- average state, the average value must be by definition less than or equal to the maximum value and at the same time greater than or equal to the minimum value of all the state values in the battery pack. Since the maximum and minimum values are of state of charge or both between zero and one, the pack-average state of charge must therefore also be between zero and one. So, the pack-average state-of- charge is within the normal range for state-of-charge. So, we can interpret the pack-average state-of -charge the same way we would interpret a normal state-of-charge and the same for the other states of the model. With this particular definition of a pack- average state vector, we can write the state vector for any individual cell as equal to that pack-average state vector plus a difference vector plus an offset vector that is unique to that cell. Here, I give that difference vector this symbol delta-x superscript i for cell i. Now, as you probably know very well the delta symbol is commonly used in the literature to represent a difference between two quantities, here I'm using it to represent the difference between the state of one particular cell and the pack-average state vector, and because the pack-average state vector is called x-bar and the difference is called delta-x, the method that I'm sharing with you is called a bar delta method, it combines the bar filter and the delta filter. The filter on this slide illustrates how this idea is going to be used. We will develop one set of equations that models the pack average behavior. Then we will use that set of equations inside of a nonlinear Kalman filter to estimate the battery pack-average state estimate and that could be sigma point Kalman filter or an extended Kalman filter doesn't really matter but in the example later this week I will use a sigma point Kalman filter. We are also going to develop a second set of equations that models the difference between any particular cell state and the pack-average behavior. Then we will use that second set of equations inside of Kalman filters to estimate the delta states. So, the pack-average state from the first filter will be combined with a delta states from the other filters in order to give state estimates for every cell in the battery pack. At first it appears that we have taken a computationally complex problem and made it worse. Before I introduced this idea of bar delta filtering to you, it seemed like we would have to implement N Kalman filters in order to estimate the states of N cells. Now, it appears that we need to implement N plus one filters to estimate the same quantities. So, in fact that's true, but the good news is, that the computational complexity of the Bar filter and the bar- delta approach actually is smaller even though we need to implement one more filter. The reason is that the different kinds of Kalman filter are not of identical computational complexity themselves and I've tried to illustrate this with a diagram on the right. On the top of the diagram, you see the previous concept. We implement one individual Kalman filter. For every battery cell, we end up with N sub s Kalman filters for Ns battery cells and each one of these Kalman filters is this one is blue boxes with the thick dark line surrounding it indicating it's a lot of computation involved. But in the bar-delta method, we have the picture on the bottom instead. The bar-filter has the same computational complexity as any one of these filters listed above it, so it's also drawn with the blue box are the big thick line so it's just as complicated as one of those but the delta filters can be made really really computationally simple. In addition to that, the pack-average state changes relatively quickly state -of-charge can vary over its entire range in a ATV application in a matter of a minute or so. So, it can change quite quickly but the delta states change much much more slowly and so the delta filters can be updated much less frequently down to as little as one over N times the rate of the bar filter. So, the overall computational complexity can be reduced from order N down to order one plus. What I mean by that the order one comes from the execution of the bar filter which has the same type of computational complexity, as we were thinking of earlier than the plus is just a little bit more computation, not one for more computation just a little more from the execution of maybe one delta filter every updated duration. So, we're going to look at this further this week. In summary, we have started to investigate some real-world concerns with implementing Kalman filtering to estimate battery-cell states. The first concern is the presence of a current-sensor bias and it's not an ideal scenario but we can attempt to estimate this sensor bias so that it will not in turn cause an offset to the state estimate produced by the Kalman filter. The second concern has to do with the computational complexity, and I claim that by using bar-delta filtering and we can implement Kalman Filtering very efficiently even for a battery pack then contains dozens or hundreds of battery cells in series. You've seen an introduction to how we can eliminate current-sensor bias by estimating its value and then subtracting that value from the measured current inside of all of the model equations. You've also seen an introduction to the concept of bar-delta filtering. In the next lessons, we're going to focus on developing the bar-delta filtering method in more detail, so that you can see all of the equations required in order to do it. Then later on this week, I will share with you some simulation results showing execution of this method that simultaneously estimates and eliminates current- sensor bias and also some results showing the speedup of the bar-delta method.