MicroPilot

MicroPilot Autopilot Users Group

To record GPS time, two fields need to be added the datalog, GPS_TIME (field # 1224) and a spare field to store the table result, in this example we are using fServo30 (field# 1256).

A table will also need to be set up, this is because the datalog custom fields can only hold 16bit values, but GPS time is 32bit, so we will use a table to reduce the value and then restore it later.

Step 1: Set up the Table


As you can see in the image the input variable is 1224 and I used 1256 (fServo30) as the output. Any unused field will work for output, usually people only have 8 or less servos connected to the autopilot so the high fServo fields can be used for other things like this.

Do not fill out the schedule boxes linearly, or use the Linear Function on this tab, we want the table to interpolate the result from 0 to 6553600 without any steps in between. So fill out the A to H boxes exactly as shown.

Make sure to enable the TLU by changing the "Disabled" box to "Slow @ 5Hz". You can use any Table # you want. If you are using a helicopter you may already have some tables set up for throttle and collective and you will have to use a higher number table. You can select any table that isn't in use.

Step 2: Add the fields to the datalog


Once you have the table set up, go to the Data Log tab. Click "Enable Custom Fields" and add the GPS time (1224) and your output field (1256, in this case) to the list of custom fields.

Save the VRS file and transmit it to the autopilot. Cycle power on the autopilot and it is now ready to record GPS time.

Record a data log and then open it up in Datalog Viewer to restore GPS time.

A note on recording datalogs: If you put [recordHistory]=50 in your fly file before the takeoff command it will cause the datalog to start recording as soon as the autopilot is ready. Otherwise it doesn't start recording until takeoff. This makes it easier to get a datalog when bench testing.

See the Ning FAQ on starting the datalog before takeoff for more info.

Step 3: Restoring GPS time
So now that the autopilot has recorded a datalog, download it by running the Datalog Viewer and clicking File -> Read log from autopilot. It will then download the log from the autopilot.

Then you can look at the two fields we are interested in by adding them to the log plots tab or just by looking at the two values in the Log Data tab.


When using an fServo field the datalog may automatically change the units for the field to a percentage. If it does this then you can change it to the raw value by going to the Log Data tab and selecting "Raw Units" in the top left corner of the tab.

Go to the point in time that you would like to calculate GPS Time and get the value of each field. For example lets use:
GPS Time: 9362
fservo30: 28

To Restore GPS time:

If GPS_TIME is a negative value, add 65536 to it. Since it is positive in this example I won't do that.

The formula to restore it is (adding 65536 for negative GPS_TIME not shown):

([fServo30] * 65536) + GPS_TIME

So to restore the GPS time value we compressed with the table, take the table output which is 28 in this example and multiply it by 65536 which equals 1835008.

Now add this to the GPS Time field to fully restore GPS time:
1835008+9362= 1844370

The Ublox GPS time format is HHMMSSm so this is 18:44:37.0, GMT -0 time.

Recording PPS - Sub-second accuracy:
Because the time when the GPS signal (with the GPS time) was sent out from the satellite isn't exactly when it was received and processed by the autopilot you can use the Field# 1693, [GPS_ppsTime1kHz] to narrow it down some more.

Field# 1693, [GPS_ppsTime1kHz], contains the number of milliseconds since the "top" of the second, or since the GPS pulse-per-second pulse was sent. This means that if you find the datalog entry with [GPS_ppsTime1kHz] closest to zero, then find the GPS position fix for the next entry with a GPS time ending in '0', you will know that at the time of the entry with GPS_ppsTime1kHz closest to zero, the aircraft was at the position given in that fix.

So to use this you would add field 1693 to the Custom Fields list in the Data Log tab of the VRS Editor.

Using the PPS value

The PPS value of a given entry is the 'true' milliseconds value of that time. So if the restored GPS time is 12:35:45.3 for example and the PPS for that entry is 750, then the accurate GPS time would be 12:35:45.750 for that entry.

If the PPS value is lower than the milliseconds of GPS time then the seconds on the GPS time must be increased by 1.

This means that the PPS value in that entry is for the next second and the GPS time must have rolled over to the next second.

To give an example of this if the GPS time is 18:23:13.8 and the PPS value is 5, the more accurate GPS time would be 18:23:14.005 for that entry. (Since 5 milliseconds is less than 800 milliseconds)


If you wish to calculate GPS time for the whole log (or automatically) then you would need a script that does the calculations on the log file. The log file is plain text so a line can be read in and then broken into columns for each field.

Views: 167

Reply to This

Share

© 2024   Created by MicroPilotNingAdmin.   Powered by

Report an Issue  |  Terms of Service