• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Mcu reset when I turn on relay.

Status
Not open for further replies.

alhareth

New Member
Hi everyone.

I`am using pic16f877a to control water pump (220v/0.75hp).

When I test the circuit without connecting the pump..once the relay turned on the pic rest.

What is the problem ?
 

Pommie

Well-Known Member
Most Helpful Member
Do you have adequate decoupling capacitors?
Do you have a diode to dissipate back emf?
Do you have a bug in your program?

Could be many things.

Try giving us more information. Schematic, code etc.

Mike.
 

alhareth

New Member
Do you have adequate decoupling capacitors?
.1uf in parallel with 10uf on vss. Vdd.pins

Do you have a diode to dissipate back emf?
Yes.

Do you have a bug in your program?
The program just test program.it sends a message to serial at the beginning of code then 10 s delay . Then it will toggle the output pin when a button pressed




....................................
 
Last edited:

Nigel Goodwin

Super Moderator
Most Helpful Member
Usually poor design, either physically or electronically.

Can you post a FULL schematic, exactly as built (don't leave anything off - everything is important), and a picture of how you've built it.
 

dknguyen

Well-Known Member
Most Helpful Member
What are you powering it off of? Can you try powering the MCU off a battery and see if it still happens?

Someone else had the same problem a while ago but I don't know what became of it.

Someone suggested putting a series diode in line before your MCU decoupling capacitors (don't include the relay coil 5V) to isolate it from dips in the power supply.
 
Last edited:

alec_t

Well-Known Member
Most Helpful Member
You also didn't post a picture of how you built it, as asked.:rolleyes:
Are you using a star ground system?
 

Diver300

Well-Known Member
Most Helpful Member
As the others have said, more information is needed.

You could try a capacitor from MCLR to ground.

Does the pic reset when the relay operates if there is nothing connected to the contacts of the relay?
 

MikeMl

Well-Known Member
Most Helpful Member
We especially need to see where the wire from the emitter of the BC547 is routed. Try lifting it, and return it all the way to the negative terminal of the 5V power supply.

Where does the 5V power come from? Hopefully, not from a USB port?
 

Pommie

Well-Known Member
Most Helpful Member
Unless there is something very strange elsewhere the schematic looks fine. Can we see the code?

Mike.
 

alhareth

New Member
Hi,

Here is the code and full schematic

test.jpg

testtt.png

I used led instead of relay it worked fine.

No thing connected to relay contacts .
 

dknguyen

Well-Known Member
Most Helpful Member
Hi,

Here is the code and full schematic

View attachment 114200

View attachment 114199

I used led instead of relay it worked fine.

No thing connected to relay contacts .
Oh, this is happening even when no motor is connected to the relay? Is the reset happening when the relay CLOSES? or OPENS? What relay are you using?

Did you try powering the relay off a separate supply like I asked?

Try placing a series diode that isolates the 10uF and 0.1uF MCU capacitors from the 100uF capacitor and connect the inductor coil on the anode side of the diode (so the inductor coil can only draw current from the 100uF capacitor and cannot draw current from the 10uF and 0.1uF capacitors).

I wonder if this issue could be caused because you are not debouncing your pushbutton. Write code for that too. You can check if the lack of debouncing causing the issue by writing a main program that just waits a bit, and then raises automatically D0 on it's own (no pushbutton) and see if it still happens.
 
Last edited:

rjenkinsgb

Well-Known Member
Most Helpful Member
The 1N4007 as a flywheel diode may not be fast enough to properly limit the voltage spike from the relay coil; normal rectifiers are rather slow to turn on or off.

Try a signal diode like 1N4148 or 1N914 etc. or high-speed rectifier in place of that.
 

Diver300

Well-Known Member
Most Helpful Member
What is the relay? What is the transistor driving it?
Your hand-drawn circuit showed a 0.1 μF capacitor on each of pins 11 and 32, while the other diagram only shows one.
Does the circuit reset if you short out the transistor? Is the power supply able to run the relay?
 

audioguru

Well-Known Member
Most Helpful Member
Your bridge rectifier is shown connected backwards. It must be a drawing error because the circuit would blow up if that is how it is wired.
 

ChrisP58

Well-Known Member
Most Helpful Member
Well, other than the bridge rectifier problem that audioguru pointed out, the schematic looks OK to me. But still doesn't show HOW it's built.

A schematic assumes that all connections, particularly the multiple power and ground busses, are made with near zero resistance/impedance interconnects.

From your description of the circuit behavior, I suspect that isn't true in your implementation of the schematic. Are you by chance using a solderless breadboard?

You said that when you energize the relay, that the pic16f877a resets. I think that the current that the relay requires may be pulling the 5 Volt rail down below the point at which the f877 resets.

To prove this theory, try separating the power to the f877 from the relay as dknguyen suggested in post #15 above. Either a separate 5V source, or diode isolating the two. At the very least, make sure the relay has it's own 5V connection to C7.

Additionally, as alec_t said in post 10, check your grounding scheme. The microcontroller circuitry can share a common ground connection to C7. But the emitter of Q1 must have it's own path to C7.
 

MikeMl

Well-Known Member
Most Helpful Member
Usually, spurious resets of controllers occur when you turn off a relay; not when you first energize the relay.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top