Como definir o tempo em nanossegundos?

3

Eu tenho um Raspberry Pi com um módulo GPS conectado a ele. Como todos os satélites GPS têm relógios atômicos muito precisos, gostaria de sincronizar o relógio do Pi com os relógios dos satélites. Eu sei como obter a data e hora dos satélites, e definir o tempo do meu Pi com:

sudo date -s "MAR 14 2016 14:53:09"

Mas isso é apenas preciso para os segundos, eu gostaria de obter pelo menos milissegundos, mas eu preferiria nanossegundos.

Eu sei que date +%s%N retorna o tempo em nanossegundos.

Como defino a hora em nanossegundos?

    
por Patrick Cook 14.03.2016 / 21:08

1 resposta

6

No momento em que os dados chegam ao seu PC através da interface USB / RS232, a resolução e a precisão não serão boas. No final do dia, sem equipamento dedicado, é melhor ficar com o NTP.

Deste tutorial de sincronização GPS

There are many cheap GPS receivers available in the market. Most of them use either an RS232, or USB connection to send their information to the attached computer. Although the clock inside the receiver itself runs with an accuracy of some nanoseconds, the transfer of the data to the computer causes such a large delay, that in practice it is not possible to synchronize the clock of the local computer with that signal with an accuracy of better than a handful of milliseconds. That kind of accuracy can also be obtained by connecting to a freely available NTP time server over the internet. Only GPS devices which have a special fast and accurate synchronization method with the computer can be used as a time synchronization device. The most expensive and accurate way to do this is to use a GPS receiver which fits in a local PCI or PCIex slot of the computer. But these cards are very expensive and not widely available. The other solution is to use the slow and inaccurate RS232 or USB interface to send general data and do the time synchronization with a pulse.

Como o @dfc corretamente aponta, o RS232 com o PPS faz o trabalho. No entanto, o dispositivo deve suportá-lo.

On most GPS devices with pulse capability, the pulse is sent once every second, starting at the beginning of every new second. This is why these GPS devices are often referred to as GPS with PPS, for pulse per second.

Unfortunately there are not a large number of GPS receivers which have the extra PPS output. I am using Garmin GPS receivers in Kazakhstan for my tourism activities and I have therefore first looked at the available devices from this manufacturer. Currently there are two Garmin GPS receivers which may be used with a direct connection with a computer: the Garmin GPS 16x LVS and the Garmin GPS 18x LVC. They both work on a supply voltage of +5 Volt which is directly available from a computer, they both send the general data in NMEA protocol over an RS232 interface and they both have a PPS output.

    
por 14.03.2016 / 21:28