Kalman filter to measure position and speed of a linear actuator

6
Kalman Filter to Measure Position and Speed of a Linear Actuator Jo¨ el Maridor, Miroslav Markovic, Yves Perriard Ecole Polytechnique F´ ed´ erale de Lausanne (EPFL) Integrated Actuators Laboratory (LAI) CH - 2002 Neuchˆ atel - Switzerland Email: joel.maridor@epfl.ch Abstract—This paper presents a method to dynamically filter the position and the speed of a linear actuator during its closing. A previous paper presented position detection without external sensor but, by simply deriving it, the corresponding speed was not usable because of the noise. The presented method describes a quick way to apply an adapted Kalman filter to effectively filter those signals without filling the DSP memory with their past values. I. I NTRODUCTION Industrial contactors establish and interrupt currents by contacting the fixed and the moving part of a linear actuator [1]. The new generation of contactors will use linear actuators with the position control, which allows following an optimized speed reference [2]. Because of the cost, this control has to be sensorless [3] and the only usable signals are the actuator winding voltage and current. The winding impedance has a resonance frequency that is much related to the position of the actuator moving part. A sinusoidal scan voltage is superposed to the main voltage (which is applied to close or open the contactor). Its frequency is close to the resonant one and therefore it is possible to measure the resulting scan current amplitude that allows position detection [4]. However, the position thus measured is contaminated by various noises and it is impossible to directly obtain the speed by deriving this position. Consequently, posi- tion and speed have to be filtered. Kalman filter algorithm can be very effective for filtering signal in order to regulate speed [5]. This paper will present a method to filter position and speed quickly and simply enough to be implemented in a DSP. The originality of the paper is an adaptation of Kalman filter for the case of time-limited computation. It also describes the method to determine the Kalman factors that allow the best filtering using signal reference. II. PROBLEM DEFINITION Fig. 1 shows: the position reference x ref which should be the same as the real position x, if the regulation works properly. The external offset such as voltage drop, temperature or contact wear can generate the unde- sired difference between those two positions, as in the presented case. the measured noisy position x meas . the real position x, which is the measured noisy position x meas without the noise n (x meas = x +n). 0 0.005 0.01 0.015 0.02 0.025 0.03 0 2 4 6 8 10 12 14 time [s] position [mm] measure, x meas position reference, x ref real position, x Fig. 1. Artificial noisy position versus time Fig. 2 shows the three corresponding speeds (s ref , s meas and s) obtained by derivating the three positions (x ref , x meas and x). It is obvious that the measured speed is very unstable and completely unusable. It is important to point out that all these signals are generated artificially but well correspond to the real 2011 IEEE International Electric Machines & Drives Conference (IEMDC) 978-1-4577-0061-3/11/$26.00 ©2011 IEEE 330

Transcript of Kalman filter to measure position and speed of a linear actuator

Kalman Filter to Measure Position and Speed of aLinear Actuator

Joel Maridor, Miroslav Markovic, Yves PerriardEcole Polytechnique Federale de Lausanne (EPFL)

Integrated Actuators Laboratory (LAI)CH - 2002 Neuchatel - Switzerland

Email: [email protected]

Abstract—This paper presents a method to dynamicallyfilter the position and the speed of a linear actuator duringits closing. A previous paper presented position detectionwithout external sensor but, by simply deriving it, thecorresponding speed was not usable because of the noise.The presented method describes a quick way to applyan adapted Kalman filter to effectively filter those signalswithout filling the DSP memory with their past values.

I. INTRODUCTION

Industrial contactors establish and interrupt currentsby contacting the fixed and the moving part of a linearactuator [1]. The new generation of contactors will uselinear actuators with the position control, which allowsfollowing an optimized speed reference [2]. Because ofthe cost, this control has to be sensorless [3] and theonly usable signals are the actuator winding voltage andcurrent.

The winding impedance has a resonance frequencythat is much related to the position of the actuatormoving part. A sinusoidal scan voltage is superposedto the main voltage (which is applied to close or openthe contactor). Its frequency is close to the resonant oneand therefore it is possible to measure the resulting scancurrent amplitude that allows position detection [4].

However, the position thus measured is contaminatedby various noises and it is impossible to directly obtainthe speed by deriving this position. Consequently, posi-tion and speed have to be filtered.

Kalman filter algorithm can be very effective forfiltering signal in order to regulate speed [5]. This paperwill present a method to filter position and speed quicklyand simply enough to be implemented in a DSP.

The originality of the paper is an adaptation of Kalmanfilter for the case of time-limited computation. It alsodescribes the method to determine the Kalman factorsthat allow the best filtering using signal reference.

II. PROBLEM DEFINITION

Fig. 1 shows:

• the position reference xref which should be thesame as the real position x, if the regulation worksproperly. The external offset such as voltage drop,temperature or contact wear can generate the unde-sired difference between those two positions, as inthe presented case.

• the measured noisy position xmeas.• the real position x, which is the measured noisy

position xmeas without the noise n (xmeas = x+n).

0 0.005 0.01 0.015 0.02 0.025 0.030

2

4

6

8

10

12

14

time [s]

po

sitio

n [

mm

]

measure, xmeas

position reference, xref

real position, x

Fig. 1. Artificial noisy position versus time

Fig. 2 shows the three corresponding speeds (sref ,smeas and s) obtained by derivating the three positions(xref , xmeas and x). It is obvious that the measuredspeed is very unstable and completely unusable.

It is important to point out that all these signals aregenerated artificially but well correspond to the real

2011 IEEE International Electric Machines & Drives Conference (IEMDC)

978-1-4577-0061-3/11/$26.00 ©2011 IEEE 330

0 0.005 0.01 0.015 0.02 0.025 0.03−4

−3

−2

−1

0

1

2

3

4

time [s]

speed [m

/s]

measured speed, smeas

speed reference, sref

real speed, s

Fig. 2. Speed versus time

system. The noise is generated by:

n = ε((R1 − 1) +R2 sin(2πF1t) +R3 sin(2πF2t)) (1)

ε is the amplitude of the noise. R1, R2 and R3

are random numbers between 0 and 1. F1 and F2

are frequencies of two sinusoidal components of noise.They can be varied in order to assess the impact ofdifferent noise levels. In this example, F1 = 1250 Hzand F2 = 6250 Hz.

In addition, an offset of 0.025 m/s is added betweens and sref , which explains the difference between x andxref .

The DSP works at 40 kHz and the contactor is closingin 30 ms. It means that there are 1200 points of positionevaluation. A good way to filter could be to sample thesepoints. Fig. 3 shows position sampled at every 32 points,xf . Fig. 4 shows that the corresponding speed sf is stillnot usable.

III. ADAPTATION OF KALMAN FILTER

A. Kalman filter theory

The discrete Kalman filter algorithm is described in[6]. Its time equations are:

x−k = Axk−1 +Buk−1 (2)

P−k = APk−1A

T +Q (3)

and its update equations are:

Kk = P−k H

T (HP−k H

T +R)−1 (4)

xk = xk−1 +Kk(xmeas,k −Hxk−1) (5)

Pk = (1−KkH)P−k (6)

0 0.005 0.01 0.015 0.02 0.025 0.030

2

4

6

8

10

12

14

time [s]

po

sitio

n [

mm

]

filtered position (32 pts), xf

position reference, xref

real position, x

Fig. 3. Filtered speed on 32 points

0 0.005 0.01 0.015 0.02 0.025 0.03−4

−3

−2

−1

0

1

2

3

4

time [s]

speed [m

/s]

speed for filtered position (32 pts), sf

real speed, s

Fig. 4. Speed after deriving the signal from Fig. 3

The parameter A relates the actual state (k) to theprecedent one (k− 1) without any perturbation or noise.The parameter B relates the control input u to the state x.xmeas,k is the measured signal and H relates the noise tothe measurement. Q and R are respectively the processnoise covariance and the measurement noise covariance.x−k is the a priori state estimation and xk the a

posteriori state estimation. P−k and Pk are respectively

the a priori and a posteriori estimate error covariance. Kis the gain that minimizes Pk.

B. Adapted Kalman filter

It is difficult to implement these equations in the DSP,because they are too time consuming for our application.An adaptation of the method applies to filter a random

331

constant [6]. In this case, (2)-(6) become:

x−k = xk−1 (7)

P−k = Pk−1 +Q (8)

Kk =P−k

P−k +R

(9)

xk = xk−1 +Kk(xmeas,k − xk−1) (10)

Pk = (1−Kk)P−k (11)

As an example, Fig. 5 shows the position filteredwith the adapted Kalman filter and a measured constantposition (x = 5 mm, R = 1 and Q = 10−5). We see thatthe signal is well filtered.

C. Adapted Kalman filter applied to actuator signals

In our application, the position is not constant butvaries with time. Fig. 6 shows that the filter is noteffective anymore. This problem is solved by correctingx−k with the slope of the position reference xref . It meansthat the position reference is used to help filtering. Thus,(7) is replaced by:

x−k = xk−1 + (−xref,k−1 + xref,k) (12)

0 0.005 0.01 0.015 0.02 0.025 0.030

2

4

6

8

10

12

14

16

Iteration

po

sitio

n [

mm

]

position reference, xref

measure, xmeas

real position, x

filtered position with Kalman, xk

Fig. 5. Filtering of a random constant using the adapted Kalmanfilter (x = 5 mm)

Fig. 7 shows the resulting filtered speed. The gainK is evaluated at each step and Fig. 8 shows its valueversus time. This value of K is calculated in (9) whichconsumes a lot of calculation lines when implementedin the DSP mainly because of the division.

D. Kalman filter with a constant K

In order to further reduce the calculation time, weconsequently tried to use a constant K and Fig. 9 shows

0 0.005 0.01 0.015 0.02 0.025 0.030

2

4

6

8

10

12

14

16

Iteration

po

sitio

n [

mm

]

position reference, xref

measure, xmeas

real position, x

filtered position with Kalman, xk

Fig. 6. Filtering of a non-constant position using the adapted Kalmanfilter

0 0.005 0.01 0.015 0.02 0.025 0.030

2

4

6

8

10

12

14

16

Iteration

po

sitio

n [

mm

]

position reference, xref

measure, xmeas

real position, x

filtered position with Kalman, xk

Fig. 7. Filter with slope correction

0 0.005 0.01 0.015 0.02 0.025 0.030

0.001

0.002

0.003

0.004

0.005

0.006

0.007

0.008

0.009

0.01

time [s]

gain

[−

]

K

Fig. 8. Gain K versus time

the filtering when K is a constant value. In order tochoose its optimal value, we search the K that minimizes

332

the difference between the filtered position xk and thereal position x using the least square method (Fig. 10),which gives finally K = 106 · 10−3 [7].

0 0.005 0.01 0.015 0.02 0.025 0.030

2

4

6

8

10

12

14

16

Iteration

po

sitio

n [

mm

]

position reference, xref

measure, xmeas

real position, x

filtered position with Kalman, xk

Fig. 9. Adapted Kalman filter with constant K

0 0.02 0.04 0.06 0.08 0.10

0.5

1

1.5

2

2.5

3x 10

−4

gain K [−]

lea

st

sq

ua

re r

esu

lt

Fig. 10. Determination of K with the least square method

Fig. 11 shows that the resulting speed sk is muchmore stable than sf from Fig. 4. We apply a secondtime the same Kalman filter algorithm to the speed (thecorresponding optimal value is Ks = 33 · 10−3). It meansthat we use a Kalman filter on the speed derived fromxk to obtain the filtered speed skk.

Fig. 12 shows that the resulting filtered speed is nowusable. We compare it to the speed sff filtered by doingthe average on 32 points for position and speed.

IV. PRACTICAL EXPLANATION

Fig. 13 explains how the presented method workspractically. First, x−k is set to the first value of thereference xref (here, x−k1 = −0.004, point A1). Then,

0 0.005 0.01 0.015 0.02 0.025 0.03−4

−3

−2

−1

0

1

2

3

4

time [s]

speed [m

/s]

speed for filtered position (32 pts), sf

speed for filtered position with Kalman, sk

real speed, s

Fig. 11. Speed derivation after filtering

0 0.005 0.01 0.015 0.02 0.025 0.03−1.5

−1

−0.5

0

0.5

1

1.5

time [s]

speed [m

/s]

real speed, s

filtered speed on filtered position (32 pts), sff

filtered speed on filtered position with Kalman, skk

Fig. 12. Comparison between filters

0 1 2 3 4 5 6 7 8

x 10−4

−15

−10

−5

0

5x 10

−3

time [s]

sp

ee

d [

m/s

]

reference (xref

)

noisy value (xmeas

)

x−

k

filtered value (xk)

B1

A1 B2

B3B4A2

A3

A4

Fig. 13. Kalman filtering explanation

the error E between the noisy value xmeas and xk is

333

calculated:

E1 = xmeas,1 − x−k1= −0.01− (−0.004)

= −0.006 (13)

In order to illustrate this example we choose the valueK = 0.3 and consequently the filtered value x (point B1)is:

xk1 = x−k1 +K ·E1

= −0.004 + 0.3 · (−0.006)

= −0.0052 (14)

Then, the second value of x− is a correction of x withthe slope of the reference (point A2):

x−k2 = xk1 − xref1 + xref2

= −0.0052− (−0.004) + (−0.0065)

= −0.0077 (15)

This process is repeated at each step to filter the signalproperly. The array B1, B2, B3. . . will form the filteredsignal.

V. REAL CONTACTOR MEASUREMENT

A. Interpretation of factor K

Factor K (0 ≤ K ≤ 1) is actually a coefficient thatdetermines the proportions of reference and mesurementthat the filter takes into account. K = 1 means that themeasured signal is not filtered at all, whereas K = 0means that the measured signal does not have anyinfluence on the result. The optimal value of K will bedetermined a follow.

B. Determination of the Kalman filtering factors Kx andKs

In order to determine the Kalman factors for filteringposition (Kx) and speed (Ks), we have simulated thenoise measured on position on the real test bench. Then,we have minimized the difference between the filteredspeed sk and the speed reference sref using the leastsquare method for both K.

If the least square method is directly performed on thenoisy signal xmeas, it appears that the best way to filterthe signal is to set both Kx and Ks to 0. But, in that case,the system will not be able to detect any offset of speedthat can appear for one reason or another (unexpectedtemperature rise, spring or contact wear).

In order to be able to detect a speed offset of 10%arround the speed reference, two more speed signals that

are 10% below (s2) and above (s3) the reference (s =sref ) are introduced as (Fig. 14):

s2 = 0.9s = 0.9dx

dt(16)

s3 = 1.1s = 1.1dx

dt(17)

0 0.005 0.01 0.015 0.02 0.025 0.03 0.035

−0.5

−0.4

−0.3

−0.2

−0.1

0

time [s]

speed [m

/s]

speeds without noise s, s2 and s

3

speed reference

filtered speeds sk, s

k2 and s

k3

Fig. 14. 10% speed offset arround the reference

The corresponding positions are:

xmeas =

∫sdt+ n (18)

xmeas2 =

∫s2dt+ n (19)

xmeas3 =

∫s3dt+ n (20)

The 3 signals (xmeas, xmeas2 and xmeas3) are filteredwith the Kalman method to obtain xk, xk2 and xk3. Thespeeds smeas, smeas2 and smeas3 are derivated from thosefiltered position. They are then filtered to obtain sk, sk2and sk3. Factors Kx and Ks are calculated with the leastsquare method that is applied to all three speeds in orderto minimize F :

F =∑

[(s− sk)2 + (s2 − sk2)

2 + (s3 − sk3)2] (21)

Fig. 15 shows that the optimal values are Kx =5.5 · 10−3 and Ks = 4.5 · 10−3.

C. Results

We now apply these Kalman factors to the industrialcontactor. Figs. 16 and 17 show the result before andafter Kalman filtering.

There are still some fluctuations but the speed iscompletely usable and it is possible to be regulated by

334

least squares method

Ks

Kx

2 4 6 8 10 12 14

x 10−3

1

2

3

4

5

6

7

8

9

10x 10

−3

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

Fig. 15. Least square method for determination of Kx and Ks

0.005 0.01 0.015 0.02−1000

−800

−600

−400

−200

0

200

400

600

time [s]

speed [m

/s]

speed measure (external sensor)

speed estimation without Kalman

speed reference

Fig. 16. Test bench measurement without filter

0.005 0.01 0.015 0.02−600

−500

−400

−300

−200

−100

0

100

200

time [s]

speed [m

/s]

speed measure (external sensor)

speed estimation with Kalman

speed reference

Fig. 17. Test bench measurement with Kalman filter

adapting the current reference if, for any reason, thisspeed deviates from the reference.

VI. CONCLUSION

The originality of the presented method is to showan effective way to implement the position and speedfilter in DSP. Kalman filters can be very time consumingin calculation but the presented method is very simpleand quick enough for various transient noisy signalsthat are a priori defined. It is possible to do real-timefiltering in order to perform regulation without fillingthe DSP memory with the past values of the signal.The demonstration is made on an artificially built noisysignals. Finally, we validated the method by showingits effectiveness with real results measured on the testbench.

REFERENCES

[1] X. Morera and A. Espinosa, “Modeling of contact bounce of accontactor,” in Electrical Machines and Systems, 2001. ICEMS2001. Proceedings of the Fifth International Conference on,vol. 1, 2001, pp. 174–177 vol.1.

[2] J. Maridor, N. Katic, Y. Perriard, and D. Ladas, “Sensorlessposition detection of a linear actuator using the resonancefrequency,” in Electrical Machines and Systems, 2009. ICEMS2009. International Conference on, 2009, pp. 1–6.

[3] M. Rahman, N. Cheung, and K. W. Lim, “Position estimationin solenoid actuators,” Industry Applications, IEEE Transactionson, vol. 32, no. 3, pp. 552–559, 1996.

[4] J. Maridor, M. Markovic, Y. Perriard, and D. Ladas, “Optimiza-tion design of a linear actuator using a genetic algorithm,” inElectric Machines and Drives Conference, 2009. IEMDC ’09.IEEE International, 2009, pp. 1776–1781.

[5] D. Bourlis and J. Bleijs, “A wind speed estimation method usingadaptive kalman filtering for a variable speed stall regulatedwind turbine,” in 2010 IEEE 11th International Conference onProbabilistic Methods Applied to Power Systems, PMAPS 2010,2010, pp. 89–94.

[6] G. Welch and G. Bishop, “An introduction to the kalman filter,”University of North Carolina at Chapel Hill, july 2006.

[7] T. Nakano, K. Nagata, M. Yamada, and K. Magatani, “Appli-cation of least square method for muscular strength estimationin hand motion recognition using surface emg,” in Engineeringin Medicine and Biology Society, 2009. EMBC 2009., 2009, pp.2655–2658.

335