sixers0130
Newbie level 1
- Joined
- Oct 31, 2010
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Los Angeles
- Activity points
- 1,297
hey guys this is my first time to post question here...
I need to design a PLL by using matlab, but what my professor lectures in class is very confusing.
Here's my matlab code and also attached:
e = zeros(1,1000); % Initializing the error signal
wc = 2*pi*95/800; % Omega for the signal coming out from VCO
% with initial frequency 95Hz and sampling frequency
% 800Hz
k = 5; % Variation allowed - Gain from VCO
h = [0.5 0.5]; % Loop filter - averager, take the last two error signal and average them
for n = 2:1000
s1 = cos((2*pi*100/800)*n + pi/3); % incoming signal
s1(1) = cos(2*pi*100/800 + pi/3); % Initializing at n = 1 since the loop starts at n = 2
s2 = sin((wc+k*e(n-1))*n + pi/8); % signal coming out from VCO
s2(1) = sin(wc + pi/8); % Initializing
z = s1.*s2; % Mixer
filter = [(z(n-(length(h)-1))) z]; % Take the last 2 data relative to current n
e = sum(h.*filter); % Get the average
end
t = 1:1000;
plot(t,e)
1. The output of the error signal e never goes to 0, so there must be something wrong. My professor says you can use a averager as a loop filter. But I don't know how can that be true if we don't use a lowpass filter to discard that information we don't want first.
2. If I want to use a lowpass filter how can I do that? I tried to use butterworth functions in matlab but I just don't understand what to put in the arguments and what they means.
3. 100Hz is the frequency of the incoming signal s1 and the target frequency. s2 has initially 95Hz of frequency with 800Hz sampling frequency on both of them.
4. The phase shift of s1 and s2 (pi/3 and pi/8) are set randomly. Do they really matter or can they both can be zero?
Thank you guys!
I need to design a PLL by using matlab, but what my professor lectures in class is very confusing.
Here's my matlab code and also attached:
e = zeros(1,1000); % Initializing the error signal
wc = 2*pi*95/800; % Omega for the signal coming out from VCO
% with initial frequency 95Hz and sampling frequency
% 800Hz
k = 5; % Variation allowed - Gain from VCO
h = [0.5 0.5]; % Loop filter - averager, take the last two error signal and average them
for n = 2:1000
s1 = cos((2*pi*100/800)*n + pi/3); % incoming signal
s1(1) = cos(2*pi*100/800 + pi/3); % Initializing at n = 1 since the loop starts at n = 2
s2 = sin((wc+k*e(n-1))*n + pi/8); % signal coming out from VCO
s2(1) = sin(wc + pi/8); % Initializing
z = s1.*s2; % Mixer
filter = [(z(n-(length(h)-1))) z]; % Take the last 2 data relative to current n
e = sum(h.*filter); % Get the average
end
t = 1:1000;
plot(t,e)
1. The output of the error signal e never goes to 0, so there must be something wrong. My professor says you can use a averager as a loop filter. But I don't know how can that be true if we don't use a lowpass filter to discard that information we don't want first.
2. If I want to use a lowpass filter how can I do that? I tried to use butterworth functions in matlab but I just don't understand what to put in the arguments and what they means.
3. 100Hz is the frequency of the incoming signal s1 and the target frequency. s2 has initially 95Hz of frequency with 800Hz sampling frequency on both of them.
4. The phase shift of s1 and s2 (pi/3 and pi/8) are set randomly. Do they really matter or can they both can be zero?
Thank you guys!