IMU Application in Measurement of Vehicle Position and Orientation for Controlling a Pan-Tilt Mechanism Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 Mechatronics, Electrical Power, and Vehicular Technology e-ISSN:2088-6985 p-ISSN: 2087-3379 Accreditation Number: 432/Akred-LIPI/P2MI-LIPI/04/2012 www.mevjournal.com Β© 2013 RCEPM - LIPI All rights reserved doi: 10.14203/j.mev.2013.v4.41-50 IMU APPLICATION IN MEASUREMENT OF VEHICLE POSITION AND ORIENTATION FOR CONTROLLING A PAN-TILT MECHANISM Hendri Maja Saputra a, *, Zainal Abidin b, Estiko Rijanto a aResearch Centre for Electrical Power & Mechatronics, Indonesian Institute of Sciences Kampus LIPI, Jl. Sangkuriang, GD. 20, Bandung 40135, Indonesia bFaculty of Mechanical and Aerospace Engineering, Institut Teknologi Bandung Jl Ganesha 10, Bandung 40132, Indonesia Received 19 February 2013; received in revised form 27 March 2013; accepted 27 March 2013 Published online 30 July 2013 Abstract This paper describes a modeling and designing of inertial sensor using Inertial Measurement Unit (IMU) to measure the position and orientation of a vehicle motion. Sensor modeling is used to derive the vehicle attitude models where the sensor is attached while the sensor design is used to obtain the data as the input to control the angles of a pan-tilt mechanism with 2 degrees of freedom. Inertial sensor Phidget Spatial 3/3/3, which is a combination of 3-axis gyroscope, 3-axis accelerometer and 3-axis magnetometer, is used as the research object. Software for reading the sensor was made by using Matlabβ„’. The result shows that the software can be applied to the sensor in the real-time reading process. The sensor readings should consider several things i.e. (a) sampling time should not be less than 32 ms and (b) deviation ratio between measurement noise (r) and process noise (q) for the parameters of Kalman filter is 1:5 (i.e. r = 0.08 and q = 0.4). Keywords: IMU, pan-tilt, gyroscope, accelerometer, magnetometer, Kalman filter. I. INTRODUCTION Two degrees of freedom pan-tilt mechanism requires orientation information of its platform due to movement of the vehicle in which it is fixed [1]. The orientation data can be read by an Inertial Measurement Unit (IMU). In this paper IMU is positioned as a part of Attitude and Heading References System (AHRS) and Inertial Navigation System (INS) as shown in Figure 1 [2]. AHRS can be used in a various applications such as land vehicles (e.g. cars, trains, and mobile robots), ships, and aircraft (eg.UAV [3]). Attitude modeling process in fact is quite complicated due to the error of sensor data which leads/causes the error accumulation in the calculation [2]. Advanced technology has developed a high precision and reliable IMU sensor using micro- electro-mechanical systems (MEMS). An advanced IMU is constructed with a combination of the three coordinate axis orientation complementary, where each axis consists of gyroscope (angular rate), accelerometer (acceleration), and magnetometer (Flux) [4]. Attitude or orientation can be represented by a three-way, i.e. (a) roll, pitch and yaw (RPY) or bank, elevation, and heading (BEH) with Euler angle ZYX method [5], (b) direction Cosine Matrix, and (c) Quaternion. The advantages and disadvantages of the three methods of representation are discussed in detail by Nguyen [6]. Euler angle is very intuitive and is widespread used, but has the disadvantage that it will have a singularity if the angle closes to 90ΒΊ [3, 6-7]. There are two approaches that are commonly used for attitude calculation. The first (relative attitude) is the attitude calculated based on inertial mechanization which uses discrete time integral of the rotational velocity measurements using data from 3-axis gyroscope. Angle resulting from this approach is roll, pitch and yaw (RPY). In this case, the determination of attitude does not depend on the value of the previous measurements and will always have a drift, for it requires correction compensation continuously. The second (absolute attitude) is calculated based on recent measurements of the data from accelerometer and magnetometer, using analytic * Corresponding Author. Tel: +62-8138-1006-059 E-mail: hendri_maja@yahoo.co.id http://dx.doi.org/10.14203/j.mev.2013.v4.41-50 H. M. Saputra, et al. / Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 42 geometry. Angle resulting from this approach is the bank, elevation, and heading (BEH). Bank and elevation are obtained from gravity vector measured by accelerometer, while heading is calculated from magnetometer and bank- elevation angle [3, 7]. Orientation of the magnetic field must mathematically be rotated to the horizontal plane. If it is not rotated to the horizontal plane heading calculation would result in a considerable error [8]. The most fundamental problem in IMU sensor is noise in the form of white noise [9] which can lead to inaccuracy and imprecision of attitude calculation. Methods to minimize the noise using a Kalman filter is discussed by Cheng [10]. Kalman filter is a very effective estimator for dynamics state estimation of complex systems, particularly linear dynamic discrete systems involving process noise and measurement noise. Implementation of Phidget Spatial 3/3/3 [9] has been discussed by Agarwal [11] and Andersson [12], but they did not mention sensor performance issues in detail. This paper provides two important things. The first is description of a simple and systematic attitude computation model so that it can be used directly to calculate absolute attitude and relative attitude as an input for controlling joint angles of a pan-tilt mechanism. Relation of coordinate systems between the pan-tilt mechanism and attitude RPY/BEH is shown in Figure 2 [1]. The second is explanation of application of IMU Phidget Spatial 3/3/3 by creating its own software using Matlabβ„’ which works in realtime manner. II. MODELING A. Sensor Model Model of angular rate, acceleration, and flux is used to obtain estimated value of relative attitude (roll, pitch, and yaw/RPY), absolute attitude (bank, elevation, and heading/BEH), position and velocity. Angular rate is modeled as follows: πœ”πœ” = πœ”πœ”π‘”π‘” βˆ’ 𝑏𝑏𝑔𝑔 βˆ’ 𝑛𝑛𝑔𝑔 (1) Where πœ”πœ”π‘”π‘” is angular rate from gyroscope, 𝑏𝑏𝑔𝑔 is the gyroscope bias, 𝑛𝑛𝑔𝑔 is noise from the gyroscope measurement. Acceleration is modeled as follows: π‘Žπ‘Ž = π‘Žπ‘Žπ‘Žπ‘Ž βˆ’ π‘›π‘›π‘Žπ‘Ž (2) Where π‘Žπ‘Žπ‘Žπ‘Ž is acceleration, π‘›π‘›π‘Žπ‘Ž is noise from the accelerometer measurement. Flux is modeled as follows: π‘šπ‘š = π‘šπ‘šπ‘šπ‘š βˆ’ π‘–π‘–π‘šπ‘š βˆ’ π‘›π‘›π‘šπ‘š (3) Where π‘šπ‘šπ‘šπ‘š is the magnetic field vector derived from the magnetometer, π‘–π‘–π‘šπ‘š is the magnetic field vector caused by vehicles interference, and π‘›π‘›π‘šπ‘š is the noise of the magnetometer measurement. Based on the three models of the sensor, the noise (𝑛𝑛𝑔𝑔,π‘›π‘›π‘Žπ‘Ž , and π‘›π‘›π‘šπ‘š ) can be minimized by the use of a Kalman filter, the bias (𝑏𝑏𝑔𝑔) can be eliminated by static calibration process, while interference (π‘–π‘–π‘šπ‘š ) can be considered as zero if it is assumed that the magnetometer is isolated from vector magnetic field generated by the vehicle. B. AHRS Model AHRS is a combination of three separate models derived through geometrical approach of the measurement sensors (gyroscope, accelerometer, and magnetometer) as shown in Figure 3. In the figure, it can be seen that the AHRS is broken down into three models: (1) the model of relative attitude consisting roll, pitch, and yaw (RPY) angles from the gyroscope, (2) the model of absolute attitude which consists of bank, elevation, and heading (BEH) angles from the accelerometer and magnetometer, and (3) the model of linear position and linear velocity from the accelerometer. It should be noted that prior to derivation of the three models described above, the difference between the sensor coordinate and global reference should be adjusted as shown in Figure 4. Notation of the two coordinates are adjusted to obtain π‘‹π‘‹π‘Ÿπ‘Ÿ = 𝑋𝑋, π‘Œπ‘Œπ‘Ÿπ‘Ÿ = 𝑍𝑍, and π‘π‘π‘Ÿπ‘Ÿ = βˆ’π‘Œπ‘Œ. Figure 1. INS components Figure 2. Relation of coordinate systems H. M. Saputra, et al. / Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 43 1) Relative Attitude Model from Gyroscope Data The relative attitude model was set up to obtain the roll, pitch, and yaw (RPY) angles. Gyroscope sensor output (πœ”πœ”) gives a value that states the amount of angular velocity. Angle (πœƒπœƒ) of the sensor output can be calculated by integration. The relationship between angular rate and angle signals are given below: πœƒπœƒ(𝑑𝑑) = ∫ πœ”πœ”(𝑑𝑑) π‘‘π‘‘π‘˜π‘˜ π‘‘π‘‘π‘˜π‘˜βˆ’1 𝑑𝑑𝑑𝑑 (4) π‘‘π‘‘πœƒπœƒ (𝑑𝑑) 𝑑𝑑𝑑𝑑 = πœ”πœ”(𝑑𝑑) (5) In discrete form, the above equation can be written as follows: πœƒπœƒπ‘˜π‘˜ +1βˆ’πœƒπœƒπ‘˜π‘˜ βˆ†π‘‡π‘‡ = πœ”πœ”π‘˜π‘˜ (6) πœƒπœƒπ‘˜π‘˜+1 = πœƒπœƒπ‘˜π‘˜ + πœ”πœ”π‘˜π‘˜βˆ†π‘‡π‘‡ (7) Where πœƒπœƒπ‘˜π‘˜ is the current time angle, πœƒπœƒπ‘˜π‘˜+1 is calculated angle, πœ”πœ”π‘˜π‘˜ is angular rate (gyroscope data), and βˆ†π‘‡π‘‡ is the current time π‘‘π‘‘π‘˜π‘˜ minus the previous time π‘‘π‘‘π‘˜π‘˜βˆ’1. 2) Absolute Attitude Model from Accelerometer and Magnetometer Data The absolute attitude model was derived to obtain bank, elevation, and heading angles [13]. The angles formed by rotation along X-axis and Y-axis were calculated from the accelerometer data by assumption that Z'β‰ˆ 1 as shown in Figure 5. If Z coordinates of the sensors is turned up the speed on Z-axis will become negative (Az<0) so that Ξ± and Ξ³ turn to negative. Rotation matrix formed by the Euler angles can be calculated by substitution of Ξ± and Ξ³, where Ξ± = sin-1(Ax) and Ξ³ = sin-1(Ay). Assuming that the magnetometer faces north or bearing (Ξ²= 0) then the following equation can be derived. R = οΏ½ 𝑐𝑐(𝛼𝛼) βˆ’π‘ π‘ (𝛼𝛼) 𝑐𝑐(𝛾𝛾) 𝑠𝑠(𝛼𝛼) 𝑠𝑠(𝛾𝛾) 𝑠𝑠(𝛼𝛼) 𝑐𝑐(𝛼𝛼) 𝑐𝑐(𝛾𝛾) βˆ’π‘π‘(𝛼𝛼) 𝑠𝑠(𝛾𝛾) 0 𝑠𝑠(𝛾𝛾) 𝑐𝑐(𝛾𝛾) οΏ½ (8) In the implementation, acceleration [ax, ay, az] and flux [mx, my, mz] should be normalized to ensure that the resulted vector is worth one. They are normalized as follows: 𝐴𝐴π‘₯π‘₯ = π‘Žπ‘Žπ‘₯π‘₯ π‘Žπ‘Ž ; 𝐴𝐴𝑦𝑦 = π‘Žπ‘Žπ‘¦π‘¦ π‘Žπ‘Ž ;𝐴𝐴𝑧𝑧 = π‘Žπ‘Žπ‘§π‘§ π‘Žπ‘Ž (9) 𝑀𝑀π‘₯π‘₯ = π‘šπ‘šπ‘₯π‘₯ π‘šπ‘š ; 𝑀𝑀𝑦𝑦 = π‘šπ‘šπ‘¦π‘¦ π‘šπ‘š ;𝑀𝑀𝑧𝑧 = π‘šπ‘šπ‘§π‘§ π‘šπ‘š (10) Where π‘Žπ‘Ž = οΏ½π‘Žπ‘Žπ‘₯π‘₯2 + π‘Žπ‘Žπ‘¦π‘¦2 + π‘Žπ‘Žπ‘§π‘§2 ; π‘šπ‘š = οΏ½π‘šπ‘šπ‘₯π‘₯2 + π‘šπ‘šπ‘¦π‘¦2 + π‘šπ‘šπ‘§π‘§2 By adjusting the magnetic field coordinates from sensor to coordinates as shown in Figure 4 then mfx=Mx, mfy=Mz, and mfz=–My. In vector form, they are expressed as below: π‘šπ‘šπ‘£π‘£π‘£π‘£π‘˜π‘˜ = [π‘šπ‘šπ‘“π‘“π‘₯π‘₯ π‘šπ‘šπ‘“π‘“π‘¦π‘¦ π‘šπ‘šπ‘“π‘“π‘§π‘§ ] (11) The magnetic field vector in the above equation is then transformed to eliminate the influence of rotation that occurs through the following equation: π‘‰π‘‰π‘šπ‘š = π‘šπ‘šπ‘£π‘£π‘£π‘£π‘˜π‘˜ 𝑅𝑅 = [π‘‹π‘‹π‘Ÿπ‘Ÿ π‘Œπ‘Œπ‘Ÿπ‘Ÿ π‘π‘π‘Ÿπ‘Ÿ ] (12) where: π‘‹π‘‹π‘Ÿπ‘Ÿ = π‘šπ‘šπ‘“π‘“π‘₯π‘₯ 𝑐𝑐(𝛼𝛼) + π‘šπ‘šπ‘“π‘“π‘¦π‘¦ 𝑠𝑠(𝛼𝛼) (13) π‘Œπ‘Œπ‘Ÿπ‘Ÿ = βˆ’π‘šπ‘šπ‘“π‘“π‘₯π‘₯ 𝑠𝑠(𝛼𝛼) 𝑐𝑐(𝛾𝛾) + π‘šπ‘šπ‘“π‘“π‘¦π‘¦ 𝑐𝑐(𝛼𝛼) 𝑐𝑐(𝛾𝛾) + π‘šπ‘šπ‘“π‘“π‘§π‘§ 𝑠𝑠(𝛾𝛾) (14) π‘π‘π‘Ÿπ‘Ÿ = π‘šπ‘šπ‘“π‘“π‘₯π‘₯ 𝑠𝑠(𝛼𝛼) 𝑠𝑠(𝛾𝛾) βˆ’ π‘šπ‘šπ‘“π‘“π‘¦π‘¦ 𝑐𝑐(𝛼𝛼) 𝑠𝑠(𝛾𝛾) + π‘šπ‘šπ‘“π‘“π‘§π‘§ 𝑐𝑐(𝛾𝛾) (15) Figure 3. AHRS modelling principle Figure 4. Equalization of global reference coordinates with the sensor coordinate H. M. Saputra, et al. / Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 44 The above equation describes components of X and Y at global reference coordinates that are rotated along X-axis and along Z-axis as shown in Figure 6. If the coordinates are adjusted back to the global reference coordinate we obtain Xh = –Zr, Yh = –Xr, and Zh = Yr. On this basis, Xh and Yh are given by the following equations: π‘‹π‘‹β„Ž = βˆ’π‘šπ‘šπ‘₯π‘₯ 𝑠𝑠(𝛼𝛼) 𝑠𝑠(𝛾𝛾) + π‘šπ‘šπ‘¦π‘¦ 𝑐𝑐(𝛼𝛼) 𝑠𝑠(𝛾𝛾) βˆ’ π‘šπ‘šπ‘§π‘§ 𝑐𝑐(𝛾𝛾) (16) π‘Œπ‘Œβ„Ž = βˆ’π‘šπ‘šπ‘₯π‘₯ 𝑐𝑐(𝛼𝛼) βˆ’ π‘šπ‘šπ‘¦π‘¦ 𝑠𝑠(𝛼𝛼) (17) Xh and Yh components in the above equation are used to calculate the north or Bearing (Ξ²) of the coordinates of the earth as shown in Figure 7. Xh and Yh are calculated using arctan so the quadrant of the two components must be considered. The two components are subject to provision shown in Table 1. At the time Zh coordinate changes in the opposite direction on Z–axis, acceleration will be negative (Az<0). In this case, Ξ² is the absolute value of (β–2Ο€). All stages, the value that has been obtained are converted into a unit of degrees as the following equation: Heading, π›½π›½π‘˜π‘˜ = 𝛽𝛽 οΏ½ 180 πœ‹πœ‹ οΏ½ (18) Elevation, π›Όπ›Όπ‘˜π‘˜ = 𝛼𝛼� 180 πœ‹πœ‹ οΏ½ (19) Bank, π›Ύπ›Ύπ‘˜π‘˜ = 𝛾𝛾 οΏ½ 180 πœ‹πœ‹ οΏ½ (20) 3) The Position and Velocity Model from Accelerometer Data Linear velocity is derived through integration process of acceleration data that can be written as follows: 𝑉𝑉�⃗ = βˆ«οΏ½π΄π΄οΏ½π‘‘π‘‘π‘‘π‘‘ (21) where AοΏ½οΏ½βƒ— is the acceleration vector (Ax, Ay, Az) after normalization. The position is obtained by double integration of the acceleration data. SοΏ½βƒ— = ∫�∫�AοΏ½οΏ½βƒ— οΏ½ dtοΏ½ dt (22) Before performing the integral, the acceleration coordinate must be adjusted to the sensor coordinates as Figure 4. In addition, the acceleration must be transformed in order to remain on the field of play in a horizontal plane (a) (b) Figure 5. Rotation of coordinate: (a) Y-axis; (b) X-axis Table 1. Quadrant rules for Xh and Yh components [8] Condition Absolute value (𝜷𝜷) (Xh< 0) πœ‹πœ‹ βˆ’ π‘‘π‘‘π‘Žπ‘Žπ‘›π‘›βˆ’1 οΏ½ π‘Œπ‘Œβ„Ž π‘‹π‘‹β„Ž οΏ½ (Xh> 0 & Yh< 0) βˆ’π‘‘π‘‘π‘Žπ‘Žπ‘›π‘›βˆ’1 οΏ½ π‘Œπ‘Œβ„Ž π‘‹π‘‹β„Ž οΏ½ (Xh> 0 & Yh> 0) 2πœ‹πœ‹ βˆ’ π‘‘π‘‘π‘Žπ‘Žπ‘›π‘›βˆ’1 οΏ½ π‘Œπ‘Œβ„Ž π‘‹π‘‹β„Ž οΏ½ (Xh = 0 & Yh< 0) πœ‹πœ‹/2 (Xh = 0 & Yh> 0) 3πœ‹πœ‹/2 Figure 6. Changes in the global reference coordinate Figure 7. Coordinate of Xh and Yh components H. M. Saputra, et al. / Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 45 through the process of multiplying the acceleration data with rotation matrix as follows: 𝐴𝐴 = [𝐴𝐴π‘₯π‘₯ 𝐴𝐴𝑦𝑦 𝐴𝐴𝑧𝑧]. 𝑅𝑅 = [𝐴𝐴π‘₯π‘₯2 𝐴𝐴𝑦𝑦2 𝐴𝐴𝑧𝑧2 ] (23) where: 𝐴𝐴π‘₯π‘₯2 = 𝐴𝐴π‘₯π‘₯ 𝑐𝑐(𝛼𝛼) + 𝐴𝐴𝑦𝑦 𝑠𝑠(𝛼𝛼) (24) 𝐴𝐴𝑦𝑦2 = βˆ’π΄π΄π‘₯π‘₯ 𝑠𝑠(𝛼𝛼) 𝑐𝑐(𝛾𝛾) + 𝐴𝐴𝑦𝑦 𝑐𝑐(𝛼𝛼) 𝑐𝑐(𝛾𝛾) + 𝐴𝐴𝑧𝑧 𝑠𝑠(𝛾𝛾) (25) 𝐴𝐴𝑧𝑧2 = 𝐴𝐴π‘₯π‘₯ 𝑠𝑠(𝛼𝛼) 𝑠𝑠(𝛾𝛾) βˆ’ 𝐴𝐴𝑦𝑦 𝑐𝑐(𝛼𝛼) 𝑠𝑠(𝛾𝛾) + 𝐴𝐴𝑧𝑧 𝑐𝑐(𝛾𝛾) (26) III. HARDWARE AND SOFTWARE The complete structure of pan-tilt mechanism control system is shown in Figure 8. In this section, the hardware is presented focusing only on IMU sensor, while the software described is only associated with data reading. A. Hardware The IMU sensor used in this research is Phidget Spatial 3/3/3 [9]. It consists of a combination of three sensors, those are: 3-axis accelerometer, 3-axis gyroscope, and 3-axis magnetometer. The electronic component of the sensor physically consists of several integrated circuits (ICs) collected in one electronic module as shown in Figure 9. Specifications of the sensor are listed in Table 2. B. Software In this paper a software has been developed using Matlabβ„’ to read measurement data from sensor Phidget Spatial 3/3/3. Figure 10 shows the flowchart of the software. Appropriate sampling time was determined by trial and error through experiment. Figure 11 depicts effect of sampling time on the magnetometer sensor (Z-axis). Figure 11(a) shows an example that sampling time less than 32 ms (e.g. 16 ms) caused mall-function of the magnetometer sensor reading. Figure 11(b) shows experiment result using sampling time of 32ms. Experiment result using sampling time above 32 ms demonstrate to some extent the similar results. Therefore, in this paper 32 ms is selected as the sampling time. The hardware connection greatly influences the program operation; therefore correct understanding of phidget library is necessary. The software reads data from the sensor and displays some information including: the three Figure 9. Top view of Phidget Spatial 3/3/3 sensor Figure 8. Pan-tilt mechanism control system H. M. Saputra, et al. / Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 46 sensors measurement data, and calculation results of both models. Output of model 3 (velocity and position) is ignored because it is useless for the pan-tilt mechanism to compensate the disruption of the platform. IV. EXPERIMENT AND ANALYSIS A. Sensor Data Measurement The measurements were conducted by adjusting the sensor at stop position (kept in a state of rest). Figure 12 shows the results of the reading of the accelerometer, gyroscope, and magnetometer sensors. The signals in the figure show that the raw data obtained from the sensor contains noise. The detail of noise reduction will be discussed in the next section. The most common noise in the IMU sensor is in the form of white noise [9], so that it can be analyzed using standard deviation and average value. Table 3 shows the analysis result. Standard deviation value of the accelerometer and magnetometer sensor is smaller than the gyroscope sensor. B. Attitude Computation using Kalman Filter A Kalman filter was designed through computer simulation using Matlab. The Kalman filter is used to minimize the noise effect. Figure 13 shows an illustration of a Kalman filter formulation. The detail formula was described by Welch and Bishop [14]. The measurement noise covariance (R) was obtained from the direct measurement when the sensor was positioned stationary (not moving). In this paper, R is the square of the standard deviation values of the measurement noise (r). The presented data in this section is the Table 2. Specifications of Phidget Spatial 3/3/3 [9] Characteristics Value Gyroscope Measurement Max Β±400 Β°/s Resolution 0,02 Β°/s Drift 4Β°/m Compass Measurement Max Β± 4 Gauss Resolution 400Β΅G Offset from North 2Β° Accelerometer Measurement Max Β±5g (49m/s2) Resolution 228Β΅g Error Through Rotation 2mg Bandwidth 110 Hz Axis 0 Noise Level (X-Axis) 300Β΅g Axis 1 Noise Level (Y-Axis) 300Β΅g Axis 2 Noise Level (Z-Axis) 500Β΅g Board Sampling Speed 4ms– 1000ms USB Voltage 4,75 – 5,25 VDC Current Consumption Max 45mA USB Speed Full speed (12Mbit) Operating Temperature 0 - 70Β°C Figure 10. Phidget Spatial 3/3/3 software flowchart (a) (b) Figure 11. Effect of sampling time on the magnetometer sensor data (Z-axis): (a) Sampling time 16 ms; (b) Sampling time 32 ms H. M. Saputra, et al. / Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 47 gyroscope sensor data that has been stored in the form of text. It was selected for Kalman filter design due to the larger standard deviation than the accelerometer and magnetometer as shown in Table 3. The parameters set in the simulation are standard deviation values of the process noise (q) and the measurement noise (r). The selected noise measurement value was 0.08ΒΊ/s. The estimated standard deviation of the process noise (q) is used to obtain the value of the process noise covariance (Q). The q value was set half of standard deviation of the measurement noise(r). The combination of parameters for the simulation can be seen in Table 4 and Table 5. The simulation results of the three parameter combinations are shown in Figure 14. It can be seen that the greater the value of q the better the Kalman filter estimates the actual movement, while the smaller the value of q the worst the Kalman filter estimate the actual movement. In contrast to the variation in the value of q, the value of r indicates that the smaller value of r makes the Kalman filter estimate the better actual movement, while the greater the value of r makes the Kalman filter estimate the worse actual movement. It can be seen that Figure 14(c) shows the better performance compared to Figure 14(a) and Figure 14(b). Based on these results the ideal ratio between the deviation of the measurement noise (r) and the deviation of process noise (q) is about 1:5 (r = 0.08 and q = 0.4) or (r = 0.008 and q = 0.04). Based on this result, in this paper r = 0.08 and q = 0.4 are chosen. Figure 15 and Figure 16 show the results of measurements of the relative attitude and absolute attitude calculation. Sensor data used to generate the attitude has been filtered through the Kalman filter. Noise in gyroscope sensor affects the results of integration, so that the calculated RPY angles accumulate error and continuously drift, when the sensor is in a state of rest. Figure 13. Operation of a Kalman filter [14] (a) (b) (c) Figure 12. Measurement of X-axis: (a) Gyroscope; (b) Accelerometer; (c) Magnetometer 0 10 20 30 40 50 60 -0.4 -0.2 0 0.2 0.4 Gyroscope X-axis time (second) A ng ul ar ra te (o /s ) StdDev = 0.0881 Mean = -0.0104 0 10 20 30 40 50 60 -0.055 -0.054 -0.053 -0.052 -0.051 Accelerometer X-axis time (second) A cc el er at io n( g) StdDev = 0.0003 Mean = -0.0538 ( ) 0 10 20 30 40 50 60 -0.82 -0.818 -0.816 -0.814 -0.812 Magnetometer X-axis time (second) Fl ux (G ) StdDev = 0.0006 Mean = -0.8170 Table 3. Standard deviation and average value of the sensor data measurements Sensor X axis Y axis Z axis Gyroscope (Β°/s) Mean -0.0104 0.0042 -0.0054 Standard deviation 0.0881 0.0880 0.0741 Accelerometer (g) Mean -0.0538 0.0126 0.9985 Standard deviation 0.0003 0.0003 0.0000 Magnetometer (G) Mean -0.8170 -0.1382 0.5598 Standard deviation 0.0006 0.0010 0.0009 H. M. Saputra, et al. / Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 48 The drift can be observed in Table 6. Drift accumulation was successfully minimized by the Kalman filter algorithm. The drift in the table (roll = 0.6ΒΊ/min, pitch = 0.2ΒΊ/min, and yaw = 0.3ΒΊ/min) is smaller than the original specification from the manufacturer, 4ΒΊ/min in average, as shown in the specifications for gyroscope sensors in Table 2. The noise analysis result of the calculated absolute attitude shown in Figure 16 is listed in Table 7. The absolute attitude in Table 7 has small standard deviation values. Thus, it can be said that the model 2 which calculates the absolute attitude using measurement data from the accelerometer and magnetometer works well. C. IMU Sensor Implementation The modelled and designed IMU sensor has been tested on a crane. Figure 17 shows the application of the IMU on a crane. Desired information from the measurements data was to determine the extent of horizontal rotation (Pan) of the crane. As the crane worked according to sequence in Table 8, the data generated by the (a) (b) (c) Figure 14. Optimization of the angular rate when the sensor is not actuated 0 50 100 150 200 250 300 350 400 0 0.2 0.4 0.6 0.8 data-i an gu la r r at e (o / s) q type No.1 & r type No.3 without Kalman with Kalman 0 50 100 150 200 250 300 350 400 0 0.2 0.4 0.6 0.8 data-i an gu la r r at e (o / s) q type No.2 & r type No.2 without Kalman with Kalman 0 50 100 150 200 250 300 350 400 0 0.2 0.4 0.6 0.8 data-i an gu la r r at e (o / s) q type No.3 & r type No.1 without Kalman with Kalman Table 8. Crane working sequence Time Events 14:42 Crane was lifting a motor wire moving from West to North 14:44 Crane was placing the motor wire at North 14:49 Crane was lifting a box moving from West to North 14:52 Crane was placing the box at North 14:54 Crane was lifting a generator moving from North to South East 14:58 Crane was lifting the generator higher at South East 15:01 Crane was placing the generator at North 15:02 Crane was rotating from North to South East, then to North 15:07 Crane was lifting two small drums from North to West 15:09 Crane was placing the drums at west 15:13 Crane was placing the boom to boom rest 15:14 Crane was lifting the boom from boom rest 15:16 Crane was lifting a motor from North to North West 15:16 Crane was placing the motor at North West 15:18 Crane was placing the boom to boom rest Table 4. Variations of the process noise (q) No Combination ofq Process noise (q) Measurement noise (r) 1 q/10 0.004 0.08 2 q (estimation) 0.04 0.08 3 q*10 0.4 0.08 Table 5. Variations of the measurement noise (r) No Combination of r Process noise (q) Measurement noise (r) 1 r/10 0.04 0.008 2 r (estimation) 0.04 0.08 3 r*10 0.04 0.8 Table 6. Drift of relative attitude value RPY angle Slope (Β°) Drift (Β°/min) Initial value Final value roll 0 -0.5959 0.6 pitch 0 0.2410 0.2 yaw 0 0.3459 0.3 Table 7. Standard deviation and mean value of the calculated absolute attitude BEH angle Mean (Β°) Standard deviation (Β°) Bank 0.7224 0.0066 Elevation 3.0845 0.0075 Heading -98.8103 0.0460 H. M. Saputra, et al. / Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 49 IMU sensor was recorded. Angle values obtained in this trial do not exactly represent the actual values because were not measured with a calibrated comparison tool. This test was only to find out the sensor ability in open environment application. The data generated in this trial can be seen in Figure 18. The figure shows that in general the developed IMU sensor can work well and can be used to measure the horizontal angle of the crane movement. The data possessed β€˜jump’ which may be caused by metal interference and the rigidity of the crane itself. (a) (b) (c) Figure 15. Calculated relative attitude: (a) X-axis; (b) Y-axis; and (c) the Z-axis \ (a) (b) (c) Figure 16. Calculated absolute attitude: (a) X-axis;(b) Y-axis; and (c) the Z-axis Figure 17. IMU sensor implementation on a crane H. M. Saputra, et al. / Mechatronics, Electrical Power, and Vehicular Technology 04 (2013) 41-50 50 V. CONCLUSIONS From the results of this research the following conclusions can be drawn. The modelling and design of the IMU sensor derived in this research could be implemented on the sensor Phidget Spatial 3/3/3 to obtain position, velocity, and attitude of an object. The standard deviation of error that occurs in the gyroscope sensor at the X axis is Β± 0.0881Β°, in the accelerometer at the X axis is Β± 0.0003 g, and in the magnetometer at the X axis is Β± 0.0006 G. In this research, through simulation and experiment, the following appropriate values are obtained: (a) sampling time should not be less than 32 ms; (b) comparison between the measurement noise (r) and the process noise (q) for the parameters of the Kalman filters is 1 : 5 with r = 0.08 and q = 0.4. REFERENCES [1] H. M. Saputra, et al., "Analysis of Inverse Angle Method for Controlling Two Degree of Freedom Manipulator," Journal of Mechatronics, Electrical Power, and Vehicular Technology, vol. 03, pp. 9-16, 2012. [2] D. H. Titterton and J. L. Weston, Strapdown inertial navigation technology, Second ed.: United Kingdom: The Institution of Electrical Engineers, 2004. [3] W. Adiprawita, et al., "Development of AHRS for Autonomous UAV," in Proceedings of International Conference on Electrical Engineering and Informatics, Institut Teknologi Bandung, Indonesia 2007, pp. 714-717. [4] K. Waller, "Developing a Benchmark Suite for The Evaluation of Orientation Sensors," MSc. Thesis, Clemson University, 2006. [5] J. J. Craig, Introduction to Robotics: Mechanics and Control, Third ed.: Pearson Education, Inc., 2005. [6] N. H. Q. Phuong, et al., "A DCM Based Orientation Estimation Algorithm with an Inertial Measurement Unit and a Magnetic Compass," Journal of Universal Computer Science, vol. 15, pp. 859-876, 2009. [7] A. Budiyono, et al., "The Application of MEMS-based Inertial Sensors for Onboard Avionics System of Unmanned Aerial Vehicles," presented at the 5 th International Symposium on Nanomanufacturing, 2008. [8] M. J. Caruso, "Applications of Magnetic Sensors for Low Cost Compass Systems," presented at the Position Location and Navigation Symposium, San Diego, 2000. [9] I. Phidgets. (2012, 25 Sept). 1056 - PhidgetSpatial 3/3/3. Available: http://www.phidgets.com/products.php?p roduct_id=1056 [10] L. Cheng, et al., "Attitude Determination for MAVs Using a Kalman Filter," Tsinghua Science and Technology, vol. 13, pp. 593-597, 2009. [11] P. K. Agarwal, "Real-time Data Acquisition, Transmission and Archival Framework," Master of Science, Department of Computer Engineering, Rochester Institute of Technology, Rochester, New York, 2011. [12] T. Andersson and M. Idegren, "Set-up and Real-Traffic Assessment of a Data Logger for Vulnerable-Road-User Motion," Master’s Thesis, Department of Applied Mechanics, Chalmers University of Technology, GΒ¨oteborg, Sweden, 2011. [13] I. Phidgets, "1056 - PhidgetSpatial 3/3/3, Code Samples For This Product, 2010," ed, 2010. [14] G. Welch and G. Bishop, "An Introduction to the Kalman Filter," University of North Carolina at Chapel Hill, Technical report, TR 95-041, 2006. Figure 18. Measurements of horizontal crane angle Relative Attitude Model from Gyroscope Data Absolute Attitude Model from Accelerometer and Magnetometer Data The Position and Velocity Model from Accelerometer Data Hardware Software Conclusions