# Single Kalman Filter: Resistance based on measurment of current and Voltage [closed]

Given measurement of voltage and current, which contain gaussian noise with known variance and a constant unknown offset $$a_0$$, I have attempted to estimate the resistance $$R=\frac{V}{I}$$. The assumption is that current and voltage are both sinusoidal with the same frequency and phase shift. I discretized the following state model assuming a constant frequency: $$$$\dot{x}(t)=\begin{bmatrix} 0 & 1 & 0 \\ -\omega^2 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}x(t)$$$$

My first approach is the filtering of voltage and current through two seperate kalman filters given the following state and measurement model: $$$$x_{k} =\begin{bmatrix} \cos\omega T_s & \frac{\sin\omega T_s}{\omega} & 0 \\ -\omega\sin\omega T_s & \cos\omega T_s &0 \\ 0 & 0 &1 \end{bmatrix}x_{k-1}$$$$

where $$x=\begin{bmatrix} A\sin(\omega t+\varphi) \\ A \omega\cos(\omega t+\varphi) \\ a_0 \end{bmatrix}$$ and $$y_{k}=\begin{bmatrix} 1 & 0 & 1 \end{bmatrix}x_k.$$ So based on this formulation, I would have two identical Kalman filters, from which I can estimate the resistance through division of the output of both filters without any problem.

My goal now is to estimate everything within one kalman filter including the resistance $$R$$. Since I am assuming that both signals are sinusoidal with same frequency and phase shift, the resistance would actually be the ratio of both amplitudes, and It would be constant in the period where the amplitude doesn't change. The thing is, the amplitude changes after a certain time interval, so the resistance would be piecewise constant.

I have used the following state space model and measurement model for the estimation:

$$$$x_{k} =\begin{bmatrix} \cos\omega T_s & \frac{\sin\omega T_s}{\omega} & 0 & 0 \\ -\omega\sin\omega T_s & \cos\omega T_s &0& 0 \\ 0 & 0 &1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}x_{k-1}$$$$ where $$x=\begin{bmatrix} A_I\sin(\omega t+\varphi) \\ A_I \omega \cos(\omega t+\varphi) \\ a_0 \\ R\end{bmatrix}$$ $$y_{k}=\begin{bmatrix} 1 & 0 & 1 & 0\\ 0 & 0 & R_{pred,k} & I_{pred,k} \end{bmatrix}x_k$$ and $$y=\begin{bmatrix} I_{meas,k} \\ V_{meas,k} \end{bmatrix},$$ where $$R_{pred,k}$$ and $$I_{pred,k}$$ are the respective resistance and current after the prediction step of the filter at time point $$k$$.

My choice of $$P$$,$$Q$$ and $$R$$ are as follows: $$$$P =\begin{bmatrix} 0 & 0& 0 & 0 \\ 0 & 0 &0& 0 \\ 0 & 0 &0 & 0 \\ 0 & 0 & 0 & 0.1 \end{bmatrix}$$$$

$$$$Q =\begin{bmatrix} 0 & 0& 0 & 0 \\ 0 & 0 &0& 0 \\ 0 & 0 &0 & 0 \\ 0 & 0 & 0 & 0.1 \end{bmatrix}$$$$

$$$$R =\begin{bmatrix} \sigma_I& 0 \\ 0 & \sigma_v \end{bmatrix}$$$$

The estimation works initially fine, where the resistance hasn't yet changed, but when it does, the kalman filter doesn't respond correctly. It either doesn't respond as fast as needed or just diverge from the real measurement.

I have implemented the extended kalman filter to tackle the nonlinearity in the measurement model, but it didn't work. the measurement remain constant at a completely random value with no change, regardless of the change in resistance.

• "The assumption is that current and voltage are both sinousodial", but your state change matrix is for a sinusoidal signal of known frequency with an unknown offset. Why? May 21, 2022 at 19:48
• Please edit your question to say what $R_{\mathrm{pred}, k}$ and $I_{\mathrm{pred},k}$ are. Where do these numbers come from? Presumably these are evolving over time -- how are they evolving over time? May 21, 2022 at 19:50
• In addition to Tim’s comments: I’m not sure where your transition matrix comes from? The usual rotation matrix doesn’t have the extra $\omega$ terms on the sinusoidal entries.
– Peter K.
May 21, 2022 at 19:54
• "The usual rotation matrix doesn’t have the extra ω terms" How did I miss that? May 22, 2022 at 5:21
• ok, I will detail my question further. May 23, 2022 at 11:58