**4.1. Magnitude of Voltage Sag**

These groups to input the magnitude of the voltage sag. There are two ways to input the magnitude;

1. Edit Text (Phase A, Phase B, Phase C Magnitude)

The Edit Text is an element that user to enter a text string(0 to 100). The program of this element is shown in Fig.14, in this program shown how to converse string to numeric.

**Figure 13.** The main concept of SagWave programming.

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

**3.12. The button "Refresh" for clear the value and graphic display** 

**microcontroller** 

The property inspector was shown in Fig.12.

new value. The property inspector was shown in Fig.12.

**Figure 12.** The property inspector of Plot, Send and Refresh Button.

user with extension \*.fig and \*.m of the same name.

the function of each component on the SagWave.

1. Edit Text (Phase A, Phase B, Phase C Magnitude)

**4. SagWave programming** 

**4.1. Magnitude of Voltage Sag** 

magnitude;

**3.11. The button "Send" for send the data from SagWave to the dsPIC** 

The "Send" button used to send the wave form data of voltage sag to dsPIC microcontroller.

The "Refresh" button used to clear the graphic, all of the value in program to provide the

Finally users are ready to let GUIDE create the Fig-file and M-file. They are two options to create; one, simply select menu File → Save As.., or users can run GUI by select menu Tools

→ Run or click on tool bar. GUIDE will save user's GUI to file with the name as gave by

The concept of SagWave programming shown in Fig. 13. Form the 3th topic, GUIDE will create an M-File with callback function prototypes. The callback function was response to an event by MATLAB code. There must be a callback to implement the function of each graphical component on the GUI. Now we must be programming the callback to implement

These groups to input the magnitude of the voltage sag. There are two ways to input the

**Figure 14.** Program on Edit Text(Magnitude) callback function for input Magnitude.

	- 2. Slider (Phase A, Phase B, Phase C Magnitude)

The Slider is the element that user to select values from continuous range between a specified minimum and maximum value by moving a bar with mouse. The program of this element is shown in Fig.15.


**Figure 15.** Program on Slider(Magnitude) callback function for input Magnitude.

## **4.2. Phase angle of Voltage Sag**

These groups to input the phase angel of voltage sag. There are two ways to input the magnitude;

1. Edit Text (Phase A, Phase B, Phase C Phase angle)

The Edit Text is an element that user to enter a text string (-90 to +90). The program of this element is shown in Fig.16, in this program shown how to converse string to numeric.

2. Slider (Phase A, Phase B, Phase C Phase angle)

The program of this element is shown in Fig.17.

**Figure 16.** Program on Edit Text(Phase angle) callback function for input phase angle.


**Figure 17.** Fig. 17. Program on Slider(Phase angle) callback function for input phase angle.

### **4.3. Voltage Sag Type**

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

**Figure 15.** Program on Slider(Magnitude) callback function for input Magnitude.

The Slider is the element that user to select values from continuous range between a specified minimum and maximum value by moving a bar with mouse. The program of this

These groups to input the phase angel of voltage sag. There are two ways to input the

The Edit Text is an element that user to enter a text string (-90 to +90). The program of this element is shown in Fig.16, in this program shown how to converse string to numeric.

**Figure 16.** Program on Edit Text(Phase angle) callback function for input phase angle.

2. Slider (Phase A, Phase B, Phase C Magnitude)

element is shown in Fig.15.

**4.2. Phase angle of Voltage Sag** 

1. Edit Text (Phase A, Phase B, Phase C Phase angle)

2. Slider (Phase A, Phase B, Phase C Phase angle)

The program of this element is shown in Fig.17.

magnitude;

These groups to select the voltage sag type, the program of this element shown in Fig. 18.


**Figure 18.** Program on Radio Button callback function for select voltage sag type.

#### **4.4. Show**

These groups to select the program to show single or repeat of voltage sag, program of this element shown in Fig. 19.


**Figure 19.** Program on Radio Button callback function for show Normal and Repeat.

#### **4.5. Point on Wave, Sag Duration and Repeat**

These groups to enter the value of Point on Wave, Sag duration and Repeat of voltage sag, the program of this element shown in Fig. 20.
