Journal of Energy, Electrical, and Computer Engineering, 2 (1) (2022) 31-37 Journal ofRenewable Renewable Energy, Electrical, and Computer Engineering Vol. 2, No. 1, March 2022, 31-37 e-ISSN: 2776-0049 Research Original Article DOI: https://doi.org/10.29103/jreece.v2i1.6889 Arduino Mega Based System Design for Sequence and Phase Difference Detection of Three-Phase Systems I Made Ari NrarthaπŸ–‚1, Ahmad Sandi Yayan Saputra1, Supriono1, Arnawan Hasibuan2, M. Sayuti3, & Waleed Khalid Ahmed Al-Ani4 1 Department of Electrical Engineering, Universitas Mataram, Nusa Tenggara Barat, Indonesia 2 Department of Electrical Engineering, Universitas Malikussaleh, Bukit Indah, Lhokseumawe, Indonesia 3 Department of Industrial Engineering, Universitas Malikussaleh, Bukit Indah, Lhokseumawe, Indonesia 4 Ministry on Industry and Minerals the State Company for Glass & Refractories, Republic of Iraq nrartha@unram.ac.id; yayansandi20@gmail.com; supriono@unram.ac.id; arnawan@unimal.ac.id πŸ–‚Corresponding Author: nrartha@unram.ac.id | Phone: +6287765512543 Received: February 20, 2022 Revision: March 18, 2022 Accepted: March 27, 2022 Abstract In a three-phase system, the difference in the angle between the phases and the phase sequence of the system is very important to ensure the system functions normally and does not cause damage to the three-phase equipment connected to the system. Trigonometric formulas in multiphase systems are used to obtain the angle difference between the phases and the sequence of phases in the system. The trigonometric formula was tested in a simulation using MATLAB software, then applied to an Arduino Mega-based system. In the simulation, the data are two voltages vs. time with a certain phase angle difference, then using the trigonometric formula in the MATLAB program, the data is recovered from the phase angle difference and the direction of rotation of the two voltages. Based on the valid MATLAB simulation test results, the program algorithm is embedded in an Arduino Mega-based system equipped with 2 voltage sensors and a 2.4-inch TFT LCD. The Arduino Mega-based system has succeeded in detecting and visualizing in the form of a graph the angle difference between the phases and the direction of rotation of the three-phase system. Keywords: arduino mega; three-phase system; phase sequence; phase difference; Introduction The AC system allows the system to have multiple phases making it more advantageous than a single-phase system. Such a three-phase AC system has several advantages such as: smaller system size for larger power such as three-phase electric motors and power plants; in the operation of a three-phase electric motor, the motor does not require an auxiliary coil to rotate; and the power delivery of a three-phase system is greater than that of a single-phase AC system. In a three-phase power system, the power plant (three-phase generator) is the main component to supply electrical power to the system. As the electrical load increases, additional power is required from other power generating units to enter the system. Other generating units that will enter the system must go through a synchronization process. One of the requirements for the synchronization process is the phase sequence of the generating unit must be the same as the system. The same phase sequence between the power generation unit and the system is very important to avoid the failure of the operation of the power generation unit. In a balanced three-phase system, the phase angle difference is 1200. Phase balance is very important for the operation of three-phase electrical equipment such as three-phase electric motors. Three-phase power supply imbalance in threephase electric motors can cause abnormal operation, and even damage the motor. This study aims to design an Arduino Mega-based system to detect differences in the angle between phases and the direction of rotation of a three-phase system. The difference in the phase angle and direction of rotation of a three-phase system can be obtained simply from the two voltage values of a three-phase system. The formulation to obtain the difference in phase angle and direction of rotation of a three-phase system was tested on MATLAB before the algorithm was implanted in an Arduino Mega-based system equipped with two voltage sensors and a 2.4-inch TFT LCD. This article describes the results of system design starting with the introduction in the first part, followed by a literature review in the second part. The methods and materials used for system design in the third, fourth, and fifth sections are the results and discussion of research, and conclusions. Literature Review Arduino Mega 2560 is a circuit board with an Atmega 2560 microcontroller chip. This type of Arduino has the most number of pins among all other types of Arduinos. This is the reason why Arduino Mega was widely used for research. Arduino Mega as a microcontroller in smart home design using a local area network (Kusriyanto & Putra, 2016), besides that Arduino Mega is also used as a basis for making smart energy meters to increase efficiency and accuracy in calculating electricity bills (Jaiswal & Chaubisa, 2017), Arduino Mega as a weather station base that uses the IoT platform (Kusriyanto 31 Journal of Renewable Energy, Electrical, and Computer Engineering, 2 (1) (2022) 31-37 & Putra, 2018). In the MPP tracking system on the PV system, Arduino Mega is used to drive a boost converter to get optimal power (Nabil et al., 2018), MPP tracking design with P&O and INC methods for stand-alone PV systems using Arduino Mega (Mishra et al., 2019). (Djamel et al., 2019) produced an Arduino Mega based PID digital controller for DCDC boost converter control. In addition to controlling the DC-DC converter, Arduino Mega has also been successfully used to control a variable frequency converter to drive a BLDC motor (Vlad et al., 2020). The development of electric vehicles requires an electric charging station, where the station requires intelligent energy billing to calculate electricity bills, (Nrartha et al., 2018) succeeded in building an Arduino Mega-based intelligent billing system for this solution. For complex systems such as automatic segmentation of uterine contractions in EHG signals, Arduino Mega collaborates with raspberry pi for hardware implementation (Naaman et al., 2021). In an electric power system, components such as generator, transmission, and primary distribution are three-phase systems. In a three-phase system, the angle difference between the phases and the sequence of the phases will produce the direction of rotation in three-phase electrical equipment such as three-phase electric motors. The direction of rotation of a three-phase electric motor can be reversed by swapping the connection of any two phases (Ben, 2020). The electric generator is the main power source in the electric power system. Sometimes the increase in load on the electric power system requires power supply from an electric generator that is not yet operating, because the power from an operating electric generator is not sufficient. An electric generator that will enter the power system requires that the electric generator has the same phase sequence as the electric power system (Teja, 2021). The unequal phase sequence will cause the electric generator unable to enter the electric power system. This is the reason why there is a need for devices to detect phase angle differences and phase sequences of three-phase systems. Figures 1.A, 1.B, 1.C, and 1.D, are the positive sequence voltage waves of a balanced three-phase system, the phasor diagram of the positive sequence, the negative sequence voltage waveform, and the phasor diagram of the negative sequence. A balanced three-phase system has an angle difference between the phases of 1200 for the positive and negative sequences. The positive sequence represents the clockwise phase rotation of A-B-C (Figure 1.B), while the negative sequence represents the anticlockwise phase rotation of A-B-C (Figure 1.D). Figure 1. Balanced Three-Phase System Figure 2. Unbalanced Three-Phase System 32 Journal of Renewable Energy, Electrical, and Computer Engineering, 2 (1) (2022) 31-37 Figures 2.A, 2.B, 2.C, and 2.D, are the positive sequence unbalanced voltage waveforms of a three-phase system, the phasor diagram of the positive sequence, the negative sequence voltage waveforms, and the phasor diagram of the negative sequence. In an unbalanced three-phase system, the angle difference between the phases is not the same. Figure 2, the angle difference between the VA and VB phases is 1500, while the VA and VC phases is 1000 so that the angle difference between the VB and VC phases is 1100. The AC voltage equation can be written as follows: 𝑣π‘₯ (𝑑) = π‘‰π‘šπ‘Žπ‘₯ π‘π‘œπ‘ (πœ”π‘‘ βˆ’ πœƒπ‘₯ ) (1) where, x, , and  are the phase of the voltage, the radian frequency, and the phase shift. The phase angle difference between voltages (), for example the voltages of phase π‘£π‘Ž (𝑑) and phase 𝑣𝑏 (𝑑) can be obtained using equation 4. π‘£π‘Ž (𝑑) = π‘‰π‘šπ‘Žπ‘₯ π‘π‘œπ‘ (πœ”π‘‘ βˆ’ πœƒπ‘Ž ) (2) 𝑣𝑏 (𝑑) = π‘‰π‘šπ‘Žπ‘₯ π‘π‘œπ‘ (πœ”π‘‘ βˆ’ πœƒπ‘ ) (3) 𝛿 = |πœƒπ‘Ž βˆ’ πœƒπ‘ | (4) An alternative way to get the voltage angle difference between phases, if the data of the voltages as a function of time are known. The formula in equations 5 to 8 can be used for this. 𝑇 (5) 𝑉𝑏,π‘Ÿπ‘šπ‘  = √ ∫0 𝑣𝑏 2 (𝑑)𝑑𝑑 𝑇 (6) 𝑇 (7) 1 π‘‰π‘Ž,π‘Ÿπ‘šπ‘  = √ ∫0 π‘£π‘Ž 2 (𝑑)𝑑𝑑 𝑇 1 𝑇 1 𝑉𝑣𝑣,π‘Žπ‘£π‘” = ∫0 (π‘£π‘Ž (𝑑) βˆ— 𝑣𝑏 (𝑑))𝑑𝑑 𝑇 𝑉𝑣𝑣,π‘Žπ‘£π‘” 𝛿 = π‘Žπ‘π‘œπ‘  ( π‘‰π‘Ž,π‘Ÿπ‘šπ‘  βˆ—π‘‰π‘,π‘Ÿπ‘šπ‘  (8) ) By using trigonometry, equation 8 can be drawn in Figure 3. Va,rms*Vb,rms  Vvv,avg Figure 3. The Trigonometric for The Angle Difference between Phases The direction of rotation of the three-phase system can be determined from the data of the two phases of the system (eg phases π‘£π‘Ž (𝑑) and 𝑣𝑏 (𝑑)). Visualization of the direction of rotation can be obtained from plotting equations 2 and 3 as follows: π‘π‘™π‘œπ‘‘(𝑣𝑏 (𝑑), π‘£π‘Ž (𝑑)) (9) Visualization of rotation direction using equation 9 can also estimate the angle difference between the voltage phases a (π‘£π‘Ž (𝑑)) and b (𝑣𝑏 (𝑑)) based on the resulting circle shape. Materials & Methods The hardware materials for designing this system are one Arduino Mega 2560, one 2.4-inch TFT LCD, and two AC voltage sensors (ZMPT101B module). The software is Arduino IDE 1.8.19 and some of the libraries are UTFTGLUE.h, SPI.h and MCUFRIEND_kbv.h. Figure 4 is a block diagram of systems based on Arduino Mega for sequence and phase difference detection of three phase systems. Arduino Mega Three-phase Power supply AC L1 L2 L3 a ZMPT101B (1) ADC A8 b ZMPT101B (2) ADC A9 Any two phases 2.4-inch TFT LCD Power supply 5 V DC from Computer USB Figure 4. Block Diagram of The System The study began by testing the direction of rotation of a three-phase electric motor by supplying a three-phase source to an electric motor and exchanging a two-phase connection to indicate a change in the direction of rotation. Based on the results of the direction of rotation of the electric motor and changes in the direction of rotation, the phase sequence of the three-phase source is determined. This determination was to validate the simulation results in MATLAB for the direction 33 Journal of Renewable Energy, Electrical, and Computer Engineering, 2 (1) (2022) 31-37 of rotation using equation 9. Then made a program in MATLAB to calculate the phase angle difference between voltages using equations 5 to 8. The phase voltage data was made according to equations 2, and 3 for phases π‘£π‘Ž (𝑑), and 𝑣𝑏 (𝑑) with frequency 50 Hz and Vmax = 220*√ 2. For one period, the voltage data for each phase was enumerated as much as 100 data. The program code with these equations in MATLAB was tested by changing the data of the phase angle difference and the phase sequence of each phase voltage and seeing whether the results of the phase angle differences between the voltages were the same. After equal or valid, the phase difference between the voltages and the altered phase sequence, the visual form was checked to determine the circular shape and direction of the resulting rotation. The next step was to create the same program code for Arduino Mega on Arduino Ide. The phase voltage data was obtained from the measurement results of two voltage sensors connected to the ADC of Arduino Mega as showed on Figure 4. Each voltage sensor was set to have 100 data for each period. On ATmega-based boards (UNO, Nano, Mini, Mega), it takes approximately 100 microseconds (0.0001 s) to read analog input, resulting in a maximum read speed of about 10,000 times per second. So, for a system that uses a frequency of 50 Hz, two voltage sensors for one period will get 100 sample data of voltage. Phase difference between the voltages could be calculated using equations 5 to 8 on the Arduino Ide using these data. Equation 9 on Arduino Ide with its library to display the rotation direction of a three-phase system and a certain circle shape depending on the phase angle difference on the 2.4-inch TFT LCD. These design steps are shown in Figure 5. START 1 Three-phase electric motor operation data such as phase difference and phase sequence. Made the same program as in MATLAB on Arduino Mega Made a program in MATLAB using equations 2,3, 5-8 and 9. Voltage data from ZMPT101B via ADC of Arduino Mega Program simulation by varying the value of the phase difference and phase sequence Display rotation direction and voltage phase difference on 2.4 inch TFT LCD Are the program results valid Results and Discussion No Documentation of results and conclusions Yes 1 STOP Figure 5. Flowchart for Design of System Results and Discussion The direction of rotation of the rotor in a three-phase induction motor is clockwise when a three-phase power supply is supplied with a positive phase sequence. Based on these results, the MATLAB program was created using equation 9. The program code in Figure 6.A, and 6.B is the result of the program code Figure 6.A. % Direction of rotation of two % voltages with different phases % -----------------------------clear clc f=50; % frequency T=1/f; % periode data = 100; % amount of data in one period t=linspace(0,2*T,data); Vrms=220; Vmax=sqrt(2)*Vrms; % for positif sequence va=Vmax*sin(2*pi*f*t-0); vb=Vmax*sin(2*pi*f*t-120/180*pi); figure(1) for i=1:data, plot(vb,va,'k-','LineWidth', 2) hold on plot(vb(i),va(i),'rs', 'LineWidth' , 2); axis([-Vmax Vmax -Vmax Vmax]); grid on title('Phase Sequence Indicator','FontSize', … 12,'FontWeight', 'bold'); xlabel ('Phase voltage b (V_b)'); ylabel ('Phase voltage a (V_a)'); legend ('Phase angle difference graph form',… 'Direction of rotation of positive sequence',1); pause(0.001); hold off end A. The program code of rotation direction B. The result of the program code of rotation direction Figure 6. MATLAB Program for Phase Sequence 34 Journal of Renewable Energy, Electrical, and Computer Engineering, 2 (1) (2022) 31-37 The results of the program code as shown in Figure 6.B, the shape of the graph is oval for the 120 0 angle difference between phases. The direction of rotation is clockwise according to the data in the program that the phase of voltage a (Va) leads 1200 from b (Vb). Another phase difference between voltages can be tested by changing the angle difference between the phases of voltage a and b, which can be shown in Figure 7. A. Phase of voltage a (Va) leads 600 from b (Vb) B. Phase of voltage a (Va) leads 900 from b (Vb) C. Phase of voltage a (Va) leads 1500 from b (Vb) D. Phase of voltage a (Va) leads 1800 from b (Vb) Figure 7. Positive Sequence Rotation Direction or Clockwise For the direction of rotation for the negative sequence or counterclockwise, the phase difference between the voltages can be shown in Figure 8 for the various phase differences of the phase of voltage a and b. A. Phase of voltage a (Va) lags 600 from b (Vb) B. Phase of voltage a (Va) lags 900 from b (Vb) C. Phase of voltage a (Va) lags 1200 from b (Vb) D. Phase of voltage a (Va) lags 1500 from b (Vb) Figure 8. Negative Sequence Rotation Direction or Counterclockwise Figures 7 and 8 show that for both positive and negative sequences, the same phase angle difference between phase of voltage a and b will produce the same circular shape. The phase angle difference between the phase voltages can be 35 Journal of Renewable Energy, Electrical, and Computer Engineering, 2 (1) (2022) 31-37 obtained based on equations 5 to 8. The MATLAB program for this program code is shown in Figure 9. Several variations of the phase angle difference were tested and the results are shown in Table 1. % Phase angle difference (PAD) % ---------------------------clear; clc; f=50; % frequency T=1/f; % periode data = 100; % amount of data in one period t=linspace(0,2*T,data); Vrms=220; DeltaA=0; DeltaB=30; DeltaD = (DeltaB- DeltaA); Vmax=sqrt(2)*Vrms; % for positif sequence va=Vmax*sin(2*pi*f*t - DeltaA/180*pi); vb=Vmax*sin(2*pi*f*t - DeltaB/180*pi); Varms=sqrt(1/length(va)*sum(va.^2)); Vbrms=sqrt(1/length(vb)*sum(vb.^2)); Vvvavg=1/length(va)*sum(va.*vb); delta = acos(Vvvavg/(Varms*Vbrms))*180/pi % PAD Figure 9. The program code of phase angle difference DeltaD (0) +/-30 +/-60 +/-90 +/-120 +/-150 +/-180 Table 1. Phase angle difference data versus program code results Program code results / delta (0) Different (%) 30,2487/30,2487 0,8291 60,2475/60,2475 0,4125 90,0000/90,0000 0,0000 119,7525/119,7525 0,2062 149,7513/149,7513 0,1658 180,0000/180,0000 0,0000 Average 0,2689 Table 1 shows that the Program code results cannot produce positive or negative values. Positive and negative values can be obtained from the program of rotation direction. Positive phase angle difference means the rotation direction is clockwise, while the opposite for the negative phase angle difference. The difference of DeltaD and Program code results is an average of 0,2689%. The next step was embedded the program code to the Arduino Mega by using Arduino Ide software. Figure 10 shows an Arduino Mega based system for detecting phase angle differences and phase sequences from a three-phase source. The results of phase sequence detection and the difference between phases are shown in Figure 11. Figure 10. Arduino Mega Based System and Three-Phase Power Supply A. Positive sequence or clockwise rotation B. Negative sequence or counterclockwise rotation Figure 11. Results shown on the 2.4-inch TFT LCD for connection of Vin1 to Line 1 and Vin2 to Line 2, and vice versa 36 Journal of Renewable Energy, Electrical, and Computer Engineering, 2 (1) (2022) 31-37 Figure 11 A shows the clockwise rotation if Vin1 is connected to line 1 and Vin2 to line 2. The phase angle difference between line 1 and 2 is 142,470. For the reverse connection, Vin1 is connected to line 2 and Vin2 to line 1, the rotation direction is counterclockwise with a phase angle difference 139,240. This is shown in Figure 11.B. Difference results for both positive and negative sequences were due to the fluctuating voltage sensor measurement. Because of that, rms voltage also fluctuates. The value of Vrms line 1 are 220,41 and 221,90 Volts for positive and negative sequence, respectively. Likewise, the value of Vrms line 2 are 225,53 and 222.50 Volts for positive and the negative sequence, respectively. The rated voltage on line 2 is higher than line 1 in both conditions. Conclusions The Arduino Mega-based system has been successfully designed to detect the phase angle difference and phase sequence of a three-phase system. The system design starts from observing the direction of rotation of the three-phase electric motor which is supplied by a three-phase source, then by swapping the connection of any two phases to produce reverse rotation. Then made a trigonometric formula to get the phase angle difference and phase sequence of the multiphase system. Two phases of the three-phase system were used, then to be tested in the MATLAB program. Based on the valid output, the program code on MATLAB was embedded in the Arduino Mega using Arduino Ide software and several libraries to display the results on a 2.4-inch TFT LCD. References Ben. (2020). How to Reverse a Three Phase Motor. https://learnelectricalmaintenance.com/how-reverse-three-phase-motor/ Djamel, O., Dhaouadi, G., Youcef, S., & Mahmoud, M. (2019). Hardware Implementation of Digital PID Controller for DC– DC Boost Converter. 2019 4th International Conference on Power Electronics and Their Applications (ICPEA), 1–4. https://doi.org/10.1109/ICPEA1.2019.8911129 Jaiswal, O., & Chaubisa, D. (2017). Arduino mega and IOT based intelligent energy meter (IEM) to increase efficiency and accuracy in current billing methodology. 2017 International Conference on Energy, Communication, Data Analytics and Soft Computing (ICECDS), 1901–1904. https://doi.org/10.1109/ICECDS.2017.8389780 Kusriyanto, M., & Putra, A. A. (2018). Weather Station Design Using IoT Platform Based on Arduino Mega. 2018 International Symposium on Electronics and Smart Devices (ISESD), 1–4. https://doi.org/10.1109/ISESD.2018.8605456 Kusriyanto, M., & Putra, B. D. (2016). Smart home using local area network (LAN) based arduino mega 2560. 2016 2nd International Conference on Wireless and Telematics (ICWT), 127–131. https://doi.org/10.1109/ICWT.2016.7870866 Mishra, J., Das, S., Kumar, D., & Pattnaik, M. (2019). Performance Comparison of P&O and INC MPPT Algorithm for a Stand-alone PV System. 2019 Innovations in Power and Advanced Computing Technologies (i-PACT), 1, 1–5. https://doi.org/10.1109/i-PACT44901.2019.8960005 Naaman, F., Zakaria, F., Zaylaa, A., Khalil, M., & Mechref, K. (2021). Automatic segmentation of uterine contractions in EHG signals: Hardware implementation with Raspberry Pi and Arduino Mega. 2021 Sixth International Conference on Advances in Biomedical Engineering (ICABME), 15–18. https://doi.org/10.1109/ICABME53305.2021.9604840 Nabil, O., Bachir, B., & ALLAG, A. (2018). Implementation of a new MPPT Technique for PV systems using a Boost Converter driven by Arduino MEGA. 2018 International Conference on Communications and Electrical Engineering (ICCEE), 1–5. https://doi.org/10.1109/CCEE.2018.8634503 Nrartha, I. M. A., Muljono, A. B., Ginarsa, I. M., Sasongko, S. M. Al, & Citarsa, I. B. F. (2018). Smart Energy Meter for Electric Vehicle Based on Bluetooth and GSM Technology. 2018 International Conference on Smart Green Technology in Electrical and Information Systems (ICSGTEIS), 7–12. https://doi.org/10.1109/ICSGTEIS.2018.8709139 Teja, R. (2021). Synchronization of Generators. https://www.electronicshub.org/synchronization-of-generators/ Vlad, M., Popov, P., & Vasile, D. (2020). Simulation of Arduino Mega 2560 board controlling a variable frequency converter driving a BLDC motor. 2020 7th International Conference on Energy Efficiency and Agricultural Engineering (EE&AE), 1– 4. https://doi.org/10.1109/EEAE49144.2020.9278996 37