powering micro controller and circuit through ac mains

I am planning to build a pcb to power the arduino directly from mains, along with other components of the circuit.
the block diagram represents what i am thinking of making.

rectifier will be step down transformer + bridge + rc filter
5 v reg - for supply to barebones arduino.
10v reg - for the dimming circuit. to provide variable 0-10 volts using arduino pwm.

is this a decent/good way of going about it ?
if not, any suggestions ?
also any improvements ?

Your proposal is sound in general if short on detail.

Don't forget about fuses.
Test as you go, get everything as you go along.

what details should i have mentioned pancake ?
where would you suggest fuses ?

fuzail:
what details should i have mentioned pancake ?

Component choices, a schematic.
You provided a rough diagram of which I did roughly "approve".

fuzail:
where would you suggest fuses ?

I would have one fuse for the transformer (primary) and another for the SSR (input), to have a better idea of "What just happened?" should anything go sideways as you proceed.

I'm not sure what to say about a block labelled "Dimmer".
I don't know how, or how well, a "dimmer", a "ballast", a "CFL light", and PWM will get along.

The power supply is one matter and the CFL-etc. circuit is another and I anticipate this subject going in many directions as a result.

aah my bad.

well the dimmer is going to be a 0-10v dc output. which is controlled by pwm using a transistor.
the ballast is supposed to take an input from 0-10v dc and based on the value dim the cfl light.

i was actually thinking of using a mechanical relay, instead of SSR .
i have actually not made a schematic as of yet. wanted to get feed back before i started working on the schematic. will post it here shortly.
then we can discuss further.

IMG_1690.JPG

Ok i have attached the schematic and pcb layout. please be kind, this is the first one i am trying by myself.
few changes,
i now have 3 regulators.
a 10v - i couldnt find one in eagle so i just placed a 12v there as a place holder of sorts
a 5v - for the micro controller.
a 3.3v - this is needed for the rf module.

transformer i am thinking of using a 230/6-0-6 - 2A
i figure ill take 6 volts across the 6 and center for the 5 and 3.3v regulator through a bridge.
and 12 volts for the 10v regulator through another bridge

the x3 screw terminal is for the 0-10v output that goes into a dimmer.
the x4 scew terminal is for the ac input.
x1 is for the 3 terminals of the relay. (n/c, c, n/o)

i am unsure of the capacitor values, if you suggest those, it would be great.
also, if you could suggest why i should use those, i would really appreciate it. helps me learn practically.

now another issue you will probably notice is the thickness of the tracks on the pcb, i have not altered them yet because i am unsure of how thick the wires should be.
i know that those tracks carrying more current should be thicker, but i don't know how to translate that into figures.
is it like 1A = 1mm or something along those lines ?

overall im pretty sure i made some mistakes, but i suppose that is the only way to learn.
i have done some work in college, with my professors on pcbs, but that was always under a watch full eye and never with such circuits.
i know this might seem ambitious, but that i suppose would be the best way to learn.

so please point out
any mistakes
any improvements
any general guidelines to follow.
etc.. etc

You cannot run two full-wave rectifiers from the same secondary winding like that - they each need a separate winding.

You don't have enough separation on the board between high voltage and low voltage parts - minimum of 10mm would
be a good starting point. (I'm assuming the relay contacts are high voltage).

Also I see no 0.1uF decoupling capacitors on the ATmega, and is there a ground plane for the logic area of the board?
Supply traces should to be thicker than signal traces, and the traces running to a fuse need to be able to carry more
current than the fuse!

Also AREF should not be connected to AVCC, it should just have a ~ 0.1uF capacitor to ground on it.

All the supply connections to the chip should meet underneath it, not run round the edges of the board, (ditto ground) and
both supply pins take 0.1uF ceramic decoupling caps right next to the relevant pin.

thanks for the details mark,

You cannot run two full-wave rectifiers from the same secondary winding like that - they each need a separate winding.

oh i see. so i would need 2 different transformers ?

You don't have enough separation on the board between high voltage and low voltage parts - minimum of 10mm would
be a good starting point. (I'm assuming the relay contacts are high voltage).

alright, i will look into that.

Also I see no 0.1uF decoupling capacitors on the ATmega,

i haven't needed to use them on a bread board circuit. so never thought to use it. where are you suggesting the use of the decoupling capacitors ?

and is there a ground plane for the logic area of the board?

sorry, i dont quite understand what that means.

Supply traces should to be thicker than signal traces, and the traces running to a fuse need to be able to carry more
current than the fuse!

yeah i realize that, but what size would you suggest per amp ? so i can have a better idea.

Also AREF should not be connected to AVCC, it should just have a ~ 0.1uF capacitor to ground on it.

alright , will make the changes.

All the supply connections to the chip should meet underneath it, not run round the edges of the board, (ditto ground)

hmm, alright, ill make those changes as well.

both supply pins take 0.1uF ceramic decoupling caps right next to the relevant pin.

you are talking about the caps across the regulators right ?

There are "Trace Width Calculators" available online (with quick Google search) that will tell you minimum trace widths to be used based on Voltage, Current, etc....

Also, if you haven't already, maybe download Eagle files for the Arduino board & a few power supply/regulator designs and study them. This can be invaluable in learning how to place & connect components on your own PCB. Arduino designs are downloadable from the product pages on Arduino.cc. Most popular online "hobby stores" (i.e. Sparkfun, Adafruit) will have Eagle files available for many of the PCBs they sell.

Great design, just like art & music, often involves a certain amount of "sampling" from others' creations. :roll_eyes:

I'm thinking on a similar thing myself, so this is timely for me. I have some questions too. These come from a position of little knowledge, so they're probably questions for the knowledgable, more than answers for fuzail :slight_smile:

  1. Why two rectifiers? Why not have just one rectifier providing 12V, and drive all the regulators from it? 3v regulators that can cope with 15V input are not hard to find. Would it be bad to drive regulators in parallel like this?

  2. Aren't the post-rectifier ripple filter capacitors of a really low value for the task? Perhaps naively, using 'delta-V = I / f.C' with a 100mA draw and a 100Hz f (from a rectified 50Hz mains supply) suggests to me that it will leave a 2V ripple. With 1A it'd be 21V (obviously too bug for a 12V supply).

things,
i have been looking around and yes it seem like cascading all the 3 with good heat sink on the first one would be best. i am going to try that.

the capacitor post rectifier is indeed low, and i just put that value looking at a few designs on the internet (they were probably for a very low current). i now understand that i would have to calculate it according to my needs.

ok re-did the schematic and the board.
i still have to work on some of the track widths. but other than than any other suggestions ? errors ? etc ?

Take a look at on-board regulators like these Recom ACmains/DC modules.
http://www.mouser.com/Power/Power-Supplies/Linear-and-Switching-Power-Supplies/_/N-axgkh?P=1z0wbce&Keyword=recom&FS=True&Ns=Pricing|0
This might be a lot simpler way for you to go vs dealing with transformers and rectifiers and all that, which is getting to be pretty old school.

those are very nice cross roads, thanks for the suggestion.
they are rather pricey though.
also im pretty sure acquiring them in india is going to be a very big ordeal.

You should update your profile so folks know you are for better source suggestions.
So India, you are working from 240VAC mains?

yes we running 220v ac mains here.
will update my profile to reflect location.

I would start with a 220vac to 5vdc switching power supply module. You can get these inexpensively via ebay although the quality may or may not be very good. If the 10v supply is only needed to provide the control input for a dimmer, then it needs to supply very little current and you can derive it from the 5v supply using a charge pump ic.