**3. S-transform algorithm**

Time-frequency transform as known as S-Transform was proposed by Stockwell and his co-workers in 1996, inheriting the advantage of Continuous Wavelet Transform (CWT). As a modification from CWT, ST can be derived by multiplying the phase factor to CWT equation as expressed in (1) where the algorithm of CWT can be defined as (2)

$$ST(\tau, f) = CWT(\tau, d)e^{i2\pi \hat{f}t}dt\tag{1}$$

MathScript Node is an embedded LabVIEW feature that links the text based I/O

variables with the inputs and outputs of LabVIEW. **Figure 2** shows ST analysis implementation in LabVIEW via MathScript Node. In order to call the user-define function from m file into the LabVIEW MathScript Node, the path for the m file directory will be added to MathScript: Search Path in MathScript Window. The input variable on the right-hand side of the MathScript Node will be the voltage signal and the output on the left-hand side of the MathScript Node indicates all

The output of transformed voltage signal using ST is in the form of N M matrix called S-matrix. Each element within the 2-dimension array of the S-matrix is a complex value where the row represents the frequency while the column represents time. Hence, the output of the S-matrix could be visually analyzed by the representation of time-amplitude graph and frequency-amplitude graph, where the amplitude stands for the absolute value or vector of each complex element from the S-matrix. The example of one of the PQ disturbance is illustrated in **Figure 3**. Further analysis is performed on the S-matrix output in the form of time-amplitude and frequency-amplitude graph as shown in **Figures 4** and **5** respectively in order to

*LabVIEW MathScript node with user define function called S-transform output features.*

possible output of the transform voltage signal by ST.

*LabVIEW as Power Disturbances Classification Tools DOI: http://dx.doi.org/10.5772/intechopen.96079*

extract the feature of PQ disturbance.

*IEEE working group recorded waveform of PQ disturbance.*

**Figure 2.**

**Figure 3.**

**Figure 4.**

**147**

*Time-amplitude graph of S-matrix.*

$$CWT(\tau, d) = \sum\_{-\infty}^{+\infty} \varkappa(t)\wp(t-\tau, d)dt\tag{2}$$

By substituting (2) into (1), the final equation for the ST can be define as,

$$ST(\tau, f) = \sum\_{-\infty}^{+\infty} \varkappa(t)\wp(t-\tau, d)e^{i2\pi \text{f}t}dt\tag{3}$$

Unlike CWT, ST applies Gaussian window instead of mother wavelet which can be defined as,

$$
\psi(t, f) = \mathfrak{g}(t)e^{-i2\pi \hat{t}t} \tag{4}
$$

Where g(t) can be expressed as,

$$g(t) = \frac{1}{\sigma\sqrt{2\pi}}e^{-t^2/2\sigma^2} \tag{5}$$

The capability of the ST Gaussian window to varies according to the frequency of the signal is depend on the Gaussian window width, σ which can be define as,

$$
\sigma(f) = \frac{1}{|f|}\tag{6}
$$

Hence, the final equation of the ST can be expressed as,

$$ST(t,f) = \frac{f}{\sqrt{2\pi}} \sum\_{-\infty}^{+\infty} \varkappa(t) e^{-\left(t-\tau\right)^2 f^2/2} e^{i2\pi ft} dt \tag{7}$$

#### **3.1 S-transform embedded in LabVIEW**

In order to apply signal processing analysis, the ST algorithm function is embedded in LabVIEW software via MathScript Node that act as a native compiler of m file which can blend textual and graphical approaches for signal processing and data analysis task. MathScript Node works in integrating m files into the LabVIEW graphical environment. Embedded process of m file ST algorithm into LabVIEW present a hybrid approach between text-based maths with graphical programming, which is enhanced the capability of previously developed algorithm to perform the analysis in a real time environment.

*LabVIEW as Power Disturbances Classification Tools DOI: http://dx.doi.org/10.5772/intechopen.96079*

which acquired from the NI 9225 card. Further work of classification process which

Time-frequency transform as known as S-Transform was proposed by Stockwell

*<sup>i</sup>*2*<sup>π</sup>ftdt* (1)

*<sup>i</sup>*2*<sup>π</sup>ftdt* (3)

(5)

�*i*2*πft* (4)

j j *<sup>f</sup>* (6)

*<sup>i</sup>*2*<sup>π</sup>ftdt* (7)

*x t*ð Þ*ψ*ð Þ *t* � *τ*, *d dt* (2)

and his co-workers in 1996, inheriting the advantage of Continuous Wavelet Transform (CWT). As a modification from CWT, ST can be derived by multiplying the phase factor to CWT equation as expressed in (1) where the algorithm of CWT

*ST*ð Þ¼ *τ*, *f CWT*ð Þ *τ*, *d e*

þ∞

�∞

By substituting (2) into (1), the final equation for the ST can be define as,

*x t*ð Þ*ψ*ð Þ *t* � *τ*, *d e*

Unlike CWT, ST applies Gaussian window instead of mother wavelet which can

þ∞

�∞

*ψ*ð Þ¼ *t*, *f g t*ð Þ*e*

*σ* ffiffiffiffiffi <sup>2</sup>*<sup>π</sup>* <sup>p</sup> *<sup>e</sup>* �*t* <sup>2</sup>*=*2*σ*<sup>2</sup>

*<sup>σ</sup>*ð Þ¼ *<sup>f</sup>* <sup>1</sup>

The capability of the ST Gaussian window to varies according to the frequency of the signal is depend on the Gaussian window width, σ which can be define as,

*g t*ðÞ¼ <sup>1</sup>

*CWT*ð Þ¼ *<sup>τ</sup>*, *<sup>d</sup>* <sup>X</sup>

*ST*ð Þ¼ *<sup>τ</sup>*, *<sup>f</sup>* <sup>X</sup>

Hence, the final equation of the ST can be expressed as,

ffiffiffiffiffi <sup>2</sup>*<sup>π</sup>* <sup>p</sup> <sup>X</sup> þ∞

�∞

In order to apply signal processing analysis, the ST algorithm function is embedded in LabVIEW software via MathScript Node that act as a native compiler of m file which can blend textual and graphical approaches for signal processing and data analysis task. MathScript Node works in integrating m files into the LabVIEW graphical environment. Embedded process of m file ST algorithm into LabVIEW present a hybrid approach between text-based maths with graphical programming, which is enhanced the capability of previously developed algorithm to perform the

*x t*ð Þ*e*

�ð Þ *<sup>t</sup>*�*<sup>τ</sup>* <sup>2</sup> *<sup>f</sup>* 2 *=*2 *e*

*ST t*ð Þ¼ , *<sup>f</sup> <sup>f</sup>*

**3.1 S-transform embedded in LabVIEW**

analysis in a real time environment.

**146**

based on ST and SVM are developed at LabVIEW platform.

*LabVIEW - A Flexible Environment for Modeling and Daily Laboratory Use*

**3. S-transform algorithm**

can be defined as (2)

be defined as,

Where g(t) can be expressed as,

MathScript Node is an embedded LabVIEW feature that links the text based I/O variables with the inputs and outputs of LabVIEW. **Figure 2** shows ST analysis implementation in LabVIEW via MathScript Node. In order to call the user-define function from m file into the LabVIEW MathScript Node, the path for the m file directory will be added to MathScript: Search Path in MathScript Window. The input variable on the right-hand side of the MathScript Node will be the voltage signal and the output on the left-hand side of the MathScript Node indicates all possible output of the transform voltage signal by ST.

The output of transformed voltage signal using ST is in the form of N M matrix called S-matrix. Each element within the 2-dimension array of the S-matrix is a complex value where the row represents the frequency while the column represents time. Hence, the output of the S-matrix could be visually analyzed by the representation of time-amplitude graph and frequency-amplitude graph, where the amplitude stands for the absolute value or vector of each complex element from the S-matrix. The example of one of the PQ disturbance is illustrated in **Figure 3**. Further analysis is performed on the S-matrix output in the form of time-amplitude and frequency-amplitude graph as shown in **Figures 4** and **5** respectively in order to extract the feature of PQ disturbance.

**Figure 2.** *LabVIEW MathScript node with user define function called S-transform output features.*

**Figure 3.** *IEEE working group recorded waveform of PQ disturbance.*

**Figure 4.** *Time-amplitude graph of S-matrix.*

**Figure 5.** *Frequency-amplitude graph of S-matrix.*

#### **3.2 Support vector machine**

SVM is basically a binary two-class classifier and has been extended to multiclass classifier. Multi error-correcting output code (ECOC) technique has been used to deal with multiclass classifications problems [24–26]. The SVM equation for function equation can be written as:

$$f(\mathbf{y}) = \sum\_{k=1}^{N} a\_i K(\mathbf{x}, \mathbf{x}\_i) + b \tag{8}$$

matrix column. The "codeword" string which are }*I*

*LabVIEW as Power Disturbances Classification Tools DOI: http://dx.doi.org/10.5772/intechopen.96079*

ability to interfacing various type of real time input signal [22].

*k* codeword [29].

12800 and 256, respectively.

**Figure 6.**

**149**

*Front panel of LabVIEW software.*

þ *<sup>t</sup>* } and }*I*

replace "-1" and "+1". Then *m* binary function is learned, one for each bit position in these binary strings. The desired outputs of *m* binary functions are specified by the codeword of class *i* during the training of class *i*. Now, new values of *X* are classified to generate an *m*-bit strings by evaluating each of the n binary function. *X* is assigned to the class whose codeword is closest after comparing string to each of the

LabVIEW is a tool to design a system of engineering application that capable to evaluate and control. LabVIEW is fast and widely used hardware integration which is convenient instrument and PC constructed with data acquisition that has the

The block diagram of voltage continues to capture and extract all the features of

voltage signal with the aid of ST algorithm. While loop is constructed to block diagram at acquired data in order to repeats the code within its sub diagram until a specific condition occurs. A While Loop always executes at least one time. The mathscript node is built to insert the ST algorithm. The input variable from the mathscript node is connect to DAQmx in order to read one or more waveforms from a task that contains one analog input channels which is voltage measurement NI. Output variable from the mathscript node is inserted into array block + feedback

This software holds the three components which are the front panel, block diagram, and icon and connector panel. The front panel on **Figure 6** serves as the user interface. The block diagram contains the graphical source code that defines the functionality of the block diagram. Voltage continuous block diagram based on example finder is select to capture the real time waveform. It determines a block diagram on continuously acquire voltage measurement using a DAQmx device referring on **Figure 7**. During the generation of PQ disturbance, voltage measurement NI is already connected via Ethernet to the computer to capture the real-time voltage signal. In order to gain voltage waveform, the physical channel must be set to ai1. To gain accurate waveform the sample rate and number of samples are set to

�

*<sup>t</sup>* } respectively used to

Where *ai* the weighting factor, *x* is the training samples and *xi* are the support vectors, b represent the bias and N is the training samples. In a classifier model, only the support vector takes effect in the classification. The kernel function helps nonlinear SVM maps the training sample from the input space into the higher dimensional feature space [27, 28]. Kernel function can be written as:

$$K(\mathfrak{x}, \mathfrak{x}\_i) = \mathfrak{d}(\mathfrak{x}).\mathtt{d}(\mathfrak{x}\_i) \tag{9}$$

Eq. (10) below is the example of nonlinear equation for radial basis function (RBF) SVM.

$$K(\mathbf{x}, \mathbf{x}\_i) = \exp\left(-\frac{||\mathbf{x} - \mathbf{x}\_i||^2}{2\sigma^2}\right) \tag{10}$$

Where *σ* is the kernel width. The only difference of nonlinear SVM function after the implementation of kernel function would be:

$$f(\mathbf{y}) = \sum\_{k=1}^{N} a\_i \Phi(\mathbf{x}).\Phi(\mathbf{x}\_i) + b = \sum\_{k=1}^{N} a\_i K(\mathbf{x}, \mathbf{x}\_i) + b \tag{11}$$

There are two types of coding design in ECOC-SVM to construct the classifiers. Most common used of coding design are One-versus-One (OVO) and One-versus-All (OVA) [26]. ECOC is used to analyze and correct the error data when conducted in the channel. The ECOC algorithm capable to enhance the performance of fault tolerance of classification model by encoding different class. The classification problem can be overcome by associating a row of a *kxm* "coding matrix" with entries {�1, 0, +1). Each class is assigned a binary string of length *m* where *m* is the number of binary classification problems to be constructed. The comparison between classes "-1" and "+1" and ignoring classes with "0" is represented from

matrix column. The "codeword" string which are }*I* þ *<sup>t</sup>* } and }*I* � *<sup>t</sup>* } respectively used to replace "-1" and "+1". Then *m* binary function is learned, one for each bit position in these binary strings. The desired outputs of *m* binary functions are specified by the codeword of class *i* during the training of class *i*. Now, new values of *X* are classified to generate an *m*-bit strings by evaluating each of the n binary function. *X* is assigned to the class whose codeword is closest after comparing string to each of the *k* codeword [29].

LabVIEW is a tool to design a system of engineering application that capable to evaluate and control. LabVIEW is fast and widely used hardware integration which is convenient instrument and PC constructed with data acquisition that has the ability to interfacing various type of real time input signal [22].

This software holds the three components which are the front panel, block diagram, and icon and connector panel. The front panel on **Figure 6** serves as the user interface. The block diagram contains the graphical source code that defines the functionality of the block diagram. Voltage continuous block diagram based on example finder is select to capture the real time waveform. It determines a block diagram on continuously acquire voltage measurement using a DAQmx device referring on **Figure 7**. During the generation of PQ disturbance, voltage measurement NI is already connected via Ethernet to the computer to capture the real-time voltage signal. In order to gain voltage waveform, the physical channel must be set to ai1. To gain accurate waveform the sample rate and number of samples are set to 12800 and 256, respectively.

The block diagram of voltage continues to capture and extract all the features of voltage signal with the aid of ST algorithm. While loop is constructed to block diagram at acquired data in order to repeats the code within its sub diagram until a specific condition occurs. A While Loop always executes at least one time. The mathscript node is built to insert the ST algorithm. The input variable from the mathscript node is connect to DAQmx in order to read one or more waveforms from a task that contains one analog input channels which is voltage measurement NI. Output variable from the mathscript node is inserted into array block + feedback

**Figure 6.** *Front panel of LabVIEW software.*

**3.2 Support vector machine**

*Frequency-amplitude graph of S-matrix.*

**Figure 5.**

tion equation can be written as:

(RBF) SVM.

**148**

SVM is basically a binary two-class classifier and has been extended to multiclass classifier. Multi error-correcting output code (ECOC) technique has been used to deal with multiclass classifications problems [24–26]. The SVM equation for func-

*aiK x*ð Þþ , *xi b* (8)

*K x*ð Þ¼ , *xi* фð Þ *x :*фð Þ *xi* (9)

2

(10)

*aiK x*ð Þþ , *xi b* (11)

2*σ*<sup>2</sup> !

*N*

*k*¼1

*f y*ð Þ¼ <sup>X</sup> *N*

*LabVIEW - A Flexible Environment for Modeling and Daily Laboratory Use*

dimensional feature space [27, 28]. Kernel function can be written as:

after the implementation of kernel function would be:

*k*¼1

*f y*ð Þ¼ <sup>X</sup> *N*

*k*¼1

Where *ai* the weighting factor, *x* is the training samples and *xi* are the support vectors, b represent the bias and N is the training samples. In a classifier model, only the support vector takes effect in the classification. The kernel function helps nonlinear SVM maps the training sample from the input space into the higher

Eq. (10) below is the example of nonlinear equation for radial basis function

*K x*ð Þ¼ , *xi* exp � k k *<sup>x</sup>* � *xi*

Where *σ* is the kernel width. The only difference of nonlinear SVM function

*ai*фð Þ *<sup>x</sup> :*фð Þþ *xi <sup>b</sup>* <sup>¼</sup> <sup>X</sup>

There are two types of coding design in ECOC-SVM to construct the classifiers. Most common used of coding design are One-versus-One (OVO) and One-versus-All (OVA) [26]. ECOC is used to analyze and correct the error data when conducted in the channel. The ECOC algorithm capable to enhance the performance of fault tolerance of classification model by encoding different class. The classification problem can be overcome by associating a row of a *kxm* "coding matrix" with entries {�1, 0, +1). Each class is assigned a binary string of length *m* where *m* is the number of binary classification problems to be constructed. The comparison between classes "-1" and "+1" and ignoring classes with "0" is represented from

different each of the deviations. The variance represents the power of this fluctuation. In equation form, the standard deviation (14) and variance (15) is calculated:

*N* � 1

ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 1

*<sup>i</sup>*¼<sup>0</sup> ð Þ *<sup>x</sup>*<sup>1</sup> � *<sup>μ</sup>*

<sup>i</sup>¼<sup>0</sup> ð Þ x1 � <sup>μ</sup>

*<sup>i</sup>*¼1ð Þ *xi* � *<sup>x</sup>* <sup>3</sup>

2

<sup>2</sup> � �<sup>2</sup> (17)

4

*<sup>i</sup>*¼<sup>1</sup>ð Þ *xi* � *<sup>x</sup>* <sup>2</sup> � �<sup>3</sup>

*<sup>i</sup>*¼<sup>1</sup>ð Þ *xi* � *<sup>x</sup>*

*<sup>i</sup>*¼<sup>1</sup>ð Þ *xi* � *<sup>x</sup>*

2

(14)

(16)

<sup>2</sup> (15)

X*N*�<sup>1</sup>

XN�<sup>1</sup>

Skewness is a measurement of data has outliers which means has symmetry. Identify the signal whether the symmetric to the left or to right of the center point. The kurtosis data can be identify based on the normal distribution of right tailed or

> 1 *N* P*<sup>N</sup>*

1 *N* P*<sup>N</sup>*

1 *N* P*<sup>N</sup>*

1 *N* P*<sup>N</sup>*

In order to complete this project, the construction of last part is handled in MATLAB software. The coding of classification PQ disturbance is created, and result is recorded. Simulation of SVM method is done to gain the accuracy of classification. SVM classifier start with load a big number of PQ disturbance sample, i.e. 100. Which randomly consist of 9 types of statistical pattern. All data is randomize using for loop. After record the whole randomized data, 2 stages of SVM algorithm will be perform. Step first for SVM is performing training samples which based on flowchart been initialized at 50%. In order to produce good generalization performance function of Gaussian or polynomial can be chosen in training model. Then fitness function will be calculated referring on the training data Therefore, the remaining data sample are used as testing process. The training result will be model for testing process. Then the accuracy is evaluated whether reach satisfaction of this project or

Target value will be compared with testing. Should be the classification success approaching 100% to reach high accuracy level. If the classification evaluate is effective enough, thus process will be start again with randomized data.

**Figure 8** above is created at editor window. The training data percentage is select for 50%. In randomize data code loop for is used. For loop function to executing a specific statement repeatedly until some false condition is met. In this application, it's for the purpose of different type of PQ disturbance. The Data is the original statistical feature of each sample. Then all the statistical data is identified which class each. It is arranged into their type of disturbance and statistical features is assemble randomly. **Figure 9** above is coding of training classification of PQ disturbances. X interval is the input of predictor data which each column will be observe while Y interval is target value. At line 40, there will be non-linear type of default value for the twoclass learning that separate the data with the hyperplane. It is important to choose type of kernel function in order to accomplish success training. RBF is used for one type training while gaussian or polynomial can be used for two type class or multiple. Polynomial is chosen due to disorder symmetry. The 'class names' to distin-

guishes the different type data which represent PQ disturbances.

*s* ¼

s <sup>2</sup> <sup>¼</sup> <sup>1</sup> N � 1

left tailed. Below is the mathematical equation:

*LabVIEW as Power Disturbances Classification Tools DOI: http://dx.doi.org/10.5772/intechopen.96079*

**4. Classification method**

far from reaching desired accuracy.

**151**

r

*Skewness* ¼

*Kurtosis* ¼

**Figure 7.** *Block diagram of high NTGV features extraction.*

and then connect to the waveform graph. The feedback on the array block is utilized to store and display each cycle of data per windows on the waveform graph. This is a simple manner to capture the features of PQ problems according to real-time signal of measurement. It is also to gain S-matrix graph of frequency time represent time series signal. Inside this mathscript node, MATLAB coding of ST and statistical command are embedded.

Extracted features will be in statistical data waveform. All the wanted features extraction coding is assemble inside the mathscript node which are mean, median, standard deviation, variance, and others. This statistical method suitable to be used when lot of data is picked for training process and it is profitable to produce an effectiveness in SVM method of classifying. This reason statistical method is choosing because the data collected is in a set of possible value of the measured quantity.

All the extracted features of the PQ disturbance signal from ST are introduce in the form of the frequency-amplitude graph. The extracted features in form of statistical data are perform based on mean, median, standard variation, variance, kurtosis and skewness.

Mean is the average value of a signal. The value of mean can be gain by adding all amplitude of signal and divide by N, sample. Mathematical equation as below (12).

$$\mu = \frac{1}{N} \sum\_{i=1}^{N-1} x\_i \tag{12}$$

Median is a middle number of arrangements of amplitude in numerical order and the mathematical equation state below:

$$m = L + \left(\frac{\frac{N}{2} - F}{f}\right)C\tag{13}$$

Standard deviation (STD) is a range of how far the signal varies from the mean and average deviation. This variance value can be gain by the average of the squaring different each of the deviations. The variance represents the power of this fluctuation. In equation form, the standard deviation (14) and variance (15) is calculated:

$$s = \sqrt{\frac{1}{N-1} \sum\_{i=0}^{N-1} \left(\omega\_1 - \mu\right)^2} \tag{14}$$

$$\mathbf{s}^2 = \frac{\mathbf{1}}{\mathbf{N} - \mathbf{1}} \sum\_{i=0}^{N-1} (\mathbf{x}\_1 - \boldsymbol{\mu})^2 \tag{15}$$

Skewness is a measurement of data has outliers which means has symmetry. Identify the signal whether the symmetric to the left or to right of the center point. The kurtosis data can be identify based on the normal distribution of right tailed or left tailed. Below is the mathematical equation:

$$\text{Skewness} = \frac{\frac{1}{N} \sum\_{i=1}^{N} (\boldsymbol{\omega}\_i - \overline{\boldsymbol{\varpi}})^3}{\left(\frac{1}{N} \sum\_{i=1}^{N} (\boldsymbol{\omega}\_i - \overline{\boldsymbol{\varpi}})^2\right)^{\frac{3}{2}}} \tag{16}$$

$$Kurtosis = \frac{\frac{1}{N} \sum\_{i=1}^{N} (\mathbf{x}\_i - \overline{\mathbf{x}})^4}{\left(\frac{1}{N} \sum\_{i=1}^{N} (\mathbf{x}\_i - \overline{\mathbf{x}})^2\right)^2} \tag{17}$$
