• No results found

Power grid integration using Kalman filtering

N/A
N/A
Protected

Academic year: 2022

Share "Power grid integration using Kalman filtering"

Copied!
55
0
0

Loading.... (view fulltext now)

Full text

(1)

UPTEC E12003

Examensarbete 30 hp Februari 2012

Power grid integration using Kalman filtering

Magnus Djerf

Påbyggnadsprogrammet till civilingenjörsexamen i elektroteknik

(2)
(3)

Teknisk- naturvetenskaplig fakultet UTH-enheten

Besöksadress:

Ångströmlaboratoriet Lägerhyddsvägen 1 Hus 4, Plan 0

Postadress:

Box 536 751 21 Uppsala

Telefon:

018 – 471 30 03

Telefax:

018 – 471 30 00

Hemsida:

http://www.teknat.uu.se/student

Abstract

Power grid integration using Kalman filtering

Magnus Djerf

Renewable power sources with a relatively uneven or constant DC power production require synchronization methods to work with the current utility power grid. The solution to this synchronization problem has been solved with semiconductor based converters and advanced switching algorithms. To enable switching algorithms that work well with the grids amplitude, phase-shift and frequency, the current waveform has to be measured and estimated.

There are many sources of noise that will add distortion of the current waveform, making its appearance less similar to the grids. The distorted measurement affects the accuracy of the converters negatively. Therefore, using a filter algorithm to attenuate the grid noise is required.

This project uses a Kalman filter with the aim to decrease the noise and estimate the current phase shift for a three phase power-grid.

To achieve reliable and fast calculation, implementing the Kalman filter within a FPGA were done.

The project contains results from both simulated MATLAB data and the FPGAs real time data. The method was able to estimate the grid within a few Hz frequency deviation and enable some noise reduction. For larger degree of harmonic distortion during steady state operation, the Kalman filter could remove more of the harmonic distortion. Limits and differences with MATLAB are discussed for the FPGA

implemented Kalman filter.

Examinator: Nora Masszi

Ämnesgranskare: Tomas Olofsson Handledare: Remya Krishna

(4)

Acknowledgements

First I would like to thank the Division of Electricity for providing equipment to make this project possible. I express my gratitude to every- one involved but especially my supervisor Remya Krishna and Deepak Ela- malayil Soman. Their support and encouragement meant a lot throughout the project. I would also like to thank Johan Abrahamsson for his help and valuable suggestions regarding labview, which gave me good intro- ductional knowledge. Many thanks to Tomas Olofsson for his patience and help to improve the written material for this thesis. I would also like to thank my co-worker Bengi Tolunay for her help to improve the mood during hours of code compilation. Many thanks to family and friends for their help, support and positive attitude.

(5)

Contents

1 Introduction and Overview 8

1.1 Introduction . . . . 8

1.2 Project overview . . . . 9

1.3 Report Organization . . . . 10

2 Noise Sources and Grid Changes 11 2.1 Error Sources . . . . 11

2.2 Quantization Noise . . . . 11

2.3 Thermal Noise . . . . 12

2.4 Transient Noise . . . . 12

2.5 Harmonic Noise . . . . 12

2.6 Frequency Deviation . . . . 13

3 Kalman States and Theory 14 3.1 State Space form . . . . 14

3.2 Kalman Filter . . . . 15

3.3 Initial values . . . . 17

3.4 Three Phase extrapolation . . . . 17

4 MATLAB Simulation 19 4.1 Experimental setup . . . . 19

4.2 Results MATLAB . . . . 21

4.2.1 Simulation 1 . . . . 21

4.2.2 Simulation 2 . . . . 22

4.2.3 Simulation 3 . . . . 24

4.2.4 Simulation 4 . . . . 25

4.2.5 Simulation 5 . . . . 27

4.3 Conclusions from MATLAB simulations . . . . 28

5 Hardware and Program interface 29 5.1 FPGA(Field Programmable Gate Array) . . . . 29

5.2 Chassi (compactRIO 9114) . . . . 30

5.3 Real-Time Controller . . . . 31

5.4 ADC and DAC Modules . . . . 32

5.4.1 NI 9205 . . . . 32

5.4.2 NI 9264 . . . . 32

5.5 Labview interface . . . . 33

6 Implementation 34 6.1 Design . . . . 34

7 Results obtained with the FPGA implementation 37 7.1 Experiment details . . . . 37

7.2 Results . . . . 38

7.2.1 Simulation 1 . . . . 38

7.2.2 Simulation 2 . . . . 39

7.2.3 Simulation 3 . . . . 41

7.2.4 Simulation 4 . . . . 43

7.2.5 Simulation 5 . . . . 44

(6)

7.3 FPGA Conclusion . . . . 46

8 Evaluation and Conclusion 47

8.1 Discussion . . . . 47 8.2 Conclusion . . . . 48 8.3 Scope for future work . . . . 48

A MATLAB Code 50

B Labview Design 51

(7)

List of Figures

1 Project Overview . . . . 10

2 Signal Model . . . . 11

3 Flowchart of the Kalman filter . . . . 17

4 Random noise influenced measurement signal. . . . 21

5 Random noise influenced measurement signal (Spectrum) . . . . 22

6 Harmonic Additive Noise 15% 10% and 5% . . . . 23

7 Harmonic Additive Noise 15% 10% 5% (Spectrum) . . . . 23

8 Three phase extrapolation . . . . 24

9 Three phase extrapolation (Spectrum) . . . . 25

10 Constant deviating frequency 53 Hz . . . . 26

11 Constant deviating frequency 53 Hz (Spectrum) . . . . 26

12 Constant deviating frequency 47 Hz . . . . 27

13 Constant deviating frequency 47 Hz (Spectrum) . . . . 28

14 Example of FPGA connections . . . . 29

15 CompactRIO chassi . . . . 31

16 Real-Time Controller . . . . 32

17 Memory Storage . . . . 34

18 Labview Design . . . . 35

19 FPGA Harmonics Generation . . . . 38

20 Steady State . . . . 39

21 Steady State (Spectrum) . . . . 39

22 Harmonic at 40% . . . . 40

23 Harmonic at 40% (Spectrum) . . . . 41

24 Decreasing Phase 46.97Hz . . . . 42

25 Decreasing Phase 46.97Hz (Spectrum) . . . . 42

26 Increasing Phase 52.84Hz . . . . 43

27 Increasing Phase 52.84Hz (Spectrum) . . . . 44

28 Harmonic additive noise third, fifth and seventh . . . . 45

29 Harmonic additive noise in third, fifth and seventh(Spectrum) . . 45

(8)

1 Introduction and Overview

1.1 Introduction

Renewable power sources have a larger influence in modern society where larger parts of the electrical power comes from such renewable sources. With gen- erator designs optimized for the local power resources, a difference from the traditional rotating synchronous machines can be seen. The power produced might not have the same frequency, phase and amplitude as the rest of the power grid. This demands synchronization methods to connect these renewable sources. Converters based on semiconductor switches that handles high power is one solution to solve the synchronization problem. By timing the switching for the converters to recreate a grid friendly current, a synchronization between the source and utility grid can be made possible. Most power electronics semicon- ductor switches involved with grid synchronization, uses a Phase Locked Loop (PLL), that has limits regarding frequency change and noise sensitivity. This project focus on a grid estimation based on a Kalman filter instead of the PLL since no prefiltetering is required.

One of the purposes with this work, is to evaluate how many Hz the grid can deviate from a steady state case and still give reasonable noise reduction and frequency adaption. The other main purpose of this report, is to give a more detailed evaluation regarding how good the method works during steady state with a small frequency change and higher degree of harmonic noise.

(9)

1.2 Project overview

While this report mainly handles the Kalman filter and its input-output re- lations, the whole perspective described in Figure 1 is important. The main objective is to produce an Alternating Current (AC), in-phase with the grid, based upon an uneven or constant Direct Current (DC) power production from a renewable power source. The renewable power source which can not be con- nected directly to the grid has to be converted to a constant DC level through rectifier bridges and capacitor banks. In case the renewable power source already produces a direct current, the rectifiers and capacitor blocks can be neglected.

Meeting the demands of the grid synchronization, phase information in the cur- rent power grid is important. To measure the grid within a reasonable voltage range, a potential divider downscales the voltage level. This potential divider has been named sensor in the figure below. The downscaled version of the power signal can then pass through the Analog to Digital converter (ADC) for a digital representation of the grid voltage.

Inside the FPGA application, the current phase shift of the grid voltage be- comes estimated through the Kalman filter while attenuating disturbances. To ensure unity power factor, or reactive power production the current controllers purpose is to produce a current depending on the utility demand. The FPGA also contains a Space Vector Modulation (SVM) block that generate pulses for a high voltage, transistor based, inverter[1]. The input for the SVM should be a three phase sinusoid with the same phase shift as the grid and this re- quires small time-steps between data points. With the in-phase, relatively noise free grid representation, the SVM produces logical output corresponding to the three phase grid information. The logical output will decide in which order the transistor switches within the inverter should be on or off and for how long[2].

With a constant DC supply voltage to the inverter from the renewable power source, the resulting waveform will be high power pulses with different length, that needs filtering to take the smooth sinusoidal shape. The final filtered ver- sion can then pass a Power Common Connection (PCC) to become integrated with the power grid.

(10)

Figure 1: Project Overview

1.3 Report Organization

Chapter one covers the introductional part and the overview of the project and further explains the macroscopic structure. The Kalman filters input and the sources of error involved is covered in Chapter 2 along with a brief explana- tion of natural frequency variation. Chapter 3 explains State space form of a voltage grid signal, Kalman filter theory and how a three phase signal can be estimated with only one measured phase. The same theory used in chapter 3 is implemented with MATLAB code and evaluated in chapter 4.

Chapter 5 gives a brief hardware and software description with focus on the equipment surrounding the FPGA and software interface used.

Chapter 6 contains the FPGA implemented design.

The seventh chapter gives the experimental details and practical results along with a brief section that highlights important facts. The final chapter discuss and concludes the results with suggestion on scope for future work.

(11)

2 Noise Sources and Grid Changes

This chapter involves what kind of errors the measured grid voltage can expect once it passes the ADC, mentioned in previous chapter. Additional information regarding the natural frequency variation will also be explained

2.1 Error Sources

Assuming that the ADC samples fast enough to meet the Nyquist sampling Criteria, a valid representation of the grid voltage is given in a digital format.

There are several sources that can produce a voltage value that deviates, from what is expected, in the measured grid voltage. Different physical phenomena causes varying sources of error, both in appearance and amount of power. By modeling these sources as a time discrete additive component, a simple error model is created, see figure 2. The aim of this model, is to describe a correct voltage value s(t)(signal) with varying sources of additional noise n(t). The following sections will cover different types of noise sources involved for an AD converted voltage signal.

Figure 2: Signal model with a signal of interest s(t) and an additive noise term n(t).

2.2 Quantization Noise

When an analog signal passes through an ADC, it might not be represented correctly. If the incoming signal exceeds the maximum voltage value available on the converter, the representation will be the highest value available. The resolution and the nominal input ranges are some of the main reason for Quan- tization errors. Nominal input ranges depends on the ADC and the user should make sure that the input analog signal stays within this range.

Resolution is decided by the amount of quantization levels that exist in the range and will represent the digitalized version of the signal in terms of a con- stant values. Higher resolution will produce less error and better representation of the signal in a digital format. When the current value to be sampled, falls between two quantization levels, it will be incorrect by maximum ∆x2 (where

(12)

∆x is the quantization intervals range). By having more quantization levels, the ∆x decreases and also the amount of error in every sample.

2.3 Thermal Noise

Thermal Noise is a material based issue that exist in every electrical application and is caused by random motion of electrons within a conductor. The noise is almost constant for the whole spectrum, exists in every frequency, and has an approximate normal distribution. While the thermal noise is small in respect to power within the actual measured voltage value, it might still affect the value to some degree. Noise power is described in (1) where kb is Boltzmann constant, T is temperature in Kelvin and ∆f , the bandwidth.

Pn= kBT ∆f (1)

2.4 Transient Noise

Sudden electrical discharge such as load disconnection and lightning strikes af- fects the grid and is another source of error, called transients. Transients can be divided into two categories, impulsive and oscillatory[3]. In general the transient based noise has short duration but high power. The oscillative power can have a sudden low frequent sinusoidal shape, appearing within the grid representation signal.

2.5 Harmonic Noise

Electrical components within the grid can produce a certain amount of har- monic distortion. The sources from which this noise is produced, is related to non-linear loads. This type of load is often related to different types of power converters such as rectifiers. There is also a high degree of harmonic distortion coming from fluorescent based loads.

When the grid current passes through non-linear loads, the load might not draw a current with a linear sinusoidal waveform. By assuming that the sinu- soidal waveform follows the additive error model mentioned above, the correct grid voltage will have additional noise. This noise, consists of multiple sinusoidal waveforms based on integer multiples of the fundamental frequency 50 Hz. For higher degrees of harmonic distortion, the actual grid voltage representation will loose its original shape. The power grid can absorb parts of the harmonic noise but some degree of distortion could be expected. Higher order harmonics are significantly attenuated by the power system and can therefore be neglected [3].

By adding the power contribution of each individual harmonic Pn and divide it with the power present in the fundamental sinusoid, P1, a measurement that reflects the amount of harmonic distortion is given(2). This measurement is called Total Harmonic Distortion (THD). For the Swedish power grid, the THD should not exceed 4% over time nor exceed the individual guideline for each harmonic according to the Swedish Power Grid [4].

T HD =

X

n=2

Pn

P1 (2)

(13)

2.6 Frequency Deviation

Frequency within the power grid depends on the balance between the loads connected and the generators present within the system [3]. Variation outside of +/- 0.1 Hz is considered to be faulty and may be deduced from abrupt changes in either load or generation part of the system. The worst cases for the frequency variation occurs when large power units are disconnected and the frequency drop could be 0.05 Hz/s which would mean 0.1 HZ deviation within two seconds [5]. When additional generators are connected an increase of 0.025 Hz/s can be expected which result in 0.1 Hz change within four seconds. The same frequency drop and increase can be expected for a system during normal steady state operations but within the range of +/-0.1 Hz.

(14)

3 Kalman States and Theory

This chapter covers the State space form for a grid representation and related Kalman filter theory with goal to fit the measured voltage of the grid.

3.1 State Space form

Most signal input and output relations can be described by a difference equa- tion, but there are some advantages by choosing a state space form. Depending on the state representation, the future behavior of the system can be estimated.

Everything based upon that the states describes every important physical phe- nomena in the system. The state space form has the advantage of being very flexible way of describing the system as well as less sensitive to errors[6].

For a power grid voltage signal, the signals behavior can only be on a sinu- soidal form (3) and is denoted S1(t). S1(t) is the current time discrete voltage value given a certain amplitude A, angular frequency w and phase shift ϕ. The three phase voltage signals (4-5) are only mentioned for future reference and will not be included in the coming state space form.

Since the sinusoidal signal can be described with three components, amplitude, angular frequency and phase, the states for this model have to reflect these components in some way.

S1(t) = A ∗ sin(wt + ϕ) (3)

S2(t) = A ∗ sin(wt + ϕ +

3 ) (4)

S3(t) = A ∗ sin(wt + ϕ +

3 ) (5)

Through an angle transformation formula[8], the extended version of (3) re- sult in (6). Making the states linearly dependent with respect to phase and amplitude from the extended voltage signal in (6) result in two states(7-8). As- suming the frequency is relatively constant over time, the signal representation can be described through an amplitude and phase shift.

S1(t) = A ∗ cos(ϕ) cos(wt) − A ∗ sin(ϕ) sin(wt) (6)

x1= A ∗ cos(ϕ) (7)

x2= A ∗ sin(ϕ) (8)

By defining x1 and x2 as the state variables that should be estimated in each new time step. Under the assumption that no delay occurs,(9) describes the state variables with additional noise w(t). This noise represents how much the states randomly change over time and also picks up small errors within the model.

To describe the actual voltage signal y(t) with the model for the current state values (10) requires a non stationary deterministic vectorcos(wt) −sin(wt).

(15)

The uncertainty of the current measurement (10) will be modeled with addi- tional measurement noise v(t). By using this model, the assumption of a con- stant frequency will result in a slightly incorrect model during frequency varia- tion. This gives a state equation(9) where A = 1 00 1 and C = cos(wt) −sin(wt).

A should not be mistaken for the amplitude related term described in (3-6).

x1(t + 1) x2(t + 1)



=1 0 0 1

 x1(t) x2(t)



+ w(t) (9)

y(t) =cos(wt) −sin(wt)x1(t) x2(t)



+ v(t) (10)

3.2 Kalman Filter

Assuming a system is described in similar time discrete state space form (9-10) there is a filter method available, a so-called Kalman filter. A Kalman filter is a filter method that minimize the mean square error of the states for a given state space system. The filter uses a linear regression method to minimize the variance of the estimation error for the states.

A more generally used form to write the state space form is given in (11-12) where x(t) is a column vector containing both states x1(t) and x2(t).

State equation

x(t + 1) = Ax(t) + w(t) (11)

Observation equation

y(t) = C(t)x(t) + v(t) (12)

The deterministic part of the model (11) is described in A and describes how the estimates propagates with time, while the w(t) term is an additive process noise term explained in the earlier section.

In (12), the measured signal can have an additive measurement noise v(t) which usually is uncorrelated with the process noise present in (11), also explained in the earlier section. Independence between process and measurement noise can therefore be assumed. For later use, it is wise to define the measured error covariance and the process error covariance respectively R and Q.

From here on forth, the following example notation will be used for the coming equations. Z(t | t − 1) indicates the ˆˆ Z value in current time, given measurements and estimates up to the previous time step (t − 1).

Prediction error covariance P (t | t − 1) which is minimized in the Kalman filter, where the state estimate ˆx(t | t) is based upon measurements and previous state values given the current time step (t).

P (t | t) = E[(x(t) − ˆx(t | t))(x(t) − ˆx(t | t))T] (13) By substituting the state estimates in (13) ˆx(t | t) and x(t) with equation (14) and respectively (11) gives the resulting form (16).

ˆ

x(t + 1 | t) = Aˆx(t | t) (14)

(16)

ˆ

y(t | t) = C ˆx(t | t) (15)

P (t + 1 | t) = E[Ax(t) + w(t) − Aˆx(t | t)][Ax(t) + w(t) − Aˆx(t | t)]T (16)

With factorization and substitution with (13), the complete form describing how an estimate transfer to the next time step is given in(17). The Q term comes from the earlier defined covariance of the process noise that affects uncertainty of the estimates. Equation (17) mainly describes how the estimation of the states comes out without further information regarding the measured voltage signal y(t) (12).

P (t + 1 | t) = AP (t | t)AT + Q (17)

For each iteration a new measurement will produce an estimated output (15) based on the state estimate in the current time ˆy(t + 1 | t) = C ˆx(t + 1 | t). By recreating the estimated grid voltage, it can be compared to the actual measurement y(t), given in the observation equation (12). Subtracting the actual measurement with the estimated output is called the residuals and in case it goes to zero the estimated voltage value in the current time step is practically the same as the measured.

The residuals multiplied with a gain K(t) will be a correction term of the next coming state estimate(19). Kalman gain K(t) (18) updates every iteration and multiplied with the residuals decide how much the uncertainty increase or decrease from the previous state estimates. The R parameter, corresponding to the measurement error covariance and its influence will be explained below.

The error covariance becomes updated (20) to be used in the coming iteration in the next time step(17). Figure 3 further explains the time steps for the Kalman filter in a flowchart below. The numbers indicates in which order each new iteration executes.

K(t) = AP (t | t − 1)C(t)T[C(t)P (t | t − 1)C(t)0+ R]−1 (18)

ˆ

x(t | t) = ˆx(t | t − 1) + K(t)[y(t) − ˆy(t | t − 1)] (19)

P (t | t) = P (t | t − 1) − K(t)C(t)P (t | t − 1) (20)

The Q and R parameters in (17) and (18) are design parameters with the origin in process noise described in (11) and the measurement noise in (12).

These parameters will have to consider the incorrect model during frequency variation as well as noise related measurements such as the noise sources ex- plained in chapter 2.

R is the measurement noise covariance and can be determine based upon prior

(17)

Figure 3: Flowchart of the Kalman filter

knowledge and measurements. If R is chosen small, there will be more trust in each measurement. If it is the opposite, measurements are considered less trustworthy. While the R parameter is easier to predetermine, the Q parameter is more difficult to anticipate, to fit a model. Small values for the Q covari- ance matrix will result in a system with slow adaption speed when the system changes but the ability to remove incorrect values. By choosing the parameter high, the system reacts faster and relevance of the model decreases. This makes the filter more trusting regarding singular measured values. The Kalman filters balance between a fast system and noise sensitivity based upon both the Q and Rs parameters mutual relation[7]. The parameter choice is the only way to affect the system design and tuning these parameters is important.

3.3 Initial values

The initial phase and amplitude information described in the states (7-8) could have a phase shift when the first measurement is taken. An initial guess will therefore not affect the coming results, except for a slightly faster convergence rate in some cases when the values coincidentally are close in the time step.

By choosing the initial guess of the error covariance P (t | t) to something large, the model can assume an incorrect value at the beginning, than afterwards converge towards the minimum error covariance.

3.4 Three Phase extrapolation

The estimated output ˆy(t | t) represent one phase estimation based on one mea- sured phase. Assuming the three phase power grid system is balanced, formula

(18)

(3-4) explains a 120 degrees phase shift between each phase and is a valid ap- proximation.

To create additional phase, S2 and S3 that are based on ˆS1, a similar trigono- metric formula used for the linearization(6) can be applied. ˆS1becomes known through equation(15) and recreating additional phase shifted signals with the current states result in (21-22). The only restriction would be to either know the amplitude or keep it constant at 1 volt to ensure correct phase shift.

Sˆ2=cos(wt) −sin(wt) cos(120) sin(120)

− sin(120) cos(120)

  ˆx1(t | t) ˆ x2(t | t)



(21)

Sˆ3=cos(wt) −sin(wt) cos(240) sin(240)

− sin(240) cos(240)

  ˆx1(t | t) ˆ x2(t | t)



(22)

(19)

4 MATLAB Simulation

This chapter covers some experiments done in MATLAB with the purpose to get an idea of the Kalman filters performance. Another purpose is to see what different tuning does in respect to frequency deviation and harmonic distortion.

4.1 Experimental setup

To check if the Kalman filter has sufficient performance during steady state operation and for frequency variations outside the steady state. The algorithm has been implemented using the Kalman filter theory explained in the previous chapter through the MATLAB function presented in Appendix A.

The Kalman filter function handles a noise corrupted grid signal and return the filtered version of the same signal based upon the Q and R tuning. For most of the following results, a sampling rate of 20 kHz has been used but a slower sampling rate of 2 kHz will be used for reference.

To get a better idea how much the harmonics are suppressed, the spectral infor- mation from both the noise influenced grid signal and the Kalman filtered are compared.

The following list shows some of the experimental setups used for the different simulations.

• Sampling rate for simulation 1-3 is 20 kHz and 2kHz for simulation 4-5.

• For most experiments below, a fundamental 50 Hz sinusoid with an ampli- tude of 1 Volt, was used. To simulate the steady state frequency variation of +/-0.1 Hz, an increase of 0.002 Hz every new period was used. This result in a 0.1 Hz increase within 1 second. This were done in Simulation 1-3.

• Simulation 4-5 uses a constant frequency deviation of either +3 Hz or -3 Hz.

• MATLABs randn() function produces normally distributed noise with mean value zero and standard deviation of one. By multiplying this noise with a gain of 0.02, a 2% noise signal can be added to the fundamental (Simulation 1-3). This additive noise terms purpose in the simulation were to model higher degree of harmonics as well as thermal noise present.

• In two simulations, the normally distributed gain were 0.04 (4%) instead of (2%) (Simulation 4-5).

• For simulations containing harmonic distortion, additional sinusoids has been added to the fundamental after multiplication with a gain. 10%

harmonic will be a multiplication of 0.1. Thus 10% of the amplitude of the fundamental(Simulation 3).

• The harmonics tested in simulation 2 are the first three odd harmonics starting from the third at 150 Hz. The gain multiplication are 0.15, 0.1 and 0.05 representing the third, fifth, and seventh.

(20)

• Simulation 3 is the only simulation that shows the additional two recreated grid phases based on equation (21-22).

• One second of simulation time has been used for all experiments below but for a better visual experience only a few periods of data have been chosen.

• The amplitude spectrum uses all data during the whole simulation time of one second. For good visual experience, only a small part of the spectrum is shown. This part vary from different simulations and contain at least the highest harmonic used.

• For all simulations the initial values for x1(0) = 0 and x2(0) = 0.

• The initial values for the error covariance matrix P (0 | 0) has been chosen to an identity matrix

After several experiments with different choices of the process noise covari- ance, Q were chosen to have a diagonal form based upon countless of simulations where stability were a problem. If the non-diagonal elements were chosen large, the system had a chance to start to oscillate and not converge towards the cor- rect waveform. Therefore, every simulation will be based upon a diagonal Q matrix.

Tuning parameters will be shown in each section below in the context where it is used.

For the following figures, the blue signal represent the measured noisy voltage signal. Simulation 1-2 and 4-5 have a correct voltage signal reference without any noise that is used for comparing. This signal is colored green except for figure 8, where it is black.

(21)

4.2 Results MATLAB

4.2.1 Simulation 1

The objective of this simulation is to show the performance when thermal noise and higher harmonics are present in the grid voltage signal. A slight frequency increase every new period result in 50.1 Hz deviation within one second. Thus simulating a natural steady state deviation. Figure 4 shows the measured grid signal, its Kalman estimate and a reference signal without noise. With no phase shift in the measured grid signal, the frequency increase occurs in time 0.615 and 0.635.

Figure 5 shows the corresponding spectrum for the Kalman estimate and the measured grid signal. The following tuning and noise parameters have been used.

• Process noise parameter Q =0.0001 0 0 0.0001

 .

• Measurement noise parameter R = 1.5.

• Additive normally distributed noise 2%.

Figure 4: Kalman estimate of a random noise influenced measurement signal compared with a reference signal without noise. The frequency is increased every new period and within steady state deviation.

(22)

Figure 5: Spectrum of the random noise influenced measurement signal and the corresponding Kalman estimate.

4.2.2 Simulation 2

Simulation 2 shows the performance of the Kalman filter while under influence of a large degree of odd harmonics and thermal noise. The same frequency increase as previous simulation were used, resulting in a 50.1 Hz deviation after one second. Figure 6 shows the Kalman estimation with the goal to follow the fundamental sinusoid without noise. The corresponding spectrum figure 7 shows how much each odd harmonic is attenuated by the Kalman filter compared to the reference grid signal. Red markers have been added on the local largest peaks in the Kalman filtered spectrum.

• Process noise parameter Q =0.00000001 0 0 0.00000001

 .

• Measurement noise parameter R = 5.5.

• Additive normally distributed noise 2%.

• Third harmonic 150 Hz at 15%.

• Fifth harmonic 250 Hz at 10%.

• Seventh harmonic 350 Hz at 5%.

(23)

Figure 6: Kalman estimate for a simulated measured signal containing harmonic additive noise 15%, 10% and 5% for the first three odd harmonics. The goal of the estimate is to follow the dotted reference signal without noise.

Figure 7: Spectrum of the harmonic distorted reference signal and its Kalman estimate. The attenuation of each of each harmonic can be seen.

(24)

4.2.3 Simulation 3

Simulation 3 has the purpose to show the additional two phases of the three phase grid. The thermal noise remains the same as previous while harmonics have been reduced. Figure 8 shows the Kalman estimated phase and the recre- ated phases based on (21-22). The goal of the Kalman estimate is to follow the measured signal without noise. The measured signal shown in figure 8 has the same frequency increase as previously simulations and since the time scale is close to one, the frequency is close to 50.1. Thus showing that the estimate manage to follow the measured signal without noise, with some degree of fre- quency deviation. The spectrum shown in figure 9 only compares the measured signal with the Kalman estimate. The spectrum also shows a suppressed third harmonic.

• Process noise parameter Q =0.000001 0 0 0.000001

 .

• Measurement noise parameter R = 2.5

• Additive normally distributed noise 2%.

• Third harmonic 150 Hz at 10%.

Figure 8: The three phase extrapolation given one Kalman estimated phase. A 10% third harmonic is present in the measured signal

(25)

Figure 9: Spectrum of the measured reference signal with random noise and a third harmonic present. The spectrum is compared to one of the Kalman estimated phases.

4.2.4 Simulation 4

Simulation 4 shows how the Kalman filter performs outside steady state with a constant higher frequency at 53 Hz. There is no frequency variation apart from the constant higher frequency. The sampling rate has been reduced to 2 kHz while the normal distributed noise has been increased to 4%. Figure 10 shows how the Kalman estimation of the referense grid signal looks like. The tuning was choosen to enable the the estimate to follow the reference grid signal instead of noise suppression and figure 11 shows that it is harder to suppress the noise with the given tuning.

• Process noise parameter Q =0.35 0 0 0.35

 .

• Measurement noise parameter R = 2.8.

• Additive normally distributed noise 4%.

(26)

Figure 10: Measured signal with a constant deviating frequency at 53 Hz and additive 4% normal distributed noise. The Kalman estimate should follow the reference signal but without noise.

Figure 11: Spectrum for a measured reference signal with a 3 Hz constant fre- quency deviation from 50 Hz. The spectrum for corresponding Kalman estimate is compared with the reference signal.

(27)

4.2.5 Simulation 5

Figure 12-13 shows a similar result as in the previous simulation with the same noise and sampling rate. The only difference is the constant deviating frequency of 47 Hz instead of 53 Hz.

• Process noise parameter Q =0.35 0 0 0.35

 .

• Measurement noise parameter R = 2.8.

• Additive normally distributed noise 4%.

Figure 12: Measured signal with a constant deviating frequency at 47 Hz and additive 4% normal distributed noise. The Kalman estimate should follow the reference signal but without noise.

(28)

Figure 13: Spectrum for a measured reference signal with a -3 Hz constant fre- quency deviation from 50 Hz. The spectrum for corresponding Kalman estimate is compared with the reference signal.

4.3 Conclusions from MATLAB simulations

The most important simulation results were shown for the steady state cases where different choices of R and Q would follow the grid signal. For a high degree of harmonic distortion, figure 6-7 showed that each harmonic could be suppressed while the frequency changed. It is also important to see how small the covariance of the process noise Q is tuned to enable such suppression. By comparing to the much larger Q used in simulation 4 and 5, sampling rate has a large influence. Concerning the 3 Hz deviation used in the later simulations, the Kalman filter manages to estimate the phase even though the deterministic vector C is based upon a constant frequency, 50 Hz. The only drawback being that noise suppression is harder in these cases.

(29)

5 Hardware and Program interface

This section describes the hardware used for an implemented version of the Kalman filter and the devices used for visual confirmation.

5.1 FPGA(Field Programmable Gate Array)

A Field Programmable Gate Array consist of programmable switches and logical cells that can be wired through correct switching. An example of connections can be seen in figure 14. Each logical cell can be configured to perform a simple task, while the programmable switches make the interconnections to make a route between logical operations, that can result in a more complex operation.

The programming of the FPGA is based on a HDL (Hardware Description Language) that makes the internal configurations[10].

Figure 14: Example of FPGA connections

A FPGAs logic cell contains Flip-Flops, LUTs(Look-Up Tables), Block- Memories and DSP48s.

Flip-flops within a FPGA have a task to synchronize logic and shift values between iterations. LUTs can be used to handle logic operations like AND, NAND, OR and NOR but can also handle temporary storage. The block mem- ories could be used for temporary storage between iterations or reading constant values. Some FPGAs have memories that handles read while writing.

High speed arithmetic slices (DSP48s) are one type of embedded block that en- ables fast arithmetic operations within the FPGA. The block contains one mul- tiplier and accumulator that either add or subtract. Depending on the FPGA

(30)

type, larger amount of bit representation can be multiplied together. [Virtex 5 FPGA XtremeDSP Design Considerations User Guide]. 48 in the name stands for the number of bits the accumulation can handle. One objective for the DSP48s blocks, is to relieve both LUT and Flip-Flops from the arduous task of performing resource consuming mathematical operations.

5.2 Chassi (compactRIO 9114)

Most of the equipment used for the application are mainly for experimental pur- poses and not practically in the industry. The experimental setup enables easy overview and access to different signals. The compactRIO chassi (By National Instruments) used in this application is reconfigurable and contains the FPGA core. Depending on the model of the compactRIO, the FPGA cores and chassi designs will be different. For this specific applications chassi, a Xilinx Virtex 5-LX50 is embedded in the bottom of the chassi. This FPGAs main circuitry contains 28,800 LUTs and Flip-flops. Multipliers are of DSP48 type (25x18 bit multipliers) and amount to 48 pieces. The embedded memory has 1,728kbits available for storage. During normal operations, the FPGA executes with the clock-rate 40Mhz, but can be configured to slower or faster rates.

Input and output are available within the chassi through sockets designed to fit certain Modules.

The input/output source is connected through a D-sub-miniature 19 pin con- nector. Each module have their own D-sub connection to enable faster parallel data transfer to the FPGA. The chassi used in this application, is a Şcom- pactRIO 9114Ť with eight module slots available, see figure 15. Most of the exterior consist of a heat-sink material to enable cooling. The chassi design in the figure requires a real time controller for communication and programming of the FPGA. Three DMA (Direct Memory Access) channels are able to send data back to either the Real-Time Controller or the host computer.

(31)

Figure 15: CompactRIO chassi

5.3 Real-Time Controller

The following text explains the CompactRIOs 9022 Real-Time controller and the main features. The Real-Time Controller shown in figure 16 deliver power to the compactRIO chassi and is mounted together with the chassi case. Com- munication with the chassi and its FPGA goes through a PCI bus. This enables the programming from the host computer through the controller and into the FPGA.

Ethernet and serial ports makes the connection via TCP/IP and serial protocols for data transfer back and forth between the host computer. The interior of the controller has 2 GB nonvolatile memory and additional 256 MB DDR2 memory for program storage and data logging. Execution of programs are performed with the embedded 533 MHz real-time processor. In this case, the Real-Time Controllers purpose is to connection to the host computer and to enable pro- gramming of the FPGA.

(32)

Figure 16: Real-Time Controller

5.4 ADC and DAC Modules

For easy signal generation and data acquisition the use of input-output modules is required to work with the Chassi and FPGA. The experimental modules have different objectives depending on signal type to be handled. Mounting the modules directly onto the compact RIO chassis through the D-subminature with 19 pins connection, enables the read or write option from each module.

5.4.1 NI 9205

The NI 9205 module work as an ADC and handles multiple input voltage signals over 32 different channels. Each channel can be modified to work with different ranges from (+/-)200mV, (+/-)1V, (+/-)5V and (+/-)10V. The resolution for the ADC is 16 bits which result in 65536 levels of representation. With a smaller range for the given ADC resolution, the quantization error decreases. Random noise decreases with a smaller nominal range. In case of voltage values that exceed the maximum range of the channel, protection for over-voltage ensures a safety limit at (+/-)30V. When the (+/-)10V is used a minimal over-range of 4 % is available for extra accuracy.

Since the multiplexer is shared, the amount of channels used affects the speed of the conversion. Aggregate sampling rate for the devise is 250kS/s and will be divided be the amount of channels used. Triggering the sampling by the user is also an important feature enabled. In Figure 1, this module represent the ADC block.

5.4.2 NI 9264

The NI 9264 module is a DAC (Digital to Analog Converter) with 16 output channels providing a voltage signal with small current. Each channel has a

(33)

resolution of 16 bits that can produce simultaneous outputs since they contain individual DA converters. The module can convert 25kS/s at maximum for each channel. Maximum output voltage for each channel is, +10.65 and minimum -10.65. Over-voltage at +/-27V can protect the module at 25 degrees Celsius.

This module has only been used to verify if the estimated phase signals, are correct.

5.5 Labview interface

In this application, the visual programming language Labview has been used and the hardware products described above are all specially designed to be compat- ible with the graphical programing language. When programming the FPGA within the CompactRIO chassi, the Labview visual block code has to be trans- formed into something the Xilinx compiler recognizes. This is done through Labview’s own tools and results in block code representation. The compilation through Xilinx result in a HDL representation which can configure the FPGA.

Since Labview and Xilinx compile the source code into a HDL language, it is hard to determine how each block will be represented in LUTs, Flip-flops and DSP48s. In case of large design which requires many pieces of circuitry, it is uncertain how much the resulting compiled version has been optimized in respect to resource sharing. Sharing resources can however be time consum- ing and might affect a time crucial path[Xilinx Synthesis and simulation design guide].

In contrast to MATLAB design, the FPGA can not handle Double precision values and is restricted to a maximum of 32 bits fixed point accuracy. If a mathematical operation within the FPGA has a resulting value that is be- tween representation levels, some accuracy is lost. Performing at the maximum amount of available representation digits is however not optimal, since the usage of LUTs might be unnecessary high. Especially for large designs with lots of mathematical operations.

(34)

6 Implementation

The objective of this chapter is to explain the main features of how to implement a similar Kalman filter design as in chapter 3. With the idea to make it a time and resource efficient design for a FPGA with limited amount of LUTs, Flip- Flops, Multipliers and Memory.

6.1 Design

A FPGA is not designed solely for matrix operations and therefore every matrix operation have been replaced with element-wise mathematical blocks. The rea- son is to utilize the most in terms of parallel processing. Appendix B shows an example of a (2 × 2) matrix multiplication and the amount of blocks required.

To make each new Kalman estimation faster and resource efficient, identity ma- trix and their mathematical operations have been excluded. Matrix A from (11) is a identity matrix and can be neglected as long as the Kalman filter is a one step predictor. Equation 23-24 describes the reduced versions of equation 17-18 without the deterministic A matrix. Since the conclusion from the MATLAB simulation were that Q had to be in a diagonal form to make it stable, the implemented model can be reduced further. The Q matrix only contribution being its diagonal elements thus resulting in only two additions in (23).

P (t + 1 | t) = P (t | t) + Q (23)

K(t) = P (t | t − 1)CT[CP (t | t − 1)CT + R]−1 (24) Figure 18 below shows the Kalman filter design, where the layout follows the Kalman filter flowchart figure 3. Each bubble within the flowchart represent a timed sequence in Labview, executing in the same order, 1-4. See Appendix B for a more detailed design.

Previous iterations values are stored within small memory blocks that can be accessed for the next iteration. Memories have been created to store P (t | t), K(t) and ˆx(t | t). To be able to store and extract these values they can not be in matrix form, therefore each element is stored in a one-dimensional array instead. For row and column vectors, the storage is similar and the following elements are stored in increasing index order.

Figure 17: Memory Storage

(35)
(36)

The only non stationary parameter for this specific Kalman filter is the C vector explained in (10). To recreate this parameter for an infinite amount of time, two pre-programmed memory blocks enables extraction of singular fixed point values. By extracting these values with 50µs interval, two fundamental sinusoid with an amplitude of 1, are created. Thus representing the time varying parameters within the C vector. An example is shown in figure 19. The For loop that surrounds the timed sequence enables this extraction where the For loop iteration decides which address in the memory to access. This concept result in 400 Kalman iterations per period, resulting in 20000 Kalman iterations every second. To ascertain that the timing is correct for extraction, a delay timer determine the operation speed. Recreating one second of a 50 Hz according to (25). Without the delay, the Kalman filter would finish one iteration within approximately 25 − 30µs.

400 (values/period) ∗ 50µs ∗ 50 (periods) = 1 (sec) (25) Within each new iteration, the Kalman filter performs a phase estimate based on a sampled value of the grid signal. This signal comes from the NI 9205 ADC module.

To enable continuous operation, the block code is places within a while loop, taking measurements and estimating the phase until the user stops the appli- cation. Initialization of parameters are done outside the while loop, since they are only required at the first time-step and would otherwise overwrite necessary information.

The signal recreation based on one measured phase from the three phase grid is performed in the same manner as in chapter 3. This makes the input ADC amplitude limited to +/- 1 V to ensure reasonable results on the other two phases. The other two recreated phases (21-22) are handled within the last timed sequence 4. A more detailed version of each timed sequence can be found in Appendix B.

(37)

7 Results obtained with the FPGA implementa- tion

This chapter shows the visual results for a FPGA implemented Kalman filter.

Similar simulations were previously done in MATLAB, chapter 4.

7.1 Experiment details

To repeat a similar experiment as previously done in MATLAB, some mod- ifications to the Kalman design were done. For spectral information of the reference grid voltage and the Kalman estimated phase, the use of First In First Out (FIFO) memories enabled the spectral comparison. This operation was not done inside the FPGA and the data were instead fed back to the (host)computer for analysis in Labview. The following equipment was used to get a simulation of a noise influenced voltage grid.

• By using a low voltage AC generator with variable amplitude and fre- quency, a downscaled grid voltage signal could be simulated. This signal passes the ADC converter(NI 9205). The amplitude were set at 1 volt with a frequency relatively close to 50 Hz.

• To simulate the odd harmonics at exactly 150 Hz, 250 Hz and 350 Hz, some design changes were done inside the FPGA. Using the same method as for the C vector design, additional memories containing sinusoidal signals were created. These sinusoidal signals had the same length and amplitude as the C vector but with more periods. See figure 19 for details regarding how each harmonic is generated.

To be able to change the amplitude of each harmonic, a gain is multiplied with the current value from the extracted harmonic memory. Thus creat- ing a sinusoidal waveform with lower amplitude over time.

These harmonic waveforms were added to the AD converted voltage signal to simulate the resulting harmonic distortion.

• To verify if the reference voltage signal and all three phases were correct, the NI 9264 DAC modules output channels were used and connect to an oscilloscope.

• For the spectrum of reference phase signal and the Kalman estimated phase signal, the whole FIFO data collected during one second was used.

• For the following results, a sampling rate of 20 kHz was used.

• The initial values chosen for the states x1= 0 and x2= 0 similar to the MATLAB simulation.

• The initial error covariance matrix P (0 | 0) was chosen to be a identity matrix.

• In the following figures,the red voltage signal represent the measured grid signal and the corresponding Kalman filtered version is colored yellow.

Blue and Green colored are the additional two phases, recreated based on (21-22). The spectrum figures will only contain the Kalman estimation and the reference voltage signal.

(38)

Figure 19: FPGA Harmonics Generation

7.2 Results

7.2.1 Simulation 1

Figure 20 shows the implemented Kalman filter during operation. The power grid source representation is a low voltage source with a small frequency vari- ation during steady state. In this figure, the Kalman filtered signal is barely visible behind the reference grid measurement. The spectrum figure 21 only contain one phase estimate compared to the noisy grid voltage signal. With the tuning below, the third harmonic can not be removed completely.

Figure 21 also contain additional even harmonics which were not generated consciously and have its origin in the voltage AC generator.

• The process noise related parameter Q =0.000488 0 0 0.000488

 .

• The measurement noise related parameter R = 1.5

• Third harmonic 150 Hz at 5%.

(39)

Figure 20: Steady state frequency variation of a low voltage source with a simulated harmonic in 150 Hz (red). The Kalman estimation (yellow) should follow this low voltage signal and extrapolate additional phases (blue and green).

Figure 21: Spectrum for the steady state voltage signal and its Kalman estimate with the goal to suppress the harmonic present.

7.2.2 Simulation 2

Figure 22 below shows an unreasonable high third harmonic at 40% of the original. The Kalman filter follows the same parameters as previous except for the Q where every diagonal element have replaced with the smallest fixed point

(40)

value available 3.05 ∗ 10−6 for this FPGA application. The Kalman filter has a hard time to attenuate this large harmonic completely and it can be seen in both figure 22 and 23. By looking closely at the spectrum in figure 23 the even harmonics are present.

• Q =3.05 ∗ 10−6 0 0 3.05 ∗ 10−6

 .

• R = 1.5

• Third harmonic 150 Hz at 40%.

Figure 22: A Third harmonic at 40% is present in the measured low voltage signal (red). The Kalman filtered version of the same signal with the goal to suppress the harmonic is colored yellow.

(41)

Figure 23: Spectrum of the measured signal and the Kalman estimate given a simulated large harmonic distortion at 40%.

7.2.3 Simulation 3

Simulation 3 repeats a similar simulation as previously done in MATLAB with a larger frequency deviation. Figure 24 shows decreasing phase of approximately 47 Hz. Harmonic noise in the third harmonic has been reduced in this case. To make the Kalman estimate follow the reference grid voltage, the tuning for the Q matrix is much larger than before.

Even harmonics are present the measured voltage signal as well.

• Q =0.01 0 0 0.01

 .

• R = 1.5

• Third harmonic 150 Hz at 2.5%.

(42)

Figure 24: Decreasing phase simulation showing the performance when the frequency deviates with -3 Hz from 50 Hz.

Figure 25: Spectrum of the frequency deviating signal and the Kalman estima- tion

(43)

7.2.4 Simulation 4

Simulation 4 shows the constant increased phase of approximately 53 Hz. Har- monic noise is the same for as in previous simulation. The tuning parameters are also the same for the resulting figures 26 and 27. Figure 27 contain the even harmonics not consciously generated.

• Q =0.01 0 0 0.01

 .

• R = 1.5

• Third harmonic 150 Hz at 2.5%.

Figure 26: Increasing phase simulation showing the performance when the fre- quency deviates with 3 Hz from 50 Hz.

References

Related documents

Då målet med palliativ vård är att främja patienters livskvalitet i livets slutskede kan det vara av värde för vårdpersonal att veta vad som har inverkan på

The contributions are, a complete model structure for a heavy-duty diesel engine equipped with a fixed geometry turbocharger and inlet throttle, and optimal control trajec- tories for

I ett bredare perspektiv kan en oklarhet om vilka riktlinjer och restriktioner som finns på datahantering i SAR-sjöräddning även innebära konsekvenser för

A simple baseline tracker is used as a starting point for this work and the goal is to modify it using image information in the data association step.. Therefore, other gen-

Again, the neck pain risk we found from rotation in a group of forklift operators (OR 3.9, Table 2 ) seems reason- able given that forklift operators are more exposed to un-

Our horizon estimation method incorporates a probabilistic Hough voting [5] scheme where edge pixels on the image are weighted in the voting, based on how likely they are to be

However, considering the interviewed Somali children’s beliefs and attitudes, knowledge of their language is good for their ethnic identity and belonging, which may correlate

Species with larvae developing in tree hollows (= tree-hollow species), nests from birds or other animals in tree hollows (= nest.. species), or rotten wood on the trunk (with rot