if you want to sync to mains.. this is what "mains" looks like


Author Message
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1442
Posted: 12:42pm 03 Dec 2024      

I'm not off grid. I use street power for cooking, 3 small A/C and clothes washing.
I use inverter power for the rest of the house.

The frequency measuring thing uses an Arduino Due, it runs at 84Mhz.
I feed it the 1 Hz pulse from GPS to tune a phase locked loop that runs
at 1 Hz locally on the chip.

This way, I know how many clocks is exactly 1 second.

since the timers run at 1/2 clock speed it is 42Mhz.
After it locks, it is
41,999,585 clocks for 1 second. This varies over time +/- 1
so it's stable to at least one part in 42 Million.
This is an excellent time reference now.
It gives me great confidence in the accuracy of any frequency measurement.

Today I checked out the inverter (running the nanoverter code, using a $2 nano
as the time base as they all do)

It sits at 49.92 Hz +/- 0.005 Hz
this is far better than mains regulation.
The inverter frequency does not change  under load, as I expected it would not.

below is data from the Due, running the frequency program that produces
the mains freq data as seen on the web page.

Each line is the average of one second's worth of 50Hz frequency measurements.
there is some noise in my work area and it makes for some variance.

first is the number of clocks for the period of the 50 Hz

next is the current number of clocks for exactly 1 second as produced by the GPS

next is the calculated frequency of the input pulse.
I take this from the workbench power, which comes from the inverter.
The pulse is from the trigger output of the DSO when I choose "mains" as the trigger input. This conditions the mains from 240 AC to a 0 - 3.3V TTL pulse.
Perfect for input into the Due microcontroller.

next is "1" or "0" to show if it's in phase lock.

next is a phasor, running from -10.0 to 10.0, showing the relative phase angle
from the GPS 1 second pulse.

last is the correction, in clocks, needed to keep the local 1 second timer in phase
with the GPS 1 Hz pulse.

We can see the frequency is 49.925 +/- 0.005


841320 41999584.00  49.92402  1  0.24261 499
841211 41999584.00  49.92648  1  -1.23669 501
841265 41999585.00  49.92448  1  -2.71719 501
841266 41999584.00  49.92513  1  -4.19664 498
841389 41999584.00  49.92885  1  -5.67373 499
841287 41999585.00  49.92779  1  -7.15092 500
841185 41999584.00  49.92696  1  -8.62651 499
841293 41999584.00  49.92288  1  9.92671 500
841312 41999585.00  49.92248  1  8.44712 500
841210 41999585.00  49.92767  1  6.97020 499
841318 41999584.00  49.92207  1  5.49213 499
841207 41999585.00  49.92735  1  4.01045 500
841247 41999585.00  49.92538  1  2.53526 501
841183 41999585.00  49.92728  1  1.05879 500
841103 41999585.00  49.92883  1  -0.42228 499
841224 41999585.00  49.92645  1  -1.90068 501
841189 41999585.00  49.92637  1  -3.37808 500
841272 41999585.00  49.92395  1  -4.85774 500
841248 41999585.00  49.92378  1  -6.33595 500
841289 41999585.00  49.93134  1  -7.81130 500
841246 41999585.00  49.92588  1  -9.28675 501
841230 41999585.00  49.92631  1  9.26392 500
841380 41999585.00  49.91928  1  7.78623 499
841345 41999585.00  49.92049  1  6.30521 500
841279 41999585.00  49.92369  1  4.82762 499
841330 41999585.00  49.92163  1  3.35148 500
841272 41999584.00  49.92556  1  1.87332 499
841223 41999584.00  49.92709  1  0.39423 500
841261 41999584.00  49.92572  1  -1.08512 499
841191 41999584.00  49.92706  1  -2.56052 500
841173 41999585.00  49.92852  1  -4.03654 500
841212 41999585.00  49.92784  1  -5.51446 501
841235 41999585.00  49.92687  1  -6.99622 499
841254 41999585.00  49.92398  1  -8.47417 500
841309 41999585.00  49.92654  1  -9.95155 499
841215 41999585.00  49.92730  1  8.60474 500
841212 41999585.00  49.92696  1  7.12263 500
841274 41999585.00  49.92393  1  5.64761 499
841209 41999585.00  49.92751  1  4.16773 500
841252 41999585.00  49.92517  1  2.68943 499
841348 41999585.00  49.92174  1  1.20727 500
841152 41999585.00  49.92909  1  -0.26854 501
841275 41999585.00  49.92547  1  -1.74306 499
841196 41999585.00  49.92868  1  -3.22196 500
841195 41999585.00  49.92687  1  -4.70031 501
841238 41999585.00  49.92953  1  -6.17959 500
841195 41999584.00  49.92641  1  -7.65845 498
841241 41999584.00  49.92530  1  -9.13330 499
841240 41999585.00  49.92599  1  9.41837 500
841178 41999585.00  49.92847  1  7.94216 501
841218 41999584.00  49.92752  1  6.46338 498
841216 41999585.00  49.92715  1  4.98432 500