[posted] Log 60 Hz AC Powerline Frequency

Jp3141

Well-known member
This uses a Teensy 3.2 and its FTM to precisely measure the frequency of the AC power line. An external GPS provides a 1 pps calibration pulse to continuously calibrate the Teensy's 48 MHz clock. Data is logged via a Raspberry Pi 0 W. A 9 V AC adapter powers the system and also provides the 60 Hz signal which is measured.

This project uses multiple FTM channels -- one for the 60 Hz, and one for the 1 pps calibration.

The Teensy's comparator and DAC are used to sense the 60 Hz signal. The comparator provides a clean output, and its hysteresis prevents false signals. Data is transmitted via the Teensy's USB serial (if connected), and to the R Pi's serial port for it to log via WiFi. A tri-color LED is also provides pulses for a visual indication of correct operation.

60Hz.jpg

For simplicity and debugging, all modules are mounted on a 3-D printed base with brass inserts to hold the GPS and R Pi boards. A small perf. board holds the R.C filter for the raw 60 Hz AC signal.

The system is very accurate (synchronized to GPS 1 pps which is +/- 20 ns) and has high resolution -- it is easy to see 0.0001 Hz frequency shifts which continually occur. The R Pi logging also prints a simple strip chart. An example of logged output is:

Code:
2022-02-01 19:11:51.738 #
2022-02-01 19:11:51.738 #    Ticks, Cycles,    Frequency,      FBUS, Total Cyc, Flt, Phase, 1Hz
2022-02-01 19:11:51.801    2405375,      3, 59.864714234,  47999029,         3,  16,    69, 584
2022-02-01 19:11:55.001  153609267,    192, 59.995167870,  47999030,       195,  16,    60, 731
2022-02-01 19:12:00.005  240812523,    301, 59.995666127,  47999029,       496,  16,    53,  11
2022-02-01 19:12:05.005  239999487,    300, 59.998914498,  47999029,       796,  16,    51,  11
2022-02-01 19:12:10.005  239989904,    300, 60.001311555,  47999030,      1096,  16,    53,  10
2022-02-01 19:12:15.001  239181069,    299, 60.003535108,  47999029,      1395,  16,    57, 731
2022-02-01 19:12:20.005  240795819,    301, 59.999828024,  47999029,      1696,  16,    60,  10
2022-02-01 19:12:25.005  239983561,    300, 60.002896198,  47999029,      1996,  16,    65,  10
2022-02-01 19:12:30.001  239182315,    299, 60.003223775,  47999030,      2295,  16,    70, 731
2022-02-01 19:12:35.001  239984842,    300, 60.002575913,  47999029,      2595,  16,    75, 730
2022-02-01 19:12:40.001  239991266,    300, 60.000971035,  47999030,      2895,  16,    77, 730
2022-02-01 19:12:45.005  240802031,    301, 59.998281451,  47999030,      3196,  16,    74,  10
2022-02-01 19:12:50.005  240022253,    300, 59.993224878,  47999030,      3496,  16,    62,  10
2022-02-01 19:12:55.001  239255002,    299, 59.984994462,  47999030,      3795,  16,    41, 732

and the terminal log looks like:
Code:
2022-02-13 17:00:15.005  239843216,    300, 60.037983313,  47999010,   4314584,  16,   221,   5, -·························0·························>
2022-02-13 17:00:20.005  239844227,    300, 60.037730239,  47999010,   4314884,  16,   289,   3, -·························0·························>
2022-02-13 17:00:25.005  240669121,    301, 60.031390608,  47999010,   4315185,  16,   345,  13, -·························0·························>
2022-02-13 17:00:30.005  239857633,    300, 60.034373390,  47999009,   4315485,  16,    47,  11, -·························0·························>
2022-02-13 17:00:35.005  239865623,    300, 60.032374877,  47999010,   4315785,  16,   105,   9, -·························0·························>
2022-02-13 17:00:40.005  239876040,    300, 60.029766624,  47999009,   4316085,  16,   159,   8, -·························0·························>
2022-02-13 17:00:45.005  239885975,    300, 60.027281712,  47999010,   4316385,  16,   208,   6, -·························0·························>
2022-02-13 17:00:50.005  239895164,    300, 60.024982413,  47999010,   4316685,  16,   253,   4, -·························0························/+
2022-02-13 17:00:55.005  239904306,    300, 60.022693799,  47999009,   4316985,  16,   294,   3, -·························0······················/··+
2022-02-13 17:01:00.005  240724393,    301, 60.017605731,  47999009,   4317286,  16,   326,  13, -·························0·················/·······+
2022-02-13 17:01:05.005  239941945,    300, 60.013278212,  47999009,   4317586,  16,   349,  12, -·························0············/············+
2022-02-13 17:01:10.005  239954304,    300, 60.010187190,  47999009,   4317886,  16,     8,  12, -·························0·········/···············+
2022-02-13 17:01:15.005  239969684,    300, 60.006339801,  47999008,   4318186,  16,    19,  11, -·························0·····/···················+
2022-02-13 17:01:20.005  239957446,    300, 60.009400167,  47999008,   4318486,  16,    36,  11, -·························0········\················+
2022-02-13 17:01:25.005  239938790,    300, 60.014067338,  47999009,   4318786,  16,    61,  10, -·························0·············\···········+
2022-02-13 17:01:30.005  239920783,    300, 60.018571630,  47999009,   4319086,  16,    95,   9, -·························0··················\······+
2022-02-13 17:01:35.005  239901348,    300, 60.023433882,  47999009,   4319386,  16,   137,   8, -·························0······················\··+
2022-02-13 17:01:40.005  239883628,    300, 60.027867763,  47999009,   4319686,  16,   187,   6, -·························0·························>
2022-02-13 17:01:45.005  239875502,    300, 60.029900010,  47999008,   4319986,  16,   241,   4, -·························0·························>
2022-02-13 17:01:50.005  239866520,    300, 60.032147880,  47999008,   4320286,  16,   299,   2, -·························0·························>
2022-02-13 17:01:55.005  240648454,    301, 60.036543630,  47999008,   4320587,  16,     5,  12, -·························0·························>
2022-02-13 17:02:00.005  239866335,    300, 60.032194180,  47999008,   4320887,  16,    63,  10, -·························0·························>
2022-02-13 17:02:05.005  239910492,    300, 60.021143636,  47999007,   4321187,  16,   101,   9, -·························0····················/····+
2022-02-13 17:02:10.005  239931536,    300, 60.015880530,  47999008,   4321487,  16,   129,   8, -·························0···············/·········+
2022-02-13 17:02:15.005  239927933,    300, 60.016781789,  47999008,   4321787,  16,   159,   7, -·························0················\········+
2022-02-13 17:02:20.005  239914527,    300, 60.020134171,  47999007,   4322087,  16,   196,   6, -·························0···················\·····+
2022-02-13 17:02:25.005  239912040,    300, 60.020757608,  47999008,   4322387,  16,   233,   5, -·························0····················\····+
2022-02-13 17:02:30.005  239944270,    300, 60.012695448,  47999008,   4322687,  16,   256,   4, -·························0············/············+
2022-02-13 17:02:35.005  239962056,    300, 60.008247304,  47999008,   4322987,  16,   271,   3, -·························0·······/·················+
2022-02-13 17:02:40.005  239972842,    300, 60.005548878,  47999007,   4323287,  16,   281,   3, -·························0·····/···················+
2022-02-13 17:02:45.005  239944460,    300, 60.012647927,  47999008,   4323587,  16,   304,   2, -·························0············\············+

Code is on Github at https://github.com/jp3141/60Hz
 
Last edited:
Back
Top