Author Topic: Any way to pick off the 50/60hz line frequency at low voltage from an ATX PSU?  (Read 14001 times)

0 Members and 1 Guest are viewing this topic.

Offline DeltaTopic starter

  • Super Contributor
  • ***
  • Posts: 1221
  • Country: gb
I'm building a microcontroller based project, which will run of the 5VSB from an ATX PSU, and the MCU will turn on the PSU when it needs to power stuff up.

I'd like to use the 50hz line frequency as a timebase for the a software RTC in the MCU (I know I could use a 32k crystal, or a proper RTC chip of module, but this is just a hobby project, and I'd like to try using the line freq as a reference), so is there a way to pick it out of the PSU?

I've looked at some schematics, and I think the answer will be a big "no".  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.
I was thinking some kind of inductive coupling to a mains conductor, driving a high impedance FET input.  I know 50/60hz can find its way into all sorts of circuits and cause problems, so how can I harness it constructively?

Cheers!
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
 

Offline dom0

  • Super Contributor
  • ***
  • Posts: 1483
  • Country: 00
Quote
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.

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.
« Last Edit: November 18, 2015, 03:02:03 pm by dom0 »
,
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
This is how I do it:
Almost any optoisolator can be used instead in the schematic below.. like the xx 817 4-pin devices so common in use.
« Last Edit: November 18, 2015, 03:18:55 pm by Paul Price »
 

Offline TerraHertz

  • Super Contributor
  • ***
  • Posts: 3958
  • Country: au
  • Why shouldn't we question everything?
    • It's not really a Blog
Previous thread here:
  https://www.eevblog.com/forum/projects/zero-cross-detector-circuit-will-this-give-me-the-irq-i-need-for-phase-control/
  http://www.dextrel.net/diyzerocrosser.htm

Things I'd add to that circuit (see pic)
* A zener to ensure the voltage across C1 never exceeds ratings of the cap or Vcb of the transistor. Also makes the ZC pulse timing more stable.
* The input resistors R1 & R2 are exposed to half mains voltage, and small metal film resistors tend to go open circuit after a while under such stress. It's better to split each into at least two.
* Wouldn't hurt to make the filtering referenced to ground at the input.

(Oops, I left out the current limiting R in series with the opto.)
Collecting old scopes, logic analyzers, and unfinished projects. http://everist.org
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19493
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
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".
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline DeltaTopic starter

  • Super Contributor
  • ***
  • Posts: 1221
  • Country: gb
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...
 

Offline pmbrunelle

  • Regular Contributor
  • *
  • Posts: 183
  • Country: ca
  • lost mech. guy
Since I too live in a first world country with decent electrical service, I consider any quartz clock to be total junk compared to using the line frequency for timekeeping.
 

Offline vk6zgo

  • Super Contributor
  • ***
  • Posts: 7586
  • Country: au
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...

And Mains transformers can be very small---some of those used in older style plugpacks/wall warts may fit in an odd spot in your power supply.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
Since its only a timekeeping signal, it doesn't need to be in phase with the mains.  => a capacitive dropper (X2 cap with a series anti-surge safety resistor) driving the two LEDs of a dual optocoupler connected in anti-parallel, with the phototransistors arranged as a push-pull output stage powered from the 5V rail, could pick off a logic level 50Hz squarewave with very low risk.   Obviously adequate clearances *MUST* be maintained, so either make a proper PCB (not forgetting mounting holes with generous safety clearances if there's anywhere it can safely be screwed down), and I'd add two holes per wire sized to their insulated O.D. to loop them through to mechanically anchor them before soldering, or build it with point to point wiring on BARE perfboard.   

If you go the perfboard route, after testing it thoroughly, epoxy pot it, and secure it inside the PSU chassis with 3M VHB tape.  The PCB will need mounting pillars and fibreboard insulation under it and must be mounted in the live 'zone' of the PSU, unless you decide to pot it and treat it like the perfboard version.


Wire to the AC input to the bridge rectifier (*MUST* be after the fuse), the 5V bus and 0V.   Sleeve the input and output side wiring separately so its double-insulated and cable-tie it firmly in place.  Use a new good quality ATX PSU as it isn't worth putting the time to mod it safely into a cheap or used one.
« Last Edit: November 19, 2015, 04:43:02 am by Ian.M »
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
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.

This circuit can be constructed far cheaper and far smaller than using a transformer and the required additional circuitry to try to do the same job.

Adding filter caps to ground is not needed, the circuit is completely isolated from the mains by the optoisolator and if the values of the caps are not carefully chosen to be small in value the attenuation would make this circuit inoperable. 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.
« Last Edit: November 19, 2015, 05:12:55 am by Paul Price »
 

Online NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9015
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
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.

One trick you can try, if the PSU has active PFC, is to try picking up the EMI generated by the PFC. You're looking for a 50-120kHz or so tone that pulses at twice the mains frequency. Main problem is that at light loads, the PSU would start period skipping and then it's basically impossible to get a reliable signal.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1528
  • Country: 00
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.

I'd rather do it with a few kV galvanic inulation from mains, so H11AA1 if you could source it or two cheapy PC817 with its input connected in anti parallel with additional current limiting resistors on 230VAC mains side ;)

AC Zero crossing detect, H11AA1 troubleshooting

Proof of concept using low reverse voltage LEDs looks like this and it shows why we need to put those diodes/LEDs in anti parallel like internal H11AA1 input ones to survive 325Vmax AC mains  :popcorn:



12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
... 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.

So your circuit can use the PSU's in-built line in filtering and MOV protection but you wont allow mine the same privilege, even though I specified connection at the bridge rectifier?

You wire the optocoupler back to back, it doesn't come that way.  Either use two singles or a dual.  The whole point is to minimise the component count on the live side.   You can use a pure resistive dropper, but to get a good low impedance output needs a reasonable LED current, so that's three resistors running moderately warm.  A cap dropper using a 0.047uF X2 cap isn't large or expensive, nor is a 6K8 resistor, and that will deliver you approx 3.5mA RMS through the LEDs.   Spikes only matter if they occur close enough to the zero crossing to reverse polarity to the LEDs, and if such a glitch even makes it accross the isolation barrier (due to the response time of  the LEDs and phototransistors) is easily filtered out on the low voltage side in software or hardware.

On the subject of used PSUs.  New, they are commodity products, and you don't need a gold plated one.  If the used or s--tty PRC PSU fails, assuming it doesn't take out your custom MCU board, you've got all the hassles or stripping it down to retrieve your opto module, getting a replacement, and refitting the module.  For a one-off, initially fitting it is likely to take something like half an hour, if you are doing the job right with all wiring properly secured. Unless you value your time at less than minimum wage, it just isn't worth using crap.  I *MIGHT* consider a lightly used premium brand PSU, but the standby supply in a modern PC leads a fairly hard life, and IMHO its better to start from new.  On the warranty issue, sure its voided, but that's what burn-in testing is for.  Stick a good load on it or stick it in a system and run it for a few days before cracking it open.
 

Offline vk6zgo

  • Super Contributor
  • ***
  • Posts: 7586
  • Country: au
Quote
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.

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.

If the output is low on standby,that would be the level to go for,& when it increases,just clip it.

I still think the small mains transformer idea is by far simpler & more reliable than any other,however.
ATX power supplies aren't tiny,so there is enough room for a small transformer.
I have seen smaller SMPS which include a small power transformer to keep various circuitry alive in standby.
 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1528
  • Country: 00
This HV cables with 3mm LEDs in anti parallel I've used to detect HV flyback DC vs AC on other pins with limited output current to a few mA  :popcorn:



For direct mains of course current limiting resistors in series with those anti parallel LEDs needed.

Beaty of this solution is it can easy survive a few kV transients as shown in HV experiments I've made using such low reverse voltage diodes in antiparallel  8)


12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
You could probably get away with a small class Y1 cap and series 1M resistor direct from mains live to a Schmidt trigger MCU input with external Schottky clamping.  Allocate 1% of the permitted no-fault earth leakage current for the class of appliance to the cap, and you've still got plenty to toggle a MCU pin. 
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
I've heard of cheap alarm clocks that run at superspeed if you (or your neighbour) have variable frequency drives.

But I prefer 32Khz oscillators, if properly trimmed these are very accurate. You can use mains line to trim it I guess.

Don't scopes get mains trigger from a wire tie-wrapped against the power supply wire?
 

Offline dom0

  • Super Contributor
  • ***
  • Posts: 1483
  • Country: 00
Don't scopes get mains trigger from a wire tie-wrapped against the power supply wire?

That totally depends on the scope.

e: I have no idea why this thread has become so long. What the fuck?
,
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
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
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19493
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
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

Oh dear. Too true.

Anybody that used a spice simulation of such a circuit must, repeat must create and debug all of the prototype circuit on a breadboard. Let's ensure the Dunning-Kruger effect causes a candidate for a Darwin Award sooner rather than later :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
There's no real problem debugging it (or cap dropper PSus) on a breadboard.  Use an AWG driving a small audio power amp for the simulated mains waveform complete with 'databurst', waveform distortion and other transients + a 100V line transformer to get a reasonably realistic voltage then scale selected component values to go from 100V RMS to 240V RMS.

Having learned how to build safe mains circuits on veroboard* in my youth, the prospect of breadboarding a ZCD circuit with ordinary test bench safety precautions does not worry me.  OTOH I certainly wouldn't breadboard the 10A TRIAC on the other end of the ZCD circuit! O0

* Hint: strip whole tracks to achieve required creepage distancea
« Last Edit: November 19, 2015, 09:51:54 am by Ian.M »
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19493
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
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.

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

For the humour impaired, attaching mains to a breadboard is a really really REALLY bad idea - worthy of the Darwin Award
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
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.

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
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.

Also for the humour impaired:  I wasn't advocating exceeding the breadboard's peak voltage ratings or even approaching them, and the 50 or 60 Hz supply suggested would be (A) fully floating and (B) current limited.
 

Offline wraper

  • Supporter
  • ****
  • Posts: 16860
  • Country: lv
H11AA1 optocoupler + resistor in series.
http://www.vishay.com/docs/83608/h11aa1.pdf
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf