**4.6. Send Button**

The Send Button is the button for user to send the data from SagWave to dsPIC microcontroller. The Duty.dat was generated by SagWave. The user clicked the "Send" button to send the Data.dat to dsPIC microcontroller by a RS-232 port. The program of this element shown in Fig. 21.

**Figure 20.** Program on Edit Text(Point on Wave, Sag Duration and Repeat) callback function.

**Figure 21.** Program on "Send" Button callback function for open communication port and send file.

#### **4.7. Refresh Button**

The Refresh Button is the button for user to clear the parameter and graph in SagWave for the next simulation. The program of this element shown in Fig. 22.

**Figure 22.** Program on "Refresh" Button callback function to clear all parameter.

#### **4.8. Plot Button**

124 MATLAB – A Fundamental Tool for Scientific Computing and Engineering Applications – Volume 1

The Send Button is the button for user to send the data from SagWave to dsPIC microcontroller. The Duty.dat was generated by SagWave. The user clicked the "Send" button to send the Data.dat to dsPIC microcontroller by a RS-232 port. The program of this

> **Edit Text Sag Duration**

**Figure 20.** Program on Edit Text(Point on Wave, Sag Duration and Repeat) callback function.

**Figure 21.** Program on "Send" Button callback function for open communication port and send file.

The Refresh Button is the button for user to clear the parameter and graph in SagWave for

the next simulation. The program of this element shown in Fig. 22.

**Edit Text Repeat**

**4.6. Send Button** 

element shown in Fig. 21.

**4.7. Refresh Button** 

**Edit Text Point on Wave**

> The Plot Button is a main element of the SagWave, when user clicked this button the callback program calculated and plot graph of voltage sag. The program of this element shown in Fig. 23 to Fig. 25.


**Figure 23.** Initial variable sections of Plot button.

#### **5. Simulation result**

From equation 1 to equation 7 in Topic 1, if we need 60%(V = 0.6) voltage sag there can be calculate and result in Table. 1. The operation of this program with the user designing the

voltage sag wave form SagWave software. Then the user clicks the "Send" button to send the parameters to dsPIC microcontroller. The actual voltage sag is created by a 3-phase 4-leg 4-wire inverter based on an *abc* algorithm.

**Figure 24.** The program of graph and vector of phase voltage plotting section.

For example, the designed waveforms have parameters as found in "Bollen, (2000)". The parameters in Table 1. are used to generate seven types of voltage sag. Users can verify waveforms through graphic display windows as shown in Fig. 24.


**Table 1.** Parameter for seven type of voltage sag.

SagWave software can create point on wave single-phase(phase A) voltage sag, the parameters are shown in Table 2. The display of waveforms was is in Fig. 25. The parameters of single-phase(phase A) repeated voltage sag is shown in Table 3, and the simulation waveform in Fig.26.

126 MATLAB – A Fundamental Tool for Scientific Computing and Engineering Applications – Volume 1

**Figure 24.** The program of graph and vector of phase voltage plotting section.

waveforms through graphic display windows as shown in Fig. 24.

**Table 1.** Parameter for seven type of voltage sag.

Voltage Sag Type

For example, the designed waveforms have parameters as found in "Bollen, (2000)". The parameters in Table 1. are used to generate seven types of voltage sag. Users can verify

A B C Magnitude Phase Magnitude Phase Lag Lead Magnitude Phase Lag Lead A *V* 0 0.6 120 - - 0.6 120 - - B *V* 0 1 120 - - 1 120 - - C 1 0 0.72 133.9 13.39 - 0.72 133.9 - 13.39 D 0.6 0 0.92 109.1 - 10.9 0.92 109.1 10.9 - E 1 0 0.6 120 - - 0.6 120 - - F *V* 0 0.808 111.79 - 8.21 0.808 111.79 8.21 - G 0.867 0 0.6 129.83 9.83 - 0.6 129.83 - 9.83

Phase Voltage

4-wire inverter based on an *abc* algorithm.

voltage sag wave form SagWave software. Then the user clicks the "Send" button to send the parameters to dsPIC microcontroller. The actual voltage sag is created by a 3-phase 4-leg

**Figure 25.** The program of Normal and Repeat as Repeat = 3.


**Table 2.** Parameter of point on wave voltage sag.

**Figure 26.** The seven types of voltage sag created using SagWave software.

**Figure 27.** a) The point on wave at 45 ; b) The point on wave at 45 ; c) The point on wave at 270


**Table 3.** Parameter of repeated voltage sag.

**Figure 26.** The seven types of voltage sag created using SagWave software.

**Figure 27.** a) The point on wave at 45 ; b) The point on wave at 45 ; c) The point on wave at 270

a) b) c)

**Figure 28.** The simulation of single-phase voltage sag repeated.
