![]() |
Forum Index : Microcontroller and PC projects : Mains frequency monitoring
Page 1 of 4 ![]() ![]() |
|||||
Author | Message | ||||
Herry![]() Senior Member ![]() Joined: 31/05/2014 Location: AustraliaPosts: 261 |
Has anyone put the Mmite to this task? Senior?! Whatever it says, I'm a complete and utter beginner... |
||||
crez![]() Senior Member ![]() Joined: 24/10/2012 Location: AustraliaPosts: 152 |
On a related matter I did use a maximite to measure mains power by sampling the mains voltage and current and then multiplying the two numbers and summing over a 20 millisecond period. |
||||
Herry![]() Senior Member ![]() Joined: 31/05/2014 Location: AustraliaPosts: 261 |
OK. Zeroing in (I hope)! I will build a zero crossing counter fed from a plugpack and a bridge rectifier. There are three zero crossings each cycle. I will use this and eg SETPIN 15, CIN to measure number of milliseconds between pulses. I note that the accuracy can be as good as .1% although specified as .9% but I suspect that it is temperature sensitive, and with temperatures here varying by as much as 20 degrees C in a day (!) I would like to be more accurate (I believe by law the mains frequency may not be beyond 1% of spec). Any thoughts on using a crystal? Senior?! Whatever it says, I'm a complete and utter beginner... |
||||
BobD![]() Guru ![]() Joined: 07/12/2011 Location: AustraliaPosts: 935 |
Assuming you have a DS3231 RTC then you could use the 1Hz output to count the number of zero crossings in one second (or more). It's crystal controlled and you can make the RTC slightly more accurate by loading the Aging Offset reg (at address &H10) with correction values. |
||||
VK2MCT Senior Member ![]() Joined: 30/03/2012 Location: AustraliaPosts: 120 |
Another plan may be to half wave rectify teh AC from the plugpack to give a 50Hz rectangular wave. (clip it at 3.3V) send MM Counting during positive half of square wave. John B VK2MCT |
||||
Paul_L Guru ![]() Joined: 03/03/2016 Location: United StatesPosts: 769 |
@Herry - I don't know where you are or how interconnected the power company generators are there, but where I grew up, in Queens County NY (part of NYC), back in the 1950s we had an hysteresis synchronous mechanical clock on the kitchen wall. I carefully hacked it to a time signal from WCBS-AM and it stayed with 1 second of the time signals for years. Here, the power companies have to keep the generators exactly synchronized, both in frequency and phase angle, or one generator would try to drive another lagging generator as a motor. That doesn't work too well when the generators produce a GigaWatt from a single shaft! What I'm saying is that you could very possibly use the power line frequency to calibrate the oscillator on a uM board, not the other way around. Paul in NY |
||||
Herry![]() Senior Member ![]() Joined: 31/05/2014 Location: AustraliaPosts: 261 |
Paul said "...you could very possibly use the power line frequency to calibrate the oscillator on a uM board, not the other way around..." Hi Paul, I'm afraid you have missed my point. Probably because I'm not very good at outlining it! Here in Australia, and in most countries AFAIK if not all, the grid system is universally interconnected and the shafts of alternators are rotated at a closely fixed speed. By law here this must be within 1% of nominal. What drags down shaft speeds is excess load whereas excess capacity increases them. Hence grid control rooms are constantly seeking to match demand and supply. What I want to do is monitor grid frequency very closely, to get a feel of the dragdown and the following corrective upspeeds deliberately introduced. So I want to very accurately measure grid frequency variations. Obviously I need to reference that to something else than the grid speed itself, because by definition that would always equal zero deviance! Senior?! Whatever it says, I'm a complete and utter beginner... |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
Agreed .... Maybe in Australia the mains is not as well maintained. I, in fact, put my oscilloscope on 'line' trigger, and using a 60Hz PWM out of controller into the vertical input, adjust the clock (for a stationary display) . |
||||
crez![]() Senior Member ![]() Joined: 24/10/2012 Location: AustraliaPosts: 152 |
A gps module, as long as it has acquired a signal, can serve as a very precise time reference. You can find them with a 10MHz or 1pps output. You are probably best counting the time for N mains cycles. If N=25 you would have 2 frequency samples per second ( in Australia ) |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
Hi Herry. This is a subject close to my heart - been tinkering with mains frequency measurement etc on and off over the last few years. Here in the UK, you are right there is a licensing agreement that the freq must stay within a tiny percentage of tolerance and the national grid provides this nice tool so you can see how they are doing. http://www2.nationalgrid.com/uk/services/balancing-services/frequency-response/ Years ago, the Post Office used to have clocks that worked using the mains frequency - which probably determined the legal aspect of mains control. I have a nice ZCD circuit which I was playing with earlier this month purely as an exercise to see how small I could make it and you get a pulse reliably around 2V either side of zero. It could stand a lot of improvements (Schmitt triggering etc... - or feed it in a Schmitt input of your PIC even better). Maybe it will give you some ideas. http://www.fruitoftheshed.com/Circuit%20Ideas.Really-Simple-Zero-Crossing-Detect.ashx On the subject of really accurate frequency measurement, have a look at Roman Black's site - he has done a lot with some really novel code to produce very accurate measurement/frequencies from any crystal... he even shows how to make a cystal oven for less that a buck(!) for hyper-stable crystal frequencies (I suspect this will figure in your design). HTH h |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
Because of daily time correction measures done by all the civilized world's power grids, this long term 1 second accuracy you noted is entirely irrelevant to the short term accuracy of the power frequency. Short term being periods less than several hours. The short term accuracy of the power grid is terrible. See this website for a realtime presentation of the UK's National Grid (company name) system's accuracy for the last 60 minutes revealing departures of approximately .2 Hz over that time span (at the time of this writing). http://www2.nationalgrid.com/uk/Industry-information/electricity-transmission-operational-data/ So, the Micromite's crystal oscillator is certainly easily stable enough to show deviations of that magnitude. There is no way in the short term to calibrate the MM frequency by the power line with any certainty! For more fascinating information about power generation systems see the Wikipedia entry "Utility Frequency," especially the Stability section: http://en.wikipedia.org/wiki/Utility_frequency The University of Tennessee Power Information Technology Laboratory also has real time maps updated every few seconds; one for the US grids and one for the entire world: http://fnetpublic.utk.edu/ |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
I just fired up a frequency counter to measure the power line frequency and found not one, but my two best counters not running. Could be from a nearby lightning strike quite a while ago that took out a microwave oven and a weather station. More likely normal equipment aging and a coincidence. They're not toast and show good signs of basic life, just not gating properly, so I hope to be able to repair them without great difficulty. Hank |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
Herry, What Paul meant was that the power line frequency might be more accurate/stable than that of the MM crystal osc., hence you would effectively be measuring the MM freq. variations rather than the powerline frequency variations if you built a powerline frequency meter that was based on the MM oscillator as a time base. A case of the device under test (DUT) being more accurate than the testing system, but it isn't in this case. The MM is more stable than the power line frequency by many orders of magnitude as you know. Hope that this wording makes it more clear what his thinking was. Hank |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
Ah. I thought he meant that the power grid would be suitable over a long period for checking/correcting the 'mite over that long period. I understand (or understood) that the mains if lower in frequency at a particular period of heavy load was then sped up in freq later to correct overall on the average. It's something I was told years ago but never had reason to test or use. John |
||||
VK2MCT Senior Member ![]() Joined: 30/03/2012 Location: AustraliaPosts: 120 |
You could use TV sig as a reference. Take composite video or luminance from a Set top box (these signals are increasingly rare I know). And feed signal into a cro locked to the vertical 'group' (50Hz) in the signal. Other cro channel could be fed with a signal from MM or mains. If the second trace doesn't drift then it's on frequency. TV sync could also be derived using a LDR taped to a screen. LDR would need low voltage supply and a series resistor. (I haven't tried this with LCD, but works a treat with Cathode Ray Tube) TV stations used to use bloody expensive rubidium oscillators as ref but now use satellites) My 2c, John B VK2MCT |
||||
Herry![]() Senior Member ![]() Joined: 31/05/2014 Location: AustraliaPosts: 261 |
|
||||
redrok![]() Senior Member ![]() Joined: 15/09/2014 Location: United StatesPosts: 209 |
Hi All; I would have thought the uMite could do this rather well. However, I'm having trouble making it work. I'm using a 200K resistor from my 120VAC 60Hz main to pin 15. I added a pair of protection diodes to +3.3v and gnd plus a 0.1uF filter cap to remove noise. My frequency counter, highly calibrated using a GPS reference, and it reads very close to 60Hz. Here is my test code snippet. Micromite MKII MMBasic Ver 5.3 Beta 4 SUB MAIN This consistently reads high, about 60.8Hz.N = 0 HzAcu = 0 Pz = 10000 ' 10 SECONDS SETPIN 15,FIN,Pz PAUSE 500 DO PAUSE Pz Hz = PIN(15) HzAcu = HzAcu + Hz N = N + 1 PRINT CHR$(27)+"[1A";N;"N";STR$(Hz,3,2);"Hz";STR$(HzAcu / N,3,5);"Hz" LOOP END SUB Is there a better way of doing this because my code is clearly not working? Yes, I have done this using period but with similar results. redrok |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Remember your frequency reference in the Micromite is just its internal RC oscillator. If you have a MM+ handy try the same code with that at it uses an external crystal |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
My comments before regarding the MM crystal need to be corrected. Due to the fact that I currently have no Micromite of any flavor, I totally forgot that the plain MM has no allowance to operate its clock from a crystal. I'm so used to even simpler micros (8 and 16 bit Pics, Arduinos) having crystals. I thought Herry's question was about using a crystal as the MM timebase, but now I read it correctly. So, what I said only holds for the MM+. (I realized this before Peter's post came through.) Too bad there is not an option (at present) to run the MM from a crystal. Could that be made an option for the MM without upsetting things too much? Cheap microcontroller crystals are in the +- 10, +- 20, and at worst +- 30 ppm frequency accuracy and stability range, so plenty of excess accuracy there for this purpose. I think to shoehorn this in to MM basic without the MM+, I'd use a small PIC (crystal driven) to deliver a reference frequency of around 100 KHz to the COUNT pin, and use that to correct the reading of the line frequency done from another COUNT pin either using the frequency method and a gate time of 100 seconds. The reference frequency should be under 300KHz according to the manual for reliable counting by the MM. The 100 second gate time is long but it will give a resolution to .01 Hz. There is +- .01 Hz for the systematic count error. For a 50 or 60 Hz the interval method on the MM, being limited to millisecond increments, provides very low frequency resolution not adequate for this line frequency measurement. The ideal method of accumulating multiple period measurements should be done with a continuous measurement of the signal under test. I could not guess what a bunch of "separate" period measurements done by the MM and then averaged would yield for accuracy. I'll have to finally get a MM to check that out. |
||||
HankR Senior Member ![]() Joined: 02/01/2015 Location: United StatesPosts: 209 |
Remember your frequency reference in the Micromite is just its internal RC oscillator. If you have a MM+ handy try the same code with that at it uses an external crystal And if you can feed in a 300 KHz or lower frequency calibrated signal into the MM, that should reveal whether the MM internal clock inaccuracy is the source of your inaccurate measurement results. It would only have to be known to about 1 in 10,000 parts which is pretty coarse. If you are able to do that please let us know what the result is. |
||||
Page 1 of 4 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |