I don't want to use an additional transformer.
I was thinking some kind of inductive coupling to a mains conductor, driving a high impedance FET input.
http://www.atmel.com/images/doc2508.pdf (http://www.atmel.com/images/doc2508.pdf)And understand absolutely fully what is meant by and implied by "It should be noted that this solution will not give any galvanic isolation for the microcontroller against the AC mains".
http://www.atmel.com/images/doc2508.pdf (http://www.atmel.com/images/doc2508.pdf)And understand absolutely fully what is meant by and implied by "It should be noted that this solution will not give any galvanic isolation for the microcontroller against the AC mains".
http://www.atmel.com/images/doc2508.pdf (http://www.atmel.com/images/doc2508.pdf)And understand absolutely fully what is meant by and implied by "It should be noted that this solution will not give any galvanic isolation for the microcontroller against the AC mains".
Yep, that jumped right out at as soon as I saw the schematic! An MCU hanging off the mains on a few resistors! :wtf:
Thanks very much for all the suggestions, although I'm starting to think that if I really want to use the grid freq I'm as well just using a small transformer...
Yep, that jumped right out at as soon as I saw the schematic! An MCU hanging off the mains on a few resistors! :wtf:That's fine if the resistors are rated to withstand the mains voltage. In practice, that means using at least two 1/4W resistors in series (preferably 3 or more - they're cheap!) and having values high enough to keep the currents low. Definitely not a good project for a beginner (really, nothing directly interfacing to the mains would be), but I have seen it used in various commercial products.
So if that's the case, is there a safe way to get a 50hz reference without connecting directly to the mains. I don't want to use an additional transformer.
... This circuit could be connected to the ATX P/S PCB at the point where the AC line voltage is already being filtered by the capacitor-common mode choke circuit that directly connects to the bridge rectifier of the ATX supply.
Ian.M: My circuit requires an optoisolator that can be salvaged from an old ATX supply or from any other SMPS equipment at zero cost. Buying a rarer breed of back to back LED optoisolator would be a more expensive way to accomplish the goal here. Also the size of and cost of the 250RMS capacitor for the voltage divider is a factor. Also, using just a capacitor voltage divider seems to be a simple solution, but this circuit idea will likely cause a clock to run fast as there will be spurious timing pulses generated because of not filtering out mains voltages glitches.
There is no need to buy a new ATX power supply either, as it takes no more time to add this mod to an used power supply than to a new one. If the ATX power supply was previously probably working fine powering a PC, it would be foolish to discard it simply because it is used but working well and also opening the case and modding a new ATX supply would void its warranty.
QuoteI don't want to use an additional transformer.
I was thinking some kind of inductive coupling to a mains conductor, driving a high impedance FET input.
You don't want to use an additional transformer, but an inductive coupler (aka transformer) would be okay? ;-)
The issue with coupling to a single mains conductor would be that you're looking at the current flow, not the voltage. So you'd get very little output in stand by mode, but you'd also have to cope with much larger outputs under load. The easiest, and safest, way is to use either an opto coupler based zero-crossing detector or a small mains transformer. The opto solution will have less stand by losses.
e: Of course a real RTC is still simpler and doesn't need mains at all.
Don't scopes get mains trigger from a wire tie-wrapped against the power supply wire?
I'm just surprised it hasn't mutated into the great illegal/unsafe capacitive dropper PSU debate! :-DD
I've seen similar threads about ZCD circuits on other forums go to a hundred or more posts with flames to the left and flames to the right and SPICE models attached in place of artillery support. |O
There's no real problem debugging it on a breadboard. Use an AWG driving a small audio power amp for the simulated mains waveform complete with 'databurst', waveform distortion and transients + a 100V line transformer to get a reasonably realistic voltage then scale selected component values to go from 100V RMS to 240V RMS.No AWG. The whole point is to use the mains directly, just like in the real circuit :) If you don't then then you won't have a visceral understanding of the "effects" that can happen when dealing with mains - doubly so if there are large motor transients or lightning strikes on the mains supply.
No AWG. The whole point is to use the mains directly, just like in the real circuit :) If you don't then then you won't have a visceral understanding of the "effects" that can happen when dealing with mains - doubly so if there are large motor transients or lightning strikes on the mains supply.Same goes for designing or modifying any mains powered electronics that isn't on the secondary side of a conventional transformer or commercial SMPSU with regulatory approvals.
Anyone thinking of connecting to the mains directly should understand why these components exist http://uk.farnell.com/MarketingProductList?CMP=e-email-191115-Bourns&orderCode=2495067,2495068,2495069,2495070,2495071 (http://uk.farnell.com/MarketingProductList?CMP=e-email-191115-Bourns&orderCode=2495067,2495068,2495069,2495070,2495071)
H11AA1 optocoupler + resistor in series.Problem with your two 33k resistors in series is that... you will have close to 0.4W power disipation in each of them so total close to 0.8W :-DMM
But what's the point if you can use 2x 1W resistors. Or alternatively can use H11AA3 or H11AA4 with higher CTR and increase resistance thus reducing the power.H11AA1 optocoupler + resistor in series.Problem with your two 33k resistors in series is that... you will have close to 0.4W power disipation in each of them so total close to 0.8W :-DMM
That is why I've used four 100k grouped with two so 50k x 2, which gives ~0.13W per each 100k resistor so even classic 100k 1/4W THT looks not so bad ;)
Also using 1/4 w resistors might be not so good idea because for most of them you are closing to their max rated voltage.It depends how those THT resistors are mounted ;)
Nothing to do with mounting. Spiral cut (trimmed) film resistors have a max voltage rating.. exceed it and they can flash over turn to turn, narrowing the film, causing hot-spotting leading to failure. Typically such resistors have a 200V rating, leaving very little margin on the peaks with two in series if the mains supply is at its upper tolerance limit. Add >10% transients at or near the peak and you are FUBARed.Also using 1/4 w resistors might be not so good idea because for most of them you are closing to their max rated voltage.It depends how those THT resistors are mounted ;)
Thermal heat shrink can be used and aditionally filled with electric insulator inside PCB case, so its 7mm mount pins length can be fine, while we have two in series.
For any of my microcontroller hobby projects where I have an I2C interface available...Yep, many RTC with I2C interface have output pin available which can be configured with choosen frequency based on its internal oscilator, so once after MPU restet we connect with such RTC, setup to given frequency and enable on output pin and no need to mess with unpredictable mains with transients from neighbours inductive loads, etc ;)
Add >10% transients at or near the peak and you are FUBARed.More like 2kV spikes for less than a millisecond. Refer to your local safety standard for the testing method in your area.
I still better like oryginal idea with resistors, while even at 2kV transient divided by 100k series resistance we get ~20mA via those antiparallel diodes which are usually capable of 50mA or so.Add >10% transients at or near the peak and you are FUBARed.More like 2kV spikes for less than a millisecond.
TerraHertz:
The two 220K resistors in my circuit are forming a voltage divider with the 22K resistor so that the voltage across the 10uF capacitor is not going to rise to a level to need a zener diode to limit the voltage to a safe value. There is additional voltage peak attenuation by the 10uF capacitor itself at the line frequency in addition to the 22K divider resistor. The capacitor discharges each half cycle through the 1K resistor and optoisolator.
Adding a zener does not make the output more stable, it is the stable zero-cross time of the mains voltage that makes the output signal stable.
I await your criticism! :)
I await your criticism! :)
It can be as simple as it is, when you have transformer, while power disipation will be orders of magnitude lower on transformer secondary, so transformer in your design is fine, but I like have MPU optoisolated from power source if easy possible - I mean trafo secondary ;)
I'm guessing the grid freq was a bit higher through the night due to low load.
2015-11-20 18:00:03 49.946999
2015-11-20 18:05:03 49.981998
2015-11-20 18:10:02 49.959999
2015-11-20 18:15:02 50.012001
2015-11-20 18:20:08 50.006001
2015-11-20 18:25:03 49.998001
2015-11-20 18:30:04 49.957001
2015-11-20 18:35:05 49.948002
2015-11-20 18:40:03 49.993999
2015-11-20 18:45:03 49.966
2015-11-20 18:50:01 49.956001
2015-11-20 18:55:02 49.910999
2015-11-20 19:00:04 50.02
2015-11-20 19:05:03 50.013
2015-11-20 19:10:02 49.976002
2015-11-20 19:15:03 50.022999
2015-11-20 19:20:04 50.022999
2015-11-20 19:25:02 50.092999
2015-11-20 19:30:02 50.051998
2015-11-20 19:35:01 50.007999
2015-11-20 19:40:03 50.112
2015-11-20 19:45:02 50.009998
2015-11-20 19:50:01 49.966999
2015-11-20 19:55:02 49.990002
2015-11-20 20:00:02 50.044998
2015-11-20 20:05:02 49.928001
2015-11-20 20:10:02 49.931999
2015-11-20 20:15:03 49.959999
2015-11-20 20:20:06 49.973999
2015-11-20 20:25:01 50.012001
2015-11-20 20:30:04 49.942001
2015-11-20 20:35:01 50.007
2015-11-20 20:40:01 50.035999
2015-11-20 20:45:02 49.941002
2015-11-20 20:50:03 50.006001
2015-11-20 20:55:02 49.984001
2015-11-20 21:00:02 49.943001
2015-11-20 21:05:03 50.015999
2015-11-20 21:10:02 50.042
2015-11-20 21:15:03 50.063
2015-11-20 21:20:04 49.964001
2015-11-20 21:25:02 49.987999
2015-11-20 21:30:02 49.986
2015-11-20 21:35:02 49.919998
2015-11-20 21:40:02 49.941002
2015-11-20 21:45:02 49.946999
2015-11-20 21:50:02 49.937
2015-11-20 21:55:01 49.959999
2015-11-20 22:00:04 50.043999
2015-11-20 22:05:03 49.976002
2015-11-20 22:10:02 50.019001
2015-11-20 22:15:01 49.977001
2015-11-20 22:20:02 49.967999
2015-11-20 22:25:03 49.918999
2015-11-20 22:30:02 49.91
2015-11-20 22:35:02 50.028
2015-11-20 22:40:01 49.991001
2015-11-20 22:45:03 50.025002
2015-11-20 22:50:02 50.028
2015-11-20 22:55:01 50.203999
2015-11-20 23:00:02 50.129002
2015-11-20 23:05:02 49.834
2015-11-20 23:10:01 49.974998
2015-11-20 23:15:01 50.077999
2015-11-20 23:20:03 50.015999
2015-11-20 23:25:01 50.021
2015-11-20 23:30:04 50.043999
2015-11-20 23:35:01 49.987
2015-11-20 23:40:02 50.008999
2015-11-20 23:45:02 49.991001
2015-11-20 23:50:03 49.938999
2015-11-20 23:55:01 49.98
2015-11-21 00:00:05 50.047001
2015-11-21 00:05:02 49.986
2015-11-21 00:10:02 49.965
2015-11-21 00:15:03 49.957001
2015-11-21 00:20:03 49.942001
2015-11-21 00:25:02 50.001999
2015-11-21 00:30:03 49.971001
2015-11-21 00:35:02 49.923
2015-11-21 00:40:01 49.950001
2015-11-21 00:45:02 49.944
2015-11-21 00:50:01 49.914001
2015-11-21 00:55:02 49.924999
2015-11-21 01:00:01 50.027
2015-11-21 01:05:01 50.063999
2015-11-21 01:10:02 50.077999
2015-11-21 01:15:01 50.084999
2015-11-21 01:20:02 50.070999
2015-11-21 01:25:01 49.997002
2015-11-21 01:30:03 49.976002
2015-11-21 01:35:01 50.033001
2015-11-21 01:40:02 50.145
2015-11-21 01:45:02 50.080002
2015-11-21 01:50:01 50.074001
2015-11-21 01:55:01 50.050999
2015-11-21 02:00:02 50.036999
2015-11-21 02:05:02 49.902
2015-11-21 02:10:02 49.935001
2015-11-21 02:15:02 50.023998
2015-11-21 02:20:06 50.022999
2015-11-21 02:25:02 50.014
2015-11-21 02:30:02 50.033001
2015-11-21 02:35:03 49.929001
2015-11-21 02:40:01 49.994999
2015-11-21 02:45:02 50.042999
2015-11-21 02:50:02 50.082001
2015-11-21 02:55:06 50.067001
2015-11-21 03:00:03 50.054001
2015-11-21 03:05:02 50.001999
2015-11-21 03:10:03 49.981998
2015-11-21 03:15:05 49.959
2015-11-21 03:20:02 49.964001
2015-11-21 03:25:02 50.013
2015-11-21 03:30:03 50.057999
2015-11-21 03:35:02 50.026001
2015-11-21 03:40:02 50.02
2015-11-21 03:45:03 50.077999
2015-11-21 03:50:01 50.084
2015-11-21 03:55:03 50.042
2015-11-21 04:00:02 50.046001
2015-11-21 04:05:02 49.963001
2015-11-21 04:10:04 49.969002
2015-11-21 04:15:01 49.978001
2015-11-21 04:20:04 49.973
2015-11-21 04:25:01 49.950001
2015-11-21 04:30:02 49.918999
2015-11-21 04:35:02 49.939999
2015-11-21 04:40:02 50
2015-11-21 04:45:02 50.023998
2015-11-21 04:50:02 49.977001
2015-11-21 04:55:02 50.015999
2015-11-21 05:00:05 50.015999
2015-11-21 05:05:02 49.963001
2015-11-21 05:10:02 49.941002
2015-11-21 05:15:02 49.946999
2015-11-21 05:20:04 49.948002
2015-11-21 05:25:03 49.938999
2015-11-21 05:30:01 49.953999
2015-11-21 05:35:04 50.081001
2015-11-21 05:40:09 50.091999
2015-11-21 05:45:06 50.085999
2015-11-21 05:50:02 50.042999
2015-11-21 05:55:02 50.014
2015-11-21 06:00:02 50.032001
The low power dissipation of the opto-coupler version will be hard to beat with a transformer, not to mention size and weight.There is nothing to beat, since we already had 50 Hz transformer on this questioned schematic, so while we already plan to use transformer in some design, than it doesn't mater how much more we loose in comparision to opto-coupler version.
I'm a massive fan of that website already! But it kept telling me the server was too busy to prepare the csv file for download, so cheers for the info. However looking at the data implies that my 7 second gain was not due to a higher freq.....I'm guessing the grid freq was a bit higher through the night due to low load.
No need to guess. See http://www.gridwatch.templar.co.uk/download.php (http://www.gridwatch.templar.co.uk/download.php) and fight your way through the skewomorphic interface to find:
Mains frequency is only guaranteed for to be within spec when averaged over a large period of time. This means you can have "high" momentary errors.
50 Hz +/- 1% during 99,9% of a year
50 Hz +2% / -4% all the time
Should be in NEN-EN 50160:2000