Pages: [1]   Go Down
Author Topic: ATMega glitching while switching mains?  (Read 854 times)
0 Members and 1 Guest are viewing this topic.
Cairns, Australia
Offline Offline
Sr. Member
****
Karma: 2
Posts: 280
Arduino??
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I've built an ATMega onto a bit of PCB. I am using it as a temperature controller for a airconditioning unit. The ATMega is powered from the same mains line, but through a transformer, then a bridge rectifier, then some capacitors, then a 7805, then another cap. It is driving an LCD and a relay.

The circuit is mounted inside the airconditioners cover.

Now, the problem I am having is that most of the time when it turns the AC unit on, the microcontroller "Glitches", and the LCD just displays garbled crap until I reset the power. Then when it tries to start the unit again, glitches again. I have a reverse blocking diode on my relay, and the board is isolated from the unit. The only other things I can think of is if the compressor is temporarily depriving power from the ATMega, or I am getting EMI through a non-contact situation.

I'm not quite sure what to do about this. Larger capacitor on the PSU maybe, or maybe I need to switch the relay with an optoisolator, or somehow enclose the whole circuit in a metal box/cage.

Cheers,
Dan
« Last Edit: July 22, 2010, 01:23:06 am by Things » Logged

Sofia, Bulgaria
Offline Offline
Full Member
***
Karma: 0
Posts: 237
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe you know all about that that grumpy_mike has described in his tutorials:
about decoupling:
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html
and about power:
http://www.thebox.myzen.co.uk/Tutorial/Power.html
and
http://www.thebox.myzen.co.uk/Tutorial/Power_Examples.html
but I've found them helpful in similar situations to yours.
« Last Edit: July 22, 2010, 02:30:24 am by mircho » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33375
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am getting EMI through a non-contact situation.
That is called radiated interference and you are suffering susceptibility problems.

You can tackle this from two ends.:-
1) Reduce the source - this is the best way so that means fitting suppressors on the mains device that is causing the problem.
2) Reduce the effects - this means doing something to the arduino circuitry like extra decoupling.

Putting it in a metal box might sound like a solution but it rarely works.
Logged

Cairns, Australia
Offline Offline
Sr. Member
****
Karma: 2
Posts: 280
Arduino??
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright, I connected the relay to a different power supply, powered up the AC unit and controller, and activated the relay from the seperate power supply, and the uC didn't drop out. I only tried it once, so not a very good data set, but it seems like it's my problem.

I guess I need to look at switching the relay through an optoisolator or something.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33375
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I wouldn't have thought so because a relay provides all the isolation you are going to get. Driving a relay through an opto isolator and separate PSU is not going to do much for you.
The result of you experiment suggests it is a layout problem with your circuit.
Logged

Cairns, Australia
Offline Offline
Sr. Member
****
Karma: 2
Posts: 280
Arduino??
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

While there technically is isolation from the mains, arcing + the high surge currents in the relay right next to the coil could cause problems. Combined with the back EMF from the coil itself. I guess my first plan of attack would be to put some components on to stop junk coming back from the relay. I do have a diode on it, but it doesn't seem to do anything ...

EDIT: Just switched it on and off from the separate relay 3 times, and it didn't drop out at all. So either the relay coil is drawing a large surge current from the microcontrollers power supply, or bring interference back into the circuit.
« Last Edit: July 22, 2010, 04:33:22 am by Things » Logged

Cairns, Australia
Offline Offline
Sr. Member
****
Karma: 2
Posts: 280
Arduino??
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Damn it, doesn't look like the relay is the problem smiley-sad

The only other wire running past mains (Except for the mains wires running to the PCB) is the temperature sensor wire.

OK, there is only ONE other option .. the pulse is being picked up by the circuit itself. I'm not sure how to shield the circuit though smiley-sad
« Last Edit: July 23, 2010, 02:12:01 am by Things » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33375
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
doesn't look like the relay is the problem
Well you might not be pleased but at least it makes sense electrically.

Quote
I'm not sure how to shield the circuit though

Down to good supply decoupling and solid (in the electrical sense)  grounds. You can try screened cables on both the mains and the sensor circuitry.
Logged

NZ
Offline Offline
Sr. Member
****
Karma: 0
Posts: 390
Turtle in a hard shell
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had a similar sort of 'noise' problem when I was building an Automated Rotational Plastic Moulder for a company while doing my final year uni project. The whole lot was controlled by a microcontroller (not an AVR, but that doesnt matter).

It was controlling 2 Variable Speed Drives, pneumatic relays and the important bit - a Gas Ignitor, to produce a spark to light the flame.

Whenever the gas ignitor would start, the microcontroller would go ballastic and the LCD would turn off. The microcontroller ended up recovering from the process, however the LCD remained off until it was power cycled - which wasnt an option for this process.

We tried everything. Put in loads of decoupling caps, new power supplies, magnets around the cables to the micro, screened cables, metal boxes, and lastly an earthing spike in the ground right by the machine.
Nothing really seemed to work that well by itself, however the earth spike and screened cables seemed to have the biggest effect. With the earth spike, cables and more decoupling, the machine was usable. The LCD did still flicker when igniting, however it didnt reset.

Still not an ideal situation, however it worked for the project - and after uni I installed a PLC in its place, which had none of the issues and worked like a charm.

So that basically told me it was the circuit design, which is what Grumpt_Mike has also suggested. PLC's are obviously designed to work in noisey industrial situations. You may want to look at a better power supply circuit. Maybe one with an inductive choke in the design rather than just a regulator with caps, as that is what the PLC I used had, so maybe its a factor.

Sorry for the spiel but I just wanted to share a similar experience.
Logged

Pages: [1]   Go Up
Jump to: