MEV Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 Journal of Mechatronics, Electrical Power, and Vehicular Technology e-ISSN: 2088-6985 p-ISSN: 2087-3379 www.mevjournal.com doi: https://dx.doi.org/10.14203/j.mev.2017.v8.60-69 2088-6985 / 2087-3379 ©2017 Research Centre for Electrical Power and Mechatronics - Indonesian Institute of Sciences (RCEPM LIPI). This is an open access article under the CC BY-NC-SA license (https://creativecommons.org/licenses/by-nc-sa/4.0/). Accreditation Number: (LIPI) 633/AU/P2MI-LIPI/03/2015 and (RISTEKDIKTI) 1/E/KPT/2015. Design and implementation of hardware in the loop simulation for electric ducted fan rocket control system using 8-bit microcontroller and real-time open source middleware Reza Aulia Yulnandi, Carmadi Machbub *, Ary Setijadi Prihatmanto, Egi Muhammad Idris Hidayat School of Electrical Engineering and Informatics, Institut Teknologi Bandung Jl. Ganesha 10, Bandung 40132, Indonesia Received 28 April 2017; received in revised form 22 June 2017; accepted 02 July 2017 Published online 31 July 2017 Abstract Hardware in the Loop Simulation (HILS) is intended to reduce time and development cost of control system design. HILS systems are mostly built by integrating both controller hardware and simulator software where the software is not an open source. Moreover, implementing HILS by using manufactured system is costly. This paper describes the design and implementation of HILS for Electric Ducted Fan (EDF) rocket by using open-source platform for development with middleware. This middleware system is used to bridge the data flow between controller hardware and simulator software. A low-cost ATMEGA 2560 8-bit microcontroller is used to calculate rocket’s attitude with Direction Cosine Matrix (DCM) algorithm and PID controller is employed to regulate rocket’s dynamics based on desired specifications. X-Plane 10 simulator software is used for generating simulated sensory data. The test results validate that HILS design meets the defined specifications, i.e. angle difference of 0.3 degrees and rise time of 0.149 seconds on pitch angle. ©2017 Research Centre for Electrical Power and Mechatronics - Indonesian Institute of Sciences. This is an open access article under the CC BY-NC-SA license (https://creativecommons.org/licenses/by-nc-sa/4.0/). Keywords: HILS; DCM; open-source platform; X-Plane; middleware; EDF rocket I. Introduction Electric-Ducted Fan (EDF) rocket is one class of rocket that uses electric thruster as its main actuator [1]. It gains popularity for education and research purposes due its low cost and versatility. One important subsystem of an EDF rocket is the autopilot system [2]. Testing an autopilot system in a real experiment directly would lead to a high risk of failure due to its low durability and a high cost. Computer’s system evolution creates the development of simulation method by using the virtual environment to imitate real situation became more preferable [3]. However, simulation result does not always give the same result as the real implementation process due to the uncertainty in electronic hardwares. Therefore, Hardware in the Loop Simulation (HILS) approach is used. HILS is the simulation system that integrates hardware system to simulation process. HILS have been carried out to improve the accuracy of results [4, 5, 6]. Most of the development processes use costly controller hardware such as Motorola's MPC5554-MCU [7]. This hardware is not suitable for simple autonomous system such as Proportional Integral Derivative (PID) algorithm due to the high cost which is not in accordance with the achieved performance. PID algorithm does not need to have a very high- speed processing unit to produce a control signal. Hardware with average speed processing will be sufficient to handle the control process. It also does not need a large memory capacity to store the program code. Moreover, most of the HILS use integrated hardware and software system which is not an open source, not a re-programmable nor having non-free license [8, 9, 10]. * Corresponding Author. Tel: +62 22 250 0960 E-mail address: carmadi@stei.itb.ac.id https://dx.doi.org/10.14203/j.mev.2017.v8.60-69 http://u.lipi.go.id/1436264155 http://u.lipi.go.id/1434164106 http://mevjournal.com/index.php/mev/index https://dx.doi.org/10.14203/j.mev.2017.v8.60-69 https://creativecommons.org/licenses/by-nc-sa/4.0/ https://crossmark.crossref.org/dialog/?doi=10.14203/j.mev.2017.v8.60-69&domain=pdf https://creativecommons.org/licenses/by-nc-sa/4.0/ R.A. Yulnandi et al. / Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 61 In this paper, the design and implementation of HILS system is presented, with the main contribution of exposing three main subsystems which are middleware design to ease bridge process, controller hardware, and simulator software. The middleware performance will be validated through comparison between sensor from simulator software and sensor from sensory hardware with attitude control mechanism to imitate simulator software. II. Component of HILS The HILS system consists of three subsystems, i.e. controller hardware, simulator software, and middleware system.  Controller Hardware acts as the main control unit in HILS. This subsystem also controls sensory data retrieval both from sensory hardware and simulator software.  Simulator Software generates sensory data as replacement of sensory hardware, establish a virtual environment to test and provide the simulated dynamics of EDF Rocket.  Middleware system bridges the data flow between controller hardware and simulator software. The middleware system is essential since hardware and software have different communication protocols. Microcontroller hardware uses Universal Asynchronous Receive Transmit (UART) protocol and simulator software uses User Datagram Protocol (UDP). Illustration of each subsystem’s tasks is shown in Figure 1. III. Design specification The HILS system for EDF rocket control system uses an 8-bit microcontroller as a main processing unit. The HILS system is designed to meet the following specifications:  The minimum sampling rate of attitude data from simulator software to controller hardware with 100 samples/second due to the middleware has to provide data with sampling rate that approach the sampling rate from sensory hardware.  The error of simulated sensor from software simulation to sensory hardware does not exceed 2° in steady-state condition.  The performance difference of rise time in control process with the same parameter of PID between the simulated sensor and sensory hardware from an initial condition to reach the reference point does not exceed 1 second and steady-state error < 2%. IV. Implementation A. Controller hardware Controller hardware is assigned to process the sensory data and generate the control signal. Typically, HILS is built with 64/32-bit single- board computer as the main processing-unit. This kind of board costs relatively high and is not preferred for trivial computation. In this work the 8-bit microcontroller of ATMEGA2560 is used to achieve the desired design specifications. This processing unit should be sufficient to meet the specifications based on the following features:  It has 16 MHz clock speed to calculate attitude and control algorithm which takes 100-120μs.  It has UART protocol for data transfer from microcontroller to personal computer through serial port (RS232) with transfer rate up to 250Kbps that can achieve minimum sampling rate of 100 samples/second according to design specification.  It has 400 KHz inter integrated circuit (I2C) communication protocol to send sensory data from IMU to microcontroller in a compact module as shown in Figure 2.  It has 256 KB flash memory to store program data and 1KB EEPROM should be adequate for calibration data storage.  It has interrupt features for pulse generator to drive motor servo that will be used to change rocket’s control surface position as shown in Figure 2. Figure 1. Functional subsystems of HILS Figure 2. Realization of HILS R.A. Yulnandi et al. / Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 62 The sensory system of our EDF rocket consists of few attitude sensors:  MPU6050 as accelerometer and gyroscope with 50 Hz data sampling rate and 16-bit word length.  HMC5883 as magnetometer with 10 Hz data sampling rate and 12-bit word length.  MS561101BA as barometer with 10 Hz data sampling rate and 24-bit word length. Gyroscope sensor produces angular velocity to directly calculate the plant’s orientation. However, gyroscope cannot be used for long term measurement because it has drift in sensing process. Accelerometer and magnetometer can be used for long-term measurement but they are slower in generating data. Therefore, those cannot be used for short term calculation. 1) Attitude calculation algorithm and sensor fusion Direction cosine matrix method is used to compute the Euler angles using information from the gyro, accelerometer, magnetic compass and/or GPS [11]. Advantages of this algorithm are its implementation simplicity which can be linearly calculated. Hence, it requires light and short-duration computation. Vectors 𝑖, 𝑗, 𝑘 represent vector body and vectors 𝐼, 𝐽, 𝐾 represent vector global as shown in Figure 3. The vector can be described as follow: 𝑖𝐵 = [ 1 0 0 ] , 𝑗𝐵 = [ 0 1 0 ] , 𝑘𝐵 = [ 0 0 1 ] 𝐼𝐺 = [ 1 0 0 ] , 𝐽𝐺 = [ 0 1 0 ] , 𝐾 𝐺 = [ 0 0 1 ] The projection of vector 𝑖 toward the X-axis of global coordinate frame can be described as 𝑖𝑥 𝐺 = |𝑖|𝑐𝑜𝑠(𝑋, 𝑖) = 𝑐𝑜𝑠(𝐼, 𝑖) (1) where |𝑖| is normalization of vector 𝑖 and 𝑐𝑜𝑠(𝐼, 𝑖) is cosine angle that created by vector 𝐼 and vector 𝑖 . When |𝐼| = 1 dan |𝑖| =1, equation (1) can be written as 𝑖𝑥 𝐺 = 𝑐𝑜𝑠(𝐼, 𝑖) = 𝐼.𝑖 |𝐼||𝑖| . Since 𝑐𝑜𝑠(𝑎, 𝑏) = 𝑎.𝑏 |𝑎||𝑏| , then 𝑖𝑥 𝐺 = |𝐼||𝑖|𝑐𝑜𝑠(𝐼, 𝑖) = 𝐼. 𝑖 (2) Similarly, the projections of vector 𝑖 toward the other axes are given as follow: 𝑖𝑦 𝐺 = |𝐽||𝑖|𝑐𝑜𝑠(𝐽, 𝑖) = 𝐽. 𝑖 (3) 𝑖𝑧 𝐺 = |𝐾||𝑖|𝑐𝑜𝑠(𝐾, 𝑖) = 𝐾. 𝑖 (4) Then equations (2), (3) and (4) can be written as 𝑖 𝐺 = [ 𝑖𝑥 𝐺 𝑖𝑦 𝐺 𝑖𝑧 𝐺 ] = [ 𝐼. 𝑖 𝐽. 𝑖 𝐾. 𝑖 ], 𝑗𝐺 = [ 𝑗𝑥 𝐺 𝑗𝑦 𝐺 𝑗𝑧 𝐺 ] = [ 𝐼. 𝑗 𝐽. 𝑗 𝐾. 𝑗 ], 𝑘𝐺 = [ 𝑘𝑥 𝐺 𝑘𝑦 𝐺 𝑘𝑧 𝐺 ] = [ 𝐼. 𝑘 𝐽. 𝑘 𝐾. 𝑘 ] Vector 𝑖, 𝑗, 𝑘 in global coordinate can be described as follow: [𝑖 𝐺 𝑗𝐺 𝑘𝐺 ] = [ 𝐼. 𝑖 𝐼. 𝑗 𝐼. 𝑘 𝐽. 𝑖 𝐽. 𝑗 𝐽. 𝑘 𝐾. 𝑖 𝐾. 𝑗 𝐾. 𝑘 ] = [ 𝑐𝑜𝑠(𝐼, 𝑖) 𝑐𝑜𝑠(𝐼, 𝑗) 𝑐𝑜𝑠(𝐼, 𝑘) 𝑐𝑜𝑠(𝐽, 𝑖) 𝑐𝑜𝑠(𝐽, 𝑗) 𝑐𝑜𝑠(𝐽, 𝑘) 𝑐𝑜𝑠(𝐾, 𝑖) 𝑐𝑜𝑠(𝐾. 𝑗) 𝑐𝑜𝑠(𝐾, 𝑘) ] = 𝐷𝐶𝑀𝐺 Vector 𝐼, 𝐽, 𝐾 in body coordinate can be described as follow: [IB JB KB] = [ I. i J. i K. i I. j J. J K. j I. k J. J K. k ] = [ cos(I, i) cos(J, i) cos(K, i) cos(I, j) cos(J, j) cos(K, j) cos(I, k) cos(J, k) cos(K, k) ] = DCMB DCM defines the rotation of plant body toward other coordinate. DCM also can be used to determine vector coordinates global of motion in case that the vector coordinates body of motion is known (vice versa). According to Figure 4, the basic equation of rotation vector on axis are 𝑟 = 𝑟(𝑡), 𝑟′ = 𝑟(𝑡 + 𝑑𝑡), 𝑑𝑟 = 𝑟′ − 𝑟 where, vector r' is rotation vector with angle vector dθ in interval time dt on axis vector u. Then vector u is cross product for r and r' Figure 3. Vector body (white) and vector global (black) Figure 4. Rotating vector on axis R.A. Yulnandi et al. / Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 63 𝑢 = 𝑟×𝑟′ |𝑟×𝑟′| = 𝑟×𝑟′ |𝑟||𝑟′| sin(𝑑𝜃) = 𝑟×𝑟′ |𝑟|2 sin(𝑑𝜃) (5) Where, |𝑟| = |𝑟′| since rotation process does not alter length of vector. The linear velocity of vector r can be defined as vector 𝑣 = 𝑑𝑟 𝑑𝑡 = 𝑟′−𝑟 𝑑𝑡 (6) Angular rate of displacement vector r can be described as follow: 𝑤 = 𝑑𝜃 𝑑𝑡 𝑢 (7) The equation (8) is obtained by substituting equation (5) to equation (7). 𝑤 = 𝑑𝜃 𝑑𝑡 𝑢 = 𝑑𝜃 𝑑𝑡 𝑟×𝑟′ |𝑟|2 sin(𝑑𝜃) = 𝑟×𝑟′ |𝑟|2𝑑𝑡 (8) Hence for small dθ, sin(𝑑𝜃) ≈ 𝑑𝜃, the equation (9) is obtained as follow: 𝑤 = 𝑟×𝑟′ |𝑟|2𝑑𝑡 = 𝑟×(𝑟+𝑑𝑟) |𝑟|2𝑑𝑡 = (𝑟×𝑟)+(𝑟×𝑑𝑟) |𝑟|2𝑑𝑡 𝑤 = 𝑟×𝑑𝑟 |𝑟|2𝑑𝑡 = 𝑟×𝑣 |𝑟|2 (9) Vector 𝑣 is described by deriving the equation as follow: 𝑤 × 𝑟 = (𝑟∙𝑟)𝑣+(𝑣∙𝑟)𝑟 |𝑟|2 = |𝑟|2∙𝑣 |𝑟|2 + 0 |𝑟|2 = |𝑟|2∙𝑣 |𝑟|2 = 𝑣 Therefore: drx = dt vx = wx × r dt dry = dt vy = wy × r dt drz = dt vz = wz × r dt Then 𝑣 = 𝑑𝑟 𝑑𝑡 = (𝑤𝑥 + 𝑤𝑦 + 𝑤𝑧) × 𝑟 DCM equation can be used to define a sensory system to implement sensors fusion for calculating attitude of the plant. As mentioned to previous section, each of sensory hardware’s measurement data can be described as follow: 𝐴 = {𝐴𝑥 , 𝐴𝑦, 𝐴𝑧 } is accelerometer sensor data 𝑀 = {𝑀𝑥 , 𝑀𝑦 , 𝑀𝑧 } is magnetometer sensor data 𝐺 = {𝐺𝑥 , 𝐺𝑦 , 𝐺𝑧 } is gyroscope sensor data The measurement results can be presented into global coordinates as shown in Figure 5 with 𝐷𝐶𝑀𝐺 = (𝐷𝐶𝑀𝐵 )𝑇 = [𝐼𝐵 𝐽𝐵 𝐾 𝐵 ]𝑇 . Accelerometer can sense earth’s gravity which can become bottom reference. It can be described as follow: 𝐾 𝐵 = −𝐴 (10) Magnetometer can sense earth’s magnetic north as reference. It can be described as follow: 𝐼𝐵 = 𝑀 (11) With 𝐾 𝐵 and 𝐼𝐵 are known, 𝐽𝐵 can be calculated by using equation 𝐽𝐵 = 𝐾 𝐵 × 𝐼𝐵 with the rule of right handed coordinate. While 𝑤𝑎 as angular velocity for orientation calculation that affected by accelerometer can be described as 𝑤𝑎 = 𝐾0 𝐵 × 𝑣𝑎 |𝐾0 𝐵| 2 where 𝑣𝑎 = 𝑑𝐾𝐵 𝑑𝑡 = (𝐾𝐴 𝐵−𝐾0 𝐵) 𝑑𝑡 Then dθa = wadt = (K0 B × va)dt = (K0 B × (KA B − K0 B) dt⁄ )dt = K0 B × (KA B − K0 B) In order to improve accuracy of attitude calculation, complementary filter can be used. The complementary filter is used to fuse the sensors for getting reliable attitude information. The basic principle of complementary filter is to weight more on the trusted sensor [12]. 𝑑𝜃 = (𝑠𝑎 𝑑𝜃𝑎 + 𝑠𝑔 𝑑𝜃𝑔 ) 𝑠𝑎 + 𝑠𝑔 with 𝑠𝑎 and 𝑠𝑔 are respectively weighted accelerometer and gyroscope sensors. Following same logic as accelerometer, we can determine angular rate with magnetometer described as follow 𝑑𝜃𝑚 = 𝑑𝑡 𝑤𝑚 = 𝐼0 𝐵 × (𝐼𝑀 𝐵 − 𝐼0 𝐵 ) To know whether zenith (K) vector using gyroscope in short term condition, it can be described as follow: 𝐾𝐺 𝐵 = 𝐾0 𝐵 + 𝑑𝑡 𝑣 𝐾𝐺 𝐵 = 𝐾0 𝐵 + (𝑑𝜃𝑔 × 𝐾0 𝐵 ) (12) With 𝑑𝜃𝑔 = 𝑤𝑔 𝑑𝑡 and 𝑤𝑔 = 𝐺 because of gyroscope can directly measure angular speed. By using same logic in equation (12), it is known that 𝐼1 𝐵 = 𝐼0 𝐵 + (𝑑𝜃 × 𝐼0 𝐵 ) (13) 𝐽1 𝐵 = 𝐽0 𝐵 + (𝑑𝜃 × 𝐽0 𝐵 ) (14) Figure 5. Illustration of sensor orientation on global coordinate frame R.A. Yulnandi et al. / Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 64 2) Control algorithm Proportional Integral Derivative (PID) is relatively simple control algorithm that is suitable for controlling simple UAV. This control method can be formed by linear calculation which can be handled by 8-bit microcontroller. PID will give feedback control signal from error in order to control the plant in a closed- loop system as shown in Figure 6. Following Figure 6, PID consists of three main component calculations of the control signal 𝑢(𝑡) as given in equation (15): 𝑢(𝑡) = 𝐾𝑝𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡 + 𝐾𝑑 𝑑𝑒(𝑡) 𝑑𝑡 𝑡 0 (15) Where 𝐾𝑝 , 𝐾𝑖 and 𝐾𝑑 describe proportional, integral, derivative gains respectively. Each of them has different responses when step input is applied. The response is shown in Table 1. Ziegler–Nichols tuning rule method is used to tune the PID gains. 3) Actuator controller Servo motors are handling control surface mechanism to generate control motion. Servo motor needs a particular signal for generating control motion which is a pulse with 50 Hz frequency. Most of servo motor is using 1000-2000 microsecond pulse width as depicted in Figure 7. Therefore, ATMEGA’s interrupt feature is a great help to resolve amount pulse generator problem. B. Simulation software Simulation software is assigned to generate manipulated virtual environment. This environment can generate a streaming simulated sensory data to controller hardware via middleware. X-Plane 10 (X-Plane version 10) is used in this work for simulation software. According to Figure 8, Byte 1 2 3 4 5 6 7 8 9 HEADER Type Data STRING 4 Byte 4-byte unsigned Integer Byte 10 11 12 13 14 15 16 17 Data 1 Data 2 4-Byte Sign Float 4-Byte Sign Float Byte ... ... ... ... 38 39 40 41 Data ... Data 8 4-Byte Sign Float 4-Byte Sign Float Figure 9. X-Plane 10 UDP format data Byte 1 2 3 4 5 ... ... ... n+2 n+3 Header D a ta – 1 D a ta - 2 ... ... ... D a ta - n C h e c k su m Figure 10. Format data protocol UART Figure 6. Closed-loop PID Figure 7. PPM signal Table 1. Step-input PID control responses Increase gain Rise time Overshoot Settling time Steady-state error Propor-tional Decrease Increase Increase little decrease Integral Decrease Increase Increase eliminate Derivative Alter little decrease decrease Alter little Figure 8. X-PLANE 10 Unit R.A. Yulnandi et al. / Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 65 most of unit on X-Plane 10 are an imperial unit. Therefore, the conversion to metric unit is needed and this is one of tasks assigned to the middleware. X- Plane 10 uses UDP protocol to transfer attitude data. X-Plane 10’s format data UDP is described in Figure 9. X-Plane 10’s data transfer rate can be increased up to 100 samples/second. It can be assumed that it can produce simulated sensory data to replace sensory hardware with fastest sampling sensory data which is 50 samples/second from gyroscope and accelerometer. C. Middleware system Middleware is assigned to provide demands needed by controller hardware which is sensory data and simulator software which is feedback control from generated sensory data. As mentioned in the previous section, the main concern of middleware system is bridging the difference of communication protocols between UDP, used in simulation software, and UART, used in controller hardware. The middleware system is designed by using Visual Studio 2012 Express. Middleware’s assignment will consists in several parts such as follow:  Setting simulator software to send data (in UDP) every 10 ms or 100 samples/second to avoid a bottleneck in sensory data.  Creating format data with error checking as shown in Figure 10, to handle UART inability to detect occurrence of data error. That also prevents glitch data which can obstruct controlling process. Header data and checksum will be good solution to prevent data error.  Bridging between UDP protocol and UART protocol. C# language with framework 4.5 can provide UDP and UART communication protocol.  Implementing real-time simulation system as well as providing Human Machine Interface (HMI) about condition of controlled plant, as shown in Figure 11, which contain: 1. Controller Mode to set condition of plant such as launch or recovery mode. 2. Map and Waypoint to show plant position and set waypoint coordinate. 3. PID Gain Controller to tune PID gain in the real-time experiment. 4. Servo Monitor to monitor control signal of servo motor. 5. Camera Controller to show plant’s point of view in launch condition. 6. Holder Controller for switching to validate mode data sensor in the experiment. 7. Sensor Monitor for monitoring plant condition in chart form. 8. Compass to show rocket’s yaw orientation. 9. Artificial Horizon to show rocket’s roll and pitch orientation. 10. UART Controller for selecting UART port of the microcontroller.  Creating sensory data conversion features because some of X-Plane 10’s parameters are using imperial unit and sensory hardware are using metric unit, for example: Accelerometer: feet second2 to meter second2 to 16 bit digital This is intended to reduce microcontroller’s workload to interpret data from X-Plane 10.  Creating data buffering for some of parameter simulated sensory data (i.e. angular speed) with time dependence. Figure 12 shows how to handle that sensory data. Figure 11. Designed middleware R.A. Yulnandi et al. / Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 66 V. Experiment The experiment is conducted in few steps to ensure that middleware system can bridge the attitude data from simulator software for control signal computation in controller hardware. Each experiment is conducted by 30 times to ensure that each experiment result is consistent. These are experiment steps:  Data transfer rate test.  Validation simulated attitude data.  Comparison of control response. A. Data transfer rate test The experiment conducted by transferring data from simulator software to controller hardware via middleware to imitate sampling rate data of sensory hardware. Each experiment uses 250 samples data and records time delay between data transmission using controller hardware’s timestamp. Every time delay is recorded on controller hardware memory. Figure 13 and Figure 14 are test sample on gyroscope and accelerometer. Accelerometer gives result of 49.94 samples/second average sampling rates with 0.42 samples/second of standard deviation. Gyroscope gives result of 49.91 samples/second average sampling rates with 0.46 samples/second of standard deviation. Start Receive Raw sensory data from XPlane Convert Raw sensory data to digital data Receive Sending Signal from scheduler Add digital data to temporary variable in buffer No Send digital data Yes Reset Temporary variable No End Transmission data End Yes Figure 12. Buffering time-dependent data Figure 13. Accelerometer data transfer rate test Figure 14. Gyroscope data transfer rate test R.A. Yulnandi et al. / Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 67 Figure 15 and Figure 16 are test sample on magnetometer and barometer. Magnetometer gives result of 9.97 samples/second average sampling rate with 0.29 samples/second standard deviation. Barometer gives result of 9.96 samples/second average sampling rate with 0.27 samples/second standard deviation. B. Validation simulated attitude data Validation process compares simulated sensor data and real sensory hardware to determine the deviation of sensory system which represents the real experiment in the laboratory. The good system produces responses that have a good fit to the actual system responses on field testing. Due to laboratory experiment limitation, plant system is placed on a regulated control system. This is intended to make sensory hardware attitude follows the plant’s attitude on simulator software. Following Figure 17, the regulated control system will have a role as plant holder to imitate plant’s attitude on simulator software. The regulated control system imitates pitch angle because it is considered has an important role in autonomous take-off, landing and altitude control. The plant holder is depicted in Figure 18. Figure 15. Magnetometer transfer rate test Figure 16. Barometer data transfer rate test Simulated attitude Controller Processor Actuator Controller Attitude Sensory Holder Plant Controller Software Simulator + Reference Data Figure 17. Controller holder plant R.A. Yulnandi et al. / Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 68 The plant holder uses motorize control mechanism to generate pitching motion on the plant. The pitch motion makes microcontroller recalculate plant’s attitude using sensory hardware. Figure 19 shows result sample of this step. On steady-state condition, testing process for pitch angle gives comparison result differs by 0.36 degree average with 0.04 degree standard deviation. C. Comparison of control response The comparison of control response is done between a plant with sensory data from simulator software and sensory hardware. Rise time and steady- state error become comparison aspect. Figure 20 is an example of control response result and performance difference is presented in Table 2. According to Table 2, average of control responses differs by 0.46s for rise time and 0.53% for steady-state error. Figure 18. Implemented holder (a) (b) Figure 19. Sensory data; (a) comparison; (b) deviation R.A. Yulnandi et al. / Journal of Mechatronics, Electrical Power, and Vehicular Technology 8 (2017) 60–69 69 VI. Conclusions According to the experimental results, it is concluded that the designed HILS system satisfies the desired specification and produces responses that have a good fit to the actual system responses. According to desired system specifications, sensory data validation can achieve occurrence error less than 2 and the rise time of control PID between simulated sensory data and sensory hardware has difference less than 1 second and steady-state error of each sensory data less than 2%. The attitude data sampling rate through middleware system suffices the demand of sensory data for controller hardware. Acknowledgement This research is funded by Ministry of Research, Technology, and Higher Education of Republic of Indonesia via research scholarship of Second Batch of Program Menuju Doktor Sarjana Unggul (PMDSU) (328/SP2H/LT/DRPM /IX/2016). References [1] H. Y. Irwanto, “HILS of auto take off system: For high Speed UAV using booster rocket,” in 2016 International Seminar on Intelligent Technology and Its Applications (ISITIA), 2016, pp. 373–380. [2] D. Joglekar et al., “Autopilot design for aerospace vehicle using GUI — A user friendly approach,” in 2013 Annual IEEE India Conference (INDICON), 2013, pp. 1–6. [3] N. P. Mahalik and Kiseon Kim, “A Prototype for Hardware-in- the-Loop Simulation of a Distributed Control Architecture,” IEEE Trans. Syst. Man, Cybern. Part C (Applications Rev., vol. 38, no. 2, pp. 189–200, Mar. 2008. [4] H. Min et al., “Thruster Control for Micro-satellite Attitude and Hardware-in-the-loop Demonstration,” in 2012 International Conference on Industrial Control and Electronics Engineering, 2012, pp. 588–591. [5] A. Bittar and N. M. F. de Oliveira, “Hardware-in-the-loop simulation of an attitude control with switching actuators for SUAV,” in 2013 International Conference on Unmanned Aircraft Systems (ICUAS), 2013, pp. 134–142. [6] A. Alsaraj and G. Stuffle, “Investigation of hardware-in-loop simulation (HILS) for guidance system,” in 2015 IEEE Advanced Information Technology, Electronic and Automation Control Conference (IAEAC), 2015, pp. 704–708. [7] J. Park et al., “Hardware in-the-loop simulation for ABS using 32-bit embedded system,” Control. Autom. Syst. (ICCAS), 2011 11th Int. Conf., 2011, pp. 575–580. [8] A. Nurhafid et al., “Modelling and simulation of RKX200 rocket flight dynamics,” in 2013 3rd International Conference on Instrumentation, Communications, Information Technology and Biomedical Engineering (ICICI-BME), 2013, pp. 230–236. [9] In-Gyu Jang et al., “Testing 32-bit embedded system using hardware-in-the-loop-simulation of automatic transmission,” in 2007 International Conference on Control, Automation and Systems, 2007, pp. 399–403. [10] Y. W. Hadi and R. T. Bambang, “Development of hardware- in-the-loop simultion for rocket guidance system,” in 2015 International Conference on Electrical Engineering and Informatics (ICEEI), 2015, pp. 229–234. [11] B. J. Emran et al., “A Cascaded Approach for Quadrotor’s Attitude Estimation,” Procedia Technol., vol. 15, pp. 268–277, 2014. [12] M. S. Islam et al., “A low cost MEMS and complementary filter based attitude heading reference system (AHRS) for low speed aircraft,” in 2016 3rd International Conference on Electrical Engineering and Information Communication Technology (ICEEICT), 2016, pp. 1–5. Figure 20. Control response comparison Table 2. Experiment result Average Standard deviation Rise time (s) Steady-state error (%) Rise time (s) Steady-state error (%) Simulated sensory 1.89 0.93 0.15 0.11 Sensory hardware 1.43 0.4 0.11 0.07