You are on page 1of 51

EEET1237 Minor Thesis Computer Engineering

Digital Signal Processing


Using Symbian C++ in Embedded Systems

Supervisor: A/Prof. Dinesh Kumar (dinesh@rmit.edu.au)

Student: Wilson Castillo Bautista (s3143667@student.rmit.edu.au)


(wcastillo@isa.com.co)

Subject Code: EEET1237 Minor Thesis Computer Engineering

Melbourne, November 19th, 2007


EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Table of Contents

1 Introduction................................................................................................................................... 6
2 Digital Signal Processing.............................................................................................................. 7
2.1 Sampling................................................................................................................................. 7
2.1.1 Sampling Theorem ........................................................................................................ 7
2.1.2 Aliasing ............................................................................................................................ 8
3 Discrete Fourier Transform (DFT) ............................................................................................... 10
3.1 Properties of the DFT........................................................................................................... 11
3.1.1 Linearity ......................................................................................................................... 11
3.1.2 Symmetry ...................................................................................................................... 11
3.1.3 Circular Time Shift ........................................................................................................ 11
3.1.4 Convolution.................................................................................................................. 12
3.1.5 Multiplication by exponential.................................................................................... 12
3.1.6 Modulation ................................................................................................................... 12
3.2 Leakage ............................................................................................................................... 12
3.3 Windowing ........................................................................................................................... 15
3.3.1 Rectangular Window .................................................................................................. 15
3.3.2 Triangular Window ....................................................................................................... 15
3.3.3 Hanning Window ......................................................................................................... 15
3.3.4 Hamming Window....................................................................................................... 15
4 Fast Fourier Transform................................................................................................................. 17
4.1 FFT Code............................................................................................................................... 21
5 Filtering ......................................................................................................................................... 23
5.1 Finite Impulse Response Filters .......................................................................................... 23
5.2 Infinite Impulse Response Filters........................................................................................ 24
6 Symbian OS ................................................................................................................................. 26
6.1 Hardware Architecture...................................................................................................... 26
6.2 C++ and Object Orientation ............................................................................................ 27
6.2.1 Fundamental Data Types........................................................................................... 27
6.2.2 Naming Conventions.................................................................................................. 28
6.2.2.1 Class Names.......................................................................................................... 28
6.2.2.1.1 T Classes............................................................................................................. 28
6.2.2.1.2 C Classes ........................................................................................................... 28
6.2.2.1.3 R Classes ............................................................................................................ 29
6.2.2.1.4 M Classes ........................................................................................................... 29
6.2.2.1.5 Static Classes .................................................................................................... 29
6.2.2.1.6 Structs................................................................................................................. 29
6.3 Symbian Software Structure in Nokia Devices ............................................................... 29
6.3.1 Application Class......................................................................................................... 30
6.3.2 Document Object....................................................................................................... 30
6.3.3 AppUi............................................................................................................................. 30
6.3.4 View Control................................................................................................................. 30
6.3.5 Model/Engine .............................................................................................................. 30
7 Development of the Application ............................................................................................ 31
7.1 Technical Specification of the Nokia 7710 ..................................................................... 31
7.2 Tools Used............................................................................................................................. 32

RMIT University © 2007 2 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

7.2.1 Microsoft Visual Studio.Net 2003 ............................................................................... 32


7.2.2 Nokia 7710 SDK for Symbian OS for C++ Supporting Microsoft Visual Studio .NET
2003 C++ and Borland C++BuilderX Mobile Edition.............................................................. 32
7.2.3 Emulator ........................................................................................................................ 33
7.2.4 Active Perl Version 5.6 ................................................................................................ 33
7.3 DSP Application .................................................................................................................. 34
7.3.1 CWavCreator............................................................................................................... 34
7.3.2 CRecordTimer .............................................................................................................. 34
7.3.3 CWavReader ............................................................................................................... 34
7.3.4 CDSPProcessor ............................................................................................................. 35
7.3.5 TMatrix ........................................................................................................................... 35
7.3.6 CWavWriter................................................................................................................... 35
7.3.7 CSettingsDialog ........................................................................................................... 35
7.3.8 CSendAppUi................................................................................................................. 35
7.4 Screen Shots of the application ....................................................................................... 36
8 Conclusions ................................................................................................................................. 37
9 References .................................................................................................................................. 38
Annex 1 – FFT Code ........................................................................................................................... 40
Annex 2 – DSP Application Flow Diagram ..................................................................................... 41
Annex 3 – Application UML Model.................................................................................................. 42
Annex 4 – Model/Engine UML Model. ............................................................................................ 43
Annex 5 – DSP Application Use Case ............................................................................................. 44
Annex 6 – ECG Diagram Circuit ...................................................................................................... 45
Annex 7 – ECG Device Supplied by RMIT ...................................................................................... 46
Annex 8 – Screen shots of DSP Application................................................................................... 47

RMIT University © 2007 3 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Table of Figures

Figure 1: DSP Processing (Lynn and Fuerst, 1999). .......................................................................... 7


Figure 2: Sampling Process ................................................................................................................. 7
Figure 3: Aliasing Condition................................................................................................................ 8
Figure 4: DFT of sin(ωt), with frequency = 4 Cycles ...................................................................... 13
Figure 5: DFT of sin(ωt), with frequency = 3.5 Cycles ................................................................... 14
Figure 6: Comparison of the rectangular vs Hanning, Hamming and Triangular windows
functions.............................................................................................................................................. 16
Figure 7: FFT Implementation of an 8-point DFT using two-point DFT. (Lyons, 2004)................ 19
Figure 8: FFT Implementation for an input sequence of 8-point, (Lyons, 2004). ...................... 20
Figure 9: Single 2-point DFT (Basic FFT Butterfly). ........................................................................... 20
Figure 10: Full FFT Implementation for an 8-point input sequence.(Lynn and Fuerst, 2004) .. 21
Figure 11: Filtering Process ................................................................................................................ 23
Figure 12: FIR Structure ...................................................................................................................... 24
Figure 13: IIR Structure ....................................................................................................................... 25
Figure 14: Two chip solution ............................................................................................................. 26
Figure 15: ASICs –Application Specific Integrated Circuit. (Sales, 2005) .................................. 27
Figure 16: UML Diagram – Symbian Application Structure.......................................................... 29
Figure 17: Application Running in Nokia Device used in the DSP application. Photo from the
target device ..................................................................................................................................... 31
Figure 18: Development Environment used in this project ......................................................... 32
Figure 19: EPOC emulator used in the development process ................................................... 33
Figure 20: Active Perl 5.6................................................................................................................... 33
Figure 21: Desktop Icon of DSP Application. (Photo from the target device)......................... 36
Figure 22: FFT Code ........................................................................................................................... 40
Figure 23: DSP Application Flow Diagram ..................................................................................... 41
Figure 24: Application UML Model .................................................................................................. 42
Figure 25: DSP Application Use Case.............................................................................................. 44
Figure 27: ECG Circuit Supplied by RMIT. Its circuit drawing can be seen inFigure 26........... 46
Figure 28: DSP Started ....................................................................................................................... 47
Figure 29: Option to Create New File ............................................................................................. 47
Figure 30: New File Created............................................................................................................. 47
Figure 31: Signal Processed .............................................................................................................. 48
Figure 32: Signal Processed using ECG input ................................................................................ 48
Figure 33: Signal Processed using ECG input. (Photo from the target device) ....................... 48
Figure 34: Selection File to Transmit................................................................................................. 49
Figure 35: Send data using three different options. ..................................................................... 49
Figure 36: Selection to other device to transmit the signal using Bluetooth. (Photo from the
target device).................................................................................................................................... 49
Figure 37: Settings Menu - Output files ........................................................................................... 50
Figure 38: Filtering Options ............................................................................................................... 50
Figure 39: Setting Menu - Duration of the WAV recording.......................................................... 50

RMIT University © 2007 4 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Table of Tables

Table 1: DFT Leakage effects........................................................................................................... 14


Table 2: Comparison of complexity between DFT and FFT. (Lockhart and Cheetham, 1989)
.............................................................................................................................................................. 17
Table 3: Values of W8nm ..................................................................................................................... 18
Table 4: Bit reversal for an 8-point FFT............................................................................................. 21
Table 5: Symbian OS Fundamental Types (Harrison, 2003). ........................................................ 28
Table 6: Technical Specification of the Nokia 7710 ..................................................................... 32

RMIT University © 2007 5 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

DSP Using Symbian C++ in Embedded Systems

1 Introduction

Embedded Systems are present everywhere around the world, from small tiny applications
to high-end complex systems. An embedded system is a special-purpose system in which
the computer is completely encapsulated by the device it controls. Unlike a general-
purpose computer, such as a personal computer, an embedded system performs one or a
few pre-defined tasks, usually with very specific requirements. Since the system is
dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of
the product. (www.en.wikipedia.org, 2006/11/17).

An embedded system must interact with the environment in which it is working.


Consequently, it must be able to perceive the external signals which make it take
decisions. For that, it must process the information received by its sensors connected to it.
And it is the point where digital signal processing comes into high level of importance
because through this process the system is able to interact and develop the functions
which it has been designed for.

The present document shows the results obtained in the development of an application
that collect information from a mobile device and process it using DSP techniques. The
system implemented runs on a mobile device that uses Symbian as operating system.
Hence, the application was developed win Symbian C++ using Microsoft Visual Studio.Net
2003, a Nokia SDK for the Nokia 7710 and a Nokia 7710 mobile device in which the
application was tested with satisfactory results. Consequently, this document will present
some basic concepts regarding to DSP technology, Symbian OS and the development
results.

RMIT University © 2007 6 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

2 Digital Signal Processing

Digital Signal Processing (DSP) is related to the numerical manipulation of signals and data
which are stored in sampled form (Lynn and Fuerst, 1999). It involves several steps which
are implemented from the acquisition of the analog input (using the analog-to-digital
conversion - ADC), which it can be the result of a sensor output (voltage, temperature,
pressure, and so on) to the generation of an analog output (using and digital-to-analog
conversion DAC) as a result of the processing. This scheme can be seen in Figure 1.

Figure 1: DSP Processing (Lynn and Fuerst, 1999).

2.1 Sampling

As it was discussed above, one of the processes involved in DSP is the ADC (Analog-to-
Digital conversion) which consists in the conversion of an analog continuous signal into
discrete signal. This process is shown in Figure 2 where a 1 Hz sinusoidal input signal is
sampled at a sampling frequency, Fs = 16 samples/second, during 4 seconds.

Figure 2: Sampling Process

2.1.1 Sampling Theorem

RMIT University © 2007 7 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

As it was shown in the DSP scheme in Figure 1, the aim of an embedded system is to be
able to represent the signal which it is processing. Consequently, it must convert the
analog signal into a discrete sequence of numbers. The key point in this process is to define
how often the system must take a sample of the signal in order to have an accurate
representation of it.

This question was formulated and solved by Shannon and his conclusion is defined by the
Shannon’s theorem. This theorem states that an analog signal, containing components up
to a maximum frequency f1 Hz, is able to be reconstructed completely if it is sampled a
regularly-spaced time intervals with a frequency of at least 2f1 samples per second. This is
shown in Equation 1.

1
T=
2 f1
Equation 1: Sampling Interval

2.1.2 Aliasing

If the sampling condition establish by the sampling theorem, discussed previously, is not
satisfied then frequencies will overlap, which means that frequencies above the sampling
frequency will appear below half the sampling frequency. This condition can be seen in
Figure 3 where the system is designed to acquire a 1 Hz sinusoidal signal. However, a 7 Hz
sinusoidal signal may affect the sampling process.

Figure 3: Aliasing Condition

Aliasing condition is solved under the following conditions:

RMIT University © 2007 8 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

¾ Sampling at least with a sampling frequency (Fs) equal to 2B, where B is the maximum
frequency of the input signal.
¾ Implementing a low pass filter, usually called anti-aliasing filter. The function of this filter
is to restrict the bandwidth of the signal in order to satisfy the sampling theorem.

The following section is related with Fourier Transform which is the heart of every digital
signal processing system.

RMIT University © 2007 9 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

3 Discrete Fourier Transform (DFT)

Spectrum analysis is the basic step in digital signal processing and always has been a
matter of concern in different fields of the engineering. The Digital Fourier Transform (DFT) is
the straightforward method to obtain the frequency components of any digital sequence.
However, the DFT requires large number of computations, which means time and
processing power for embedded systems, and these resources are critical in real world
applications. Consequently, since 1965 — after the discovery of a procedure to reduce the
number of computations in the computation of the DFT (Cooley and Tukey, 1965) —, a
series of algorithms has been developed in order to reduce the amount of required
computations to obtain the frequency components, these are called, collectively, Fast
Fourier Transform (FFT) Algorithms. As it can be seen later in this document, they are a
mathematical procedure that give the same result as the DFT but more efficiently.

The use of discrete Fourier series is restricted to periodic signals, which make them
impossible to apply when the signal to analyse is a non-periodic one (Lai, 2004). However,
Discrete Fourier Transform (DFT) can be named as an additional Fourier representation,
which can be used to analyse any digital signal of finite length (Lynn and Fuerst, 1998).

The DFT is derived from the continuous Fourier Transform which is defined as below (Lyons,
R, 2004):


X ( f ) = ∫ x(t )e − j 2πft dt
−∞
Equation 2: Continuous Fourier Transform

Where x(t) is the continuous time-domain signal. This equation is used to extract spectrum
information from the input signal, x(t), (McClellan, Schafer, Yoder, 2003). In fact, the result
of its application to any input signal is the frequency domain representation, X(f).

However, this mathematical procedure can only be applied to continuous time-domain


signals. Consequently, a discrete version is defined in Equation 3:

N −1
X (m) = ∑ x(n)e − j 2πnm / N
n =0
Equation 3: DFT Equation (exponential Form)

Equation 3 is called DFT (in exponential form) because it is a discrete Fourier-Like


transformation.

N −1
X (m) = ∑ x(n)[cos(2πnm / N ) − j sin(2πnm / N )]
n =0
Equation 4: DFT Equation (rectangular form)

RMIT University © 2007 10 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Using Euler’s relationship e


−j
= cos(φ ) − j sin(φ ) , Equation 3 can be converted into Equation
4. This is called DFT equation in rectangular form where it is possible to visualize the real
and imaginary components of the transform where:

x(n) = nth component of the input signal which is represented in discrete form.
X(m) = mth component of the output.
m = index of the DFT output in the frequency domain,
N = number of samples of the input signal.

The DFT can be seen as a mathematical transformation of any discrete input signal into its
spectral representation. In fact, it gives N distinct spectral coefficients X(m) for any given
discrete signal.

3.1 Properties of the DFT

There are important DFT properties that make it useful in DSP processing. These properties
are demonstrated in several references (Cristi 2004), (Lynn and Fuerst, 1999). The following
gives a summary of some of them:

3.1.1 Linearity

If
x1[n] ↔ X 1[m] and X 2 [n] ↔ X 2 [m]
Then
Ax1[n] + BX 1[m] ↔ AX 2 [n] ↔ BX 2 [m]
Equation 5: Linearity property of DFT

3.1.2 Symmetry

If the input signal, denoted as x[n] with n= 0, 1, 2, 3,… N-1, is real then:

X ( m) = X * ( N − m) 1
Equation 6: Symmetry property of DFT

3.1.3 Circular Time Shift

If
x[n] = X [m]
Then
x1[n − n0 ] ↔ X [m]e( − j 2πmn0 / N ) = X [m]Wnmn0
Equation 7: Time shifting property of DFT

1 The * symbol means conjugation

RMIT University © 2007 11 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

3.1.4 Convolution

If
x1[n] ↔ X 1[m] and X 2 [n] ↔ X 2 [m]
Then
N −1

∑ x [ n ] x [ k − n ] ↔ X [ m] X
k =0
1 2 1 2 [ m]
Equation 8: Convolution property of the DFT

3.1.5 Multiplication by exponential

If
x[n] ↔ X [m]
Then
x[n]e j 2πnM / N ↔ X [(n − M ) N ]
Equation 9: Multiplication by exponential property of the DFT

3.1.6 Modulation

If
x1[n] ↔ X 1[m] and X 2 [n] ↔ X 2 [m]
Then
N −1
1
x1[n]x2 [n] ↔
N
∑ X [k ] X
k =0
1 2 [m − k ]
Equation 10: Modulation property of the DFT

3.2 Leakage

Because DFT output is just an approximation of the true spectra of the original input signal,
it is possible to find output values in the spectrum that do not match the real spectra
values of the input. This condition is called leakage.

In order to understand the leakage characteristic in the DFT it is necessary to see the
following examples. Figure 4 shows the DFT of the input signal denoted as sin(ωt) with f=1Hz.
The frequency sampling, Fs, has been established as 16 Samples per cycle. In this example
a four cycles signal is being analysed which means N = 64.

The DFT is applied to the input signal in order to determine the frequency components of it.
As can be seen in Figure 4, most of the output values of the DFT, denoted as |X(m)|, are
zero with exception of the frequency components with index m=4 and m=60, that is X(4) =
32 and X(60) = 32. As it was stated above each output value of |X(m)| represents the
magnitude of the frequency component determined by the index m. Moreover, to

RMIT University © 2007 12 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

determine which component represent m=4 and m=60 the following equation must be
applied:

mf s
f component (m) = , where m=0,1,2,…, N-1.
N
Equation 11: DFT frequency component

As a result of applying this equation, it is possible to obtain the frequency values of m=4
and m=64;

4 fs 60 f s
f component (4) = = 1hz and f component (60) = = 15hz
64 64

The importance of this result is that the frequency component, m=4, corresponds to 1hz
which is accordingly with the pure sinusoidal input signal, with frequency 1hz, that is being
analysed. The value found at m=60, corresponds to the symmetry property of the DFT as it
was discussed before.

Figure 4: DFT of sin(ωt), with frequency = 4 Cycles

RMIT University © 2007 13 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

However, the following example, shown in Figure 5, gives a different result. In this case, the
frequency of the input signal has been changed to 0.875 hz, note that The Sampling
Theorem is still enforced (Lynn and Fuerst, 1999). Consequently, under this new conditions
an input signal of 3.5 cycles is being analysed with the same Fs=16 samples per cycles and
with N=64.

Figure 5: DFT of sin(ωt), with frequency = 3.5 Cycles

As can be seen in the figure, the application of the DFT to the new signal gives a set of
different results. Applying Equation 11, to the first set of outputs, give the following results:

m Fcomponent(m) |X(m)|
0 0.00 Hz 5.76
1 0.25 Hz 6.28
2 0.50 Hz 8.59
3 0.75 Hz 21.88
4 1.00 Hz 19.07
5 1.25 Hz 5.65
6 1.50 Hz 3.06
7 1.75 Hz 2.00
8 2.00 Hz 1.44
Table 1: DFT Leakage effects

Table 1 shows the magnitude values for the first nine frequency components. It is noted
that there are values different from zero to frequencies that does not match this frequency
of the input signal. This is called leakage. Moreover, according to the results shown there is
a DC component in the input, which it is not true. Frequency component, m=0
corresponds to DC.

The previous results showed an undesired characteristic of the DFT, Leakage. And it is
caused due to the fact that the input signal does not have an integral number of cycles

RMIT University © 2007 14 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

over the period analysed, in this case N=64 samples. Consequently, the input energy of the
signal has leaked in the other frequency components (Lyons, 2004).

3.3 Windowing

Leakage is a common problem that is present in practical digital signal processing systems.
Because signals in the real world contain a mixture of frequencies and very few of them
behave in the way presented in Figure 4, where it was possible to capture an integer
number of cycles. In contrast, it is more common to find applications like the one shown in
Figure 5 (Lynn and Fuerst, 1999).

In order to reduce the leakage effect a common practice in digital signal processing
system is to multiply the input signal by a suitable window function before processing
(applying the DFT) (Lyons, 2004). The selection of the window to be applied to the input
signal depends of the application; the following mathematical expressions define the
coefficients of some window functions (Lyons, 2004).

3.3.1 Rectangular Window

w(n) = 1 , for n = 0, 1, 2, …, N-1

3.3.2 Triangular Window

n n
w(n) = , for n = 0, 1, 2, …, N/2 and w( n) = 2 − , for N/2+1, N/2+2,…, N-1
N /2 N /2

3.3.3 Hanning Window

⎛ 2πn ⎞
w(n) = 0.5 − 0.5 cos⎜ ⎟ , for n = 0, 1, 2, …, N-1
⎝ N −1 ⎠

3.3.4 Hamming Window

⎛ 2πn ⎞
w(n) = 0.54 − 0.46 cos⎜ ⎟ , for n = 0, 1, 2, … N-1
⎝ N −1⎠

Applying window functions to the input, shown in Figure 5, and then applying the DFT, give
the results shown in the following figures. For a better understanding, only the first 32 values
are plotted:

RMIT University © 2007 15 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Figure 6: Comparison of the rectangular vs Hanning, Hamming and Triangular windows functions.

As can be seen in the figures above, the effect of applying the window function to the
input signal before processing improve the output and the magnitude of the frequency
components no related with the input are reduced considerably.

RMIT University © 2007 16 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

4 Fast Fourier Transform

The DFT is the mathematical procedure that straightforward gives the frequency
components of a discrete-time input signal. However, its computation is very inefficient,
especially when the input sequence (N) is large. In fact, the complexity of the DFT is related
with the input sequence and it grows as N2.

A procedure that reduces substantially the amount of computations was discovered in


N
1965 (Cooley and Tukey, 1965) and it reduces the complexity to log 2 N . This procedure
2
led to the development of other algorithms which are called collectively Fast Fourier
Transform (FFT) algorithms (Ingle and Proakis, 2007). The comparison of the number of
computations between DFT and the FFT algorithms is shown in the Table 2. As it can be
seen in this table, the efficiency of FFT over DFT increases as N is larger which make the use
of FFT ideal for real time applications.

The FFT is based on the DFT equation which it was described before. For instance, in order
to obtain the frequency components for any digital input sequence composed by N
points, the following DFT equation is applied.

N −1 N −1
X (m) = ∑ x(n)e − j 2πnm / N = ∑ x(n)WNmn , where WN = e − j 2π / N
n =0 n =0
Equation 12: Origin of the FFT

N DFT = N2 FFT = N/2log2N DFT/FF η2


T
16 256 32 8 75.00%
64 4096 192 21 89.06%
256 65536 1024 64 93.75%
1024 1.05 x 106 5120 205 96.00%
4096 1.68 x 107 24576 683 97.22%
16384 2.68 x 108 114688 2341 99.79%
65536 4.29 x 109 524288 8192 98.44%
Table 2: Comparison of complexity between DFT and FFT. (Lockhart and Cheetham, 1989)

2 Efficiency FFT over DFT

RMIT University © 2007 17 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Note that the value WN = e − j 2π / N is calculated several times during the computation of the
DFT as WNnm . It is demonstrated (Lynn and Fuerst, 2004), (Lyons, 2004) that for an input
sequence of N=8 only eight different values of W8nm are calculated. These results can be
seen in the following table.

Value of n
0 1 2 3 4 5 6 7
0 1 1 1 1 1 1 1 1
(1 − j ) − (1 − j ) − (1 − j ) (1 − j)
1 1 2
-j 2
-1 2
j 2

2 1 -j -1 j 1 -j -1 j
− (1 − j ) (1 − j) (1 − j) − (1 − j )
Value 3 1 2
j 2 -1 2 -j 2
of m 4 1 -1 1 -1 1 -1 1 -1
− (1 − j ) (1 − j) (1 − j) − (1 − j )
5 1 2
-j 2 -1 2 j 2

6 1 j -1 -j 1 j -1 -j
(1 − j) − (1 − j ) − (1 − j ) (1 − j)
7 1 2 j 2
-1 2
-j 2
Table 3: Values of W8nm

The reason of this is because the periodicity of the WNnm term ( W Nm is often called twiddle
factor). Consequently, the computation of the DFT is slow and processing expensive.
Indeed, the FFT algorithms take the approach of reducing the number of redundant
computations. Lyons, 2004, shows how the Radix-2 FFT algorithm divide any N=2i sequence
input in two segments, even and odd components, as it is shown in the following equation.

( N / 2 )−1 ( N / 2 )−1
X ( m) = ∑ x(2n)WNnm/ 2 + WNm
n =0
∑ x(2n + 1)W
n =0
nm
N /2

and

( N / 2 )−1 ( N / 2 )−1
X (m + N / 2) = ∑ x(2n)WNnm/ 2 − WNm
n =0
∑ x(2n + 1)W
n =0
nm
N /2

Equation 13: Simplification of the DFT computation

Note that to obtain the second half of the FFT it is not necessary to calculate again those
values. In fact, only changing the sign of the twiddle factor ( WNm ) in the results of X(m) it is
possible to obtain X(m+N/2) values. The implementation of this FFT, for an input sequence
of N=8 values, is shown in Figure 7.

RMIT University © 2007 18 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

∑ x ( 2 n )W
0
4
nm

∑ x(2n +1)W
0
4
nm

Figure 7: FFT Implementation of an 8-point DFT using two-point DFT. (Lyons, 2004).

The previous results could be simplified in order to obtain four 2-point DFT. Consequently,
Equation 13 can be converted in the following one:

X (m) = A(m) + WNm B(m),


and

X (m + N / 2) = A(m) − WNm B(m)

Where

( N / 2 )−1 ( N / 4 )−1 ( N / 4 )−1


A(m) = ∑ x(2n)WNnm/ 2 =
n =0
∑ x(4n)WN2nm/ 2 +
n =0
∑ x(4n + 2)W
n =0
( 2 n +1) m
N /2

It is possible to say that W N2 /nm2 = W Nnm/ 4 which gives the following result:

( N / 4 )−1 ( N / 4 )−1
A(m) = ∑ x(4n)WNnm/ 4 + WNm/ 2
n =0
∑ x(4n + 2)W
n =0
nm
N /4

Equation 14

Equation 14 is similar to Equation 13 and shows the possibility to reduce the number of
computations in the implementation of DFT. Similarly, it is possible to compute B(m):

RMIT University © 2007 19 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

( N / 4 )−1 ( N / 4 )−1
B ( m) = ∑ x(4n + 1)W
n =0
nm
N /4 + WNm/ 2 ∑ x(4n + 3)W
n =0
nm
N /4

Equation 15

The results obtained in Equation 14 and Equation 15 show the possibility of reducing the
number of mathematical multiplications in order to obtain an efficient way to calculate
the DFT for any given input sequence. In fact, Figure 8 shows the implementation of the FFT
for an 8-point input sequence. As in can be seen in the figure, the problem has been
simplified into four 2-point DFT computations.

Figure 8: FFT Implementation for an input sequence of 8-point, (Lyons, 2004).

The computation of the basic 2-point DFT is shown in the following figure. The flow signal is
similarly to a butterfly. It is the reason why this computation is also known as FFT butterfly.

x(r)
WN0

x(r+N/2) WNN/2

Figure 9: Single 2-point DFT (Basic FFT Butterfly).

The definition of the twiddle factor is WNm = e − j 2πm / N which gives the following results for
WN0 = e − j 2π 0 / N = 1 and WNN / 2 = e − j 2πN /( 2 N ) = e − jπ = −1 . These results, give the full 8-point
implementation of the FFT, shown in Figure 10.

RMIT University © 2007 20 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

A(0)
x(0) X(0)
1 W40 W80

A(1)
x(4) -1 X(1)
W41 W81

A(2)
x(2) W42 X(2)
1 W82

A(3)
x(6) -1 W43 X(3)
W83

B(0)
x(1) W84 X(4)
1 W40

B(1)
x(5) -1 W85 X(5)
W41

B(2)
x(3) W42 W86 X(6)
1

B(3)
x(7) -1 W43 W87 X(7)
Figure 10: Full FFT Implementation for an 8-point input sequence.(Lynn and Fuerst, 2004)

Another important aspect to point out is the fact that the input sequence is bit reversed
before the FFT implementation. It is called bit reversal because the input data index is
obtained by reversing the bits of the binary representation of the normal input data index
order. This is better understood with the following table:

Data Binary Reversed Data Input


Input Code Code to FFT
x(0) 000 000 x(0)
x(1) 001 100 x(4)
x(2) 010 010 x(2)
x(3) 011 110 x(6)
x(4) 100 001 x(1)
x(5) 101 101 x(5)
x(6) 110 011 x(3)
x(7) 111 111 x(7)
Table 4: Bit reversal for an 8-point FFT.

4.1 FFT Code

RMIT University © 2007 21 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

The code, exposed in Annex 1 – FFT Code, shows the implementation of the radix-2 FFT
algorithm. The code executes the bit reversal prior to calculate the FFT.

RMIT University © 2007 22 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

5 Filtering

Digital Filtering consists in the processing of a Digital Signal using mathematical


computations in order to remove undesired frequency components. They behave in the
same way as their counterpart in the analog domain. Consequently, it is possible to define
digital filters like Low-Pass, Band-Pass, High-Pass, and so on.

Digital Filters can achieve theoretically any filtering effect if a mathematical algorithm can
express this characteristic. However, their main constrain is speed because they cannot
operate any faster that the embedded system that posses them.

Figure 11: Filtering Process

Digital Filters can be found in two different forms: Finite Impulse Response (FIR) filters and
Infinite Impulse Response (IIR) filters.

5.1 Finite Impulse Response Filters

Finite impulse response filters (FIR) are the most popular filters because of the simplicity in
their implementation. Basically, FIR filters use only current and past input samples without
using any previous output samples. This is one of the reasons why FIR filters are commonly
referred as nonrecursive filters.

FIR filter have useful properties that make them suitable for different applications:

¾ Because of their structure FIR filters are inherently stable.


¾ They do not require feedback.
¾ The phase change is proportional to the frequency which means they can be
designed to be linear phase.

RMIT University © 2007 23 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

The equation difference for the FIR filter is shown Equation 16.

y[n] = b0 x[n] + b1 x[n − 1] + ... + bN x[n − N ]


Equation 16: FIR Difference Equation

A basic structure of a FIR filter can be seen in Figure 12 where it is possible to observe that
they use addition to calculate their outputs; b0, b1, … bN-1 are called the filter coefficients
and they are calculated as a result of the design of the filter. Additional literature, Lyons,
2004, shows deeply detail regarding to analysis and implementation of FIR filters.

Figure 12: FIR Structure

5.2 Infinite Impulse Response Filters

The main difference between Infinite Impulse Response (IIR) filters and FIR filters is that the
former ones require feedback. In fact, each IIR filter output sample depends on previous
input samples and previous filter output samples. In contrast, FIR filter output samples
depend only on past input samples.

y[n] = b0 x[n] + b1 x[n − 1] + ... + bM x[n − M ]


− a1 y[n − 1] − a2 y[n − 2] − ... − a N y[n − N ]
Equation 17: IIR Difference Equation

The feedback characteristic of IIR filters give to a DSP system a computational reduction in
the processing of signals that the system requires to filter. However, they may become
unstable (oscillating indefinitely) if the feedback coefficients are calculated improperly.

IIR filters structure can be seen in Figure 13. As it can be seen it is more complex that their
counterpart FIR filters because of the feedback loops. Additionally, this generates high
quantization error which they are implemented, in practice, as cascade first and second-
order rather that the straight structure shown here. Another aspect to have into account in
the implementation is that the coefficients should be taken as reals to avoid complex
calculations (Hussain, 2007).

The design of IIR filters is highly dependent in their analog counterparts because of the
great amount of resources available. Consequently, if the design of an IIR needs to be

RMIT University © 2007 24 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

carried out, first their analog version is designed (Chebyshev, Butterworth, Elliptic filters),
using common methods. Then, this design is converted to digital using either technique
Bilinear Transformation or Impulse Invariance which are commonly called as discretization
techniques.

Figure 13: IIR Structure

RMIT University © 2007 25 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

6 Symbian OS

This section assumes that the reader has a basic knowledge on C++ in order to understand
the terminology used here. Many online resources exist to learn C++ from the basics
(www.cplusplus.com, 2007/08/01).

Symbian OS is a multitasking operating system which includes features like file system, a
graphical user interface framework, multimedia support, a TCP/IP stack and libraries for
different communication features (Babin, 2006).

Symbian OS was designed specifically for mobile devices, for that reason it has small
memory and lower power consumption. Additionally, there is a wide amount of resources
(see www.symbian.com, 2007/08/01) that allow third party entities to produce applications.
Thus, applications developed in Symbian can run in different platforms for years without
restarting the device (Nokia, 2004).

Symbian OS is object oriented which means that all system objects from applications to
interrupt handlers are defined as C++ classes. Additionally, the pre-defined APIs allow the
use of multitasking and efficient memory management (Nokia Forum, 2004).

6.1 Hardware Architecture

As it was described before, some of the main key issues in the design of Symbian devices
are the lower power consumption, the limited memory resources and the quality of the
applications in order to avoid restarting the system. Consequently, the hardware designed
for these tasks must meet these constrains.

Inside a Symbian system there are two domains; one is related with the mobile radio
interface, referred commonly as Baseband processor or modem and the other domain is
related with the application processor which runs the user interface and the high-level
code under Symbian. This two domains solution can be seen in the Figure 14.

Figure 14: Two chip solution

The two domains system operates independently from each other. The baseband
processor requires hard real-time software, periodic power management and security for
the network. Meanwhile, the application processor is able to operate in two modes; full

RMIT University © 2007 26 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

power when it is interacting with the user and sleep mode, running the basic software
routines when the system is in idle mode. The application processor code contains the
frameworks and libraries for build-in applications and third-party development (Sales, 2005).

ARM LCD
DSP DMA
CPU controller

System Bus

PIC RTC IRAM

slow fast
Memory
Controller UART IR I/O USB Audio IPC NAND

Figure 15: ASICs –Application Specific Integrated Circuit. (Sales, 2005)

The application processor is the core of the Symbian system that is contained in a single
piece of silicon commonly referred as System-on-chip ASICs (Application Specific
Integrated Circuits) or ASSP (Application Specific Semiconductor parts). It has CPU,
memory, display, audio interfaces, input/output interfaces and additional peripherals
according to the particular design. An example of the structure for a System-on-chip can
be seen in Figure 15.

6.2 C++ and Object Orientation

Symbian OS makes use of C++ for system applications. However, the use of C++ in a
Symbian environment differs of its use on other system environments:

¾ C++ has private inheritance, but Symbian OS does not use it.
¾ C++ does not know anything about DLL, but Symbian OS does additionally, Symbian
OS define (explicitly) the number of bits to represent basic types.
¾ Symbian OS is focusing in error handling and cleanup in order to make a better
memory management.

6.2.1 Fundamental Data Types

Symbian OS define different classes and each of them has different characteristics. These
characteristics differ in the way how the objects are created (either in the heap or in the
stack) and specifically how they should be cleaned up. These classes have a particular set
of rules which are used to define the creation or destruction of instance of these classes
straightforward.

In order to distinguish the different types, Symbian OS use a simple naming convention
which gives a prefix to the class name (usually T, C, M or R). A design engineer easily can

RMIT University © 2007 27 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

determine the behaviour of the parent according to the basic types contained on it.
Consequently, there is no need to concern about cleaning and creation issues instead
there will be more space to give particular attention to the important factor, the role of the
class.

Data Type Description


TInt8, TUint8 Signed and unsigned 8-bit integers
TInt16, TUint16 Signed and unsigned 16-bit integers
TInt32, TUint32 Signed and unsigned 32-bit integers
Tint, TUint Signed and unsigned integers: in practice, this means a 32-bit integer
TReal32, Single- and double-precision IEEE 754 floating-point numbers
TReal64, TReal (equated to float and double). TReal is equated to TReal64
Narrow and wide characters (equated to unsigned char and
TText8, TText16
unsigned short int)
Boolean– actually equated to int due to the early compilers
TBool used.Some code depends on this so it has not been changed with
the new compilers.
TAny Equated to void, and usually used as TAny* (a 'pointer to anything' )
Table 5: Symbian OS Fundamental Types (Harrison, 2003).

6.2.2 Naming Conventions

Every system use naming conventions to indicate what it is important. Consequently,


Symbian OS is not the exception to this rule. However, as a engineer developer there is no
need to adhere to this rules but it will help to understand the code in a easier way. The
fundamental rule is to use names that have meaning without exaggerate in the
abbreviation. Additionally, there is a basic rule in the design of application program
interfaces (APIs), use American English spelling. American English is the international
language of APIs (Harrison, 2003).

6.2.2.1 Class Names

The initial character of the class indicates the basic properties of it. The following are the
main classes defined by Symbian OS.

6.2.2.1.1 T Classes

They behave in the same way as the build-in classes in C++, hence they are prefixed with
the same letter, “T”, which means type. They do not have destructor. Consequently, T
classes should not contain any member class that has a destructor.

Examples of T Classes are: TDesC, TPoint, TFileName.

6.2.2.1.2 C Classes

C classes are named with the prefix “C” which means that they are derived from the
CBase class (which is defined in e32base.h). They have two main characteristics:

RMIT University © 2007 28 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

First, CBase class has a virtual destructor which means that CBase derived classes may be
destroyed properly by simple deletion of the CBase pointer. Second, CBase oveloads the
zero operator which means that any instance of the derived CBase classes are initialized to
zero. The great advantage of this is that developer engineer does not have to initialize
manually the elements in the constructor.

CBase derived classes must be created in the heap.

6.2.2.1.3 R Classes

R Classes indicate the use of a resource; hence, “R” should be added as a prefix in the
name of the class. R classes are related with any class that owns a resource other than on
the default heap. R Classes use Close() or Reset() method to free the object.

6.2.2.1.4 M Classes

M Classes refer to those ones with pure virtual functions and with no member data. They
are the only one which use multiple inheritance and they are referred as ‘mixins’ hence
the use of “M”.

6.2.2.1.5 Static Classes

There is no more naming conventions in relation with the naming of classes. Symbian OS
has left some space to the creation of classes with no prefix letter; they are the static
member functions which cannot be instantiated.

6.2.2.1.6 Structs

Structs are C-style struct, without any member functions.

6.3 Symbian Software Structure in Nokia Devices

The best way to understand the application structure inside a Symbian device is to observe
the UML class diagram in Figure 16 (forum.nokia.com 2007/08/01).

Figure 16: UML Diagram – Symbian Application Structure

The four application framework classes are:

RMIT University © 2007 29 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

¾ Application Class
¾ Document Object
¾ AppUi
¾ View Control

6.3.1 Application Class

The Application class is initiated as startup object and it defines the properties of the
application. Additionally, it creates a new blank document. This class inherits its properties
from the CEikApplication class defined in the application framework.

6.3.2 Document Object

The document object is used to store the application’s persistent data. If the application is
file bases, this object is responsible for storing and retrieving application’s data. It is
compulsory from the system point of view to have an instance of the Document Class
(inherited from CEikDocument) even if the application does not handle persistent data.

6.3.3 AppUi

The AppUi is responsible for handling application events such as Options menu commands,
opening/closing files and the application losing focus. Additionally it creates an instance of
the view control which it posses. Its base class is CEikAppUi.

6.3.4 View Control

The view control is responsible for the interaction with the user because it displays data on
the screen in such a way that the user can operate. In Nokia devices, the term container is
used instead of view, but the functionality is the same. A view control is derived either from
CCoeControl or CEikDialog.

6.3.5 Model/Engine

The model engine is used to encapsulate the application functionality; it handle data,
persistence and algorithms.

RMIT University © 2007 30 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

7 Development of the Application

This section shows the results obtained in the development of the application result of this
project. The name of the application was “originally named” DSP.

Figure 17: Application Running in Nokia Device used in the DSP application. Photo from the target device

The project was developed in a Nokia 7710 device that uses Symbian OS version 7.0 which
has the following specifications.

7.1 Technical Specification of the Nokia 7710

Characteristic Description
Series Series 90 1.1
Symbian OS 7.0s
Memory 90 Mb
Processor 32-bit RISC CPU based on ARM-9 series, ~150 Mhz
Battery Lithium Polymer, 1300 mAh
Network GSM 900/1800/1900
Datasupport (E)GPRS, HSCSD
Dimentions 128 x 69.5 x 19 mm, 142.5 cc,
Weight 189 g
Flashcards MMC
Screen 16 bit, 640 x 320 pixels
IR/bluetooth no/yes
Camera 0,99 Mp
Music support Stereo
Radio Yes
Voice support yes

RMIT University © 2007 31 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Loudspeaker Yes
Table 6: Technical Specification of the Nokia 7710

7.2 Tools Used

To accomplish this development the following tools where used:

7.2.1 Microsoft Visual Studio.Net 2003

The development system used in this project was Microsoft Visual C++ .NET version 2003 as
Nokia suggested it in the widely documentation offered for application development.

Figure 18: Development Environment used in this project

7.2.2 Nokia 7710 SDK for Symbian OS for C++ Supporting Microsoft Visual Studio .NET 2003
C++ and Borland C++BuilderX Mobile Edition

The software development kit used for the application is the Nokia 7710 which provides the
needed tools, application program interfaces (API), sample code, and documentation
used to develop C++ applications.

The SDK comes with an emulator which is used to test the applications prior to embedded
in the target device.

RMIT University © 2007 32 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

7.2.3 Emulator

An important tool in the development process is the emulator (EPOC) which is part of the
SDK supplied by Nokia. The emulator allows test the application in the development
process reducing the time to market in real world applications. However, it is the target
device which determines the real behaviour of the application.

Figure 19: EPOC emulator used in the development process

7.2.4 Active Perl Version 5.6

In order to compile and install the application in the target device it is necessary to install
the version 5.6 of Active Perl.

Figure 20: Active Perl 5.6

RMIT University © 2007 33 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

7.3 DSP Application

The results of this development are shown in the UML diagram model which can be seen in
Annex 3 – Application UML Model and Annex 4 – Model/Engine UML Model. It is possible to
note that the structure of the DSP application follows the implementation rules established
by Symbian OS as it was point out in section 6.3 (Symbian Software Structure in Nokia
Devices). In fact, DSP Application contains the main classes; CTest2App, CTest2Document,
CTest2AppUi and CTest2Container. Additionally, it is observable that CTest2App inherits
from CEikApplication, CTest2Document inherits from CEikDocument and CTest2AppUi
inherits from CEikAppUi. Additionally, the model/engine class is represented by several
subclasses each one executing one role in the whole system.

The UseCase and the flow diagram of the application can be seen in Annex 5 – DSP
Application Use Case and Annex 2 – DSP Application Flow Diagram.

The several subclasses that compound the model/engine are enumerated as follows:

¾ CWavCreator
¾ CRecordTimed
¾ CWavReader
¾ CDSPProcessor
¾ TMatrix
¾ CWavWriter
¾ CSettingsDialog
¾ CSendAppUi

These classes are the heart of this project because they execute the main functions inside
the application:

7.3.1 CWavCreator

It is a Symbian C class derived from CBase and MMdaObjectStateChangeObserver, its


main purpose is to create a wav file with a variable duration (defined by the user). The
outcome of this class is a wav file named YYYYMMDD-HHmmSS.wav where YYYY is the year;
MM, the moth; DD, the day of the month; HH the hour in 24-hour format; mm the minutes
and SS corresponds to the seconds.

7.3.2 CRecordTimer

This is a Symbian C class derived from CActive which create thread to record a wav file
from the audio input, either embedded microphone or external handsfree device. It uses
CMdaAudioRecorderUtility to create the wav file.

7.3.3 CWavReader

RMIT University © 2007 34 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

This class is in charge to read the wav stored in the memory of the device and extract the
information related to it, like Frequency Sampling, Fs; Number of bits per samples, BPS; and
the length of data N.

Once the information is read it is converted to a TMatrix instance which is owned by


CTest2AppUi.

CWavReader is derived from CBase.

7.3.4 CDSPProcessor

This class is one of the most important classes of the whole development. It is derived from
CBase and it is in charge of the calculation of the FFT and inverse FFT. Additionally, it filters
the signal according to the settings defined by the user. The filter used in this application is
a spectral filter, hence the system has access to spectral content of the signal.

The FFT algorithm used is a 2-radix FFT as it is shown in Annex 1 – FFT Code.

7.3.5 TMatrix

TMatrix is a T class which contains the information of the data being processed. It has
methods to write itself in a text file. The data contained in this class is complex. Additionally,
it has the CPlot methods that allow it to be plotted in the screen.

7.3.6 CWavWriter

This class creates a wav file as a final outcome of the processing of the data. The
information is taken from the TMatrix instance which is used as an input parameter for the
creator method.

7.3.7 CSettingsDialog

CSettingsDialog is a class derived from CEikDialog and it is used to allow the user to set up
the parameter of the application. These parameters are:

Output File: Allows the user to choose between

7.3.8 CSendAppUi

This is a API supplied by Nokia as part of their SDK and this class is used to execute
operations of sending messages through either Email, MMS and Bluetooth.

RMIT University © 2007 35 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

7.4 Screen Shots of the application

Annex 8 – Screen shots of DSP Application shows different screen shots taken from
emulator and from the nokia device. In order to start using DSP application, the user needs
select the DSP icon which appears in the desktop as it can be seen in Figure 21.

The code application can be obtained under the following links (wcastillo@isa.com.co,
s3143667@student.rmit.edu.au ).

Figure 21: Desktop Icon of DSP Application. (Photo from the target device)

RMIT University © 2007 36 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

8 Conclusions

The development of the present project clearly gave evidence that theory can be
followed in the practice in relation with the DSP processing techniques. In fact, the DSP
algorithms designed in theory for this project were implemented by softwares routines that
worked all of the time.

The development process of the Symbian C++ application took many working days
because of the set of rules that must be followed to develop for Symbian devices.
However, once, as developer engineer, I was used to them and obtained familiarity to the
development tools, this process was more enjoyable focusing in the main role of the
application.

The complexity of the DFT led to the development of algorithms in order to improve
efficiency in the calculations. It is widely demonstrated that the complexity of the
calculation of the DFT is reduced because of the cyclic redundancies in the twiddle factor
( WNm ).

One of the important key points in the FFT algorithm implemented is that the properties
and characteristics of the DFT apply straight forward to the FFT.

The outcome of the DSP project could be used as a starting point for another project
initiative that will have to process the signal obtained. Because the main job in process the
signal is already done, hence other future developments do not have to start from scratch.

RMIT University © 2007 37 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

9 References

Babin S., 2006, Developing Software for Symbian OS, An Introduction to Creating
Smartphone Applications in C++, Jhon Wiley & Sons, Ltd, West Sussex, England
Cooley J. W., Tukey J. W., 1965, An algorithm for the machine computation of complex
Fourier series. Mathematical computations, 19:297-301, April 1965.
‘cplusplus.com – The C++ Resources Network’, www.cplusplus.com, 2007/08/01.
Cristi R., 2004, Modern Digital Signal Processing, Thomson Learning, Pacific Grove, USA.
‘Designing C++ Applications For the Nokia 7710 device’, 2004, www.forum.nokia.com.
Harrison, R., 2004, Symbian OS C++ for Mobile Phones, John Wiley & Sons, Ltd, West Sussex,
England.
Hussain Z. M., 2007, Digital Signal Processing, Lecture Notes EEET2113, EEET1469, EEET1416,
EEET1123, RMIT University, School of Electrical and Computer Engineering, Melbourne,
Australia.
Ingle V.K., Proakis J. G., Digital Signal Processing Using Matlab, Second Edition, Thomson,
Toronto, Canada
Jones, D. L., 2006, Decimation in Time (DIT) Radix-2 FFT,
www.cnx.rice.edu/content/m12016/latest/
Lai, E., 2004, Practical Digital Signal Processing for Engineers and Technicians, Elsevier,
Burlington, USA.
Linn, P., Fuerst, W., 1999 Introductory Digital Signal Processing with Computer Applications,
Second Edition, John Wiley, New York, USA
Lockhart G. B., Cheetham B. M. G. 1989, Basic Digital Signal Processing, Butterworths,
Norwich, England.
Lyons, R. G., 2004, Understanding Digital Signal Processing, Second Edition, Prentice Hall,
New Jersey, USA.
‘Nokia 7710: Getting Started with C++ Application Development’, 2006
http://www.forum.nokia.com/main/resources/technologies/symbian/index.html, Nokia
Forum, 2007/08/01.
McClellan J. H., Schafer R. W., Yoder M. A., 2003, Signal Processing First, Prentice Hall, New
Jersey, USA.

RMIT University © 2007 38 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Sales, J., 2005, Symbian OS Internals, Real-time kernel programming , John Wiley & Sons, Ltd.
West Sussex, England.
Symbian, Symbian Developer Network, http://www.symbian.com/developer/index.html,
2007/08/01.

RMIT University © 2007 39 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Annex 1 – FFT Code

The following code calculates the FFT for any input sequence with N values where n is a
power of 2i.(Jones, 1992, http://creativecommons.org/licenses/by/1.0).

void fft(int n, int m, double *x, double *y)


{
int i,j,k,n1,n2;
double c,s,e,a,temp1,temp2;
j = 0; /* bit reversal */
n2 = n/2;
for (i=1; i < n - 1; i++)
{
n1 = n2;
while ( j >= n1 )
{
j = j - n1;
n1 = n1/2;
}
j = j + n1;
if (i < j)
{
temp1 = x[i];
x[i] = x[j];
x[j] = temp1;
temp1 = y[i];
y[i] = y[j];
y[j] = temp1;
}
}
n1 = 0; /* FFT Calculation*/
n2 = 1;
for (i=0; i < m; i++)
{
n1 = n2;
n2 = n2 + n2;
e = -6.283185307179586/n2;
a = 0.0;
for (j=0; j < n1; j++)
{
c = cos(a);
s = sin(a);
a = a + e;
for (k=j; k+n1 < n; k=k+n2)
{
temp1 = c*x[k+n1] - s*y[k+n1];
temp2 = s*x[k+n1] + c*y[k+n1];
x[k+n1] = x[k] - temp1;
y[k+n1] = y[k] - temp2;
x[k] = x[k] + temp1;
y[k] = y[k] + temp2;
}
}
}
return EXIT_SUCCESS;
}
Figure 22: FFT Code

RMIT University © 2007 40 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Annex 2 – DSP Application Flow Diagram

[Start App
(DSP)]
Mobile DSP Processing
Using Symbian C++ on
Embedded Systems
Initial Conditions

[User Selection]

[Settings] [New File]

[OK Cancel]
New *wav File Filtering
[Output] [Filter] [Duration]
[File Created] [Data Filtered]
[User Selects
New File or
File Output Filtering Duration Change Settings]
Select Process Create FFT File

[Process File] [FFT File Created]

[FFT Calculated]
Open *.wav File Calculate Inverse FFT

[Wav File Opened] [iFFT Created]

Extract, Fs, N, Bits Create Data File

[Info obtained (Fs, Bits, N)] [Data File Created]

Calculate FFT Plot

[Data Plotted]

[Tx email] [Tx MMS] [Use Bluetooth]

send email send MMS Bluetooth

[Transmitted] [Transmitted]

[Exit]

Figure 23: DSP Application Flow Diagram

RMIT University © 2007 41 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Annex 3 – Application UML Model

External Classes::CEikApplication External Classes::CEikDocument External Classes::CEikAppUi

CTest2App CTest2Document CTest2AppUi


-iTest2AppUi : CTest2AppUi * -iDisplayState : TDisplayState
+OpenIniFileLC(inout aFs : RFs) : CDictionaryStore * +NewL(inout aApp : CEikApplication) : CTest2Document * -iAppContainer : CTest2Container *
#CreateDocumentL() : CApaDocument * +NewLC(inout aApp : CEikApplication) : CTest2Document * -iWavCreator : CWavCreator *
#AppDllUid() : TUid +~CTest2Document() -iWavReader : CWavReader *
+RestoreL(inout aStore : const CStreamStore, inout aStreamDic : const CStreamDictionary) -iWavWriter : CWavWriter *
+StoreL(inout aStore : CStreamStore, inout aStreamDic : CStreamDictionary) -iFileName : HBufC16 *
+OpenFileL(in aDoOpen : TBool, inout aFilename : const TDesC, inout aFs : RFs) : CFileStore * -iDSPProcessor : CDSPProcessor *
+CreateAppUiL() : CEikAppUi * -iFs : RFs
-CTest2Document(inout aApp : CEikApplication) -iFHigh : TReal
-ConstructL() -iFLow : TReal
-iCreateFFTFile : TBool
-iRecordTime : TUint
-iCreateDataFile : TBool
-iFilter : TBool
1 -iDuration : TInt
-iRemoveDC : TBool
-iPassword : TBuf16<KPasswordLength>
-iSettingsDialog : CSettingsDialog *
-iSendAppUi : CSendAppUi *
-iPoints : CArrayFix<TPoint> *
-iPlot : TBool
«utility»Utility::WavReader «utility»Utility::Matrix «utility»Utility::DSPProcessor +iTMatrix : TMatrix *
+KStandardFormatChunkLen : TInt = 16 +KAlmostZero : TReal = 0.00005 +KPI : TReal = 3.14159265358979324 +ConstructL()
+KChunkHeaderLen : TInt = 8 +KLineBufferLength : TInt = 38 +CTest2AppUi()
+KChunkDataHeaderLen : TInt = 8 +KArrayGranularity : TInt = 100 +~CTest2AppUi()
+KFormat16Bit : TInt = 16 +KBufferLength : TInt = 2048 +Matrix() : TMatrix *
+KFormatMono : TInt = 1 +Plot() : TBool
+KDataFormat : TInt = 1 +HandleCommandL(in aCommand : TInt)
+KBlockAlign : TInt = 2 +DynInitMenuPaneL(in aResourceId : TInt, in aMenuPane : CEikMenuPane*)
+KConversionFactor32768 : TReal32 = 32768.0 +StoreL(inout aStore : CStreamStore) : TStreamId
«utility»Utility::WavCreator «utility»Utility::SettingsDialog «utility»Utility::WavWriter +RestoreL(inout aStore : const CStreamStore, in aStreamId : TStreamId)
+KIntervalRecord : TInt = 5000000 +KMinimumDuration : TInt = 3 +KDataWriteLen : TInt = 4096 +SendFileAsAttachmentL()
+KLengthFileName : TUint = 19 +KMaximumDuration : TInt = 10 -ExternalizeL(inout aStream : RWriteStream)
+KIdealDuration : TInt = 5 -InternalizeL(inout aStream : RReadStream)

CTest2Container
-iListBox : CEikTextListBox *
-iMessageList : CDesCArrayFlat *
-iMsgIndex : TInt
-iOutputText : HBufC16 *
-iAppUi : CTest2AppUi *
+NewL(inout aRect : const TRect, in aAppUi : CTest2AppUi*) : CTest2Container *
+NewLC(inout aRect : const TRect, in aAppUi : CTest2AppUi*) : CTest2Container *
+~CTest2Container()
+PrintLineL(inout aText : const TDesC)
+OfferKeyEventL(inout aKeyEvent : const TKeyEvent, in aType : TEventCode) : TKeyResponse
+Draw(inout aRect : const TRect)
+CountComponentControls() : TInt
+ComponentControl(in aIndex : TInt) : CCoeControl *
-ConstructL(inout aRect : const TRect)
-CTest2Container(in aAppUi : CTest2AppUi*)
-SizeChanged()

Figure 24: Application UML Model

RMIT University © 2007 42 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Annex 4 – Model/Engine UML Model.

RMIT University © 2007 43 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Annex 5 – DSP Application Use Case

DSP Application

«uses» GetFs

«uses» «uses»
CaptureInformation ReadWavFile
GetBPS
«uses» «uses»
«uses»
Sensor
«uses» GetN
WriteWavFile
ProcessSignal «uses»
NewFile
«extends»
GetFFT
«uses»
«extends»
WriteFFTFile
«uses»
«uses»
Start FilterSignal

WriteDataFile

«extends» GetInverseFFT
SendInformation PlotSignal
User
TransmitSignal

«extends» «extends» «extends»

TxBluetooth TxEmail TxMMS

Figure 25: DSP Application Use Case

RMIT University © 2007 44 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Annex 6 – ECG Diagram Circuit

Figure 26: ECG Circuit Used for testing. Device supplied by RMIT

RMIT University © 2007 45 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Annex 7 – ECG Device Supplied by RMIT

Figure 27: ECG Circuit Supplied by RMIT. Its circuit drawing can be seen inFigure 26.

RMIT University © 2007 46 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Annex 8 – Screen shots of DSP Application

Figure 28: DSP Started

Figure 29: Option to Create New File

Figure 30: New File Created

RMIT University © 2007 47 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Figure 31: Signal Processed

Figure 32: Signal Processed using ECG input

Figure 33: Signal Processed using ECG input. (Photo from the target device)

RMIT University © 2007 48 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Figure 34: Selection File to Transmit

Figure 35: Send data using three different options.

Figure 36: Selection to other device to transmit the signal using Bluetooth. (Photo from the target device)

RMIT University © 2007 49 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

Figure 37: Settings Menu - Output files

Figure 38: Filtering Options

Figure 39: Setting Menu - Duration of the WAV recording

RMIT University © 2007 50 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007
EEET1237 Minor Thesis Computer Engineering DSP Using Symbian C++ in Embedded Systems
Supervisor: A/Prof. Dinesh Kumar Wilson Castillo (s3143667@student.rmit.edu.au)

RMIT University © 2007 51 of 51


School of Electrical and Computer Engineering Melbourne, 19th November, 2007

You might also like