Electronic – arduino – How to use a transformer to power a 5V chip (an Atmega328)

ac-dcarduinoatmegatransformer

I am designing an Atmega328 based device which needs to be powered directly from 230V AC. I have found a transformer in my local electronics store which seems perfect, but I have never worked with transformers before.

Does this unit output 6/9/12 V DC or does it output AC which needs to be converted?

If it still needs to be converted to DC, what size/type diodes and capacitors should be used and how to get it to 5V?

Lastly, should this transformer, with its blue and black primary wires, be connected in serie or parallel to a mains supply running through my device? It is a device that connects to the mains, and then you connect another device (e.g. TV) to it, so should it connect in serie or parallel to the wires running to power the TV?

Thank you for helping out!

Best Answer

(Note that ready-made power supplies that will fit your requirements are available just about everywhere. These remove safety hazards associated with mains voltage, so they're very much recommended for a beginner.)

Here is a random linear power supply circuit:

enter image description here

Your transformer outputs AC, so you need to 1) rectify it using a diode bridge and 2) bring it down to regulated 5V using a linear regulator. The transformer should be rated for the current you need with some margin.

Output voltage of your transformer should be somewhat larger than desired voltage to take into account linear regulator dropout and diode drop, but not too large because any excess power will have to be dissipated by the regulator as heat.

Diodes should be able to withstand both forward current and reverse voltage (this is essentially guaranteed automatically for power diodes). A 1N4007 (rated for 1A) will likely fit. If not, cheap 5A diodes are available. A diode bridge is more convenient than 4 individual diodes.

The regulator (7805, LM1117-5.0 or any number of other ICs) should also be rated for the current you need. Note that a heatsink might be required.

Choice of capacitors is normally dictated by the linear regulator datasheet. There's normally some minimum value required for stability. The capacitors should be rated for voltages they're under. Note that the voltage is >5V for C1, and it's also pulsing, so make sure you provide a large margin for safety.

Note that you really want a mains switch and a fuse before the transformer (not shown in the circuit). Also note that mains can kill you, so read up on electrical safety before doing anything if you have not done so already.

Everything that is connected to mains is connected in parallel so that full mains voltage and lowest possible source impedance is available for every device.