My PC's ATX power supply stopped working. I opened it and noticed that it makes a high pitch sound when turned on. I can't figure out which component in the power supply makes that sound, so that I can replace it.
WARNING - PC Power supplies have lethal voltages internally both when mains voltage is applied and also for a variable period of time after being turned off.
A power supply that has been turned off for many minutes MAY contain voltages that can kill you.
If you don't know what you are doing and what precautions to take then if you "play" with such devices you may not live long enough to learn.
The most likely source of the noise is "magnetostriction" of the switched mode power supply transformer core. The core is driven at excessive currents and/or with an unusual waveform and acts as an audio transducer as the core is magneticallly squeezed thn released by the alternating current.
It is likely that the fault is not in the core itself but is caused by either oscillations being at a lower than usual frequency and/or the supply being overloaded by a fault.
Be aware that outputs MAY be non mains isolated. They are usually but ... .
Turn supply OFF. Connect DC meter to a psu output. Turn on psu. Measure voltage. Repeat for all outputs.
Remove mains power.
Leave to stand for say 30 minutes.
Treat the psu as if it is still alive. It may be.
Examine the pcb, looking for unusual signs.
Capacitors with ruptured (broken) tops or split cans.
Charred, brown or blackened resistors.
Cratering in plastic bodies of power transistors.
Main power supply caps are a good start to look at - but expensive to replace.
Discharging high voltage capacitors:
Capacitors can remain charged for hours in some cases.
Seconds to minutes is more common.
If there is a concern that capacitors may have retained charge they can be discharged by "shorting" or (preferably) by using a resistor with two probes.
Don't try this at home if not competent and confident with such things. Eye damage (wear goggles) and electric shock are a possible danger.
Turn off the power !!!
Wear safety goggles.
Spark discharge can throw very small pieces of metal further than you may be happy with. Usually only a danger to eyes unless the capacitor is seriously huge.
Be SURE the power is off !!!!!!
Use an insulated wire or test lead with 2 bare ends. Ideally have a resistor in the middle large enough to limit current and small enough to discharge the largest cap quickly enough.
Most pepole just use a piece of insulated wire or a test probe. Be aware of the exciting nature of spark discharge.
Is the power really really off ? !!!!!!!!!!!!!!!!!!!
Short between earth (chassis etc) and possible high voltage point.
Note that power MUST be removed ! :-(
and that in very rare cases damage may be caused (not usual)
AND that the "zap" and spark of a substantial discharge can make you jump and hurt yourself on something sharp. This is more likely than you'd credit until you've discharged a really large capacitor this way.
Note obvious shock hazards if doing this!
WARNING - Capacitors that have been discharged can "regrow" some charge after a while. This can be enough to give you a shock. Two dischargings a few minutes apart is usually enough to remove most of the charge but be aware of the possibility.
How exactly has it stopped working?
Have you tested the output for voltage? Is the fan working?
It is quite likely a coil/transformer that is whining due to a e.g. shorted output transistor, bad capacitors or faulty load, causing excess current/pulse skipping which produces audible frequencies. Make sure you have removed all the loads to confirm they are not the problem.
As mentioned already, I would really just replace it, as they are nasty things to work with even with the proper tools and one problem can often be caused by another less obvious one. The capacitors can hold a lot of charge after power has been removed which can be very dangerous unless discharged properly.
There are troubleshooting guides out there but often they contain bad information and still need a thorough knowledge of SMPS and the right equipment to be sure of decent results.