# ​Verifying the final steps in the solution

A project log for Full Stack GPS Receiver

From raw RF samples of the GPS L1 C/A signal to a position fix, in a completely open fashion

Sometimes it is easier to work backwards. If you have positions for multiple Space Vehicles, and a position in Earth Centered, Earth Fixed (ECEF) coordinates, how can you verify it?

An example position could be (3851787, -78307, 5066308)

At http://www.oc.nps.edu/oc2902w/coord/llhxyz.htm there is a tool to convert from ECEF (in km, not meters) to Lat/Long/Alt.

Converted to Lat/Long/Alt the output you get is:

Latitude,Longitude, Height (ellipsoidal) from ECEF

Latitude : 52.93473 deg N

Longitude : 1.16467 deg E

Height : 174.1 m

This looks intuitively OK (somewhere in England, at a reasonable altitude). So the next step is to check this on a map. For Latitude, N is positive and S is negative. For longitude W is positive and E is negative.

A quick search on Google Maps for "52.93473, -1.16467" will show where the solution is. For these numbers you should be somewhere just south of Nottingham in England.

But what do you do if the final location is wrong?

For debugging, you can also run this process backwards, but you will also need to find your altitude. For me the best tool for this is google Earth.

Once you have latitude, longitude and altitude you can convert your known position to ECEF position using the above website.

You can then run the calculations backwards to see what errors exist in your Space Vehicle positioning.

For example, the five Space Vehicles used had the following X,Y,Z and transmit time:

SV A ( 10796463, -11059512, 21468778) @ 466786.70444515
SV B ( 25624907, 5493917, 6376860) @ 466786.69914821
SV C ( 17562614, 17600801, 9306610) @ 466786.69828776
SV D ( 12436654, 8851501, 21813026) @ 466786.70476175
SV E ( 18466455, 6615577, 17512965) @ 466786.70642941

The distance in each axis can be calculate by subtracting the known position (3851787, -78307, 5066308):

SV A ( 6944676, -10981205, 16402470)
SV B ( 21773120, 5572224, 1310552)
SV C ( 13710827, 17679108, 4240302)
SV D ( 8584867, 8929808, 16746718)
SV E ( 14614668, 6693884, 12446657)

The straight line distance can now be calculated with d = sqrt(x*x+y+y+z*z)

SV A 20,925,018.76
SV B 22,513,018.04
SV C 22,770,985.88
SV D 20,830,121.85
SV E 20,330,171.52

The time of flight for the signal can be calculated by dividing the distance by the speed of light (299,792,458 m/s):

SV A 0.069,798,349
SV B 0.075,095,344
SV C 0.075,955,833
SV D 0.069,481,807
SV E 0.067,814,152

If you add this time of flight to the transmit time they should all be equal:

SV A 466786.774,243,500
SV B 466786.774,243,555
SV C 466786.774,243,593
SV D 466786.774,243,558
SV E 466786.774,243,553

So in this case, the range of times of about +/- 50ns or so - equating to +/- 15m.

## Discussions 