Forum Discussion
Altera_Forum
Honored Contributor
17 years agoHi,
Thanks for the link, however I can't get through this link. May be you can email it to me at: kadhiem_ayob@yahoo.co.uk I have added the upconversion/downconversion as well in the code below. The recovered I/Q fluctuate between .2 ~ .4 even though the inputs are unitary, they don't go minus/plus as I thought first. ///////////////////////////////////////// clear all; %******************* Tx *********************** %generate random zeros and ones symb = round(rand(1,50)); %convert symbols to two frequencies(f1,f2) %f1 = 10/256,f2 = 20/256 for i = 1:50 if symb(i)==0 incr(i)=10; else incr(i)=20; end end %one cycle sine/cosine data lut = exp(2*pi*j*[0:255]*1/256); %modulate using f1,f2 %f1,f2 generated with lut pointer from modulo adder k = 1; n = 0; for t = 1:length(incr) for i = 1:64 %upsample symbols by 64 n = n + 1; x(n) = lut(k); k = k + incr(t); if k>256 k=k-256; end; %modulo 256 addition end end %check FM signal spectrum figure;hold f = linspace(0,1,length(x)); plot(f,20*log10(abs(fft(x)))); %upconvert to carrier = 100/256 carrier = exp(j*2*pi*[0:length(x)-1]*100/256); x_up = real(carrier .* x); %check FM signal spectrum f = linspace(0,1,length(x_up)); plot(f,20*log10(abs(fft(x_up))),'r'); %******************* Rx *********************** %downconvert xr = x_up .* real(carrier); xi = x_up .* -imag(carrier); %filter off the high sideband h = fir1(40,2*20/256+.05); xr = filtfilt(h,1,xr); xi = filtfilt(h,1,xi); x = complex(xr,xi); %check FM signal spectrum f = linspace(0,1,length(x)); plot(f,20*log10(abs(fft(x))),'g--'); legend('baseband','upconverted','downconverted'); %demodulate I = real(x); I_diff = [diff(I) 0]; Q = imag(x); Q_diff = [diff(Q) 0]; m = (I.*Q_diff - Q.*I_diff)./(I.^2 + Q.^2) ; % decimate by 64 m = m(32:64:end); %compare Rx symbols with Tx symbols figure; plot(m) str = sprintf('%d',symb);legend(str) ////////////////////////////////////////////// Thanks