For any enquiries email Colin Mitchell

The Power Supply
This discussion covers the:
commonly called:
or the

Page 1: Basic Electronics
               The capacitor - how it works
                The Diode - how the diode works
                Circuit Symbols - EVERY Circuit Symbol
                Soldering - videos
Page 2: The Transistor
              - PNP or NPN  Transistor TEST
Page 2a: The 555 IC 
                The 555 - 1
                The 555 - 2
                The 555 - 3
                The 555 TEST
Page 3: The Power Supply  
download as .pdf (900kB)
               - Constant Current
               - Voltage Regulator
Page 4: Digital  Electronics

               - Gates  Touch Switch Gating
Page 5: Oscillators

Page 6: Test - Basic Electronics (50 Questions)
Page 7: The Multimeter - using the Multimeter
Page  8: Constructing a Project

                                   to Index
This type of power supply is VERY DANGEROUS and is not allowed in many countries.
I have NEVER built one or used one as I value my life.
I am including it because it is a CONSTANT CURRENT POWER SUPPLY and there are many different types of CONSTANT CURRENT power supplies for illuminating components such as strings of LEDs and these power supplies are perfectly safe.
This discussion covers how to work with a CONSTANT CURRENT POWER SUPPLY or CONSTANT CURRENT CIRCUIT.  
But first we have to discuss the MAINS
                                   to Index

The "MAINS" is a voltage of either 120v AC or 240v AC.
It is rising and falling at a rate of 50 or 60 times per second and this is called the frequency.
Frequency is measured in Hertz, with 50Hz or 60Hz being the frequency of the Mains.
Since the voltage is rising and falling we call it ALTERNATING and because the CURRENT is the part of the Mains that provides all the work (heat) it was the most important part of the MAINS.
That's why they called the Mains,  AC (ALTERNATING CURRENT)
The Mains is a very dangerous voltage to deal with as the 120v AC is really a voltage that rises to 180v and then drops to minus 180v at the rate of 60 times per second.
The 240v is really a voltage 345v and then a voltage of minus 345v, rising and falling at a rate of 50 times per second.
Your body can only handle 60v to 80v and anything above that can cause instant death.
That's why building a power supply and having mains voltages present on your work desk requires extreme caution.
Electricity must pass through your body to earth or a pipe or another wire to produce "electrocution." 

                                   to Index

Fig 1. The "Mains" WAVEFORM
The "MAINS" is dangerous because the voltage is much higher than stated on any appliance.
It is actually 180v or 345v for the 240v mains.
The ACTIVE lead rises 340v then falls 340v below "ground" 50 times per second and this will produce a CURRENT FLOW through your body that will kill you very quickly.
                                   to Index
Obviously you don't want to touch the mains and that's why everything connected to the MAINS is covered with plastic.
Plastic is an insulator and that's why you can handle hair-dryers and electric drills etc. 
Mains transformers are also safe because they have a layer of plastic between the primary and secondary winding.
This layer of plastic is called INSULATION. 
The primary winding is connected to the mains and the secondary winding is connected to your project.
The insulation between the two windings means you can NEVER touch the "MAINS."
Ask yourself this simple question: "Would you poke a knife or fork into a toaster?"  No. Because you may touch the heating element and you may get a shock.
But you will pick up a hair-dryer because the case is made of plastic.
The plastic is an insulator and you trust plastic to isolate the "MAINS."
The same with a mains transformer. The plastic provides insulation (called ISOLATION).
The energy from the mains is converted to magnetic flux and is passed to the metal core of the transformer. Th
is flux passes through the turns of the secondary winding to produce energy and that is how the energy is passed from the mains to your project. It is through magnetism.
                                   to Index
We are not going into great detail about the transformer.
But we are going to cover some of the basic facts.

In the diagram above, the winding connected to the "mains" is called the PRIMARY and the low-voltage winging is called the SECONDARY.
The symbols on each wire indicate an AC voltage is present on each wire but the size and shape of the waveform does not correspond to the actual waveform present on the wire.
The two lines in the middle of the symbol represent the metal core of the transformer and the fact that the two windings are separate, indicates they do not touch.
You can see from the photo, the primary winding is on the top of the bobbin and secondary below. The plastic bobbin creates an insulation of up to 5,000 volts insulation.
The number of loops on the diagram does not indicate any of the voltages or currents as this will depend on the size of the transformer, the size of the wire and the number of turns.
This type of transformer is called a MAINS TRANSFORMER and the frequency of the mains (50 or 60 cycles per second) will produce an output voltage that is 50Hz or 60Hz.
The "active" of the mains is also called LIVE and is either red or brown and "neutral" is either black or blue.
We have also added a wave to show the voltage on the active wire will be rising at the beginning of the cycle while the neutral will be falling. This is not completely true and is just to show the wires are not rising at the same time. 
Here are two facts that are not widely understood:
If 110v is connected to the primary of a 240v transformer, the 12v secondary will produce 6v.
The output voltage will be half, but the full original current will be available.
You cannot connect 240v to a 110v transformer because as soon as the voltage passes 110v, the flux density in the core reaches a maximum and it cannot produce a back voltage and the current will increase. The transformer will get very hot and "burn-out."  

to Index
The circuit shows a Power Supply using a transformer.
insulation is between the primary and secondary where the two lines have been placed. The two lines indicate a magnetic circuit exists between the two windings.  

to Index
We can remove the transformer and replace it with a capacitor.
You can see one of the mains wires is connected directly to the Power Supply.
This is ok when the Neutral line is connected to 0v of the supply.
But what happens if the power supply is connected via an extension-lead and the wires are reversed!!
The active will be connected to the 0v and this is just like poking a nail into the active hole of the power-outlet on the wall.
If you are touching the frame of a metal toaster at the same time, you will get a shock.

Fig 3. The Capacitor in our discussion

Fig 4. The MAINS reversed  !!!!!
If you touch the 0v rail, you will get a shock !!!

                                   to Index

Let's put aside the dangers of a CAPACITOR-FED POWER SUPPLY and see how it works. 

                                   to Index
The capacitor in the diagram above can be replaced with a door and two bar magnets.
When the mains moves the magnet up, the magnet on the other side of the door moves up too.
The two magnets do not touch each other but are influenced by magnetism.
The same with a capacitor.
When the left plate of the capacitor is charged by the mains, the left plate is filled by the "electricity" from your power supply.

Fig 5.  The Magnet
                                   to Index
Place a sheet of aluminium foil on each side of the door and connect one side to the active of the mains.
The foil is exactly like a capacitor.
Now connect the 0v of the power supply to your leg and touch the aluminium foil.
You will get a SHOCK.
The capacitor works like this.
When the active line of the mains is rising, it is putting a charge on the plate on the left side of the door.
This effect is influencing charges on the other plate by a term called ELECTROSTATIC ATTRACTION.
At the moment the charges on the plate you are touching consist of "pairs" of positive and negative charges with an equal number of each. This results in a neutral or zero volt condition.
But when the charge on the left plate increases, it pushes the opposite charges off the plate you are touching and these charges go through your body. These charges are called ELECTRICITY.
As the active line rises and falls 50 or 60 times per second, the charges pass though your body at the same rate and even though the number of charges is very small, you will feel a "tingle".
A capacitor contains two larger sheets of foil and the spacing is between the sheets is much smaller.
That's why a capacitor will give you a bigger "tingle."

Fig 6.  Stand at door
                                   to Index
A 100n capacitor will give you a 7mA "tingle."  
A 220n capacitor will KILL YOU !!
That's right. A current as low as 16mA will prove FATAL.
The "trip detectors" in your house will detect leakage as low as 15mA and "cut off" the power in 1 or 2 cycles.
These detectors are called RCD - Residual Current Device (detector) or GFI (Ground Fault Interrupter) save your life because they operate very quickly.
Without a detector you will be either thrown off the wires or "STUCK TO THEM LIKE GLUE."

Fig 7.  The 100n capacitor

                                   to Index

All our calculations are made with multiples of 100n capacitors.
This makes the calculations easy.
A 100n capacitor will pass or "produce" 7mA when connected to a bridge or 3.5mA if only a single diode is used (assuming 240v AC supply - all values are halved for 110v).
                                   to Index

Now we come to the first basic fact of a capacitor-fed power supply.
The output voltage of ALL capacitor-fed power supplies is 180v or 340v - depending on the supply voltage.
The output voltage of a capacitor-fed power supply only drops to 12v or 35v when a load is connected.
When the load is removed, the supply rises to
180v or 340v. That's another reason why they are so DANGEROUS.
                                   to Index

The simplest CAPACITOR-FED power supply requires a diode and a red LED.
These two items are called the LOAD.
The capacitor passes current in ONE DIRECTION when the mains is rising and then it passes current in the OPPOSITE DIRECTION when the mains is falling.
This is also described as the CAPACITOR CHARGING when the mains is rising and the CAPACITOR DISCHARGING when the main is falling.
Figure 1 above shows the waveform of the mains and you can see it rises 340v above ground and 340v below ground.
In fig 8, the two LOADS are on the OUTPUT of the cap-fed power supply.
When the mains is rising, the output of the power supply rises and when it is 1.7v, the red LED turns ON and the voltage does not rise any more.
This means the voltage-difference between the top of the red LED and the mains will be stored in the capacitor and the capacitor will be charged to 338v.
When the voltage of the mains falls, the output of the power supply will be NEGATIVE and when it is 0.7v NEGATIVE, the diode prevents the voltage falling. The capacitor is discharged and starts to charge in the opposite direction to 340v. It really has -340v across its terminals.  
The red LED is the LOAD in one direction and the diode is the LOAD in the other direction.

Fig 8. POWER SUPPLY using a single diode

                                   to Index

The basic half-wave capacitor-fed power supply is shown in the diagram.
Each 100n of capacitance will deliver 7mA RMS (10mA peak on each half-cycle).
In the half-wave supply, the capacitor delivers 3.5mA RMS because the current is lost in the lower diode when it discharges the capacitor.
Don't use the peak value in any calculations because this only applies for a very short portion of the cycle (or half-cycle). 


Here's a clever use of a zener diode.
A zener diode effectively BREAKS DOWN in BOTH DIRECTIONS. 
The 12v zener breaks down when the voltage on the "top" of the diode (the cathode) is 12v and it "breaks down" at 0.7v when the voltage is in the opposite direction.
The load will see a maximum of 12v and the zener will discharge the capacitor, ready for the next "positive cycle."

So, how does it work?
When a load is not connected, all the current from the capacitor will pass through the zener.
If the capacitor is 470n, this current will be 16mA.
When a load is connected, SOME of the current will be TAKEN from the zener and will flow through the LOAD.
If the resistance of the load is reduced, MORE current will flow though the LOAD and when it reaches 16mA, ALL the current from the capacitor will flow though the LOAD and NOTHING will flow though the zener.
If you reduce the LOAD . . . . this will happen:
The voltage across the LOAD will REDUCE to 11v, 10v, 9v,  . . .  BUT the current will remain at 16mA. Eventually the voltage will reduce to 1v @16mA

The "rating" of the zener diode is the milliwatt (called the WATTAGE) dissipation. This is the amount of heat it will "get rid of" without getting too hot. The heat is mainly passed through the leads to the PC board.
Most small zener diodes are 400milliwatt (mW) and the next size is 1 watt.
To work out the dissipation of the 12v zener above, the value of the capacitor is used to work out the current and the 12v is used for the voltage part of the equation.
The equation is
V x I   where V is volts and I is amps.
The circuit above is working in the milliamp range, where 1,000mA = 1 amp.
For each 100n, the circuit will deliver 3.5mA
Suppose the capacitor is 470n = 16mA
The wattage dissipation for the zener will be 12x16 = 200mW.
A 400mW zener will not get too hot.
There is a small amount of heat generated when the zener is discharging the capacitor, so we allow 210mW.


If you want to add an electrolytic across the LOAD, you will need to add a diode to prevent the electrolytic discharging on the second-half of the cycle.

                                   to Index

A diode connected to a capacitor  . . .
This circuit DOES NOT WORK. The capacitor will charge during the first cycle and produce an output.
But when the MAINS is "falling" the capacitor will not charge in the opposite direction because the diode will act like an OPEN CIRCUIT and not put any load on the capacitor.
The capacitor must be charged in one direction and then discharged in the opposite direction.
In other words it must deliver a current to the "POWER SUPPLY" (also called the LOAD) in BOTH DIRECTIONS.
In fig 9. the capacitor will remain charged from the first cycle and both sides of the capacitor will rise and fall at 50 or 60 times per second.
The capacitor must be discharged during the second part of the cycle so it can be charged again.
It is ONLY the charging and discharging process that causes current to flow.
The discharging process can also be called CHARGING IN THE OPPOSITE DIRECTION.
The capacitor must have a LOAD in BOTH DIRECTIONS.

Fig 9.
A diode connected to a capacitor WILL NOT WORK
                                   to Index

Although this circuit will work, the red LED will illuminate in one direction as the mains voltage rises but when the main voltage FALLS, the REVERSE CURRENT through the LED will destroy the crystal.   The red LED is providing a LOAD in both directions but the REVERSE direction will destroy the crystal. You need a diode to provide the LOAD in the reverse direction.

Fig 10. A LED connected to a capacitor WILL NOT WORK

                                   to Index

The other type of CAPACITOR-FED POWER SUPPLY uses a bridge. A bridge is a set of 4 diodes. You need to refer to other sections of this course to see how the 4 diodes "steer" to the incoming AC waveform to produce a series of "bumps" that are all above the 0v line.
This is called PULSATING DC or "DC with RIPPLE."

Fig 11. Cap-fed POWER SUPPLY with BRIDGE
                                   to Index
The current produced by a capacitor-fed power supply is quite small and we use the simple rule:
100n delivers 3.5mA for a single diode, and
7mA for a BRIDGE supply.
The single diode supply actually delivers 7mA for half-a-cycle to the LED and 0mA for the other half-cycle. In the second half-cycle the capacitor is delivering 7mA to the diode and this energy is wasted or "lost." That's how we get an average of 3.5mA.
The capacitor can be increased to 220n or 470n for a higher current. 
                                   to Index
The type of capacitor used in a cap-fed power supply must be a SPECIAL TYPE.
It must be rated at 400v AC and must be constructed with materials and insulation that will NOT BLOW UP.
These special types of capacitors have the identification
X2 (X2 does not mean "times two" or "use two capacitors" !! It is a special identification that the capacitor is rated for MAINS OPERATION).
Any capacitor will work, but some will short-circuit or blow-up for no apparent reason.
Because the capacitor is charging and discharging 100 or 120 times per second, there is a certain amount of stress on the foil and insulation and that's why it must be strongly constructed.
Although there is theoretically no energy lost in the capacitor, it will heat up a small amount due to losses.
The charging and discharging is classified as RIPPLE CURRENT and this current ALWAYS causes a small amount of heating. In our case, this ripple current is the MAXIMUM for the capacitor. Normally ripple current is only a fraction of the maximum as the capacitor (such as an electrolytic will be charged to a voltage and experience a slight increase and decrease in voltage and this will cause a small current to flow. But in our case the voltage is changing FULLY and also in the reverse direction and creating maximum current-flow.
                                   to Index
The capacitor-fed power supply is a CURRENT arrangement.
The output current depends on the value of the capacitor.
The output voltage will be 340v if NO LOAD is present.
                                   to Index
The capacitor-fed power supply is a CONSTANT CURRENT supply and they way you explain how the circuit works is entirely different to a normal power supply. 
                                   to Index

Here is a simple cap-fed power supply driving a red LED.

When the circuit is turned ON, we do not know if the mains voltage is zero, a small positive value or full 340v.
If it is 340v and the capacitor is not charged, a VERY HIGH current will flow to charge the capacitor  and this will damage the LED.
To limit (reduce) this current we add a 470R resistor in series with the active line (It can be in either line).

Fig 12. Adding a SAFETY RESISTOR
                                   to Index

Now here's the amazing part:
We can add more LEDs to the circuit and they will ALL glow:

Fig 13. Cap-fed POWER SUPPLY with 6 LEDs
                                   to Index
You cannot add hundreds of LEDs because as you add another LED, the voltage across the combination increases by 1.7v and when the total becomes 340v, NONE of the LEDs will illuminate. That's because there is zero volt difference between the mains voltage and the LED voltage.
                                   to Index
A single-diode design is not a good design because the LEDs are only illuminated for each half-cycle. LEDs turn ON and OFF very quickly and they will appear to "flicker." A better circuit uses  a BRIDGE.
                                   to Index
The bridge will deliver 2 pulses of energy during each cycle and this will result in 100 or 120 "flickers" each second. 
More LEDs can be added and they will ALL illuminate.
                                   to Index
To eliminate the "flicker," the output needs an electrolytic. This will store the energy during a peak and deliver it when the mains voltage is low.  See the waveform on the circuit.   The voltage remains high enough to keep the LED constantly illuminated.

Fig 15. A BRIDGE Cap-fed POWER SUPPLY with electro
                                   to Index
LEDs on 240v
You need at least 50 LEDs in each string
to prevent them being damaged via a surge through the 1k resistor - if the circuit is turned on at the peak of the waveform. As you add more LEDs to each string, the current will drop a very small amount until eventually, when you have 90 LEDs in each string, the current will be zero.
For 50 LEDs in each string, the total characteristic voltage will be 180v so that the peak voltage will be 330v - 180v = 150v. Each LED will see less than 7mA peak during the half-cycle they are illuminated. The 1k resistor will drop 7v - since the RMS current is 7mA  (7mA x 1,000 ohms = 7v). No rectifier diodes are needed. The LEDs are the "rectifiers."  Very clever. You must have LEDs in both directions to charge and discharge the capacitor. The resistor is provided to take a heavy surge current through one of the strings of LEDs if the circuit is switched on when the mains is at a peak.
                                   to Index
This clever design uses 4 diodes in a bridge to produce a fixed voltage power supply capable of supplying 35mA.
All diodes (every type of diode) are zener diodes. They all break down at a particular voltage. The fact is, a power diode breaks down at 100v or 400v and its zener characteristic is not useful.
But if we put 2 zener diodes in a bridge with two ordinary power diodes, the bridge will break-down at the voltage of the zener. This is what we have done. If we use 18v zeners, the output will be 17v4.
When the incoming voltage is positive at the top, the left zener provides 18v limit (and the other zener produces a drop of 0.6v)  This allows the right zener to pass current just like a normal diode.  The output is 17v4. The same with the other half-cycle.
The current is limited by the value of the X2 capacitors and this is 7mA for each 100n when in full-wave (as per this circuit). We have 1u capacitance. Theoretically the circuit will supply 70mA but we found it will only deliver 35mA before the output drops. The capacitors should comply with X1 or X2 class. The 10R is a safety-fuse resistor.
The problem with this power supply is the "live" nature of the negative rail. When the power supply is connected as shown, the negative rail is 0.7v above neutral. If the mains is reversed, the negative rail is 340v (peak) above neutral and this will kill you as the current will flow through the diode and be lethal. You need to touch the negative rail (or the positive rail) and any earthed device such as a toaster to get killed. The only solution is the project being powered must be totally enclosed in a box with no outputs.
                                   to Index

This circuit is the best cap-fed power supply. It uses 4 diodes to produce the best current from the 220n capacitor and an electrolytic to smooth out any flickering.
                                   to Index

Here's a circuit using two 16v zeners. 
If a16v zener is placed AFTER the bridge, you only need ONE 16v zener  !!!!
The 0.47u will deliver 33mA.
The 16v zeners will limit the voltage to 16.7v
The output of the bridge will be 16.7v -0.7v -0.7v = 15.3v
The voltage drop across R2 will be 3.3v
This will provide 12v for the 12v zener.
                                   to Index

Here is a 38 LED lamp using a capacitor-fed power supply to illuminate 38 white LEDs.
The total voltage across the LEDs is 38 x 3.6 = 138v. This means the incoming voltage is 340v - 138 = 202v.  The 334 capacitor will deliver about 20mA.
                                     to Index
The fastest way to learn electronics is to work with a faulty circuit.
The following circuits have been presented on the web from people who do NOT understand electronics. 
                                   to Index

Here is a circuit from Professor D.Mohankumar.

It has 2 mistakes.
If the load is removed from the circuit above, the output voltage will rise to 39v.   

Here's why:
The 474 capacitor will deliver 7mA for each 100n = 33mA.   The voltage across the 1k2 resistor will be:
V =
I x R = 0.033 x 1,200 = 39 volts.   The 25v electrolytic will BLOW UP.
The wattage of the 100R resistor needs to be I x R  = 0.033 x 0.033 x100 = 0.1 watt   NOT 1 WATT !!!

HOW and WHY?
We start to analyse the circuit by finding out the current delivered by the capacitor in a full-wave arrangement. (33mA)
The output voltage will rise until the load takes 33mA. This is 39v.  The output voltage cannot rise to 40v because the load will take 34mA and only 33mA is available.
This circuit is called a CONSTANT CURRENT circuit and is analysed in a completely different way to a normal circuit. That's why you have to go by our method of analysis.

But the major fault with the circuit is the output current.
At 15v, the output current will be 23mA  because 10mA will be taken by the 1k2 and LED.
At 20v, the output current will be 18mA  because 15mA will be taken by the 1k2 and LED.

                                   to Index

The 474 capacitor will deliver 33mA.
The 7812 regulator requires 8mA.  This leaves 25mA.
The voltage on the output of the bridge will rise to 30v until 25mA is taken by the 1k2 resistor. 
This will leave NOTHING for the output of the circuit.
If you draw 13mA, the voltage on the input of the regulator will drop to 14v  and the regulator will start to drop out of regulation.  
This circuit is badly designed and will NEVER deliver 50mA.
It will deliver UP TO  13mA.
That's why you have to test everything you design before making any predictions.

                                   to Index
Here's another faulty circuit.
How can you work out what is happening ?
Consider the top terminal is connected to the active and the lower terminal is connected to neutral.
The active rises to 345v and falls to minus 345v while the neutral wire does not move.
When the active rises, it charges to the 220n and delivers a current through the top 1N4004 diode.
You can consider the neutral wire to be at the same potential as the earth connection on the power supply and the second zener diode and lower 1N4004 diode are not needed.
If you like to think the active and neutral "spread apart" as the active rises, you will be able to see the neutral wire drops slightly until the 12v zener conducts and drops 0.7v across its leads.
The active now drops and the first 12v starts to conduct when the voltage is -0.7v. This allows the 220n to discharge and then charge in the opposite direction to -345v. When the active line starts to rise from its voltage of -345v, the capacitor starts to discharge and then start to charge in the positive direction.
As you can see, the second zener and lower diode can be removed from the circuit. They have no effect on the operation of the circuit.    
                                   to Index

Here's another circuit that does not work.
Each 100n will deliver 3.5mA in half-wave for 250v input. This becomes 1.75mA for 110v or 3.85mA for the circuit above.
But the 10k resistor will drop a voltage when 3.85mA is flowing.
The voltage-drop will be 0.00385 x 10,000 = 38v.
This means the 220n does not see 110v, but 72v and the current will be less than 3.85mA.
(about 3mA). 
Jose Pino says the circuit will deliver 100mA !!!!!
It will deliver 3mA or less !!!!!
                                   to Index

What is the first transistor doing ???  It is simply putting a 270 ohm load across the supply. It is assisting the 1k by providing a base current for the second transistor and current to keep the zener in conduction, but simply connecting the 270R to the base of the second transistor will do the same thing, or decreasing the 1k will provide additional current.
This circuit WILL NOT WORK.
Where is the diode to discharge the 2u2 capacitor ????
                                   to Index
The three 1u capacitors will pass 3 x 70mA = 210mA.
The voltage drop across R2 will be 0.21 x 100 = 21v. The wattage will be V x I = 21 x 0.21 = 4.4watts
The voltage drop across R4 will be 0.21 x 10 = 2.1v.
The characteristic voltage-drop across a 1 watt LED is 3.6v
The voltage needed by the 1 watt LED and R4 is 2.1 + 3.6 = 5.7v
The 4.7v zener will not allow the LED to illuminate.
The circuit is just another mess by
Professor D.Mohankumar. It is untested and DOES NOT WORK !!
                                   to Index

The bridge is around the wrong way !!!
                                   to Index

The capacitors will pass about 180mA.
The output voltage will be 340v. The 180v electrolytics will BLOW UP !
The 100R resistor will dissipate 3.2 watts.
The impedance of 2.2u and 0.47u is about 1,300 ohms. The 470R across the capacitors will pass another 60mA, making a total for the supply 240mA.  The 470R will dissipate about 1.7 watts.
                                   to Index
Very few people know anything about designing a capacitor-fed power supply.
You can see all these mistakes on the web.
The circuits above have not been tested and most of them will not work or BLOW UP !
All the components are "live." This means they are all at a potential (voltage) that can be as high as 340v.Touching any of them is the same as touching the active wire of the mains.
Almost every circuit will pass more than 15mA and this amount of current will throw you across the room or give you a nasty shock if you touch a component with one hand and touch something that is earthed with another part of your body.

When designing and testing this type of power supply I always use an isolation transformer.

You can make your own isolation transformer by connecting two identical transformers "back-to-back."
You only have to make sure the secondary voltages are the same. Such as 12v and 12v.
The mains will enter at 240v, come out at 12v and enter the second transformer to produce 240v out.
If you use a 30 watt transformer and a 10 watt transformer the output wattage will be 10 watt.
When using this type of transformer, the high voltage will be present but if you touch either output wire and a toaster, for example, you will not create a "short-circuit."
The 30 watts will still kill you but you can work on the power supply with a soldering iron and if you forget to switch it off, you will not create a short-circuit with the iron, as all the voltages are FLOATING.