INTRODUCTION
Electric Power Quality (PQ) has captured increasing concern in recent years and has led to the development of various types of PQ monitoring instruments. However, there is a need for a PQ monitoring instrument that can be used to perform fast and accurate detection of power disturbances. A real time PQ monitor should be able to acquire voltage and current waveforms, identify the disturbances from the abnormalities detected and thereby understand the causes of the disturbances. To perform all these functions in real time, there is a need for special hardware with massive computing power, sophisticated software to analyze data and advanced signal processing techniques for analyzing the PQ disturbance signals.
Due to the different types of PQ disturbances and signals encountered in power
systems, various signalprocessing techniques have been applied for analyzing
the signals. Among the different signalprocessing techniques, the most widely
used are, the Fast Fourier Transform (FFT) and the Short Time Discrete Fourier
Transform (STFT) (Moussa et al., 2004). Both the FFT and STFT techniques
are most often used for analyzing power disturbance signals which are of stationary
in nature. But for nonstationary signals, the FFT and STFT do not track the
signal dynamics properly because FFT only shows the existence of certain frequency
component and STFT has the limitation of having to choose a fixed window width.
While the FFT based analysis is ideal for the calculation of magnitudes of the
sinusoidal signals in their steady state, it does not have the temporal characteristics
to cope with sharp changes and discontinuities in the signals. Fourier based
analysis therefore cannot accurately detect the onset and the end of sustained
events such as voltage sags or swells or transients such as interruptions and
capacitor switching (Moussa et al., 2004). Due to the limitation of FFT,
it has been used mainly for analyzing harmonic signals in realtime (Mohammed
et al., 2005; Gherasim et al., 2004). Although the modified version
of the FFT, which is the STFT, can resolve some of the problems introduced by
the FFT analysis, the STFT still have some technical problems. In the STFT technique,
the resolution is greatly dependent on the width of the window function. If
the window is of finite length, thus it covers only a portion of the signal
and causes the frequency resolution to get poorer. On the other hand, if the
length of the window in the STFT is considered as infinite so as to get a perfect
frequency resolution, then all the time information will be lost (Moussa et
al., 2004). Owing to the limitations of the FFT and STFT in analyzing PQ
disturbances, the Continuous Wavelet Transform (CWT) is used as an alternative
approach for analyzing stationary, nonstationary and nonperiodic wide band
signals because of its capability in focusing on short time intervals for high
frequency components and long intervals for low frequency components. The use
of CWT to analysis stationary and nonstationary has been proposed on offline
analysis by (Malabika and Biswajit, 2004) for detect and characterise Power
quality disturbances. A wavelet transform is used (Rafael, 2002) to review the
state of the art techniques in signal processing for automatic classification
of power quality events and to give a sign of the next trends. Reciprocally,
the CWT provides accurate time location and bad frequency resolution at high
frequency. This characteristic is appropriate for real signals such as voltage
sags and transient over voltages (Olivier et al., 2000).
This research, presents the realtime implementation of CWT using the Digital Signal Processor (DSP) hardware system for detecting various types of PQ disturbances, namely, voltage sag, swell, transient and harmonics. The DSP is distinct from the generalpurpose microprocessor in which it has a far higher computing power. The proposed hardware system architecture uses the Texas Instrument TMS320C6711 DSP Development Starter Kit (DSK) with an ADS8364EVM 250kHz, 16bit, 6channel, simultaneous sampling Analog Digital Converter (ADC) mounted on its daughter card. The experimental results displaying a CWT analysis of several PQ disturbances in real time are compared with the results obtained from processing the signals in MatLab with respect to speed and accuracy.
CONTINUOUS WAVELET TRANSFORM THEORY
The CWT provides an approach that can be more flexible than the STFT. The CWT uses a timewindow function that changes with frequency, as opposed to the STFT for which the window function is fixed. This adaptive time window function is derived from a prototype function called a mother wavelet. The mother wavelet is scaled and translated to provide information in the frequency and time domains, respectively (Poularikas, 2000).
The continuous wavelet transform is defined as follows:
The Fourier transform of a signal x (t) is
where x (t) is a signal and Ψ_{t,s} (τ) is the wavelet basis function set which can be defined as follows:
where s is the scaling variable (s > 0) and defined by
where f_{o} is the frequency of the chosen mother wavelet. The factor
in Eq. 3 is a scaledependent normalization factor, employed
so that all wavelets have the same energy. For large values of s the window
function becomes a stretched version of the mother wavelet. Therefore large
values of s provide a broad timewidth windowing function located in the low
frequency region of the frequency domain. On the other hand, small values of
s provide a narrow timewidth windowing function located in the highfrequency
region of the frequency domain.
The parameter s in the wavelet analysis is similar to the scale used in maps. As in the case of maps, high scales correspond to a nondetailed global view (of the signal) and low scales correspond to a detailed view. Similarly, in terms of frequency, low frequencies (high scales) correspond to a global information of a signal (that usually spans the entire signal), whereas high frequencies (low scales) correspond to a detailed information of a hidden pattern in the signal (that usually lasts a relatively short time).
By substituting Eq. 3 into Eq. 2
As seen in the above equation, the transformed signal is a function of two variables, t and s, the translation and scale parameters, respectively. Psi (t) is the transforming function and it is called the mother wavelet.
The CWT has a frequencydomain integral:
and represents the decomposition of x (f)' into a set of wavelet basis functions, Ψ*_{t,s} (f'), defined by

Fig. 1: 
Data
flow through the system 
Consequently the CWT can now be written as
The CWT has a filterbank interpretation in which each wavelet basis function can be thought of as a filter through which the original signal is passed. Each filter, however, has a fixed relative bandwidth as opposed to the fixed absolute bandwidth of the STFT (Poularikas, 2000).
In this study, all processing of the CWT algorithm has been done in the DSP. 1024 samples of a PQ signal are applied to the mother wavelet in DSP via external memory interface and multichannel bidirection serial port (McBSP) as shown in Fig. 1. The McBSP sends interrupt to the DSP core whenever a new completed sampled data has arrived from ADC and then the analyses of this data will be carried out using CWT in DSP. The output of the analyses will then appear on the PC.
DSP BASED HARDWARE ARCHITECTURE
The PQ disturbance detection hardware is designed by considering the DSP hardware, a data acquisition device using an ADC converter and signalconditioning module to interface it with the voltage and current probes. The system is DSP based because it offers several advantages such as software upgradeable, low cost and with low power consumption. The architecture of the system hardware is shown in Fig. 2 in terms of a block diagram. The prototype uses a signalconditioning module for mains input isolation, a TMS320C6711DSP in the DSK evaluation board and a high performance 16bit ADC, ADS8364 EVM. A PC running on Windows XP is interfaced with the DSK through a parallel port, DB25.
The DSK is a complete DSP system with a powerful (150 MHZ, max. 900 MFLOPS) processor and it comes with all the necessary hardware and software support tools for realtime processing [], including the Code Composer Studio (CCS) software. The TMS320C6711DSP processor is a floatingpoint DSP with verylonginstructionword architecture, which is ideal for mathematical processing (Chassaing, 2002).
For the required accuracy and resolution, a 12bit ADC is sufficient to measure the voltage variation and harmonic distortion. However, for measuring voltage fluctuations and current harmonic distortions, at least a 16bit ADC is needed (Shiun, 2003). Therefore, a 16bit ADC, which is ADS8364EVM, is used for all the functions.
The ADS8364EVM has the features of highspeed, low power, 6channel simultaneous sampling ADC, analog inputs (05V) configurable as singleended or differential, direct connection to the C5000 and C6000 DSK platforms through the 80pin interface connectors and a highspeed parallel interface. The conversion time for the ADS8364 is 3.2 μs with a 5MHZ external clock and the acquisition time is 0.8 μs, in which both are fast enough for working in real time. To maximize the output rate of 250 KSPS, the read function is performed at the start of the next conversion (ADS8364EVM User’s Guide, 2002).
Programming in DSP is by means of using the Code Composer Studio (CCS) software
developed by Texas Instruments and the C language. The CCS provides an integrated
development environment which incorporates the software tools for code generation,
such as a C compiler and assembler. It has graphical capabilities and supports
realtime debugging. CCS is used in this application because it offers the following
advantages (Gherasim et al., 2004):
• 
The code is easily ported to DSP without having to substantially modify
the source code. 
• 
It offers a preemptive multitasking environment. Software expansion is
easy and the realtime analysis module provides detailed realtime information
on the algorithms being run. 
• 
It has a realtime data exchange module transferring data in realtime
between the DSP and PC. 
The implementation of CWT analysis based on DSP is described as shown in Fig. 3. Both the CCS and the C languages are used in this work to interface the DSK with PC and display the results.

Fig. 2: 
DSP
based hardware architecture 

Fig. 3: 
Implementation
of CWT analysis 
POWER QUALITY DISTURBANCES
DETECTION
Power quality analysis considers various types of PQ disturbances such as transient, harmonic distortion, voltage sag, voltage swell, noise, notching, interruption and voltage fluctuation. Using the CWT programmed in the DSP hardware system, some of the abovementioned disturbances are analyzed. The results of CWT analysis in DSP are compared with that the results of offline CWT analysis using the MatLab program in PC, from the point of CPU processing time. The comparison of results in terms of CPU processing time is shown in Table 1, where it is clear that CWT algorithm takes less processing time in DSP than in MatLab. On the other hand, Table 1 shows that the CPU processing time is same for all disturbances processed either in DSP or MatLab because, the data size and the execution clock cycle are the same.
Offline of PQ disturbances were carried out using MatLab based CWT codes implemented in personal computer and C language based CWT codes implemented in DSP, respectively. The results obtained from both analyses are presented and compared.
For realtime analysis of PQ disturbances, analyses was carried out using C language based CWT implemented in DSP.
Offline analysis of PQ disturbances: Figure 4a shows
a pure sine waveform whereas Fig. 4b shows the corresponding
CWT analysis of the waveform.
Table 1: 
Processing
time in DSP and MatLab 


Fig. 4a: 
Pure
sine waveform 

Fig. 4b: 
CWT
analysis of pure sine waveform 

Fig. 5a: 
Voltage
sag waveform 

Fig. 5b: 
CWT
analysis of voltage sag 
From Fig. 5, it is seen that the CWT analysis show straight
lines which indicate clearly that there are no disturbances in the waveform.
Figure 5a shows a voltage sag waveform obtained from PQ monitoring.
The result of CWT analysis of the voltage sag is shown in Fig.
5b, in which the CWT is capable of localizing the voltage sag by determining
the starting and ending times of voltage sag as well as its duration.

Fig. 6a: 
Voltage swell waveform 

Fig. 6b: 
CWT analysis of voltage swell 

Fig. 7a: 
Transient waveform 

Fig. 7b: 
CWT analysis of transient 

Fig. 8a: 
Transient waveform 

Fig. 8b: 
CWT analysis of transient 

Fig. 8c: 
Two transients at 207 and 335 ms 
In DSP, precisely can get the duration of voltage sag using cursor in CCS
and in this disturbance the duration occurs between 198 up to 321 ms.
Figure 6a shows a voltage swell waveform and the analysis using CWT of this disturbance is shown in Fig. 6b. The shape of CWT analysis in Fig. 6b appears according to the amplitude of the cycles.
From the Fig. 6b it can be seen the duration of voltage swell
which is started from 152 up to 633 ms.
Figure 7a shows a transient waveform in which the disturbance has time duration shorter than voltage sag or voltage swell. The transient disturbance can be detected by using CWT analysis in which it can detect the exact time of occurrence of a transient at 175 ms as shown in Fig. 7b.
Another transient waveform is analyzed as shown in Fig. 8a.
It is obvious from the figure that a transient occurs at 335 ms, in which the
CWT analysis of this disturbance indicates another hidden disturbance at 207
ms as shown in Fig. 8b. After enlarging the portion of the
waveform between 100 to 360 ms of Fig. 8a, a notching is shown
at 207 ms as indicated in Fig. 8c in the circle.

Fig. 9a: 
Voltage notching 

Fig. 9b: 
CWT analysis of voltage notching 

Fig. 10a: 
Interruption waveform 

Fig. 10b: 
CWT analysis of interruption waveorm 

Fig. 11a: 
Harmonics from function generator 

Fig. 11b: 
CWT analysis of Harmonics in DSP 

Fig. 12a: 
Voltage signal from mains supply 

Fig. 12b: 
CWT analysis of mains voltage in DSP 
Notching can be defined as a periodic voltage disturbance caused by the normal
operation of power electronic devices when current is commutated from one phase
to another (Jaya et al., 2004). Figure 9a shows a voltage
notching disturbance obtained from monitoring. The result of CWT analysis on
the voltage notching indicates that the notches in the mains signal occur from
216 up to 988 ms and the precise time of these notches are shown in Fig.
9b.
Power interruption is a related power quality problem and it is usually due
to occurrence of faults in power systems. The interruption waveform is shown
in Fig. 10a where the interruption starts at 320 ms. The
CWT analysis result of this waveform is shown in Fig. 10b.
The Code Composer Studio (CCS) is used to download the CWT code in DSP memory and also can be used to get the exact time of any point in the analyzed waveform using data cursing, which means can obtained the time of any disturbance precisely. This facility gives DSP with CCS more accurately than MatLab.
Realtime analysis of PQ disturbances: For realtime analyses of PQ
disturbances, a square wave signal obtained from a function generator and CWT
analysis of this signal in realtime is shown in Fig. 11a
and b, respectively. The fundamental frequency is 50 Hertz
and other odd harmonics are shown in Fig. 11b.
The next signal considered for realtime analysis of signals in DSP is a voltage signal from the mains supply, which is shown in Fig. 12a. The signal was applied to the ADS8364EVM ADC and the output of the analysis in realtime using CWT is shown in Fig. 12b. From the Fig. 12b, it is clear there is no harmonic in the signal.
CONCLUSIONS
A realtime and offline implementation of CWT using the DSP hardware system is carried out to detect various types of PQ disturbances, namely, voltage sag, voltage swell, transient, voltage notching and harmonics. The hardware system architecture consists of the Texas Instrument TMS320C6711 DSP development starter kit with 16bit, 6channel, 250kHz, ADS8364EVM analog digital converter mounted on its daughter card. The results of the CWT analysis of disturbances in offline was compared with the results of analysis implemented using MatLab in terms of processing time and accuracy and the processing time of CWT in DSP is less than that in MatLab. The CWT in the DSPbased system provides an accurate and fast detection of power quality disturbances as obtained in results.