Digital Signal Processing Reference
In-Depth Information
Example 5.2: Generation of Two Tones Using Two Second-Order
Difference Equations (
two_tones
)
This example generates and adds two tones using a difference equation scheme. The
output is also stored in memory and plotted within CCS. The difference equation
to generate a sine wave is
()
=
(
)
--
(
)
y n
Ay n
-
1
y n
2
where
(
)
A
=
2
cos
sin
sin
w
w
w
T
()
=-
(
)
y
1
2
T
-
()
=-
(
)
y
2
T
with two initial conditions,
y
(
-
1) and
y
(
-
2),
w=
2
p
f
, and
T
=
1/
F
s
=
1/(8 kHz)
=
0.125 ms, the sampling period. The
z
-transform of
y
(
n
) is
{
}
-
{
}
()
=
()
+
()
()
+
()
+
()
Yz
Az Yz
-
1
y
1
z Yz
-
2
z y
-
1
1
y
2
which can be written as
{
}
=
()
-
()
-
()
-
()
Yz
1
Az
-
1
+
z
-
2
Ay
1
z y
-
1
1
y
2
(
)
(
)
+
(
)
+
(
)
-
1
=-
2
cos
sin
ww
T
sin
T
z
sin
w
T
sin
2
w
T
(
)
=
z
-
1
w
T
Solving for
Y
(
z
) yields
()
=
(
)
(
)
2
Yz
z
sin
w
T
z
-+
Az
1
The inverse
z
-transform of
Y(z)
is
()
=
(
{
(
)
-
1
yn
ZT
Y z
=
sin
n T
w
f
=
1.5kHz
(
)
=
A
=
2
cos
w
w
w
T
0 765
.
Æ¥
A
2
14
=
12 540
,
()
=-
(
)
()
¥=-
14
y
1
sin
T
=-
0 924
.
Æ
y
1
2
15 137
,
-
()
=-
(
)
=-
()
¥=-
y
2
sin
2
T
0 707
.
Æ
y
2
2
14
11 585
,
f
=
2kHz
=
-
()
=- Æ
A
0
()
¥=-
14
y
1
1
y
1
2
16 384
,
-
()
=
y
20
The coefficient of the second-order difference equation
A
, along with the two initial
Search WWH ::
Custom Search