Mains Power

Mains power (sometimes mains or line) refers to the AC power at the final stage of the electrical grid that is run into most buildings and is available at wall outlets. The voltage used varies throughout the world however in North America the standard is 110 - 127 V AC while Europe is 220 - 240 V AC. There is significant danger in coming into contact with mains as the only limit to the current is a breaker or fuse in the service box for the building which is designed to prevent damage to the building's wiring, not prevent damage to connected devices or electrocution. As such devices with exposed mains power have inherent hazards when they are powered.

Live or Hot Chassis
Some devices such as CRT displays or televisions or radios may have been designed with a live chassis that is connected to mains power. This means touching the chassis while having contact with either neutral or earth ground can complete a circuit and result in a significant electrical shock. These also pose a hazard for diagnostics and can lead to other difficulties such as finding a suitable DC ground reference for taking measurements.

TODO - Document methods of determining a live chassis in an unpowered state.

Mains Bulk Capacitors
Mains bulk capacitors are present in many new and old devices, most notably the vast majority of general purpose AC-to-DC power supplies are SMPS (Switch Mode Power Supplies), those power supplies rely on rectifying the mains input voltage from AC into DC which is stored in bulk capacitors. This is done to allow a transistor to switch this DC through a transformer at much higher frequencies (often 100 kHz to 1 MHz) than the grid (50 or 60 Hz), this allows the magnetics (eg. transformer) in the power supply to be smaller, lighter, cheaper and more efficient. However those mains voltage bulk capacitors can be rather large on high powered devices to improve regulation performance and increase hold-up time during grid brownouts, because of this those large mains voltage capacitors can pose a shock hazard even after the device has been powered off due to the charge stored in those capacitors.

Discharging Mains Bulk Capacitors
Most modern devices include bleeder resistors to discharge those capacitors however this can take tens of minutes and those resistors can fail. Because of this you should always discharge mains bulk capacitors before touching a PCB after it has been powered on. To discharge a capacitor manually use an insulated tool such as plastic handled pliers to place a resistor (around 100 kΩ) directly across the pins of the capacitor, this will discharge the capacitor over several seconds and avoid damaging the capacitor or metal tool due to a sudden discharge. After this step or on devices where you can visually identify the bleeder resistor across the capacitor and have confidence it is functional you can then bridge the capacitor pins with a metal tool directly. If the device is not connected to earth ground, a non-insulated metal tool can be used as a circuit cannot be made through you however this is generally discouraged.

Voltages Present on Mains Bulk Capacitors
Mains bulk capacitors are charged through rectifiers to the peak mains voltage, however while mains voltage is typically denoted as '230 V AC' this is a contraction of '230 Vrms AC' with 'rms' meaning root mean square. AC voltage is expressed in terms of rms because it allows for easier calculations of power and compatibility with ohms law. An example being 220 Vrms AC × 0.5 A = 110 W. However this means the peak voltage is higher than the rms voltage and this peak voltage is what those capacitors are charged to (240 Vrms AC will be 340 Vp AC and 120 Vrms AC will be 170 Vp AC).

In addition to charging directly through rectifiers some high powered devices like ATX power supplies will have APFC (Active Power Factor Correction), this uses a boost converter to optimize the power extracted from the full AC waveform to improve efficiency and reduce strain on the grid. However this results in the mains bulk capacitor being charged to higher than the mains peak voltage, in some cases up to 400 V DC even in countries where the grid voltage is 100 Vrms AC.

Safety Capacitors
TODO
 * Those are called safety capacitors because their failure can result in parts the user can touch becoming live at mains voltage.
 * Things like X and Y class safety capacitors must be replaced with proper safety capacitors of equivalent type, not just any random film or ceramic capacitor.

Earth Leakage Safety Devices
TODO