Author Topic: MCU reset when relay is on, dip in supply  (Read 6143 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
MCU reset when relay is on, dip in supply
« on: May 17, 2016, 06:12:24 am »
I have to drive ac load through relay by micro controller. Problem is MCU reset as power dips when relay is on or off.
Relay contact is 220Vac/50Hz. My circuit is follow:

1. TO power the MCU I have +5V supply from SMPS of 2A(current is more than enough).
2. There is separate isolated 12V in circuit.
3. MCU pin drive opto, which Then turn on relay by 12V which turn on/off the laid.
4. problem is there is huge dip in supply which caused MCU reset. Although I have isolated 12V & 5V supply.
I have placed a diode in series of +5V also, no effect.
Huge parallel capacitors 1000uf/470uF/10uF/0.1uF very close to MCU supply but no effect.
There is free-wheeling diode on relay & relay card is separated from MCU board, jumper wires connect two boards.

5. One thing I have noticed that there is dip only when load is connected across relay, if load is disconnected then there is no dip in supply, relay turn on/off correctly.
If I connect load across it even a zero watt bulb even then dip happens

6. I dont understand that when +5V & +12V are isolated then why there is dip in +5V supply? There is huge spike across +5V supply.
7. I haven't tried snubber across the relay load contacts, since it is ready made relay board.

What could be the problem.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: MCU reset when relay is on, dip in supply
« Reply #1 on: May 17, 2016, 06:23:00 am »
Does the chip reset when switching an unconnected relay? Try a snubber over the coil.
If the chip resets when switching off an inductive load. Try a snubber over the contact, or more preferably, the load.
 

Offline Delta

  • Super Contributor
  • ***
  • Posts: 1221
  • Country: gb
Re: MCU reset when relay is on, dip in supply
« Reply #2 on: May 17, 2016, 06:24:43 am »
Please post a schematic.

What is the load?

Try a better PSU, that one sounds a bit shit...

Run your MCU from a 7805 or similar NPN regulator, from the 12V rail of the PSU.
« Last Edit: May 17, 2016, 01:49:34 pm by Delta »
 

Offline Whales

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: au
    • Halestrom
Re: MCU reset when relay is on, dip in supply
« Reply #3 on: May 17, 2016, 07:34:05 am »
Sounds like interference.  As per Delta: please post a schematic and photos of your setup.

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: MCU reset when relay is on, dip in supply
« Reply #4 on: May 17, 2016, 08:42:11 am »
Yes, (5) does sound like EMI from the load circuit crashing the MCU.  In addition to the schematic Delta requested, we need to see closeup photos of both sides of both boards and a photo showing an overall view of the boards and all their wiring.

(6) How do you know there is a huge dip/spike on the 5V supply?   If you are using a scope, take the overall view photo with the probes connected as they were when you were measuring the 5V supply, as its likely the probe is being affected by the EMI transient - possibly due to poor choice of ground.
 

Offline mav_iqdirect

  • Contributor
  • Posts: 15
  • Country: us
Re: MCU reset when relay is on, dip in supply
« Reply #5 on: May 17, 2016, 09:42:31 am »
What micro are you using? We had almost the same behaviour with ATmega MCU wired in 220VAC schematics with relays switching large inductance load unless we tightened the RESET pin directly (no resistors) to MCU VCC. After this, the MCU worked flawlessly.
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: MCU reset when relay is on, dip in supply
« Reply #6 on: May 17, 2016, 03:10:39 pm »
It is a spike. Max voltage goes upto 25V or so & dips to -10V or so when checked on CRO. THough I have long ground probe of CRO around 30cm. Attached is the screenshot.

I will paste the schemtic also. But isolated smps +5V powered MCU drives +12V opto which then drive a relay. SMPS is 3.5A.

If I disconnect the load no spikes however even if small bulb is connected there is reset problem.

Relay are of OMRON with free-wheeling diode on it.



Problem is there is lcd(20x4) connected which start showing something giberish. Although MCU keeps on operating i.e driving outputs/input led/switch.

I have assumed that MCU reset since I see gibbberish on LCD.

 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: MCU reset when relay is on, dip in supply
« Reply #7 on: May 17, 2016, 03:37:42 pm »
Long ground leads + a scope's high input impedance results in it picking up all sorts of EMI crap that doesn't actually affect the circuit under test if its not being probed.  Try with the shortest possible ground lead (preferably a springy wire ring + leg clipped on the ground just back from the bare probe tip, directly across the MCU's decoupling cap, and the spike will probably vanish.

It sounds like the LCD may be crashing.  When you take the overall view photo, please put a ruler in the shot for scale so we can estimate how long your wires are.
 

Offline Delta

  • Super Contributor
  • ***
  • Posts: 1221
  • Country: gb
Re: MCU reset when relay is on, dip in supply
« Reply #8 on: May 17, 2016, 06:46:20 pm »
Erm, if your MCU was resetting, wouldn't your LCD initialisation code run again and the display would be back to its startup state?  Are you using a 4bit HD44780 interface?  If so, I reckon it's dropping a nybble for some reason.

What. Is. The. Load?
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: MCU reset when relay is on, dip in supply
« Reply #9 on: May 18, 2016, 09:19:35 am »
1. Attached is the ckt.
2. I had found that in actual board while making ground of +5V & +12V are shorted together.
Relay is on other board then MCU itself.
I have noticed that its not the MCU which gets reset but first a line get printed in gibberish which printed ok if load is not connected. Then everything printed on lcd is gibberish.

Load is a bulb of around 15W.
I have two ckts one uses PIC16 other uses AT89C51, both misbehaving in same way.
And problem occurs only when load is connected if load is removed & relay is turned on/off then there is no problem.
In my above post I have shown the spike in MCU supply(though CRO ground lead is large.)

 

Offline mcinque

  • Supporter
  • ****
  • Posts: 1129
  • Country: it
  • I know that I know nothing
Re: MCU reset when relay is on, dip in supply
« Reply #10 on: May 18, 2016, 11:46:58 am »
I agree with other posts saying that's a spike; is the snubber diode placed close as possible to the relay?
 

Offline klunkerbus

  • Supporter
  • ****
  • Posts: 162
  • Country: us
  • Electrical Engineer (retired early)
Re: MCU reset when relay is on, dip in supply
« Reply #11 on: May 18, 2016, 12:43:31 pm »
As Delta suggests, if you're using the 4-bit parallel interface with the LCD, the gibberish likely isn't gibberish at all. I saw that very frequently on my 3D printer.  A missed or extra strobe detected by the LCD gets the nibbles in the 8-bit ASCII character transfers messed up and you can be unintenionally asking for characters in the extended ASCII character set for that display.  What happens is the 2nd half of data for one character is combined with the first half of data for the next... Depending on the display, the extended character set has characters in another language, graphic symbols, greek symbols, etc.  It'll look like gibberish, but the display is actually doing exactly what it is being instructed to do.

On my 3D printer, I found it is easier to live with this problem than prevent it.  I added a few more places in the firmware that would reinitialize the LCD interface as a way to recover from it. 

EDIT: On my printer, an unintentional static discharge was usually how the display would get confused. I've attached an image of a sample garbled screen resulting from the nibble issue. 

« Last Edit: May 18, 2016, 09:07:57 pm by klunkerbus »
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: MCU reset when relay is on, dip in supply
« Reply #12 on: May 18, 2016, 01:31:23 pm »
If the switching of a 15 watt lightbulb causes your MCU to reset you're either running the bulb wires over the mcu board or your supply has little to none decoupling.

Show us an image of your actual setup.
 

Offline Delta

  • Super Contributor
  • ***
  • Posts: 1221
  • Country: gb
Re: MCU reset when relay is on, dip in supply
« Reply #13 on: May 18, 2016, 01:34:44 pm »
Run the LCD much slower.  Use nice wide strobe pulses.  Mate sure the strobe output is being driven low rather than being tristated.  Put a pull down on the strobe.
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: MCU reset when relay is on, dip in supply
« Reply #14 on: May 18, 2016, 04:29:54 pm »
No it seems that MCU do not reset. Only gibberish appears on lcd(20x4). All operation of mcu works ok.
Problem occur when only I turn on two relays & that too in case when load is connected across it. If load is not connected, gibberish do not appear on it.

I have done some workaround. Earlier I trun on relay & next print some data on lcd.
Now I turn on relay->1 sec delay->reinit lcd->print required data on lcd again.
It seems to be working.

But problem is this spike whu it happens even when load is 15W bulb.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: MCU reset when relay is on, dip in supply
« Reply #15 on: May 18, 2016, 04:58:07 pm »
Your schematic is incomplete - it doesn't show the LCD.  Also we have no idea of how you've wired it up.   A 15W incandescent bulb will draw a surge of close to 0.7A at switch-on from cold, which is more than enough to cause EMI problems if your wiring layout is poor.  CFL and LED lamps can be as bad depending on their inrush current limiting.
« Last Edit: May 18, 2016, 04:59:48 pm by Ian.M »
 

Offline Delta

  • Super Contributor
  • ***
  • Posts: 1221
  • Country: gb
Re: MCU reset when relay is on, dip in supply
« Reply #16 on: May 18, 2016, 05:03:52 pm »
You are really not making it easy for people to help you!

Why on earth not just post a full schematic, explain how you are driving the LCD, and photos of your setup, instead of this constant back-and-forth as people try to prise small amounts of information from you at a time?  |O
 

Offline mcinque

  • Supporter
  • ****
  • Posts: 1129
  • Country: it
  • I know that I know nothing
Re: MCU reset when relay is on, dip in supply
« Reply #17 on: May 18, 2016, 07:36:30 pm »
No it seems that MCU do not reset. Only gibberish appears on lcd(20x4). All operation of mcu works ok.
Problem occur when only I turn on two relays & that too in case when load is connected across it. If load is not connected, gibberish do not appear on it.

Knowing this I can bet it's EMI radiating because the relay contacts are arcing. I bet if you put the relay far away from the display you don't have this issue.
I had this kind of issues with a cheap, garbage LCD screen.
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: MCU reset when relay is on, dip in supply
« Reply #18 on: May 19, 2016, 04:23:26 pm »
1. Attached are the images of project.
CRO probe photo has very small ground wire on it for measurement.
All CRO photos are taken through it.
One of PIC has lcd problem which is shown.

Wire from +5V smps runs around 75cm before going to board.

2. Earlier I had left lcd(20x4), pins D0-D3 left floating. I am using lcd in 4 bit mode. But then I short them & grounded them, I saw problem even rises more & lcd hangs more.

3. Due to these spikes many times AT89C55 hangs but PIC didn't hang it keeps on operating, I have disabled PIC's BOR. But in both cases lcd shows gibberish or all black lines as in attached pics.


4. Attached is the ckt. Its not exact pin to pin. But connections are like this only.

5. Tomorrow I will try by placing a series diode after +5V then a ferrite bead & then decoupling cap of 10uF. Bith in +5V & for +12V.
Also will placed EMI filter capacitor in parallel i.e a 0.15uF cap & 1M in parallel at 220Vac input of SMPS.

Then will note the results.
 

Offline mcinque

  • Supporter
  • ****
  • Posts: 1129
  • Country: it
  • I know that I know nothing
Re: MCU reset when relay is on, dip in supply
« Reply #19 on: May 19, 2016, 07:54:31 pm »
I'm not a PIC expert, but I can't see a proper decoupling cap for the pic. And is the reset pin floating with no pullup resistor?
Anyway, that gibberish for me is caused by EMI, can you move temporarly the LCD to see if the issue persists?
 

Offline pelule

  • Frequent Contributor
  • **
  • Posts: 513
  • Country: de
  • What is business? It’s other people’s money
Re: MCU reset when relay is on, dip in supply
« Reply #20 on: May 19, 2016, 08:40:41 pm »
If a "spike" of a swithing relay generates a reset of the CPU, my first thought is, are there some open inputs (high impedance pins)?
What you did with that many unused pins.
Are all unused ports set to output (if possibel)?
Are all unused input ports tight to a GND or VDD (via reisitor)?

BR
PeLuLe
You will learn something new every single day
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: MCU reset when relay is on, dip in supply
« Reply #21 on: May 20, 2016, 04:28:08 pm »
There is no unsued IO. On all pins i have a 1K sip connected.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: MCU reset when relay is on, dip in supply
« Reply #22 on: May 20, 2016, 05:18:00 pm »
I do not see much decoupling. And I see long antenne wires.
Significantly shorten the lcd wires. Make sure it has a decoupling capacitor.

With this board, you can't improve immunity much due to the disrances. So instead add a snubber over the load to catch the load dump.
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: MCU reset when relay is on, dip in supply
« Reply #23 on: June 01, 2016, 04:06:59 am »
I will make a new power supply with isolated dc grounds & line filter & using inductor at dc dupply.
Will place it close to MCU board & will see the results.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf