Adding Partial Support for SBAS to the SoftGNSS – Part1

In this set of articles I want to share my code which adds to the SoftGNSS GNSS SDR a partial support for SBAS signal processing – WAAS, EGNOS and SDCM. The support is only partial because this new code does only signal acquisition and tracking. The reason is that SBAS and GPS signals share the same family of spreading codes (GPS C/A code type), are modulated the same way and are using the same carrier frequency. However the navigation data is encoded in a different way and the data messages are quite different from GPS. In these articles I am trying to add only a small amount of new code. Therefore I leave the implementation of SBAS navigation data processing to the readers of these articles.

For various reasons I will not always publish the complete Matlab files. In most cases I will point just to the lines that must be altered. Overall the changes are required in

  • The code for C/A code generators and related functions
  • The signal processing files that use these code generators
  • Various files that are responsible for receiver settings
  • The settings and acquisition GUI files

These code changes will allow not only to process SBAS signals, but also will remove the maximum 32 PRNs limit in acquisition code.

In this first article I will present changes of the C/A code generators and the related functions. All these files are located in the include folder.

Note that the receiver code will not work if changes only from this part (article) are used! All changes from all articles in this series must be implemented for the receiver to work correctly! The other parts will be published in near future.

Function generateCAcode.m

This function already can generate some of the C/A codes that are used by SBAS. However this new code bellow adds support for additional C/A codes and a proper mapping of the PRN number to the index in the array containing G2 generator (code) shifts.

The newest GPS interface control document or as it is called today – Interface Specification (the IS-GPS-200G at the time of writing) contains even more C/A codes. But to support these PRN codes the actual generator (Matlab) code must be changed. The changes are not too complicated, but these changes would break connection to our book and that we would like to avoid. Also these codes are not used anywhere at the moment. Therefore we will change only the G2 generator shifts and (almost) nothing else.

The original code lines listed here

%--- Make the code shift array. The shift depends on the PRN number ------
% The g2s vector holds the appropriate shift of the g2 code to generate
% the C/A code (ex. for SV#19 - use a G2 shift of g2s(19) = 471)
g2s = [ 5, 6, 7, 8, 17, 18, 139, 140, 141, 251, ...
      252, 254, 255, 256, 257, 258, 469, 470, 471, 472, ...
      473, 474, 509, 512, 513, 514, 515, 516, 859, 860, ...
      861, 862 ... % end of shifts for GPS satellites
      ... % Shifts for the ground GPS transmitter are not included
      ... % Shifts for EGNOS and WAAS satellites (true_PRN = PRN + 87)
      145, 175, 52, 21, 237, 235, 886, 657, ...
      634, 762, 355, 1012, 176, 603, 130, 359, 595, 68, ...
      386];

must be replaced by this one with more shifts for the G2 generator

%--- This array stores the amount of shift of the G2 generator code
% The shift value depends on the PRN number of the C/A code.
% For example: GPS PRN#19 - use a G2 shift of g2s(19) = 471.
% SBAS PRNs must be converted to the correct array index.
g2s = [  5,   6,   7,   8,  17,  18, 139, 140, 141, 251, ...
       252, 254, 255, 256, 257, 258, 469, 470, 471, 472, ...
       473, 474, 509, 512, 513, 514, 515, 516, 859, 860, ...
       861, 862, ... % end of shifts for GPS satellites
       ... % Shifts for the ground GPS transmitters
                 863, 950, 947, 948, 950, ...
       ... % Shifts for SBAS satellites (true_PRN = array_index + 82)
                                                    145, ...
       175,  52,  21, 237, 235, 886, 657, 634, 762, 355, ...
       1012, 176, 603, 130, 359, 595, 68, 386, ...
       ... % end of SBAS PRNs by the old standard, the new, extra codes:
                                               797, 456, ...
       499, 883, 307, 127, 211, 121, 118, 163, 628, 853, ...
       484, 289, 811, 202, 1021, 463, 568, 904 ...
       ];

The G2 shifts in this array have indexes from 1 to 76, what works well for GPS PRNs 1 to 37. But it does not work for SBAS PRNs which in our case are from 120 to 158. We want to use the SBAS PRN values as a valid parameter to this function, so we must map the real SBAS PRN number to the correct array cell. Therefore the original code below

%--- Pick right shift for the given PRN number ---------------------------
g2shift = g2s(PRN);

must be replaced by this code

%--- Pick the right shift for the given PRN number -----------------------
if ((PRN > 37) && (PRN < 120)) || (PRN > 158) || (PRN < 1)
    error(['The PRN (', num2str(PRN), ') is not in the range of valid PRNs!']);
end

if PRN > 37
    g2shift = g2s(PRN-82); % SBAS PRNs
else
    g2shift = g2s(PRN);
end;

Function makeCaTable.m

This function creates a table for the acquisition code with sampled C/A codes for all GPS PRNs. The original code was always making a table for the 32 GPS PRNs. Now the new code will make the table only for the PRNs selected in the settings (GPS and/or SBAS).

First the old code shown below to reserve the array space for the PRN codes

%--- Prepare the output matrix to speed up function ---------------------
caCodesTable = zeros(32, samplesPerCode);

must be replaced by this new code

%--- Prepare the output matrix to speed up function ---------------------
caCodesTable = zeros(length(settings.acqSatelliteList), samplesPerCode);

Then accordingly these old lines for the for loop

%=== For all satellite PRN-s ...
for PRN = 1:32
    %--- Generate CA code for given PRN ----------------------------------
    caCode = generateCAcode(PRN);

must be replaced by this code

%=== For all satellite PRN-s ...
for PRN = 1:length(settings.acqSatelliteList)
    %--- Generate CA code for given PRN ----------------------------------
    caCode = generateCAcode(settings.acqSatelliteList(PRN));

Also the comment at the end of the loop can be updated to match the new code. The rest of the code is the same.

1 thought on “Adding Partial Support for SBAS to the SoftGNSS – Part1

Leave a Reply

Your email address will not be published.