Bit synchronizer for GNSS receivers
performs bit synchronization on the input samples
numtr] = gnssBitSynchronize(
samples with a window
n, as defined in . The function searches
the input samples for the maximum number of transitions from a positive to a negative value
and from a negative to a positive value, and returns the bit synchronization index
syncidx and the number of transitions corresponding to each sample
Use this function for global navigation satellite systems (GNSS) receivers that use code division multiple access (CDMA) schemes. These GNSS receivers include GPS, NavIC, and QZSS.
Bit Synchronize Signal Generated Using C/A-Code
Perform bit synchronization for a noisy signal generated from random bits using C/A-code. Assume perfect time and frequency synchronization.
Generate the transmit signal from random bits using C/A-code.
n = 20; % Number of C/A-code blocks per bit numbits = 500; % Number of data bits numcachips = 1023; % Number of C/A-code chips txbits = randi([0,1],numbits,1); cacode = 1 - 2*double(repmat(gnssCACode(1,"GPS"),n*numbits,1)); txsig = cacode.*repelem(1 - 2*txbits,numcachips*n,1);
Add additive white Gaussian noise (AWGN) to the generated signal.
snrdB = -25; % Signal to noise ratio in dB rxsig = awgn(txsig,snrdB,"measured");
Multiply the noisy signal with time synchronized reference C/A-code and integrate the samples.
corrsamples = rxsig.*cacode; integsamples = sum(reshape(corrsamples,numcachips,));
Delay the samples by a fixed offset.
dly = 15; % Number of samples delayed bitsyncin = [zeros(dly,1);integsamples(:)];
Perform bit synchronization on the input samples.
[syncidx,numtr] = gnssBitSynchronize(bitsyncin,n);
Display the value of bit synchronization index,
syncidx. Note that it is equal to the number to samples delayed + 1.
syncidx = 16
Plot the transition chart at each sample location.
bar(numtr) xlabel("Sample Location") ylabel("Number of Transitions") title("Transition Chart")
samples — Input samples
real-valued column vector
Input samples, specified as a real-valued column vector of length greater than or
For a better estimate of the bit synchronization index, specify a large number of
input samples (such as hundreds of times
n — Window size used for searching
Window size used for searching the input samples, specified as a positive integer. This value represents the number of spreading code blocks per bit, or the number of samples per bit.
syncidx — Bit synchronization index
integer in the range [1,
Bit synchronization index, returned as an integer in the range [1,
n]. This index value represents the maximum number of transitions
within the window size
The data type of the index is same as that of
numtr — Number of transitions corresponding to each sample location
Number of transitions corresponding to each sample location, returned as a column
vector of length
 GPS Enterprise Space & Missile Systems Center (SMC) - LAAFB. NAVSTAR GPS Space Segment/Navigation User Segment Interfaces. IS-GPS-200L. El Segundo, CA: SAIC (GPS SE&I), May 14, 2020. https://navcen.uscg.gov/sites/default/files/pdf/gps/IS_GPS_200L.pdf.
 Kaplan, Elliott D., and C. Hegarty, eds. Understanding GPS/GNSS: Principles and Applications. Third edition. GNSS Technology and Applications Series. Boston ; London: Artech House, 2017.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Introduced in R2022b