Datasheet
Aalap Tripathy, 2004P3PS208
PSOC Lab, BITS Pilani Goa Campus
28
0 20 40 60 80 100 120 140 160
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
The building of a square wave: Gibbs' effect
MATLAB Code (For Verification)
t = 0:.02:3.14;
y = zeros(10,length(t));
x = zeros(size(t));
for k=1:2:19
x = x + sin(k*t)/k;
y((k+1)/2,:) = x;
end
plot(y(1:2:9,:)')
title('The building of a square wave: Gibbs'' effect')
Assuming w(t) =
⎟
⎠
⎞
⎜
⎝
⎛
+−+−+−+ ..9cos
9
1
7cos
7
1
5cos
5
1
3cos
3
1
cos
2
2
1
0000
ttttt
o
ωωωωω
π
And ω
0
=2πf, Let us assume f=1 unit = 1 Khz (say)
So, w(t) =
⎟
⎠
⎞
⎜
⎝
⎛
+−+−+−+ ..9cos
9
1
7cos
7
1
5cos
5
1
3cos
3
1
2cos
2
2
1
ttttt
πππππ
π
To generate a sine wave from a given square wave, we need to pass this through a Band Pass Filter
The following simplification (based on AN2086) has the following features:
1. Use the BPF2 User module datasheet to determine the filter parameters such that:
• Center frequency = 1Khz
• Q=4
• Oversampling Rate = 50
2. Two BPF2 filters are used to obtain accuracy
3. An 8 bit counter used to obtain a square wave of 1Khz frequency
4. For demonstration purpose, we are also using a 16 bit counter (fed at 24 Mhz) to implement a divide by 200. This
generates the clock input for the programmable gain amplifier
5. Output of Counter8_1 fed to pin P0[0]
6. This is externally connected (Explore advantages and disadvantages of internal connection if possible) to the input
of a programmable gain amplifier (PGA) in the analog module section
7. To avoid saturation of the output sine wave, gain of PGA set to 0.75 (Examine practical limits of PGA gain when
the final output becomes unidentifiable). Note that saturation of the square wave is meaningless because after
clipping this would still be square.