MCU reset when relay is on, dip in supply - Page 1
Forum section: electronics / beginners

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: May 17, 2016, 06:12:24 am
content: 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 happens6. 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.

author: Jeroen3
author_rank: Super Contributor
timestamp: May 17, 2016, 06:23:00 am
content: 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.

author: Delta
author_rank: Super Contributor
timestamp: May 17, 2016, 06:24:43 am
content: 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.

author: Whales
author_rank: Super Contributor
timestamp: May 17, 2016, 07:34:05 am
content: Sounds like interference. As per Delta: please post a schematic and photos of your setup.

author: Ian.M
author_rank: Super Contributor
timestamp: May 17, 2016, 08:42:11 am
content: 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.

author: mav_iqdirect
author_rank: Contributor
timestamp: May 17, 2016, 09:42:31 am
content: 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.

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: May 17, 2016, 03:10:39 pm
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: May 17, 2016, 03:37:42 pm
content: 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.

author: Delta
author_rank: Super Contributor
timestamp: May 17, 2016, 06:46:20 pm
content: 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?

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: May 18, 2016, 09:19:35 am
content: 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.)

author: mcinque
author_rank: Unknown
timestamp: May 18, 2016, 11:46:58 am
content: I agree with other posts saying that's a spike; is the snubber diode placed close as possible to the relay?

author: klunkerbus
author_rank: Unknown
timestamp: May 18, 2016, 12:43:31 pm
content: 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.

author: Jeroen3
author_rank: Super Contributor
timestamp: May 18, 2016, 01:31:23 pm
content: 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.

author: Delta
author_rank: Super Contributor
timestamp: May 18, 2016, 01:34:44 pm
content: 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.

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: May 18, 2016, 04:29:54 pm
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: May 18, 2016, 04:58:07 pm
content: 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.

author: Delta
author_rank: Super Contributor
timestamp: May 18, 2016, 05:03:52 pm
content: You are really not making it easy for people to help you!Why on earth not just post afullschematic, 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?

author: mcinque
author_rank: Unknown
timestamp: May 18, 2016, 07:36:30 pm
content: Quote from: Vindhyachal.takniki on May 18, 2016, 04:29:54 pmKnowing 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.

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: May 19, 2016, 04:23:26 pm
content: 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.

author: mcinque
author_rank: Unknown
timestamp: May 19, 2016, 07:54:31 pm
content: 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?

author: pelule
author_rank: Frequent Contributor
timestamp: May 19, 2016, 08:40:41 pm
content: 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)?BRPeLuLe

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: May 20, 2016, 04:28:08 pm
content: There is no unsued IO. On all pins i have a 1K sip connected.

author: Jeroen3
author_rank: Super Contributor
timestamp: May 20, 2016, 05:18:00 pm
content: 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.

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: June 01, 2016, 04:06:59 am
content: 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.