Running a Picaxe 18m2 off 230v

Steve2381

Senior Member
Hi all.

New project being designed here, and a small size is essential.
My question is that of powering a 5v or 12v circuit from the mains, without a transformer (my usual method). This is something I have never done before.
The project is basically a relay switch with certain advanced functions, but it will need to be supplied with simply 230v - no batteries. How do they achieve quality low voltage supplies in small commercial 230v equipment e.g smoke detectors, PIR sensors etc
I know playing with 230v is a whole new world.... but I am an electrician so I know what I am tinkering with.
 

premelec

Senior Member
You don't get isolation but capacitors can provide impedance to limit current into a bridge/zener...many caveats... particularly what if the capacitor shorts? Note that any spikes on the mains line see the capacitor as a much smaller impedance and thus pass high current pulses... at the very least put a resistance in series with the capacitor [flameproof one :)]. With all the isolated switching 80-240v plug in units which are built to standards available you'd need pretty strong reasons to NOT use one... I repaired a Chinese multiple LED light recently which had only a capacitor V drop system... they didn't even put in a series resistor. You could hack a commercial unit to feed a few ma to PICAXE - still a very dicey proposition good luck [BTW there are circuits on the Internet that show these structures - if it's not isolated it's not safe... ].
 

Dippy

Moderator
Read Microchip App Note AN954 for ideas.
Read it thoroughly, no skimping, as this could end in tears.
There are other varieties but that should get you started.
As you are an electrician I don't need to stress the hazards.
Just be aware that some of the audience here aren't electricians and might try it.
This sort of stuff is NOT for novices.

There are switcher alternatives which are more efficient but require more components.
I've done several microcontroller designs based on this but care is required.

Does this actually involve a PICAXE?
If so, will you be programming your PICAXE in-situ powered from Mains?
 

darb1972

Senior Member
I haven't looked into Mains transformers of late, but I think you might be able to get a step down transformer that is fairly low current and low voltage in an smd package (have a look at someone like element 14). A transformer will address many issues including isolation. If you have room for a relay then hopefully you can fit a small transformer.

If the relay coil current poses an issue for the transformer, look at running the picaxe and low current circuit via the transformer/bridge rectifier/cap/regulator, and use an appropriate opto coupler/triac or relay with a 230V rating. Or, better still, for the low voltage supply, again, check out the likes of element 14 for a miniature Mains rated AC/DC converter. Plenty of those on the market.
 

Svejk

Senior Member
A better approach perhaps is to use a 5V phone charger. It provides isolation and should have enough power to switch the relay.
 

inglewoodpete

Senior Member
I wouldn't purchase a mains-sourced USB supply directly from China. It is too easy for some suppliers to apply approval markings when they are not approved or safe. There have been too many stories of fires, meltdowns and electric shocks for me to take the risk. A coffin is so much more expensive than a proper, locally approved USB supply!

Having said that, I'd use a pre-loved phone charger that was bought locally and has been subject to local electrical safety approval.

Back to the original subject. I've worked with mains appliances (and built many as projects) for over 40 years. I have considered building transformerless supplies for my projects several times over the years and always decided against them. Some may call me a coward but hey: I'm still alive (at least I was last time I checked:)).
 
Last edited:

Goeytex

Senior Member
Transformerless power supplies need the utmost care and consideration. I am referring to the capacitive type shown in Figures 1 and 2 HERE . These are based upon information from Microchip AN954.

These circuits require an X rated capacitor (C1) which won't destruct under high initial surge currents. To get decent filtering at the output the filter capacitor needs to be rather large, something on the order of 2200uF. But the amount of tolerable ripple depends upon what is being powered.

The first thing that needs to be done is to determine the required DC output current. Then the values of the components can be determined based upon the formulas given in in AN954. The Daycounter site has a calculator that allows you to back in to the components via trial & error. IM0 this type of circuit, although quite common in mass production devices where every penny counts, is dangerous and unforgiving if not properly designed and tested. Power ratings of the components are critical and fusing is a must.

Here is another good link with easy to understand formulas and an example circuit based upon 230V mains.

IMO if you need more than about 50ma output consider using a more traditional design with a small transformer. The size of the class X capacitor and required filter capacitors will be so large that you won't be saving much space.

PS: I am the last person to discourage someone from doing what they request if it is within reason. So I will not discourage you in this. However I will highly encourage you to wear safety goggles when testing, in case you miscalculated something and a cap or diode decides to explode.
 
Last edited:

bluejets

Senior Member
Hi all.

New project being designed here, and a small size is essential.
My question is that of powering a 5v or 12v circuit from the mains, without a transformer (my usual method). This is something I have never done before.
The project is basically a relay switch with certain advanced functions, but it will need to be supplied with simply 230v - no batteries. How do they achieve quality low voltage supplies in small commercial 230v equipment e.g smoke detectors, PIR sensors etc
I know playing with 230v is a whole new world.... but I am an electrician so I know what I am tinkering with.
You may well be aware of what you are doing but, where will the final project end up?
If anywhere other than locked away in your test bench, it has a potential to do some innocent person harm.
Whenever I hear the words"I know what I'm doing" it sends a shiver down my spine and I am reminded of an advert that used to be on Aus TV " Norm......and I know boats".

https://www.youtube.com/watch?v=G5mas-GNJ80
 

SAborn

Senior Member
You could look into using the Viper 22A chip, i have used several in projects of different forms, and they are a magic chip, but needs to be applied in circuit to suit your application.

As per others here i wont go into details due to the lesser skilled perhaps following an example given, but do you research on the chip and decide from there, and from what its worth i purchase my Viper chips from China without a problem yet.
 

hippy

Technical Support
Staff member
I don't think direct mains powering or transformerless supplies are things to be casually indulged in and are best avoided whenever possible.

It's not just the 'how to' of doing it but needing a safe system of work while developing with the appropriate safety equipment and environment to develop in.

With getting it wrong having such potentially catastrophic and life endangering consequences it also brings a whole new meaning to having confidence that everything is right and components are as they are required to be.
 

fernando_g

Senior Member
You could look into using the Viper 22A chip, i have used several in projects of different forms, and they are a magic chip, but needs to be applied in circuit to suit your application.
SAborn, from where (or from whom) do you purchase the required transformer?

When using Vipers, or its Power Integration counterparts, I've always ended with custom parts. Is there a "catalog" item?
 

Dippy

Moderator
fernando-g; check out PI LNK30x family for non-isolated lower-power mains bucks. No custom magnetics needed, but I did add filtering.
They can produce pretty good results for low power circuits. With micros I added some post-regulation and had glitch-free perfromance over many months continuous.
I even made an isolated PIC-programmer to prevent smoke...
I looked at Vipers before but moved to PI devices.
 

Steve2381

Senior Member
Thanks all for the input. I knew there would be some raised eyebrows at this.
The Picaxe will be programmed off project and inserted into a finished PCB. Can use a 5v phone charger - unless you took it apart and used the contents.
The enclosure will simply have Live, Neutral and Earth to it.
I am not against using a small transformer, but size is an issue and I had no idea what various methods existed.
I used to be chief engineer on a Swan superyacht, and we had all manner of wonderful 230v botched foreign devices running off the two 45kw generator sets to contend with. Safety goggles went through their paces on that boat.
Further plans will be posted to keep all informed, and I will be highly precautious and careful
 

KMoffett

Senior Member
"Can['t] use a 5v phone charger - unless you took it apart and used the contents. "

I've done that on a lot of projects where I needed a small, low voltage supply inside something already powered from the line. Carefully cut open the case, and voila...a regulated, isolated, power supply. And thanks to device obsolescence, usually free in the junk drawer. Only trick is how to mount it.

Ken
 

Jeremy Harris

Senior Member
There are some nice, properly approved, isolated, switched mode power supplies that are ideal (and safe) for applications just like this. I have one running my house heating controller (which uses a Picaxe 20M2) and another that runs my home made electric car charge controller (which uses a Picaxe 08M2 to generate the command signals required).

In both cases I opted to use the Vigortronix range of tiny supplies, see here for a tiny and affordable 5V supply: http://www.rapidonline.com/electrical-power/vigortronix-vtx-214-003-105-3w-ac-dc-power-supply-single-output-5v-84-2174
 
Top