From what I read there are 37 ( 1-32 are for traditional GPS code 33-37 are reserved for other use and ground transmitting ) carefully chosen pseudo random sequences 1023 bits long called Coarse/Acquisition and each GPS satellite has assigned one sequence which is broadcast over and over again.

Is this pseudo-random sequence hard-coded into GPS receivers? Or the receiver can recognise such sequences on fly and store for future timing synchronisation - so then even if new sequences appears they are still recognisable.


The PRN ("Pseudo Random Noise") is generated in the GPS receiver using a pair of 10-bit shift registers - Shift register is a set of memory cells when a clock pulse is applied to register the content of each cell shifts on a step to the right.

The input to the first cell is determined by the combined state of other cells then everything is shifted right and process repeats.

By shifting and adding values from two shift registers we can obtain unique Coarse/Acquisition PRN for each satellite.

The satellite PRN generator is fixed but it's easy to modify state by adding values and selecting different initial state for other GPS satellites (take a look into SV variable in the example code )

So answering part of my own question I think it's not possible to introduce new recognisable by GPS receivers PRN codes without some sort of software update.

Below are emulated GPS shift registers in python ( source https://natronics.github.io/blag/2014/gps-prn/ ) and here is code in action for PRN24 https://ideone.com/YZpfiP

#python code
SV = {
   1: [2,6],2: [3,7],3: [4,8],4: [5,9],5: [1,9],6: [2,10],7: [1,8],
   8: [2,9],9: [3,10],10: [2,3],11: [3,4],12: [5,6],13: [6,7],14: [7,8],15: [8,9],
   16: [9,10],17: [1,4],18: [2,5],19: [3,6],20: [4,7],21: [5,8],22: [6,9],23: [1,3],
   24: [4,6],25: [5,7],26: [6,8], 27: [7,9],28: [8,10],29: [1,6],30: [2,7],31: [3,8],32: [4,9],

def shift(register, feedback, output):
    """GPS Shift Register

    :param list feedback: which positions to use as feedback (1 indexed)
    :param list output: which positions are output (1 indexed)
    :returns output of shift register:


    # calculate output
    out = [register[i-1] for i in output]
    if len(out) > 1:
        out = sum(out) % 2
        out = out[0]

    # modulo 2 add feedback
    fb = sum([register[i-1] for i in feedback]) % 2

    # shift to the right
    for i in reversed(range(len(register[1:]))):
        register[i+1] = register[i]

    # put feedback in position 1
    register[0] = fb

    return out

def PRN(sv):
    """Build the CA code (PRN) for a given satellite ID

    :param int sv: satellite code (1-32)
    :returns list: ca code for chosen satellite


    # init registers
    G1 = [1 for i in range(10)]
    G2 = [1 for i in range(10)]

    ca = [] # stuff output in here

    # create sequence
    for i in xrange(1023):
        g1 = shift(G1, [3,10], [10])
        g2 = shift(G2, [2,3,6,8,9,10], SV[sv]) # <- sat chosen here from table

        # modulo 2 add and append to the code
        ca.append((g1 + g2) % 2)

    # return C/A code!
    return ca

#get PRN 24
prn_code = PRN(24)

print prn_code;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.