Author Topic: Powering Atmel AVR off mains [laminator controller project]  (Read 20805 times)

0 Members and 1 Guest are viewing this topic.

Offline cprobertson1Topic starter

  • Frequent Contributor
  • **
  • Posts: 358
  • Country: scotland
  • 2M0XTS / MM6XKC
Powering Atmel AVR off mains [laminator controller project]
« on: September 09, 2014, 05:28:19 pm »
So I've finally got round to etching my own PCBs - and decided to streamline the process a little bit when it comes to passing the board through my Laminator by controlling the motor for the rollers (AVR > Optocoupler > TRIAC) but ran into a problem.

When I tore down the laminator I discovered, much to my chagrin, that the motor runs at mains voltage taken straight from the plug! Not even a board inside it to mod...

Oh well - just means I need a bigger Triac? Well... yes and no - I also need to power the AVR that's running the whole shebang! (actually, I could probably use an NE555 to do the same thing but hey-ho - that won't be as easy to adjust ;))

So what *is* the best way to power my board when all I have is 230V mains AC? Any ideas? This gent here has done something similar - but I can't see how he's getting the power to his PIC - I assume he's not throwing mains voltage to it but I can't see anything by way of voltage rectification or transformers!
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #1 on: September 09, 2014, 05:34:58 pm »
nothing stopping you using mains dropping resistors with single rectifier diode into a zener with a cap in parallel. Not the most isolated method though. I'm currently fixing some hair straighteners that work in this way, for some unearthly instead of using a comparator they used a pic and even relabeled it.
 

Offline cprobertson1Topic starter

  • Frequent Contributor
  • **
  • Posts: 358
  • Country: scotland
  • 2M0XTS / MM6XKC
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #2 on: September 09, 2014, 06:22:55 pm »
Quote
for some unearthly instead of using a comparator they used a pic and even relabeled it.
What in the name of... weird - I would have thought that overkill for straighteners :O Then again, I suppose if you want precise temp control it might be the best option...possibly...

Quote
not the most isolated method though.
I'm not **too** worried about formally isolating it - it will all be inside the plastic casing - if I accidentally blow the arse out of it I have a coffee jar full of ATTiny13s (it's a long and boring story - grabbed them from the uni - they were going to throw them out!)

I've not dealt much with AC I'm afraid - let alone mains! (it scares me)

ANYWAY - so just to confirm: big resistor to drop the AC voltage down to the target voltage range of the AVR > high voltage diode to take out half the wave from the AC > zener+cap [parallel] to smooth out the remainder?

What's the name of this method of dropping the voltage btw? Actually... come to think of it... which equations would I use to calculate the size of the dropper resistor (is it simply Ohms law for the voltage drop at the target current > calculate power using P=I^2.R?) (that works out at... 1.125k ohms and 45W for the resistor I think? (assuming 0.2A for the AVR + triac trigger current so I'm probably overestimating it - but that seems kinda high -taking we're talking about alum clad resistor-sort of level here?)
« Last Edit: September 09, 2014, 06:24:49 pm by cprobertson1 »
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #3 on: September 09, 2014, 06:28:21 pm »
Better scared and cautious of the mains than cocky and dead. It took me 3 months to look at a work colleagues hair straighteners because I never had time to sit down and do it properly and calmly having cleared space.

200mA, are you joking ? for that you need a plug pack. You AVR won't need more than 5-10mA i don't know how much drive the triac needs.

Yes ohms law for the resistor value, my comment on isolation was more about yours and others safety in what sounds like may be a bodge.

Make sure that the "-" side is true main neutral and you have a chance of surviving if something goes wrong.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #4 on: September 09, 2014, 06:30:45 pm »
Quote
for some unearthly instead of using a comparator they used a pic and even relabeled it.
What in the name of... weird - I would have thought that overkill for straighteners :O Then again, I suppose if you want precise temp control it might be the best option...possibly...

Not that I'm an expert but I don't think so, the ADC or internal ref will have 1023 steps thats 4.88mV at 5V supply of resolution, offset errors on comparators are 2mV or less, it would mean though that different models could be reprogrammed etc but really I never saw why. Probably someone didn't know how to use a comparator.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16284
  • Country: za
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #5 on: September 09, 2014, 06:40:25 pm »
Resistive power supply or even a 220n 400VAC class X2 capacitor, a diode, a 12V zener diode and a 470uF 25V capacitor then you will have a non isolated power supply for the PIC. Tip is to drive the triac in quadrant 4, with the common of the power supply being the one mains rail and the whole MCU having a -12V circuit with a 7905 regulator to drive the MCU, with a 2N2222 to the -5V rail driving the triac via a 220R resistor, with a 1k resistor holding it in the off state when desired. Most speed controllers use this method.

http://www.mouser.com/catalog/specsheets/stevalill004v1.pdf

This illustrates the whole idea, look on p9 for the circuit.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16284
  • Country: za
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #6 on: September 09, 2014, 06:41:22 pm »
Quote
for some unearthly instead of using a comparator they used a pic and even relabeled it.
What in the name of... weird - I would have thought that overkill for straighteners :O Then again, I suppose if you want precise temp control it might be the best option...possibly...

Not that I'm an expert but I don't think so, the ADC or internal ref will have 1023 steps thats 4.88mV at 5V supply of resolution, offset errors on comparators are 2mV or less, it would mean though that different models could be reprogrammed etc but really I never saw why. Probably someone didn't know how to use a comparator.

GHD right..............

Televisionmagforum has a whole series of videos on fixing them on YT.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #7 on: September 09, 2014, 06:48:49 pm »
yea the most common fault is one of the main mains dropper resistors fail.........
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16284
  • Country: za
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #8 on: September 09, 2014, 06:53:22 pm »
No, most common is you were sold a fake one...........

Then again here a genuine GHD is darn expensive, and even there you are not sure unless you buy from the authorised agents. Fonk kong mall ones are dirt cheap, and I simply aim them at the round file when I get asked if I can fix it.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #9 on: September 09, 2014, 06:55:28 pm »
Well my colleague assures me they are original and to be honest I was impressed with how well made they are, I mean they even screwed down the heater wires to the PCB rather than just solder them.
 

Offline cprobertson1Topic starter

  • Frequent Contributor
  • **
  • Posts: 358
  • Country: scotland
  • 2M0XTS / MM6XKC
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #10 on: September 09, 2014, 06:59:32 pm »
Quote
200mA, are you joking ?

Ha! Sorry, meant to be 0.2mA not 0.2A! haha - lol sorry, ATTiny13 runs at 240 microAmps at 1MHz and I'm running it at 0.1MHz which is about 0.13-0.15mA according to the datasheet. 50mA for the gate trigger on the triacs I have handy though - might need to see about finding a lower power version. Again, since I'll be buying parts in it's not a problem xD

Quote
Better scared and cautious of the mains than cocky and dead.
Very true! ;)

I'm considering just powering it from a battery and hacking a battery slot on the top of the casing. BUT then again I wouldn't actually learn anything from doing that ;)



Quote
Resistive power supply ... resistor holding it in the off state when desired. Most speed controllers use this method.
Thanks SeanB! Will look into that soon!
 

Offline wraper

  • Supporter
  • ****
  • Posts: 16864
  • Country: lv
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #11 on: September 09, 2014, 07:09:18 pm »
You don't need much average current to drive triac. You can open it with short pulses and it will stay open until mains voltage becomes zero again. Either sense mains or just do multiple short pulses. So All the thing will consume a small current, you only need a big enough capacitor to supply current during those pulses.
 

Offline mrkev

  • Regular Contributor
  • *
  • Posts: 225
  • Country: cz
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #12 on: September 09, 2014, 07:28:31 pm »
The problem with powering your circuit from uninsulated mains is the uninsulated mains... If someone swap the neutral with the live, the circuit will work, but you'll get the live potencial at your gnd... So use this only if you can insulate WHOLE device completely.
Other thing is that cap is usually better than resistor (they are often used together). There is gonna be voltage drop, but as the voltage on cap is not in phase with the current, it won't get hot. This method is OK, if your current is below few mA (IMHO that is enough for you), making voltage drop on resistor about 50V and another 200V on cap; so you shouldn't need more than 2W resistor... Somethimes (especially cheap chineese circuits) use something like 0.5W or 1W resitori nstead of fuse...
 

Offline kingofkya

  • Regular Contributor
  • *
  • Posts: 143
  • Country: us
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #13 on: September 09, 2014, 08:28:57 pm »
You might want to check this part out. Just follow the app notes in the datasheet.
http://www.mouser.com/ds/2/149/FSAR001B-112572.pdf

You can do the same thing with transistors and passives but you have to pay attention to how your biasing transistors.As well as capacitor droppers. Here is a few of my experiences if that helps. http://hackaday.io/project/1092/logs


 

Offline eneuro

  • Super Contributor
  • ***
  • Posts: 1528
  • Country: 00
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #14 on: September 09, 2014, 09:29:33 pm »
50mA for the gate trigger on the triacs I have handy though - might need to see about finding a lower power version.
Rather consider using zero-cross optoisolated triac driver MOC3043 with LED trigger current 5mAmax  in the case of 3043 version while 3041 has 15mAmax and 3042 10mAmax ;)
I used to add NPN transistor on AVR output pin and @ 5V MCU power supply 330R resistor in series with MOC3041 input LED, so while it is abput 1.2Vf on this diode we get about 11mA current and there were no problems even with MOC3041 to drive BTA16 triacks, while MCU pin with 4.7k resistor makes very small switching current in AVR.
Those values 15mAmax, 10mAmax, 5mAmax are maximum triger currents and it looks like they are switched at much lower currents, but I used to limit this current to about 10mA and do not care which version of MOC304X I put into circuit it works  8)

« Last Edit: September 09, 2014, 09:31:41 pm by eneuro »
12oV4dWZCAia7vXBzQzBF9wAt1U3JWZkpk
“Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I have really worked, is mine”  - Nikola Tesla
-||-|-
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8275
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #15 on: September 10, 2014, 02:58:58 am »
The input clamp diodes on PICs are sufficiently well-spec'd that they could probably be used both for powering it and as a triac trigger at the same time:
http://ww1.microchip.com/downloads/en/AppNotes/00521c.pdf
http://ww1.microchip.com/downloads/en/AppNotes/00954A.pdf

Since the motor is unlikely to operate at the low current consumed by the MCU, you could arrange it so that the voltage across the triac powers the rest of the circuit through a capacitive/resistive dropper when it's off, and when the triac is on, a low-value resistor provides the necessary voltage.

I'll also echo the remarks about these simple direct-mains-powered circuits being non-isolated, and thus you should exercise caution and isolate any user-accessible parts.
 

Offline cprobertson1Topic starter

  • Frequent Contributor
  • **
  • Posts: 358
  • Country: scotland
  • 2M0XTS / MM6XKC
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #16 on: September 10, 2014, 09:16:50 am »
Quote
I'll also echo the remarks about these simple direct-mains-powered circuits being non-isolated, and thus you should exercise caution and isolate any user-accessible parts
Whole laminator has a plastic outer casing: there's an aluminimium bar inside it going across the rollers, if it went live it could in theory transmit to any copper clad board going through it but it has mains going to power resistors on it for the heating anyway. I'll test it with the casing on at any rate ;)

Quote
The input clamp diodes on PICs are sufficiently well-spec'd that they could probably be used both for powering it and as a triac trigger at the same time
Mind I'm using an AVR ATTiny13 ;) I trust them about as far as I can throw them. Which to be fair is about 30 meters so that's not as bad as it sounds.

Quote
eneuro, kingofkya, amyk
will check your links tonight - at work just now and the firewall is blocking them xD


Most importantly, what is the best way to probe the circuit with my multimeter while keeping myself at arms length? I dont have crocodile leads rated to 250V which basically leaves me with my standard Fluke TL71 probes - do I just have to bite the bullet and get in there manually? Ideally I shouldn't have to touch the 230V coming off mains, but at the same time what if I wire it wrong - better safe than sorry! (And better sorry than dead - at least in most circumstances)


Thank you all for your help by the way! I'll get a few circuit diagrams up tonight for "approval" xD
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #17 on: September 10, 2014, 09:30:33 am »
power anything under test from an RCD!
 

Offline cprobertson1Topic starter

  • Frequent Contributor
  • **
  • Posts: 358
  • Country: scotland
  • 2M0XTS / MM6XKC
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #18 on: September 10, 2014, 10:33:41 am »
Quote
power anything under test from an RCD!
Very good shout! Will do!

Im considering just making the timing device (with the AVR) battery powered in order to keep away from the mains entirely: I can trigger the motor with a TRIAC or a relay while keeping myself more or less well away from the mains. Will also make it a bit more modular so I can modify it in future as required. In terms of safety this is probably the best option - at least until I know more about AC and mains power.

--edit--
IF I do go battery-powered I'll still post a proposed schematic for the circuit as if it were running from the mains - might as well turn it into a learning experience and get some feedback on it and advice on how to improve it!
« Last Edit: September 10, 2014, 10:37:10 am by cprobertson1 »
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #19 on: September 10, 2014, 11:06:19 am »
You will still need a common connection for the mains and still won't be isolated unless you use an optocoupler if that can be done. A relay is a good idea, if it's low speed switching like every few seconds it will be fine
 

Offline cprobertson1Topic starter

  • Frequent Contributor
  • **
  • Posts: 358
  • Country: scotland
  • 2M0XTS / MM6XKC
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #20 on: September 10, 2014, 11:24:16 am »
Probably going to be switching on for [1/10 to 1/2 seconds, off for 10 seconds]: i.e fairly slow.

Quote
You will still need a common connection for the mains and still won't be isolated unless you use an optocoupler if that can be done.
l be using an optocoupler/TRIAC sorry - meant to say earlier xD. Was just going to feed a wire down through the case from the IC (the signal line should be low voltage DC) and have all the high voltage stuff like the relay or optocoupler/TRIAC inside)

I think I actually have a couple of high voltage relays salvaged from my old boiler lying around - think they were made my Omron and can take up to 400V or 10A so that's well within limits.

How isolated are relays? i.e is there a risk I'd end up with mains going through to the signal wires from the microcontroller? I'm pretty sure there's a partition inside these ones separating the coil from the switching elements - can't remember, I have touched them like once since I got them.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #21 on: September 10, 2014, 11:27:03 am »
Isolation on relays is generally many hundreds if not a few thousands of volts, check yours out. Yes you could use relays it's not the most efficient but possibly simpler for you right now.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #22 on: September 10, 2014, 12:14:07 pm »
Omron G5L relays (contacts 10A/250V) are good for 2 kV @50/60Hz for up to 1 min, impulse 4.5kV isolation.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #23 on: September 10, 2014, 12:38:01 pm »
But don't forget that relays require way more current to turn on than a TRIAC or optotriac. You're never going to drive a relay using a linear regulator off mains. If you want isolation, use an optotriac, these are very easy to use, just follow the example diagrams on the optotriac datasheets.
 

Offline PepeK

  • Regular Contributor
  • *
  • Posts: 62
  • Country: sk
Re: Powering Atmel AVR off mains [laminator controller project]
« Reply #24 on: September 10, 2014, 12:43:10 pm »
Buy the smallest 1 - 2 VA transformer from 230 or 120 V to 6 or 9V and create a circuit : rectifier, filtering capacitor, 7805 stabilizer. Non isolated mains are really dangerous, imagine one day you decide to flash a new program via ISP connector and your computer will connected through ISP cable to mains ...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf