There is a newer version of the record available.

Published September 26, 2022 | Version 2022week38-2023week03
Dataset Open

Mains Frequency

Description

Measurements of Mains Frequency (aka Utility Frequency)

This repository provides measurements of the mains frequency (duration of every fully wave), taken in southern Germany (Plochingen), starting on week 38 in 2022. New data is uploaded weekly.

The data has been captured using a microcontroller with clock frequency synchronized to a 1-pps GPS signal. More details about the measuring methodology can be found below.   

For each week, two data sets are uploaded: 

  1. raw data: a stream of type-length-value (TLV) records as received from the measuring device (micro-controller). 
  2. clean data: sanity-checked data produced from raw data and converted to user-friendly comma-separated values (CSV) format

More information about the data formats (TLV and CSV) and about the process to clean data (sanity check) can be found below.

Source Code

Source code including the microcontroller code, server code, and jupyter notebook to process the data is made available through Github: Github Repository

Measurement Methodology

The timer capture functionality of the microcontroller is used to capture the period of the mains sine waves and the 1-pps signal of a GPS device to calibrate the timer clock of the microcontroller. 

Transformer --(sine wave)--> half-wave rectifier --(half sine wave)--> Schmitt-Trigger --(square wave)--> Microcontroller --(samples)--> Computer --> raw file 
                                                                                                            ^ 
                                                                                                            |
GPS Device <-------------------------------1-pps signal------------------------------------------------------

RAW Data Records -- TLV Files

Raw data is recorded in binary format (Little Endian) as a stream of type-length-value (TLV) records. Type is a uint16 number; length is a uint16 number defining the length of the value(s ) in bytes.

The interpretation of the value(s) depends on the type. The following types are defined:

  • SAMPLES record (type 0): a batch of n = length/4 uint32 values defining the number of clock ticks of n consecutive waves. The clock ticks at a nominal rate of 42 MHz. 
  • ONEPPS record (type 1): a single uint32 value defining the number of clock ticks per second, calibrated by a 1-pps signal from a GPS device.
  • WALLCLOCKTIME (type 2): a single uint64 value defining nanoseconds since the UNIX epoch (00:00:00 UTC, Jan. 1, 1970) referencing the stream roughly to wallclock (real) time. Note that this is just a rough reference to real-time. In particular, not every sample is timestamped, but wallclock timestamps are inserted into the stream every second.

C code to parse raw TLV files is provided in the Git.   

Clean Data -- Processing and Format of CSV Files

Clean data, published as comma-separated values (CSV) files, is created from raw data as follows:

A sanity check is performed on 1-pps records calibrating the microcontroller clock. In seldom cases, the GPS device might not output a 1-pps signal for a short period. In these cases, the 1-pps value deviated significantly from the nominal value of 42 MHz (the nominal clock frequency of the microcontroller). Such 1-pps records are removed.

No further checks have been performed on the raw data, in particular, samples are not filtered. Recommended further post-processing includes downsampling the data to remove (very seldom) outliers affecting only one or two consecutive waves. To this end, a median filter calculating the median of five consecutive samples has shown to be very effective.   

The clean CSV file contains the following fields:

  • f_mains: mains frequency as captured by uncalibrated 42 MHz clock. The crystal oscillator can be expected to have an accuracy of 30 ppm over the full temperatur range (the calibration shows an accuracy better than 20 ppm, which is typical for for crystal oscillators at room temperature). 
  • f_mains_syncd: mains frequency, calibrated to 1-pps signal of GPS device (using the value f_clk_synd as described next).
  • f_clk_syncd: calibrated clock frequency of microcontroller using 1-pps signal (nominal 42 MHz).
  • clk_accuracy_ppm: estimated clock accuracy in ppm (relevant when interpreting f_mains instead of f_mains_syncd).
  • t_wallclock: wallclock time in nanoseconds since UNIX epoch (00:00:00 UTC, Jan 1, 1970). Note that this timestamp is only taken once per second to roughly reference the samples to wallclock time. Therefore, several samples have the same wallclock timestamp! Still, it is useful for selecting all samples of one day, hour, minute, etc.
  • t_wallclock_str: string representation of t_wallclock value (in UTC). 

Gaps in Data

No or incomplete data is available during these periods due to technical maintenance:

  • Nov 5-8, 2022
  • Nov 23, 2022
  • Dec 19, 2022

 

 

 

Files

data-clean-2022week38.csv

Files (38.2 GB)

Name Size Download all
md5:a121fb8da83db5ed954ac8ebad18f698
1.8 GB Preview Download
md5:a2913e2baa3b87150d64e0eb90f2fd9b
2.1 GB Preview Download
md5:2a730643f546a31feea6c22b6e981826
2.1 GB Preview Download
md5:31494469b8cabadd7358de8810a39bd0
2.1 GB Preview Download
md5:df250cf6008297b313d5332e8d454a8d
2.1 GB Preview Download
md5:f3f35e63c2c61d1da986d37e574de6ec
2.1 GB Preview Download
md5:61985b9db7870541e8985d7845029814
1.6 GB Preview Download
md5:e45b168cc40654527b8e393e9a9d7efb
1.7 GB Preview Download
md5:2d39f6aa7e9ee7fb9e5bfdaf25501aca
2.1 GB Preview Download
md5:28eeb0882b367f12fd087cbc2ff2f867
1.9 GB Preview Download
md5:14439f92182b5ae1d8e5aa88c4ef32ed
2.1 GB Preview Download
md5:cc3274ebe020c1e53091cb2b1211240d
2.1 GB Preview Download
md5:96fe2f06d3f76db3ad68534ea582a6bb
2.1 GB Preview Download
md5:65aae0d925dbfffa6f032e68daf96a20
2.0 GB Preview Download
md5:90d8cd041ba10f25ae85ca422e7d7d19
2.1 GB Preview Download
md5:014d4054256f1825c6c63f6f3ff6e013
2.1 GB Preview Download
md5:5a984858fb2ffe17cae2dabf6f1e81bb
2.1 GB Preview Download
md5:43977410c76050fe8f661c455ada4bc5
2.1 GB Preview Download
md5:d6dd8d6096a540dd89b6b71fbbbe6834
123.8 MB Download
md5:ba799a2e66ef7bde522f2d49a47898ca
144.5 MB Download
md5:0dc10e772f3d0bb5d59865b794ace33b
144.5 MB Download
md5:a6e81fb77d8b7b3d5275fa216fe3eccc
144.5 MB Download
md5:f2de4d6f38e3a701879767d139e90f1a
144.5 MB Download
md5:faef25db63d2d96567d056d9153eac9d
144.5 MB Download
md5:d23dad5fd20d305b9a060138e626b7f5
112.8 MB Download
md5:dac0252d6db44c4577006dd84af0e24d
118.3 MB Download
md5:88e92a180ae4409c292ce601b9227a32
144.5 MB Download
md5:cc36c232f72ec84edbb67dc30d3f548f
136.9 MB Download
md5:c2096261de3f56edaa86975838aa2865
144.5 MB Download
md5:4e2121d361e8f2345bcf39b5e4ede839
144.5 MB Download
md5:005fc969d28746eadd4933726fecb999
144.5 MB Download
md5:82121dc96ecc8ed41b3a5a4cb5a763b3
140.6 MB Download
md5:eee11e41be315e15384ede224ee516ac
144.5 MB Download
md5:e4432baa1892e4be16f9ac2eb29ef803
144.5 MB Download
md5:d665fa528c7997b7a34412670d4e364b
144.5 MB Download
md5:2764cbfa125eea554d5174d09df4794f
144.5 MB Download