Design and implement of pulse width modulation with low-cost hardware in the loop

Received Sep 28, 2019 Revised Nov 9, 2019 Accepted Dec 15, 2019 The paper presents a low-cost hardware in the loop based on Arduino. Sinusoidal Pulse Width Modulation (SPWM) designing, analyzing, and implementation is experimented as hardware in the loop. Sinusoidal Pulse Width Modulation implementation via MATLAB\Simulation demonstrates in this work. In this paper, Arduino Mega2560 platform, microcontroller, introduce as hardware. A comparative study of the both techniques is presented. Arduino interfaces with PC Target MATLAB environment. Three phases Voltage Source Inverter directs by the generated pulses that loads with three phases RLC. The obtaining output current and voltage waveform of RLC load of Hardware-in-the-Loop validates to the MATLAB\simulation output waveform. The compering shows the output waveforms are primarily having the same pattern. Arduino consider as the lost cost as microcontroller which could be used in real application.


INTRODUCTION
Pulse Width Modulation (PWM) is technique that allows complicated control of power electronic converter to apply. PWM can be accomplish via virtual, MATLAB, and Hardware in loop. MATLAB\Simulink simulation and Hardware-in-the-Loop HIL are techniques methods of design and implement modeled system. These techniques are used to implement and test any modeling-controlled system. However, accomplishment of HIL is slightly different from MATLAB\Simulink simulation. HIL is used a part of the control system loop in real hardware, whereas some parts are simulated. Generally, with HIL, controlled plant or process is simulated because of doing experiment with actual plant is costly [1]. Thus, the problem, testing and validating designing circuit in real time is very crucial and expensive. The gole in this project, sinusoidal pulse with modulation design is experimented with HIL using low cost (Arduino) hardware [2]. The cost of Arduino can find in [3].
Converting electrical power form DC/AC is rapidly cumulative, as rustle of advances of power switch semiconductors [4], increasing using renewable energy, control electric machines also transferring electrical power between two different frequency systems [5]- [6]. Power electronic converter is controlled via many methods; hence, Pulse Width Modulation PWM is extensively applied. PWM is created through programing a microcontroller like Arduino platform which is considered as low-cost hardware microcontroller [7]- [8]. Pulse Width Modulation (PWM) is technique that generates a train of pulsing waveform of high and low, which turn on and off solid state switching. PWM controls the pulsating waveform duty ratio by another input control waveform [5]. PWM techniques are considered most compatible modulation methods [9]- [10] for reduction in harmonic of inverters in contrasting with multiple and single pulse width modulations [11] HIL were firstly realized by [1] for real time flight simulation, where the instruments simulation with fixed cockpit was the purposes [12]. Typical HIL consists of Microcontroller board, Arduino or DSP cards, a host PC, and special interface cable [13]. Hardware-in-the-loop shows easy way of testing and see how the actual system is performing in hardware. It enables virtual system model to operate with physical part in order to enhance the simulation output [14]. HIL technique is used to validate MATLAB/SIMULINK simulation and results of experiment [15]. The implementation of SPWM via simulation and HIL were developed and discussed with their VSI output voltage and load current. Usually, extraordinary power converter application is desired high efficiency and less harmonic distortion [16]. In this work, SPWM is realized via MATLAB simulation, in one hand. In another hand, we use HIL to realize SPWM. Both generated SPWM are verified and test by feeding three phase voltage source invertor VSI which is loaded with three phase AC load, testing load. The block diagram of SPWM is shown in Figure 1 with VSI and AC load.

IMPLEMENTATION AND MODELING SPWM WITH MATLAB\SIMULINK SIMULATION
Sinusoidal PWM is one of PWM techniques of driving power electronic converter. It is commonly used in industrial, since it does not need so sophisticated method to implement. Using this method is being able to control the waveform and frequency of the converter (inverter) output [17]. SPWM is created by comparing of two signals; sinusoidal reference wave from, and carrier waveform [18]. Where, the carrier is sawtooth or triangle wave from. The crossing between the carrier and reference waveform yields on and off status of switches [19]. The reference frequency is regulated the output frequency of inverter, where, the carrier requency controls the pulses' number per half cycle of the output waveform [13]. This technique is not complicated to imply; however, this technique is unable to fully consume the DC bus voltage [20][21] where a three-sine wave generator with 1200 phase shift between each other with saw tooth generator. The design modelling is based on [1].

Development of sinusoidal PWM
Based on MATLAB Simulation\ Simulink, SPWM can be achieved by using sine wave and triangle generator. The required output voltage is produced by directing the each other with saw tooth generator. The design modeling is based on [1]. The whole system of development SPWM with VSI and RLC load is showed in Figure 2. In addition, changing the amplitude and frequency of the reference or sinusoidal modulating signal would alter the patterns of output voltage pulse-width. However, the Sinusoidal waveform is not change.
[22] Further, the triangle waveform or carrier signal is generated at high frequency; in this paper is 4000 Hz. It determines the switching frequency of the switching power electronic [23]. While sinusoidal modulating signal is created at low frequency 50 Hz. The state of high and low are determined by the intersection between the reference and triangular waveform. Thus, the intersection positions would define the time of variable switching state. [24][25]

Simulation results
In this section SPWM simulations are performed. Figure 3 shows six pulses of SPWM. Where, the SPWM of six pulses is fed to three phase inverters. Each two pulses are on and off in different time. The performance of proposed testing load is simulated on MATLAB Simulink model. Three phase sinusoidal gate pulses are generated by the SPWM method.  Recently HIL simulation is growing for testing, design, and implementation control system; some part of control loop system where are simulated and some are real hardware. HIL is described by processing of real part in real time with simulated components. Widely, HIL simulation has been utilized for studying the performance of modeled control system in real-time [17]. Arduino mega260, as shown in Figure 6 [18], is used as a microcontroller of the hardware in the loop. Arduino considers as the lowest microcontroller price. Arduino mega256 is powered by ATmega2560 [3]. It has 54 input/output pins (of which 14 can be used as PWM outputs), a power jack, a 16 MHz crystal oscillator, 4 UARTs (hardware serial ports), 16 analog inputs, an ICSP header, a USB connection, and a reset button. In recent year, Arduino and Mat Lab Company realizes a support package [3] for Arduino to interface and work with MATLAB program, especially MATLAB Simulink.

SPWM implementation with hardware in the loop
As mention, SPWM can by created by intersection of two waveforms; triangle and sine wave. In HIL, it is used the same technique in order to generate the pulses (signals) of SPWM. Though, the generated SPWM. Signals are created in real time. Implement of HIL, SPWM and testing load (VSI & RLC load) models are decomposed into two Simulink model. One of them is built and uploaded to the Arduino, as show in Figure 7(a). It is contained modeling of SPWM generator and serial transmitter block, which interface with the host PC and Mathlab. This Simulink model with Arduino are represented the hardware. However, data type converter has to be place between spwm signal generator block and serial transver block. Because of the matlap simulink enverinment need data to be in unt8. The second Simulink model is contained testing load (VSI & RLC load) and serial receiver, which is fixed on host PC, as shown in Figure 7 (b). Previously, Arduino was set up and defined on the host PC also; it was interfaced and defined with MATLAB program. Now, the SPWM designed model is ready to verify and upload to the Arduino through USB cable. By clicking the Deploy to Hardware in the model window toolbar the program is started the verification and down loading the model to microcontroller board. Once the model completely downloaded, SPWM model generator starts to run and send signal to Simulink simulation environment, testing load (VSI & RLC load) model. After the simulation is accomplished, the results should be exhibited on the scopes of testing load model.

Simulation results of SPWM with HIL
After the SPWM gate singles have been receiving from Arduino to MATLAB on host computer, the simulation starts to process the model and the output would show in the scopes. Figure 8 is shown a six pulse for three phase VSI. Where, Figure 9(a) is depicted three phase line to line voltage and three phase line to neutral voltage of VSI output. Also, the filtered three phase load current and line to line output voltage are shown in Figure 9

Experiment setup and Instrumentation
As illustrated in Figure 11, the test instrumentation consists of the host computer and Arduino Kit. The instrumentation computer allows the user to interface and control the kit settings. Voltage and current waveform in both implementations are almost sinusoidal after pass through second order filter. However, HIL is took longer time to accomplish, since it was processing SPWM in real time.