Kalman Filter and MPU6050 Sensor in Positioning Issue for one-axis Solar Tracking System

HỘI NGHỊ KHOA HỌC TOÀN QUỐC VỀ CƠ KHÍ – ĐIỆN – TỰ ĐỘNG HÓA (MEAE2021) Kalman Filter and MPU6050 Sensor in Positioning Issue for one-axis Solar Tracking System Dao Hieu 1,*, Khong Cao Phong 1 1 Faculty of Electro-mechanics, Hanoi university of Mining and Geology, Hanoi, Viet nam, e-mail: daohieu@humg.edu.vn ARTICLE INFO ABSTRACT Article history: th Gyroscope and accelerometer are widely used in applications that have to Received 15 Jun 2021 estimate the motion of object

pdf7 trang | Chia sẻ: Tài Huệ | Ngày: 16/02/2024 | Lượt xem: 233 | Lượt tải: 0download
Tóm tắt tài liệu Kalman Filter and MPU6050 Sensor in Positioning Issue for one-axis Solar Tracking System, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
t. The motion, velocity and position of an Accepted 16th Aug 2021 object are determined based on the principle of integrating one or two Available online 19th Dec 2021 layers from the acceleration. That causes cumulative errors in the results Keywords: to increase rapidly over time due to noise of sensors. Therefore, noise is a big issue in control systems. Theories and experiments have proved that MPU6050, Solar Tracking, noise filter is a solution to solve the issue. Kalman filter is the most common filter which is suitable to reduce sensor noise problem. This paper Kalman filter, accelerometer, introduces the process of designing a Kalman filter to improve the gyro, gyroscope. accuracy of MPU6050 data which is used to determine motion trajectory and position of a solar tracking system. Quality of unfiltered data, filtered data and the simulation, testing results will be detailed in the article. Copyright © 2021 Hanoi University of Mining and Geology. All rights reserved. 1. Introduction light source in real time. With these tracking systems, the efficiency can be improved by 20- The gradual depletion of fossil fuels (oil, coal, 30% compared to fixing systems (J.Rizk et al ...) and the disasters that hydropower and 2008 and K.Tseng et al 2019). The solar tracking nuclear power hide are driving the global energy system has two types: track on one axis and track trend towards renewable energy sources. And on two axes. there, the supply from solar energy is a big part (Nadarajah et al 2016). Photovoltaic cells are With a moving mechanical system, tracking used to convert energy from sunlight into and monitoring requirements are indispensable. electrical energy. They are integrated called That contributes to ensure the system works solar panels. The efficiency is the highest when correctly and efficiently. The most importance the surface of the panel and the direction of light parameter of the system is the position form a certain angle (Frank Dimroth et al 2007). (orientation) of the panel. This information and Due to the relative displacement of the earth and the direction of the light is the basis for tracking the sun, in each region of the earth, at each time control (East-West rotating). of the year, the sun's orbit is different (Sidek et al In this study, the authors employ a widely 2014). Therefore, tracking systems are used to used and low-cost sensor to determine the drive the solar panels to the position of the best position for one-axis solar tracking system. It is 200 HỘI NGHỊ KHOA HỌC TOÀN QUỐC VỀ CƠ KHÍ – ĐIỆN – TỰ ĐỘNG HÓA (MEAE2021) an integrated sensor that includes a gyroscope and 3-axis accelerometer. The 3-axis accelerometer is a type of sensor specialized in determining position systems for moving objects in space. Due to its very high mechanical sensitivity, its measurement signal have a lot of noise. A Kalman filter is used to accurately determine measurement and control results. The processing, data filtering and results are presented in detail in the following sections. 2. MPU6050 sensor in solar tracking system The sensor MPU6050 is proposed in this study. This is a low-cost sensor, which is widely used in applications to determine the position of objects in space. The sensor is integrated on the where the sensor blue board (Figure 24). This board can is located communicate with a controller via I2C communication standard by SCL and SDA pins. It is equipped with a gyro measuring angular Figure 36. The MPU6050 sensor is fixed on the velocity around 3 axes, and an accelerometer test solar tracking system measuring linear acceleration in the same axes (InvenSense Inc 2013). 2.1. The gyroscope Gyro works based on the direction of gravity and the earth’s magnetic field. It is the natural sensor to use for estimating an angle (as it measures the derivative of an angle). It has some problems. The gyro measurements can give us angles relative to initial orientation, then we can simply VCC 3-5 Vdc in calculate the angular velocity. In many GND Ground applications, we are interested in the absolute SCL, SDA I2C Bus interface angle of the object, such as knowing if the object XDA, XCL I2C Bus for external sensor ADD I2C Slave Address (High/Low) is standing straight up or not. In addition, the INT Interrupt digital output sensor has bias errors, meaning that the angle Figure 35. MPU 6050 board (module) estimate will drift. Experients showed that any bias in the angular velocity measurement will The measurements are placed on the test lead to a growing error in the angle estimate solar tracking system as indicated in Figure 36. (Lund university 2018). In this application, the The sensor is fixed on the rotating shaft (driven tracking system only rotates in one axis. by motor), which rotates the solar panel to an Consequently, we are only interested in angle according to the direction of sunlight. rotations around the x-axis (rotations in the y-z plane) and thus only use one of the gyro measurements . 201 HỘI NGHỊ KHOA HỌC TOÀN QUỐC VỀ CƠ KHÍ – ĐIỆN – TỰ ĐỘNG HÓA (MEAE2021) 2.2. The accelerometer developed extensively (Youngjoo Kim et al 2018; The accelerometer might seem unrelated to and Phạm Duy Dưởng 2019) and is incorporated the orientation of the device, as it measures the in many different applications (Haykin 2001; Lê three linear accelerations of the object. However, Ngọc Duy et al 2018; and Trịnh Tuấn Dương the acceleration is measured relative to free-fall, 2019). meaning that when the device is kept still, there The Kalman filter uses discrete-time should be an acceleration of magnitude modeling to estimate the states of a system using 2 2 2 2 a linear stochastic equation (Kalman 1960): √푎푥 + 푎푦 + 푎푧 = 9.8 푚/푠 . The way this magnitude is distributed on the three body-fixed 푥푘 = 퐹푥푘−1 + 퐵푢푘−1 + 푤푘−1 (1) accelerations ax(t), ay(t) and az(t) will give us In addition, at the time k, it is possible to exactly information about the absolute orientation. In measure and observe the state of the system by practice the tracking system is never completely some method. It is represented by a linear still when balancing, because of the effects of equation: wind on the solar panels. So that, ay and az will always contain parts that come from actual 푧푘 = 퐻푥푘 + 푣푘 (2) movements, which will influence the computed Here: F is the transition matrix, it is applied to angle, i.e., there are noises on the angle estimate. the previous state x ; B is the input control Another problem is that the accelerometer can k-1 matrix, it is applied to the control vector u ; H is have slant states along with the solar panel, k the observation matrix, it converts the measured which will give us a bias in the accelerometer state into the observed state; w and v are two signal (Lund university 2018). k k random variable vectors representing the 2.3. Combine accelerometer and gyro to reduce system noise and the measurement noise, they noise were assumed to follow Gauss distribution with When the object moves, the gyro gives the mean value is 0 and covariance matrices are Q result with a smaller error than the and R ( wk ~ N(0,Qk) ; vk ~ N(0,Rk) ). accelerometer. When the object is stopped, the The matrices Q, R, F, H can be changed over value of the gyro is not as stable as the time (according to step k), but here, we assume accelerometer. In applications, that they do not that they are constant to make the calculation need high accuracy of measurements, low speed more convenient. response and allow large control errors, we often use a combination of both these sensors. Tests The Kalman filter consists of two processes: and experiments show that, the percentages of 1 – estimate prior state; 2 – based on the two sensors can vary depending on specific measurement results to correct the prediction. system conditions. Estimate prior state 3. Processing data by Kalman filter Estimate prior state is the process for 3.1. Kalman filter estimating a prior state value and a prior The Kalman filter was introduced in 1960 by covariance matrix. We must first initialize the R.E. Kalman (Kalman 1960). Later, it is re- initial value of the estimated posterior state introduced by a other documents (Greg Welch et 푥̂푘−1|푘 , and error correlation matrix Pk-1|k. The al 1997; and Simon Haykin 2001). Today, it is 202 HỘI NGHỊ KHOA HỌC TOÀN QUỐC VỀ CƠ KHÍ – ĐIỆN – TỰ ĐỘNG HÓA (MEAE2021) process of predicting the prior state and prior the smallest amplitude of variation of the covariance matrix is determined as follows: measurement result (when not using the Kalman algorithm, it was determined by experiment). In 푥̂ = 퐹푥̂ + 퐵푢 (3) 푘|푘−1 푘−1|푘 푘 which, the Gyro is error-corrected by the bias 푇 determined from the initial 1000 measurements 푃푘|푘−1 = 퐹푃푘−1|푘퐹 + 푄 (4) performed when the MPU is stability. The final Here: 푥̂푘|푘−1 is the prior state estimated at time result is the average of 50 consecutive results. In k; 푥̂푘−1|푘 is the posterior state estimated at time addition, after a certain period, the MPU is soft k-1; Pk|k-1 is the prior error correlation matrix; reset and reconfigured to increase the stability of and Pk-1|k is the posterior error correlation the sensor, and to reduce measurement errors. matrix. This processing algorithm is depicted in Figure 37. Correction of estimate The data is recorded by the CPU and sent to Correction of estimate is the process based computer. The system is tested in three different on the measurement value to correct the prior modes: When the system is stable at a certain estimate, thereby getting the correct posterior angle; When the system moves from small angle estimate. This result is the output of Kalman to large angle; and When the system moves from filter. The estimate process is done as follows: a large angle to a small angle. The measurement results show that the data still has errors and 푥̂푘|푘 = 푥̂푘|푘−1 + 퐾푘 ∗ (푧푘 − 퐻 ∗ 푥̂푘|푘−1) (5) oscillation (Figure 38). 푇 푇 −1 퐾푘 = 푃푘|푘−1퐻 (퐻푃푘|푘−1퐻 + 푅) (6) Start 푃푘|푘 = (퐼 − 퐾푘퐻)푃푘|푘−1 (7) Init, config MPU Here: Kk is the gain of Kalman filter, it is changed for each estimate of k and is chosen so that the Determine correlation of the posterior estimate error is Gyro_offset minimal; I is the unit matrix; 푥̂푘|푘 is the estimatex Time to read posterior state at time k, and also is the output data Time++ value of the Kalman filter. Get Gyro_Angle 3.2. Read and pre-process MPU6050’s data Time to Get Accel_Angle reset This study uses microcontroller Pic16f1938 to connect and read data from MPU6050 via I2C Sum=Sum + 0.8Gyro + 0.2Accel Reset communication (Microchip 2011). This MPU microcontroller is also the center process unit Count=50 (CPU) to control the tracking system. The Count++ Angle=Sum/50 selected MPU6050 address is the high address (InvenSense Inc 2013). Because of the track Count=0, Sum=0 system is particularly rotate around one-axis, so the x-axis is select and the system move in y-z Figure 37. Algorithm for reading and pre- plane. Data is pre-processed by combining the processing MPU6050’s data measurement data of Gyro and Accelerometer at the respective rate of 80%-20%. This ratio gives 203 HỘI NGHỊ KHOA HỌC TOÀN QUỐC VỀ CƠ KHÍ – ĐIỆN – TỰ ĐỘNG HÓA (MEAE2021) in the overall results. When the system is stable at an angle, the measurement results oscillate around the stable corner point (Figure 38a). When the system moves from a small angle to a large angle, the measurement results have increased trend, but lower (smaller) than desired (Figure 38b). When the system moves from a large angle to a small angle, the measurement results have also increased trend, but slower (larger) than desired (Figure 38c). (a) From that reason, The authors have continued to use the Kalman filter towards better stability. 3.3. Kalman filter for data and result Pre-processing data based on proportional sum of gyro and accelerometer measurement results did not meet the requirements. Therefore, these data are used to build Kalman filter on Matlab2013 software. The filter construction process is depicted in Figure 39. Begin (b) Init parameters for system Create Kalman filter parameters Load data N Y i < endPoint True(i) GyroMeasure(i) AccelMeasure(i) (c) Plot graphs Figure 38. Pre-processed data graph is plotted of data Kalman filter: by Matlab2013 uk = gyroMeask1; zk = accelMeask1; xk1Minus = phi * xk + psi * uk; End pk1Minus = phi * pk * phi' +0; The characteristics in Figure 4 indicate that, S = H * pk1Minus * H' + R; K = pk1Minus * H' + inv(S); even though, the measured value has been xk1 = xk1Minus + K*(zk - H*xk1Minus); processed to reduce noise by combining multiple pk1 = (eye(2,2) - K*H)*pk1Minus; methods (summarizing the results of the gyro and accelerometer, averaging of multiple Figure 39. Building Kalman filter on Matlab results). However, the results are still misleading. The noise still appears, sometimes The processing of building Kalman filter had there are some large noises that make big falses selected R = 0.01, the matrices Q = [0.00001 0 0 204 HỘI NGHỊ KHOA HỌC TOÀN QUỐC VỀ CƠ KHÍ – ĐIỆN – TỰ ĐỘNG HÓA (MEAE2021) 0]; and H = [0.8 0]. Following that, the system. Experiments show that, the allowable characteristic that describes the data after limits can be up to +-2 degrees, which is the error filtering is the blue line. It follows the desired value of mechanical system. The code segment characteristic (the green line) and has a much describing Kalman filter in the Pic16f1938 smaller error than the pre-processing data (the microcontroller is shown in Figure 41. red line) (Figure 40). float32 Kalman(float32 newAngle, float32 newRate) { //angle = X_Raw_Gyro_Angle; rate = newRate - bias; angle += dt * rate; P_00 += dt * ( dt*P_11 - P_10 - P_01 + Q_angle); P_01 -= dt * P_11; P_10 -= dt * P_11; P_11 += Q_bias * dt; S = P_00 + R_measure; K_0 = P_00 / S; K_1 = P_10 / S; y = newAngle - angle; angle += K_0 * y; bias += K_1 * y; P_00 -= K_0 * P_00; P_01 -= K_0 * P_01; P_10 -= K_1 * P_00; P_11 -= K_1 * P_01; } Figure 41. Kalman code in CPU Pic16f1938 4. Conclusion This paper presents the method and process of building Kalman filter applied to MPU6050 sensor data processing in 1-axis solar tracking test system. Simulation and testing results have demonstrated the quality of the designed Kalman filter. Responses and errors are completely within the allowable limits of the test Figure 40. Data graph with Kalman filter system. The test results also show that, even with From the designed Kalman filter in Matlab, systems that do not need high accuracy, and the selected coefficients and filters have been set quick respond such as solar tracking systems, on the Pic microcontroller (CPU). Testing results the measurement data of the accelerometer is for good response, stable measurement still unstable. Therefore, the use of filtering parameters. System control error is +-1 degree, solutions to remove noise is unavoidable. And within the allowable limits of the solar tracking the final optimal solution is still to use the 205 HỘI NGHỊ KHOA HỌC TOÀN QUỐC VỀ CƠ KHÍ – ĐIỆN – TỰ ĐỘNG HÓA (MEAE2021) Kalman filter algorithm. This research is done on R. E. Kalman. (1960). A new approach to linear a small model, under test conditions. With actual filtering and prediction plobems. solar farms, the sources of noisy may be more Transaction of the ASME-Journal of Basic and stronger, so in order to use the MPU6050 Engineering, 82 (Series D): 35-45. sensor, the filter parameters may have to be Sidek M.H.M., Hasan W.Z.W., Ab. Kadir M.Z.A., adjusted to be more suitable. Shafie S., Radzi M.A.M. (2014). Ahmad S.A., Reference Marhaban M.H. GPS based Portable solar axis tracking system using astronomical Paper published in journal equations, 10.1109/ PECON.2014.7062450 Frank Dimroth, Sarah Kurtz. (2007). High- Google Scholar efficiency multijuntion solar cells. MRS Trịnh Tuấn Dương, Nguyễn Ngọc Linh. (2019). Bulletin 32, 230-235(2007). Ứng dụng bộ lọc kalman trong việc xử lý tín https://doi.org/10.1557/mrs2007.27. hiệu thu được từ cảm biến đo nồng bụi Sharp J. Rizk, Y. Chaiko. (2008). Solar tracking system: GP2Y1010AU0F. Tạp chí khoa học và công More efficient use of solar panels. World nghệ, Đại học công nghệ - Đại học quốc gia Hà Academy of Science, Engineering and nội. P-ISSN 1859-3585|E-ISSN 2615-9619. Technology 17 2008. https://tapchikhcn.haui.edu.vn. Book K. Tseng, C. Wang , G. Lin. (2019). "Effect of the Greg Welch, Gary Bishop. (1997). An Sun Elevation for Fixed PV System and introduction to the Kalman Filter. Single-Axis-Tracking PV System," 2019 IEEE Department of Computer Sience, University 6th International Conference on Industrial of North Carolina at Chapel Hill, Chapel Hill, Engineering and Applications (ICIEA), 2019, NC 27599-3175. pp. 805-809, doi: 10.1109/IEA.2019.8714782 InvenSense Inc. (2013). MPU-6000-Datasheet1. https://invensense.tdk.com Lê Ngọc Duy, Phan Đình Hiếu, Nguyễn Anh Tú, Lưu Vũ Hải. (2018). Nghiên cứu lọc thích Lund university. (2018). Angle estimation using nghi-kalman cho cảm biến gia tốc trên xe lăn gyros and accelerometers. điện. Tạp chí khoa học và công nghệ. Số đặc https://www.control.lth.se biệt 2018. Microchip.(2011). Pic16f1938 datasheet. Nadarajah Kannan, Divagar Vakeesan. (2016). Solar energy for future world: A review. devicedoc/40001574c.pdf. Elsevier journal. Simon Haykin. (2001). Kalman filtering & neural 22. networks. John Wiley & Sons, Inc. ISBNs: 0- 471-36998-5 (Hardback); 0-471-22154-6 Phạm Duy Dưởng, Đoàn Quang Vinh. (2019) Xây (Electronic) dựng bộ lọc Kalman mở rộng cho thuật toán định vị quán tính. Tạp chí khoa học và công Youngjoo Kim, Hyochoong Bang. (2018). nghệ Đại học Đà nẵng, Vol 17, No 9,2019. Introduction to Kalman filter and its ISSN 1859-1531. application. IntechOpen, 3.0. 206

Các file đính kèm theo tài liệu này:

  • pdfkalman_filter_and_mpu6050_sensor_in_positioning_issue_for_on.pdf