Optocoupler for PC PSU's 5V line to Picaxe input pin?

moorea21

Senior Member
I'm hopefully going to put together a picaxe based 'alarm', which will sound when/if I leave the power switched on at the wall when I've turned the PC off. Leaving it like this wastes electricity, as the monitor etc are still on standby, and I keep forgetting...

Powered from a 5V phone charger, it will take input from the 5V line of the PC's PSU, and activate a piezo buzzer glued to the bottom of a small tin) if the 5V signal is not present. So, if the picaxe is powered up, but the PC is off, the alarm goes, until I switch everything off at the wall.

I think isolating the picaxe input from the PC would be sensible?

Can anyone recommend any particular optocoupler for this? Or would a 10K resistor be adequate?
 

Aries

New Member
I have always used KB814s, except for a brief period when they became difficult to find.
 

Goeytex

Senior Member
Personally, I would not bother with an OPTO in this case. A 10K or even 22K series resistor combined with the PIC's internal ESD diodes should be more than adequate to protect the Picaxe input.
 

tmfkam

Senior Member
Why not get a "Smart" power strip that turns off the power to all sockets when the "monitored" socket draws no current?

My vote goes to the KB814.
 

hippy

Technical Support
Staff member
I would go with just a 10K resistor.

Instead of having an additional 5V power supply for the PICAXE you should be able to power it from the PC's 5V Stand-By supply which will always be on when the PC is plugged in. Then it can monitor the actual 5V from the PC via the 10K.

Whenever it's powered up but the monitored 5V isn't high you can sound the piezo. Using two output lines to drive the piezo will allow both a normal volume and loud-volume. You might find that's loud enough without having to glue to a baffle or any surface.
Code:
                 .---------.
5V STBY -------->| 5V      |
          ___    |         |   _|
5V ------|___|-->| IN   O1 |--| |
          10K    |      O2 |--|_|
0V ------------->| 0V      |    |
                 `---------'
 

moorea21

Senior Member
Many replies! Thanks to all of you.

Hippy:- I didn't know it was possible to tap into a 5V supply from a PC that's plugged in but not switched on.

Previously when I wanted a loud piezo, I used 2 of them, didn't know I could overdrive one. All sound advice. Pun partly intended.

My PSU: https://www.manualslib.com/manual/1008201/Xfx-Xtr-550w.html?page=14#manual

In the furthest right column, is a purple wire listed as '+5VSB'. This sounds like the one I'd need. Can't see how to hack into it without cutting the wire, and dividing it in 2 directions; is that 100% harmless? no odd current paths likely?

tmfcam: Hadn't heard of a smart strip, a quick look on Amazon turns up a number of them that don't mention monitoring, looking further it seems to be difficult to find any with UK plug patterns that don't cost a fortune. I think the cost difference would be a win for the DIY solution. Also I'm lazy, and maybe an offensive sounding buzzer might eventually train me to switch it off at the wall myself. It worked for Dr. Pavlov after all.

Thanks to all other too, I'll try and follow Hippy's idea and just use a 10k resistor, as long as that has no chance of endangering my PC.
 

inglewoodpete

Senior Member
The piezo question is that there are a couple of solutions. If you are using the PICAXE to generate the (square-wave) sound, then hippy's voltage doubling method is the simplest way out.

However, if you are driving self-oscillating piezo sounders (with DC), then two can produce more noticable sound. Any two piezo sounders (not 'speakers') are likely to produce slightly different frequencies and will produce a more noticable sound due to 'beating' of the two output frequencies.
 

tmfkam

Senior Member
Taking the minimal component approach...

A self oscillating piezo connected with the +ve to 5Vsb and the -ve to 5V would sound when the PC was off but plugged in. The drain from the "off" 5V likely to pass a mA or two, enough to sound the piezo.
 

oracacle

Senior Member
Splicing into three people write should fine, you could probably pretty the PICAXE from it depending on it's current rating. 5v can find on why red wire from the PSU.

Thinking about it, this project could be completed with s single a NAND gate. Both ref and purple high, no output, either goes low you get an output. But I like the idea of using a PICAXE
 

moorea21

Senior Member
The self oscillating piezo ideas sound good (there's that pun again...) but I'm hoping to build with what I have lying around, which doesn't include self oscillating piezos, although I have 2 non self oscillating ones glued to the bottom of a small tin, so they'll do fine I think. The minimal approaches are intriguing, but if I decided to finesse/change the system then the flexibility of starting with a micro controller might pay off.
 

hippy

Technical Support
Staff member
In the furthest right column, is a purple wire listed as '+5VSB'. This sounds like the one I'd need. Can't see how to hack into it without cutting the wire, and dividing it in 2 directions; is that 100% harmless? no odd current paths likely?
That sounds like the one. The way I tap into PC and vehicle wires is to use a scalpel or craft knife to remove a small circle of sheathing. That way you can wrap a take-off wire around the original and solder without having to cut and rejoin the original wire. Insulate when done.

If doing multiple wires in a bundle, eg +5VSB and GND/0V, stagger the cuts so, even if insulation falls off there's little chance of the two shorting each other. A tie-wrap can help there.

Connect the bare ends into standard choc-bloc so you can disconnect and have safe flying wires. Check the +5VSB to GND/0V voltage with a meter before connecting a PICAXE. It should be about 5V but best to be sure.
Code:
        .---------------------------.    _______
        |      _                    |   |       |
-----.  |  .--| |--------------     `-->| O   O |
     |==O==|  | |                       |_______|
-----'     `--| |--------------          _|___|_
--------------| |--.     .-----         |       |
              | |  |==O==|          .-->| O   O |
--------------| |--'  |  `-----     |   |_______|
             _|_|_    |             |
            |_____|   `-------------'
              |_|
There are crimp-on taps but I don't have much experience with those.

Thinking about it, this project could be completed with s single a NAND gate. Both ref and purple high, no output, either goes low you get an output. But I like the idea of using a PICAXE
True. The advantage of a PICAXE is there can be a delay so you have time to switch it off at the mains without it immediately alerting you that you haven't. Also beeping and various tones can be more annoying and difficult to ignore than a continuous drone.

You might be able to avoid the NAND gate if the buzzer goes between 5V and 5VSTB, but that that would depend on how the rails are when powered off, 0V or floating. I wouldn't recommend it.
 

PhilHornby

Senior Member
Powered from a 5V phone charger, it will take input from the 5V line of the PC's PSU, and activate a piezo buzzer if the 5V signal is not present. So, if the picaxe is powered up, but the PC is off, the alarm goes, until I switch everything off at the wall.
If you wanted to stick with this approach, you could monitor the state of the PC via a USB connection (just checking the +5V pin) - thus keeping it all external. (Sometimes you get a choice in the BIOS, as to whether the USB ports are powered off with the PC, or left ON).
 

moorea21

Senior Member
I'll probably stick with splicing into the standby 5V line, as my PC has no side cover, so the 'guts' are exposed anyway. I originally did this for extra cooling when video editing; I don't do that any more, but the lack of a side panel doesn't seem to be a problem, apart from visually.
 
Top