Cyber-Physical Systems (BIL-435), week 6 of 14

Estimation and Filtering: The Kalman Filter, State Estimation and Bad Data

Prof. Dr. Utku Kose, Süleyman Demirel University

Estimation lab

Two parts of this interactive lab are virtual laboratories in three dimensions (3D) with the hardware in the foreground. Part A replays the evening of the battery on a battery management bench. Part C opens the control room of the campus. Part B computes the formulas of the lecture step by step, and Part D asks for the values of stage 6 by hand. Part E is a field task with the battery management system, the energy management system and a clamp meter. In the calculator every intermediate value is rounded, and the next step continues with the rounded value. The results of Parts A and C can be copied into the Colab notebook. Each laboratory first shows its room. Start moves the view to the bench or the desk, and the view returns to the room at the end. The laboratories work best with a mouse or a touchpad on a computer.

Part A: The battery management bench

The battery management bench replays the recorded evening of 17:00 to 21:00 on a module of the battery and scales every reading to the whole pack. A programmable load draws the discharge of the evening. The current sensor of the module reads 5 kW too little, with a noise of 2 kW, and the voltage gives the state of charge with a noise of 0.01. A reference meter of the laboratory shows the true state of charge, and the management board runs the estimator that you choose.

Choose the estimator and the process noise Q below the view and press Run. Every run replays the same recorded readings. Your missions: First, run coulomb counting and the voltage alone and compare their errors. Second, run the Kalman filter with at least four values of Q and find the one with the smallest root-mean-square (RMS) error. Third, run the Kalman filter with the offset and compare its error and its estimate of the offset with the true -5 kW.

RunEstimatorQRMS errorError at 21:00Offset (kW)

Back to the lecture: The Kalman filter: Predict and correct, where the text continues after the box of this part.
Continue in Colab, section 2: Paste your runs into MY_RUNS and compare them with the model.

Part B: The filter, step by step

The calculator follows the formulas of the lecture. It combines the two temperature sensors of the library. It then computes one step of the Kalman filter at 19:00 and its steady gain for the chosen values of $Q$ and $R$. Before the step, the estimate is 0.51545 with the variance $9.51 \times 10^{-6}$. The measured discharge is 129.7 kW, and the voltage gives 0.50322.

Back to the lecture: The Kalman filter with matrices, where the text continues after the box of this part.
Continue in Colab, section 3: Estimate the offset of the current sensor with the filter in matrix form.

Part C: The control room of the campus

The control room of the campus receives 13 power readings at 19:00. Six come from the feeder meters of the main switchboard and six from the meters of the buildings over the network. The main meter adds the sum of all six feeders. The state estimator computes the six feeder powers by weighted least squares, the test value J and the normalized residuals. If J exceeds the threshold, it removes the meter with the largest normalized residual and estimates again. The levers of the test terminal block simulate the faults of the readings. On a real switchboard, an open secondary circuit of a current transformer under load is dangerous, so the block shorts it before any wire is opened.

Choose a fault on the test terminal block below the view and press Run the estimator. Your missions: First, run the estimator without a fault and with two different faults, and note the meter that the test finds for each fault. Second, give the B3 feeder meter an offset and find the smallest offset in whole kW that the test detects.

RunFaultOffset (kW)JThresholdResultMeter foundJ without it

Back to the lecture: Bad data: Residuals and the chi-square test, where the text continues after the box of this part.
Continue in Colab, section 4: Paste your runs into MY_METERS and compare them with the model.

Part D: By hand: Stage 6 of the microgrid

The car park meter at the switchboard reads 90.0 kW with $\sigma = 1.5$ kW. The controller of its chargers reports 85.3 kW with $\sigma = 2.5$ kW: Compute their weighted mean in kW to two decimals. A filter has $P^- = 4 \times 10^{-5}$ and $R = 10^{-4}$: Compute its gain to three decimals. Finally, compute the steady gain for $Q = 4 \times 10^{-6}$ and $R = 10^{-4}$ to three decimals.

Back to the lecture: The campus microgrid, stage 6: Estimating the state of the microgrid, where the text continues after the box of this part.
Continue in Colab, section 5: Compute the results of stage 6 of the campus microgrid.

Part E: Field task: The zero of the current sensor

The battery management system (BMS) of the container counts the charge with a current sensor on the main cable, and that sensor has the offset of the lecture. The master module of the BMS has a menu for its measurements, its contactors and its service functions. The engineer also has a clamp meter for direct current (DC) and the screen of the energy management system, which sets the power of the inverter.

The keys work as on the real device. The keys ▲ and ▼ choose a line, OK opens it or starts and saves a change, and the escape key (ESC) goes back. A number changes digit by digit: ◀ and ▶ choose the digit, and ▲ and ▼ change it. On a computer, the arrow keys, Enter and Escape work as well, once the front panel has been clicked.

Back to the lecture: In the field: The zero of a current sensor, where the text continues after the box of this part.