Академический Документы
Профессиональный Документы
Культура Документы
DEVELOPMENT
OF Open Source
COMPASS SDR
Submitted by:-
Adarsh Khandelwal
B Tech, Part IV
IT BHU, VARANASI,INDIA
An OpenSource COMPASS/BEIDOU Software Defined
Receiver
1. Summary
3.2 Acquisition
3.3 Tracking
4. Bibliography
SUMMARY
Software-defined radio receivers (SDR) is a concept for transceivers in which the
signal processing is accomplished via a programmable general-purpose
microprocessor or digital signal processor (DSP), as opposed to an application-
specific integrated circuit (ASIC). A software receiver differs from a hardware
receiver by performing correlations in software running on a general
purpose microprocessor. It can afford batch data processing options that are
not available in hardware implementations. New frequencies and new pseudo-
random number (PRN) codes can be used simply by making software changes.
SDR are not only research tools for the development and test of new navigation
and positioning algorithms. The flexibility of software architectures enables
them to record several pieces of information that are not limited to
position and velocity. Correlator and discriminator outputs, frequency and
phase lock indicators and several synchronization messages are just a few
examples of the parameters that a software receiver makes available to
users and researchers. And the software receiver could be reprogrammed to
adjust a new navigation system, which provides an added benefit from the
use of the software radio architecture. Along with the decrease of the
required processing time, the high configurability, high development speed, low
cost software receiver is obtaining more people's favors.
In this paper, a complete Intermediate Frequency (IF) Software COMPASS
Receiver was developed using matlab code. It can be used for acquisition,
tracking, and calculating position for the COMPASS B1I and B2I signals.
Then after multi-core programming capability of Matlab have been exploited to
insure parallel processing for three constellation and combining the results using
proper algorithms for more precise coordinates.
Need of the SDR
Perfect and precise positioning have always been a thing of importance be it for military
purposes, civilian usage or navigation (indoor and aircrafts).With advent of newer
constellations in the group:-GLONASS,GALILEO,COMPASS,GAGAN and many more to come in
the list we can be assured of getting unparallel accuracy and precision.
1. Designing Software Defined Receiver for Compass as they have insured minimum no of
satellite in the constellation ie 4.This will insure better PVT results in combination with
other available constellations forming an augmented receiver. After acquisition and
tracking have been done it would be mainly focusing on decoding of data and finding
pseudo-ranges and PVT solutions.
2. As the hardware receiver designs are not open source and non-reconfigurable, software
base gives lots of freedom to each user to change algorithms at any level in the highly
modular structure of the receiver.
This project shall benefit numerous researchers, students and developers around the world in
understanding the core working of GNSS acquisition, tracking and post-navigation processing of
the raw GNSS samples.
We well know we need to constantly update and change algorithms to achieve more better
results and design a robust model in itself.
With such a large pool of GNSS researchers and open source contributors something know to
all and within reach can help in rigorous and dynamic updates of the model we are developing.
Each could add with changes and see if results improve in varied conditions. The platform shall
seek mutual development be it in signal processing, algorithms or architectural modifications.
Finally we would have a model being worked upon by hundreds and thousands of minds and
the GNSS would not be a thing of industries and high end institutions but within reach of
civilians and then can configure whatever and whenever they want.
Ultimately we have a full fledge receiver to get PVT solutions using varied constellations.
Applications of Compass are equivalent to those of GPS and other constellations and can be
seen mostly in highly precise navigation of land, sea, air and low orbiting spacecraft .Besides
this, Compass is also suitable for the dissemination of highly precise global and local time scales
as well as for establishing global geodetic coordinate systems and local geodetic networks. The
system can also be used for providing precise coordinates for cadastre works. Further usage
could contain the support of research work in geology, geophysics, geodynamics,
oceanography and others by providing position and time information. Similar uses are possible
for large scale construction projects.
With this range of applications and the achievable accuracy, Compass has become an attractive
tool for navigational and geodetic purposes. But not only Compass as a stand-alone system
draws the interest of scientists around the world. The fact that there are two independent, but
generally very similar satellite navigation systems also draws attention to the combined use of
both systems. This combined use brings up a number of advantages. At first, the number of
observable satellites is increased with respect to one single system. This will provide a user
with a better satellite geometry and more redundant information, allowing him to compute a
more accurate position fix. In cases with obstructed visibility of the sky, such as mountainous or
urban areas, a position fix might not be possible at all without these additional satellites.
Besides that, the more satellite measurements are available, the earlier and more reliably a
user can detect and isolate measurement outliers or even malfunctioning satellites. Thus, the
combined use of GPS , Compass, Galileo and GLONASS may aid in Receiver Autonomous
Integrity Monitoring (RAIM), providing better integrity of the position fix than a single system
alone.
BeiDou System Overview
Space Constellation
BeiDou Navigation Satellite System is called BeiDou System for short,with the abbreviation
as BDS. When fully deployed, the space constellation of BDS consists of five Geostationary
Earth Orbit (GEO) satellites, twenty-seven Medium Earth Orbit (MEO) satellites and three
Inclined Geosynchronous Satellite Orbit (IGSO) satellites. The GEO satellites are operating in
orbit at an altitude of 35,786 kilometers and positioned at 58.75°E, 80°E, 110.5°E, 140°E and
160°E respectively. The MEO satellites are operating in orbit at an altitude of 21,528 kilometers
and an inclination of 55° to the equatorial plane. The IGSO satellites are operating in orbit at
an altitude of 35,786 kilometers and an inclination of 55° to the equatorial plane.
By the end of 2012, there are five GEO, four MEO and five IGSO BeiDou navigation satellites in
orbit.
Coordinate System
BDS adopts the China Geodetic Coordinate System 2000 (CGCS2000), and the definition is
listed below:
The Z-axis is in the direction of the IERS (International Earth Rotation and
The X-axis is directed to the intersection of IERS Reference Meridian (IRM) and the plane
passing the origin and normal to the Z-axis;
The Y-axis, together with Z-axis and X-axis, constitutes a right handed orthogonal
coordinate system. The origin of the CGCS2000 is also the geometric center of the CGCS2000
ellipsoid, and the Z-axis is the rotation axis of the CGCS2000 ellipsoid. The parameters of
the CGCS2000 ellipsoid are as follows:
μ = 3.986004418*10^14
Flattening: f = 1/298.257222101
The time reference for the BDS uses the BeiDou navigation satellite system Time (BDT).
BDT adopts international system of units (SI) seconds, rather than leap seconds, as the
basic unit for continuous accumulation. The start epoch of BDT was 00:00:00 on January 1,
2006 of Coordinated Universal Time (UTC). BDT is counted with week and seconds of week
(SOW). BDT is related to the UTC through UTC(NTSC). BDT offset with respect to UTC is
controlled within 100 nanoseconds (modulo 1 second). The leap seconds are broadcast in
navigation (NAV) message.
Signal Specifications
Signal Structure
The B1 signal is the sum of channel I and Q which are in phase quadrature of each other. The
ranging code and NAV message are modulated on carrier. The signal is composed of the
carrier frequency, ranging code and NAV message.
2. Modulation Mode
6. Spurious
In-band spurious shall be at least 50 dB below the unmodulated carrier of B1I over the satellite
signal bandwidth (1 dB).
7. Signal Coherence
(1) The random jitter of the initial phase difference between the ranging code modulated on
carrier and carrier is less than 3° (1σ) (relative to the carrier) for B1I signal.
(2) Carrier phase quadrature difference between channel I and Q is less than 5° (1σ).
8. Equipment Group Delay Differential
Equipment group delay is defined as the delay between the antenna phase center of a
satellite and the output of the satellite onboard frequency source. The equipment group
delay differential of B1I is given as T GD1 in NAV message with uncertainty less than 1
nanosecond (1σ).
The chip rate of the B1I ranging code is 2.046 Mcps, and the length is 2046 chips. The
B1I ranging code (hereinafter referred to as C B1I ) is a balanced Gold code truncated with
the last one chip. The Gold code is generated by means of Modulo-2 addition of G1 and G2
sequences which are respectively derived from two 11-bit linear shift registers.
Navigation message
Tracking Loop Measurements
Extraction
Navigation Solution
The received signal at the antenna is amplified and then down converted to the desired
intermediate frequency (IF). The down converted signal is sampled and sent to the signal
processor block. Amplification, down conversion and sampling are performed in the radio
frequency (RF) front-end block. The signal processor block consists of tracking loop as well as
navigation message extraction and measurement generation components. One signal processing
block is assigned for each satellite signal being tracked and is herein simply called a “channel”.
Generally, a signal tracking loop consists of the following components.
• Doppler removal component in which the carrier part of the received signal is removed
• Correlation component in which the ranging code part of the received signal is removed
• Discriminator component which can compute the difference (error) between the locally
generated signals and the received ones
• Loop filter component which smoothes the output of the discriminators
PostProcessing.m
Create data
vectors
Acquisition.m
Tracking.m
postNavigation.m
Positions solutions
End
The acquisition functions of the receiver were designed to be flexible. An outline of the acquisition
processing is shown in Figure. The acquisition steps of the receiver are as follows:
(1) Gather a reasonable amount of data for use in the FFT acquisition processing. The default value
is currently 4 ms of data samples.
(2) When enough data has been collected, call the acquire function, specifying the satellite to
search for and scan over a wide range of coarse Doppler bins by performing the following steps:
c) Perform inverse FFT;d) Search for peaks exceeding the detection threshold.
Loop initialisation
PRN = 1:no of satellites
Loop initialisation
j = 1:no of freq bins
If peakMetric>threshold
Store acqRes for PRN
Acquisition Result Plot
Acquisition Metric was compared to a predefined empirical value of 3 and satellites with values greater
than 3 were tracked using tracking.m file.
Tracking algorithm for GLONASS is similar to that of the GPS with no major changes as such. The prime
importance is using different carrier frequencies (obtained from acquisition.m in acqResults structure) in
PLL for each tracking channel. And codes would remain same for all DLL loops unlike GPS though they
will be of three types:-E(early),P(prompt) and D(delay) like GPS.
The PLL discriminator used for GLONASS phase lock loop is a two-quadrant arctangent Costas
discriminator.
1. Coherent discriminator: where all power is on I channel, implying phase lock is achieved.
2. Non-coherent discriminator: where phase lock is not required.
Loop filters
The objective of a loop filter is to reduce the effect of noise on the discriminator output signal in order
to generate an accurate and smooth estimate of the original signal at its output and to pass this
information to the NCO. A loop filter rejects as much noise as possible and responds to the changes in
signals which are caused by both receiver and satellite dynamics (Ward et al 2006). Satellites dynamics
cause Doppler changes up to 0.9 Hz/s and receiver dynamics causes additional changes, wither higher
acceleration causing faster changes in Doppler .The loop filter order and noise bandwidth are two main
parameters of a loop filter. By carefully choosing these parameters, the performance of a tracking loop
can increase significantly.
Integrate +Dump
Integrate +Dump
Integrate +Dump
Integrate +Dump
Integrate +Dump
90 Integrate +Dump
The software correlator has the task of generating the code and carrier replica signals and
performing the necessary correlations and accumulations needed to feed into the tracking functions.
When the number of samples processed is equal to a complete code period (1 ms for COMPASS B1/B2
code) the tracking loop function is called. The correlator continually computes results on six separate
correlator spacings for each channel at every sample. These include prompt correlators for the in-phase
(I) and quadrature (Q) signals components, as well as early and late offset correlators for each. The early
and later correlators are spaced one-half chip from the prompt value, and are used primarily in
calculating the tracking loop feedback values. At the start of each pass through the tracking loops, the
accumulated correlator measurements are used to calculate an error in the replica signal alignment,
which is then used to adjust the carrier and code increments used in the correlator for the next set of
samples. The tracking error is determined using a discriminator function based on a combination of the
six available accumulations calculated for each channel by the software correlator function. This
discriminator value is used to calculate new values for the code and carrier increments, which are then
fed back into the carrier and code replica generator to be applied during the next correlation interval.
TRACK RESULT
Afore shown Plot shows the navigation bits extracted by tracking.m program along with PLL and DLL
Discriminators plots.
Magnified view of the navigation message clearly showing data bits which can now be extracted by
postNavigation.m
NAVIGATION DATA DECODING
NAV Message Classification
NAV messages are formatted in D1 and D2 based on their rate and structure. The rate
of D1 NAV message which is modulated with 1 kbps secondary code is 50 bps. D1 NAV
message contains basic NAV information (fundamental NAV information of the
broadcasting satellites, almanac information for all satellites as well as the time offsets
from other systems); while D2 NAV message contains basic NAV and augmentation
service information (the BDS integrity, differential and ionospheric grid information)
and its rate is 500 bps.The NAV message broadcast by MEO/IGSO and GEO satellites is D1 and
D2 respectively.
D1 NAV Message
Secondary Code Modulated on D1
For D1 NAV message in format D1 of rate 50 bps a secondary code of Neumann-
Hoffman (NH) code is modulated on ranging code. The period of NH code is selected as long as
the duration of a NAV message bit. The bit duration of NH code is the same as one period of
the ranging code. Shown as in Figure, the duration of one NAV message bit is 20
milliseconds and the ranging code period is 1 millisecond. Thus the NH code (0, 0, 0, 0, 0, 1, 0,
0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0) with length of 20 bits, rate 1 kbps and bit duration of
1 millisecond is adopted. It is modulated on the ranging code synchronously with NAV message
bit.
D1 NAV Message Frame Structure
The NAV message in format D1 is structured in the superframe, frame and subframe. Every
superframe has 36000 bits and lasts 12 minutes. Every superframe is composed of 24
frames (24 pages). Every frame has 1500 bits and lasts 30 seconds. Every frame is composed of
5 subframes. Every subframe has 300 bits and lasts 6 seconds. Every subframe is composed of
10 words. Every word has 30 bits and lasts 0.6 second.
Every word consists of NAV message data and parity bits. In the first word of every subframe,
the first 15 bits is not encoded and the following 11 bits are encoded in BCH(15,11,1) for
error correction. So there is only one group of BCH code contained and there are
altogether 26 information bits in the word. For all the other 9 words in the subframe both
BCH(15,11,1) encoding for error control and interleaving are involved. Each of the 9 words of
30 bits contains two blocks of BCH codes and there are altogether 22 information bits in
it.
Corresponding program responsible for decoding and finding navigation solution:-
postNavigation.m
TrackResults Settings
Find Preambles
For i=1:activechnanelList
Initialise current
measurement
calculatePseudoranges
Calculate Receiver
LeastSquarePos Position
Transform from
PZ90.02 to WGS84
Coordinate conversion
Store Results
findPreambles.m
ephemeris.m
satposg.m
calculatePseudoranges.m
leastSquarePos.m
satClkCorr.m
cart2geo.m
cart2utm.m
FindPreambles.m:-
It finds the first Time Mark occurrence in the bit stream of each channel. The Time Mark is a unique
bit sequence ‘111110001101110101000010010110’ .At the same time function returns list of channels,
that are in tracking state.
Basically tracking output from each channels are correlated with timemarks and positions of timemarks
are found by comparing absolute value of correlation to a threshold value.The process thus gives
position of timemarks for each channel and mean while keeps track of active channel list too.
Ephemeris.m:-
It decodes ephemerides and time of frame start from the given bit stream. The stream (array) in the
parameter DATA must contain 30000 bits. The first element in the array must be the first bit of a string.
The string number of the first string in the array is not important.
ALGORITHM:-
Ephemeris.m(for each
channel )
For i=1:15
(for 15 strings)
Take 85 data
85 bits out of 15 strings taken from bits
trackResults(channelNr).I_P(subFrameStart(channelNr) +...
300 : subFrameStart(channelNr) + 300 + (1500 * 20) -1)
As per decoded
Corresponding to ICD value of ‘m’
Only 5 first strings are of interest.
Table no:4.4 and 4.5 (either of 1:5 of
The rest strings contain almanac
‘m’ ie string no)
that is not used in this program.
get
corresponding
ephemeris
parameters
Satposg.m:- This function calculates initial position, velocity and acceleration of the satellites in
prnList on the transmit Time based on ephemeris data (eph).
Algorithm
Transmit time Satposg.m Active PRN List
(TOW)
Ephemeris Data
For i=1:no.
length(prnList)
Divide calculation
into subintervals
Initialize constants
(c20, u, ae, J)
CalculatePseudoranges.m
Track results Settings
Channel List
For i= 1:
length(channel list)
LeastSquarePos.m:-
This Function calculates the Least Square Solution for Receiver’s Position
Input:-
satpos - Satellites positions (in ECEF system: [X; Y; Z;] -one column per satellite)
obs - Observations - the pseudorange measurements to each satellite:
(e.g. [20000000 21000000 .... .... .... ])
settings - receiver settings
Outputs:-
pos - receiver position and receiver clock error (in ECEF system: [X, Y, Z, dt])
el - Satellites elevation angles (degrees)
az - Satellites azimuth angles (degrees)
dop - Dilutions Of Precision ([GDOP PDOP HDOP VDOP TDOP])
The concerned algorithm is similar to that of GPS SDR exactly.
Transformation from PZ90.02 to WGS84.
After calculation of Receiver position using LeastSquarePos.m it was needed to transform from
PZ90.02 to WGS84. satellites broadcast their positions in PZ-90 coordinates as a part of their
navigation messages. The navigation message is broadcast by each satellite and usually refreshed every
half-hour.
The PZ-90 geocentric coordinate frame, specified as an abstract mathematical entity, is just one
element of an overall reference system to represent the earth from geometric, gravitational, and
geodetic standpoints. Like its counterpart, WGS84 for GPS, PZ-90 is a self-contained and self-consistent
system within which to define a 3-D position. A comprehensive description of WGS84 is available from
National Imagery and Mapping Agency (NIMA) reports and the description of PZ-90 comes mainly from
the GLONASS Interface Control Document .The values of the defining parameters for the PZ-90 gravity
model and its ellipsoid are slightly different from those of WGS84. These differences, however, are
easily accommodated. A more difficult problem arises from the differences in the ECEF coordinate
frames.
The ECEF coordinate frames of WGS84 and PZ-90 differ in their formal definitions. While each locates
the origin at the center of mass of the earth, the directions of the z axes are different: WGS84 defines it
as passing through the instantaneous pole of 1984; PZ-90 adopts instead the average position of the
pole between the years 1900 and 1905. This description, however, is not adequate as a basis for
determining a transformation between GPS and GLONASS. Actually, even if the formal definitions were
identical, it would not have ensured that the coordinates of a point as determined by measurements
from the two systems would be identical. The coordinate frame for each system is realized (or,
implemented) by adopting the coordinates of a set of stations. A consistent set of such coordinates
defines implicitly the ECEF coordinate frame (i.e., an origin, a set of directions for the Cartesian axes,
and a scale factor). Therefore, even if GPS and GLONASS had adopted the same definition for the
reference coordinate frame, the independent implementation of each system would have kept the two
from being identical.
A transformation between PZ-90 and WGS84, the coordinate frames used by GLONASS and GPS,
respectively, has been studied and implemented in combining measurements from the two systems
[29]. From the research results of Lincoln Laboratory, the difference between the two coordinate
frames is that the zero meridian
(X-axis) of PZ-90 is East of that for WGS84. A small clockwise rotation of 0.4
seconds of arc of the Z-axis of PZ-90 brings the two coordinate frames substantially
into coincidence. The residuals are reduced further, though only slightly, by a 2.5 m
displacement of the origin along the Y-axis. As shown in Figure 4.1, the estimated
transformation between PZ-90 (u, v, w) and WGS84 (x, y, z) is:
x 1 -1.96x10-6 0 u
⁼
Y 1.96x10-6 1 0 v
Z 0 0 1 w
Final Navigation solution
Bibliography
1. K. Borre, D.M. Akos, N. Bertelsen, P. Rinder, and S.H. Jensen: “A Software-Defined GPS and
Galileo Receiver” (ISBN 0-8176-4390-7)
3. Kai Borre, Aalborg University, Dennis Akos, University of Colorado ,“A Software-Defined GPS and
Galileo Receiver: Single-Frequency Approach”
%--------------------------------------------------------------------------
% Initialization =========================================================
% Generate all C/A codes and sample them according to the sampling freq:
caCodesTable = makeCaTable(settings);
fprintf('(');
%--- Make the correlation for whole frequency band (for all freq. bins)
for frqBinIndex = 1:numberOfFrqBins
%--- Generate carrier wave frequency grid (freqency step depends
% on "settings.acqCohIntegration") --------------------------------
frqBins(frqBinIndex) = settings.IF - ...
(settings.acqSearchBand/2) * 1000 + ...
(1000 / (2*1)) * (frqBinIndex - 1);
%--- Generate local sine and cosine -------------------------------
sigCarr = exp(1i*frqBins(frqBinIndex) * phasePoints);
%% a=length(sigCarr);
%% fprintf('length os sigcarr is:%d',a);
%--- "Remove carrier" from the signal and Convert the baseband
% signal to frequency domain --------------------------------------
%pause;
IQfreqDom1 = fft(sigCarr .* signal1);
%--- Check which msec had the greater power and save that, will
%"blend" 1st and 2nd "settings.acqCohIntegration" msec but will
% correct data bit issues
results(frqBinIndex, :) = acqRes1(1:samplesPerCode);
%--- Find the correlation peak and the carrier frequency --------------
[peakSize frequencyBinIndex] = max(max(results,[],2));
%--- Find code phase of the same correlation peak ---------------------
[peakSize codePhase] = max(max(results));
%--- Find 1 chip wide CA code phase exclude range around the peak ----
samplesPerCodeChip = round(settings.samplingFreq /...
settings.codeFreqBasis);
excludeRangeIndex1 = codePhase - samplesPerCodeChip;
excludeRangeIndex2 = codePhase + samplesPerCodeChip;
%--- Correct C/A code phase exclude range if the range includes array
%boundaries
if excludeRangeIndex1 < 2
codePhaseRange = excludeRangeIndex2 : ...
(samplesPerCode + excludeRangeIndex1);
elseif excludeRangeIndex2 > samplesPerCode
codePhaseRange = (excludeRangeIndex2 - samplesPerCode) : ...
excludeRangeIndex1;
else
codePhaseRange = [1:excludeRangeIndex1, ...
excludeRangeIndex2 : samplesPerCode];
end
%--- Find the second highest correlation peak in the same freq. bin ---
secondPeakSize = max(results(frequencyBinIndex, codePhaseRange));
else
%--- No signal with this PRN --------------------------------------
fprintf('. ');
end % if (peakSize/secondPeakSize) > settings.acqThreshold
end
2. Acquisition_4ms code
function acqResults = acquisition_4x5ms(longSignal, settings)
%Function performs cold start acquisition on the collected "data". It
%searches for COMPASS signals of all satellites, which are listed in field
%"acqSatelliteList" in the settings structure. Function saves code phase
%and frequency of the detected signals in the "acqResults" structure.
%
%acqResults = acquisition(longSignal, settings)
%
% Inputs:
% longSignal - 11 ms of raw signal from the front-end
% settings - Receiver settings. Provides information about
% sampling and intermediate frequencies and other
% parameters including the list of the satellites to
% be acquired.
% Outputs:
% acqResults - Function saves code phases and frequencies of the
% detected signals in the "acqResults" structure. The
% field "carrFreq" is set to 0 if the signal is not
% detected for the given PRN number.
%-----------
% Initialization =========================================================
a=length(longSignal);
fprintf('%d longSignal=\n',a);
longSignal = reshape(longSignal, settings.acqResampleCoef, ...
length(longSignal) / settings.acqResampleCoef);
% Generate all C/A codes and sample them according to the sampling freq:
caCodesTable = makeCaTable(settings);
length(caCodesTable);
%--- Initialize arrays to speed up the code -------------------------------
% Search results of all frequency bins and code shifts (for one satellite)
results = zeros(numberOfFrqBins, 20*samplesPerCode);
% Carrier frequencies of the frequency bins
frqBins = zeros(1, numberOfFrqBins);
fprintf('(');
%--- Make the correlation for whole frequency band (for all freq. bins)
for frqBinIndex = 1:numberOfFrqBins
%--- Generate carrier wave frequency grid (freqency step depends
% on "settings.acqCohIntegration") --------------------------------
frqBins(frqBinIndex) = settings.IF - ...
(settings.acqSearchBand/2) * 1000 + ...
(1000 / (2*5)) * (frqBinIndex - 1);
%--- Generate local sine and cosine -------------------------------
sigCarr = exp(1i*frqBins(frqBinIndex) * phasePoints);
%--- "Remove carrier" from the signal and Convert the baseband
% signal to frequency domain --------------------------------------
%pause;
IQfreqDom1 = fft(sigCarr .* signal1);
IQfreqDom2 = fft(sigCarr .* signal2);
IQfreqDom3 = fft(sigCarr .* signal3);
IQfreqDom4 = fft(sigCarr .* signal4);
%--- Multiplication in the frequency domain (correlation in time
domain)
convCodeIQ1 = IQfreqDom1 .* caCodeFreqDom;
convCodeIQ2 = IQfreqDom2 .* caCodeFreqDom;
convCodeIQ3 = IQfreqDom3 .* caCodeFreqDom;
convCodeIQ4 = IQfreqDom4 .* caCodeFreqDom;
%--- Check which msec had the greater power and save that, will
%"blend" 1st and 2nd "settings.acqCohIntegration" msec but will
% correct data bit issues
%/results(frqBinIndex, :) = acqRes1(1:samplesPerCode);
%/results(frqBinIndex, :) = acqRes2(1:samplesPerCode);
%/results(frqBinIndex, :) = acqRes3(1:samplesPerCode);
%/results(frqBinIndex, :) = acqRes4(1:samplesPerCode);
%pause;
results(frqBinIndex, :) = [acqRes1(1:5*samplesPerCode) ...
acqRes2(1:5*samplesPerCode) ...
acqRes3(1:5*samplesPerCode) ...
acqRes4(1:5*samplesPerCode)];
% if ( (max(acqRes1) > max(acqRes2)) &..
% (max(acqRes1) > max(acqRes3)) &..
% (max(acqRes1) > max(acqRes4)))
% results(frqBinIndex, :) = acqRes1;
% code_phase_corr = 0*samplesPerCode/4;
% code_phase_slot = 1;
% elseif ( (max(acqRes2) > max(acqRes1)) &..
% (max(acqRes2) > max(acqRes3)) &..
% (max(acqRes2) > max(acqRes4)))
% results(frqBinIndex, :) = acqRes2;
% code_phase_corr = 1*samplesPerCode/4;
% code_phase_slot = 12;
% elseif ( (max(acqRes3) > max(acqRes1)) &..
% (max(acqRes3) > max(acqRes2)) &..
% (max(acqRes3) > max(acqRes4)))
% results(frqBinIndex, :) = acqRes3;
% code_phase_corr = 2*samplesPerCode/4;
% code_phase_slot = 3;
% else
% results(frqBinIndex, :) = acqRes4;
% code_phase_corr = 3*samplesPerCode/4;
% code_phase_slot = 4;
% end
%--- Find the correlation peak and the carrier frequency --------------
[peakSize frequencyBinIndex] = max(max(results,[],2));
%--- Correct C/A code phase exclude range if the range includes array
%boundaries
if excludeRangeIndex1 < 2
codePhaseRange = excludeRangeIndex2 : ...
(samplesPerCode + excludeRangeIndex1);
elseif excludeRangeIndex2 > samplesPerCode
codePhaseRange = (excludeRangeIndex2 - samplesPerCode) : ...
excludeRangeIndex1;
else
codePhaseRange = [1:excludeRangeIndex1, ...
excludeRangeIndex2 : samplesPerCode];
end
%--- Find the second highest correlation peak in the same freq. bin ---
secondPeakSize = max(results(frequencyBinIndex, codePhaseRange));
else
%--- No signal with this PRN --------------------------------------
fprintf('. ');
end % if (peakSize/secondPeakSize) > settings.acqThreshold
%--------------------------------------------------------------------------
% -----------------
% Channel status
trackResults.status = '-'; % No tracked signal, or lost lock
% Loop discriminators
trackResults.dllDiscr = ones(1, settings.msToProcess).*inf;
trackResults.dllDiscrFilt = ones(1, settings.msToProcess).*inf;
trackResults.pllDiscr = ones(1, settings.msToProcess).*inf;
trackResults.pllDiscrFilt = ones(1, settings.msToProcess).*inf;
% CodeLength:
settings_codeLength = settings.codeLength;
% Summation interval
PDIcode = 0.001;
loopCnt_samplingFreq = settings.samplingFreq;
loopCnt_codeLength = settings.codeLength;
loopCnt_dataType = settings.dataType;
loopCnt_codeFreqBasis = settings.codeFreqBasis;
loopCnt_numberOfChannels = settings.numberOfChannels
Ln=sprintf('\n');
trackingStatus=['Tracking: Ch ', int2str(channelNr), ...
' of ', int2str(settings.numberOfChannels),Ln ...
'PRN: ', int2str(channel(channelNr).PRN),Ln ...
'Completed ',int2str(loopCnt), ...
' of ', int2str(codePeriods), ' msec',Ln...
'C/No: ',CNo,' (dB-Hz)'];
try
waitbar(loopCnt/codePeriods, ...
hwb, ...
trackingStatus);
catch
% The progress bar was closed. It is used as a signal
% to stop, "cancel" processing. Exit.
disp('Progress bar closed, exiting...');
return
end
end
% Find combined PLL/FLL error and update carrier NCO (FLL-assisted PLL) -----
-
I2 = I1; Q2 = Q1;
I1 = I_P; Q1 = Q_P;
if (sign(I2)~=sign(I1))
I2 = -I2;
Q2 = -Q2;
end
oldCarrNco = carrNco;
oldCarrError = carrError;
loopCnt_carrFreq(loopCnt) = carrFreq;
loopCnt_codeFreq(loopCnt) = codeFreq;
(loopCnt_samplingFreq/1000)/settings_codeLength;
loopCnt_dllDiscr(loopCnt) = codeError;
loopCnt_dllDiscrFilt(loopCnt) = codeNco;
loopCnt_pllDiscr(loopCnt) = carrError;
loopCnt_pllDiscrFilt(loopCnt) = carrNco;
loopCnt_I_E(loopCnt) = I_E;
loopCnt_I_P(loopCnt) = I_P;
loopCnt_I_L(loopCnt) = I_L;
loopCnt_Q_E(loopCnt) = Q_E;
loopCnt_Q_P(loopCnt) = Q_P;
loopCnt_Q_L(loopCnt) = Q_L;
end % for loopCnt
4. PostNavigation
function [navSolutions, eph,SOW,satPositions,
satClkCorr,navSol_channel_rawP,subFrameStart,activeChnList,nav_bits] =
postNavigation(trackResults, settings)
%Function calculates navigation solutions for the receiver (pseudoranges,
%positions). At the end it converts coordinates from the WGS84 system to
%the UTM, geocentric or any additional coordinate system.
%
%[navSolutions, eph] = postNavigation(trackResults, settings)
%
% Inputs:
% trackResults - results from the tracking function (structure
% array).
% settings - receiver settings.
% Outputs:
% navSolutions - contains measured pseudoranges, receiver
% clock error, receiver coordinates in several
% coordinate systems (at least ECEF and UTM).
% eph - received ephemerides of all SV (structure array).
%--------------------------------------------------------------------------
%Local variables (to speed up code, bacause working with structs is slow):
trkRslt_I_P = zeros(size(trackResults, 2), (settings.msToProcess -
settings.skipNumberOfFirstBits));
trkRslt_PRN = zeros(size(trackResults, 2));
%% Changed by JAY %%
for i = 1:size(trackResults,2)
trkRslt_I_P(i,:) =
trackResults(i).I_P((settings.skipNumberOfFirstBits+1):end);
%trkRslt_PRN(i) = trackResults(i).PRN;
absoluteSample(i,:) =
trackResults(i).absoluteSample((settings.skipNumberOfFirstBits+1):end);
end
%for i = 1:size(trackResults, 2)
% absoluteSample(i,:) = trackResults(i).absoluteSample;
%end
set_numberOfChnls = settings.numberOfChannels;
set_c = settings.c;
set_navSolPeriod = settings.navSolPeriod;
set_elevationMask = settings.elevationMask;
set_useTropCorr = settings.useTropCorr;
set_samplesPerCode = round(settings.samplingFreq / ...
(settings.codeFreqBasis /
settings.codeLength));
set_dataTypeSizeInBytes = settings.dataTypeSizeInBytes;
%Local variables - end.
%%
%%
% Decode ephemerides =====================================================
for channelNr = activeChnList
channelNr;
%Add condition for the case of weak signal (Not all nav data is
available):
delFromActiveChnList = [];
%% Changed BY JAY 4/15/2013
%--- Exclude satellite if it does not have the necessary nav data -----
% we will check existence of at least one variable from each
% navigation string. It would be better to check existence of all
variable
% but in this case the condition will be too huge and unclear!
if (isempty(eph(trackResults(channelNr).PRN).IODC) || ...
isempty(eph(trackResults(channelNr).PRN).M_0) || ...
isempty(eph(trackResults(channelNr).PRN).i_0) );
%--- Exclude channel from the list (from further processing) ------
%activeChnList = setdiff(activeChnList, channelNr);
delFromActiveChnList = [delFromActiveChnList channelNr];
end
% Initialization =========================================================
% Set the satellite elevations array to INF to include all satellites for
% the first calculation of receiver position. There is no reference point
% to find the elevation angle as there is no receiver position estimate at
% this point.
satElev = inf*ones(1, set_numberOfChnls);
% Save the active channel list. The list contains satellites that are
% tracked and have the required ephemeris data. In the next step the list
% will depend on each satellite's elevation angle, which will change over
% time.
readyChnList = activeChnList;
transmitTime = SOW;
%pause;
%##########################################################################
%# Do the satellite and receiver position calculations #
%##########################################################################
% These two lines help the skyPlot function. The satellites excluded
% to do elevation mask will not "jump" to possition (0,0) in the sky
% plot.
navSol_channel_el(:, currMeasNr) = nan*ones(set_numberOfChnls, 1);
navSol_channel_az(:, currMeasNr) = nan*ones(set_numberOfChnls, 1);
% Find pseudoranges
======================================================
navSol_channel_rawP(:, currMeasNr) = calculatePseudoranges(...
set_numberOfChnls, set_samplesPerCode, absoluteSample,...
set_c, set_dataTypeSizeInBytes, ...
subFrameStart + set_navSolPeriod * (currMeasNr-1),
activeChnList)';
% Coordinate conversion
==================================================
[navSol_E(currMeasNr), ...
navSol_N(currMeasNr), ...
navSol_U(currMeasNr)] = cart2utm(xyzdt(1), xyzdt(2), ...
xyzdt(3), ...
navSol_UtmZone);
navSol_channel_az(activeChnList, currMeasNr) =
nan*ones(length(activeChnList),1);
navSol_channel_el(activeChnList, currMeasNr) =
nan*ones(length(activeChnList),1);
%Some trciks to speed up code. Structs are VERY SLOW in scilab 5.3.0.
navSolutions.X = navSol_X;
navSolutions.Y = navSol_Y;
navSolutions.Z = navSol_Z;
navSolutions.dt = navSol_dt;
navSolutions.latitude = navSol_latitude;
navSolutions.longitude = navSol_longitude;
navSolutions.height = navSol_height;
navSolutions.utmZone = navSol_UtmZone;
navSolutions.E = navSol_E;
navSolutions.N = navSol_N;
navSolutions.U = navSol_U;
navSolutions.DOP = navSol_DOP;
navSolutions.channel.SVN = navSol_channel_SVN;
navSolutions.channel.el = navSol_channel_el;
navSolutions.channel.az = navSol_channel_az;
navSolutions.channel.rawP = navSol_channel_rawP;
navSolutions.channel.correctedP = navSol_channel_corrP;