plcv 0.01 (IPv6 access)

Kasper Pedersen 2009


My Power Line Common View experiment: An attempt to improve ntp time transfer by adding common view of the power line. Or if you have good local timebases, a tool to monitor the phase twist in the power grid.

The PLCV kit has several small parts:

powertracker.c - this program tracks the phase of the power line relative to a simulated power line running off of the system clock. For this to work the period (and siblings) must be set correctly before compilation. The phase difference between simulated and measured is exposed using shared memory.

powerserver.c - listens for incoming udp requests on port 124, and reads the shared memory from powertracker. The client can request the phase at any utc second rollover in the last 256 seconds; In practice the client requests a value a second or two old.

powerclient.c - useless utility that performs a request against a server to obtain the server's power line phase offset relative to the server's clock. This is intended for testing, since it tells you little other than whether the server is working and accepting requests.

powercompare.c - this program does what powerclient does, twice, and subtracts. It sends to udp/124 on the remote end, and to udp/124 on localhost. Thus powertracker and powerserver must be running on both ends. If both clocks are accurate, the output is the power line phase difference between the two points. This is very useful during early setup, in order to check that all participating systems are listening to the same phase, at the same polarity. Or if not, find the offset.

shm_commonview.c - does what powercompare does at 14 second intervals, and presents this to ntpd as a shm refclock. If the power line phase is the same at the server end and at the client end, ntpd will then lock the client's clock to the server's clock using common view. There's a commented-out hack near the end of the file if you connect to different phases or get the phase inverted.

attention: most of these sources have a #define named 'period'. If you are not on 50Hz, this needs changing from 20000.

Sense circuits: I suggest using a step down transformer to ~24V, put 1k in series, and a 12V clamp across that. The resulting trapez waveform is then fed to the CTS pin on a serial port. The resulting zero crossing offset isn't too bad, though a better one can be built.

2009.12.06: The collected data is here

std.dev. offset
powerline cv 65 us 7 us
close ntp server 490 us 496 us
local timebase 11 us 1 us

99% of the time it is seen as within 200 us. 99.9% are within 276 us. 99.99% are within 312 us, and the distribution is nice and symmetrical.
That's a bit better than ntp over an idle 15/15 VDSL. There, when the offset has been removed, 99% is within 600 us, 99.9% are within 6.5ms, and the distribution is asymmetrical.

Thus, power line phase comparison is better than plain ntp. FM radio RDS+Pilot CV is still better.

Note that the x axis is scaled differently for the ntp plot