# how to sample and modulate a gps gold code

I am trying to simulate the data transmission of a GPS satellite. Telecommunications is not my field so I am struggling a bit with some concepts. I managed to generate the Gold code of the GPS transmitter using shift registers. This creates a pseudorandom 1023-vector with [-1 1] values. Now I want to create a sampled version of this signal up to 5.714Hz assuming the clock of the codes work at 1.023 Mchip/s and then modulate this signal with a sinusoidal carrier of 4.309 MHz sampled at the same frequency. I am not sure how to sample the signal. From what I've understood, I wrote something like this in Matlab but it's not right :

a = [1 1 1 1 1 1 1 1 1 1 ]
b = [1 1 1 1 1 1 1 1 1 1 ]
for k = 1: 1023
A(k) = a(10) ;
B(k) = mod(b(2)+b(6),2) ;
C_A(k) = mod(A(j)+B(j),2) ;
Af = mod(a(3)+a(10),2) ;
Bf = mod(b(2)+b(3)+b(6)+b(8)+b(9)+b(10),2) ;
% shifting
sg_1 = [ Af a(1:n-1) ] ;
sg_2 = [ Bf b(1:n-1) ] ;
end
code_vect = (C_A-0.5)*2 ;
% UP TO HERE IT'S OK, I GOT THE C/A CODE, how to modulate it?
code_vect = code_vect(index,:) % this is 1x1023 Gold code vector
sa_fq = 5.714e6     %sampling freq
ca_fq = 4.309e6     %carrier freq
cd_fq = 1.023e6   %code frequency (I am right?)
clk = 1.023e6   %clock rate
time = 1/sa_fq : 1/sa_fq :1023/sa_fq   %time vector
for i = 1:1023
%sampled signal, I'm sure this is wrong but don't know how to do it
code_vect_sa((ceil(sa_fq)*i)-(ceil(sa_fq)-1):(ceil(sa_fq)*i))=code_vect(i)*ones(1,ceil(sa_fq))
end
carr = cos(2*pi*(ca_fq+cd_fq)*time) %carrier
sig_mod = code_vect_sa*carr ; modulated signal


Can you guys give a hint on how to solve it. Thanks in advance

• what do you try to do here: code_vect_sa((ceil(sa_fq)*i)-(ceil(sa_fq)-1):(ceil(sa_fq)*i))=code_vect(i)*ones(1,ceil(sa_fq))? The rest looks ok Apr 14 '16 at 18:28
• Hi, that is the section I don't exactly know how to do. I am trying to get a sampled version of the Gold code where the samplig frequency is 5.714MHz, just the signal before modulation. I don't know how to do it, so I thought just to make the frequency an integer and "replicate" the code values 6 times per code Apr 14 '16 at 18:42
• I think you don't need that line of code, as you sample when you do carr = cos(2*pi*(ca_fq+cd_fq)*time). Your time axis indicates the samples that you are going to take. Does this make sense? Apr 14 '16 at 18:44
• Well I am not completely sure. What I got is that I should multiply the modulated signal by the modulated carrier; actually my professor asks me the modulated C/A code as one of my results, but I don't know how to do it, for the carrier is more straightforward. Apr 14 '16 at 18:48