Need Relay advice please

Thread Starter

Hurdy

Joined Feb 27, 2006
137
Papa I have built the circuit you provided me and I have a new problem.
When the output pin of my PIC goes HIGH and it triggers my relay, my clock resets itself. Is this because my output pin has been pulled to ground?

I have attached a copy of the datasheets for the components I am using along with a modified circuit diagram. I assumed they should all work fine for my requirements, though I have been told they are a bit overkill for what I need.

Do you think I have got a wrong component or is it a fault of the PIC?

The datasheet for the PIC says it can do Port B 100ma.

Also you should note that I put a continuity test across my two switching pins of my relay to make sure it is swithes. It switches, but sometimes it will quickly switch on and off, and every once in a while it will switch and stay switched and not switch off until I take power away from the circuit. When it stays switched it causes my 7 segments to all go off except for 1 where it goes quite silly and dim ish.
 
Originally posted by Hurdy@Mar 17 2006, 01:49 PM
Papa I have built the circuit you provided me and I have a new problem.
When the output pin of my PIC goes HIGH and it triggers my relay, my clock resets itself. Is this because my output pin has been pulled to ground?

I have attached a copy of the datasheets for the components I am using along with a modified circuit diagram. I assumed they should all work fine for my requirements, though I have been told they are a bit overkill for what I need.

Do you think I have got a wrong component or is it a fault of the PIC?

The datasheet for the PIC says it can do Port B 100ma.

Also you should note that I put a continuity test across my two switching pins of my relay to make sure it is swithes. It switches, but sometimes it will quickly switch on and off, and every once in a while it will switch and stay switched and not switch off until I take power away from the circuit. When it stays switched it causes my 7 segments to all go off except for 1 where it goes quite silly and dim ish.
[post=15073]Quoted post[/post]​
It seems to me that you maybe drawing a wee bit too much current through the relay. Try putting a resistor in the emmitter of the transistor. Something around 100ohms. You could use a pot and adjust it until you find a point the the relay reliably switches but the circuit doesn't lock up.

I personally would lose the darlington and use a 2N2222 or similar.
 

Papabravo

Joined Feb 24, 2006
13,732
Originally posted by Hurdy@Mar 16 2006, 10:49 PM
Papa I have built the circuit you provided me and I have a new problem.
When the output pin of my PIC goes HIGH and it triggers my relay, my clock resets itself. Is this because my output pin has been pulled to ground?

I have attached a copy of the datasheets for the components I am using along with a modified circuit diagram. I assumed they should all work fine for my requirements, though I have been told they are a bit overkill for what I need.

Do you think I have got a wrong component or is it a fault of the PIC?

The datasheet for the PIC says it can do Port B 100ma.

Also you should note that I put a continuity test across my two switching pins of my relay to make sure it is swithes. It switches, but sometimes it will quickly switch on and off, and every once in a while it will switch and stay switched and not switch off until I take power away from the circuit. When it stays switched it causes my 7 segments to all go off except for 1 where it goes quite silly and dim ish.
[post=15073]Quoted post[/post]​
No this is because the relay coil does not have enough DC resistance and you are effectively dragging your Vcc down. The PIC can sense this condition of the supply dropping and it puts the processor into RESET. Some relay coils are designed to work without additional DC resistance because of the way they are wound and some are not. What you need to do is figure out how much DC current is required to hold the relay on, measure the DC resistance of your coil and pick a resistor with an appropriate power rating so you get the desired current in the coil.
 

Thread Starter

Hurdy

Joined Feb 27, 2006
137
Ok back again. I have done some testing and playing around with the circuit. I threw out the transistor, resistor and diode circuit you gave me. Connected the circuit so that the + input of the relay is connected to the output of my PIC and the other side of the relay to ground.

When the output of my PIC is LOW, there is no continuity between the relay switching pins. When my PIC goes HIGH, the relay switches and I get continuity between my switching pins as I should and then when my PIC output pin falls LOW again the relay switches off as it should.

So from my testing it is something to do with the relay driver that is causing the problem. Any ideas? I would like to implement a feature that will prevent any back flow damaging the PIC.
 

Papabravo

Joined Feb 24, 2006
13,732
Originally posted by Hurdy@Mar 16 2006, 11:26 PM
Ok back again. I have done some testing and playing around with the circuit. I threw out the transistor, resistor and diode circuit you gave me. Connected the circuit so that the + input of the relay is connected to the output of my PIC and the other side of the relay to ground.

When the output of my PIC is LOW, there is no continuity between the relay switching pins. When my PIC goes HIGH, the relay switches and I get continuity between my switching pins as I should and then when my PIC output pin falls LOW again the relay switches off as it should.

So from my testing it is something to do with the relay driver that is causing the problem. Any ideas? I would like to implement a feature that will prevent any back flow damaging the PIC.
[post=15078]Quoted post[/post]​
You need to look at the DC resitance of the coil. Add a resistor in series to get the current you want. Leave the diode across the coil or the inductive kick will damage things.
 

Thread Starter

Hurdy

Joined Feb 27, 2006
137
ok i have measured the resistance of my coil and it is 125.7 ohms.
I will check the datasheet to see if it says the minimum current needed for the coil.
 

Thread Starter

Hurdy

Joined Feb 27, 2006
137
reading the datasheet it says the coil has a resistance of 125ohms like I measured. It says normal operating current is 40mA.
The output voltage of my pic pin is 5.5V. I take it just simple ohms law will work out what I need.
 

Thread Starter

Hurdy

Joined Feb 27, 2006
137
I calculate this.

V = 5.5
I = 40ma

5.5 / (40x10^-3) = 137.5 ohms

I take it I have to take away my coil resistance from this?

137.5 - 125.7 = 11.8 ohms

Is this how you do it?
 

Papabravo

Joined Feb 24, 2006
13,732
Originally posted by Hurdy@Mar 16 2006, 11:45 PM
I calculate this.

V = 5.5
I = 40ma

5.5 / (40x10^-3) = 137.5 ohms

I take it I have to take away my coil resistance from this?

137.5 - 125.7 = 11.8 ohms

Is this how you do it?
[post=15082]Quoted post[/post]​
I'm surprised the coil resitance is that high, and still collapsed your power supply
but that should do it. Now compute the power required in the resistor as
(0.040)*(0.040)*12 = 19.2 mW so no problem with even a quarter watt resistor.
The voltage drop across the resistor with the solenoid on is (.040)*12 = 0.48 volts.

I hope this works
 

Thread Starter

Hurdy

Joined Feb 27, 2006
137
The nominal power for the relay is 200mW.

Sorry Papa, what are you telling me to try?

Papa I have discarded the transistor, and resistor and all works fine.
Do you think maybe the transistor is pulling too much?

Is the transistor needed to protect the PIC, or is just the diode fine?
 

Thread Starter

Hurdy

Joined Feb 27, 2006
137
I also tried what windoze killa said but I only have a resistor as low as 150 ohms. The relay didn't switch at all though :(.
 
Originally posted by Hurdy@Mar 17 2006, 03:28 PM
I also tried what windoze killa said but I only have a resistor as low as 150 ohms. The relay didn't switch at all though :(.
[post=15086]Quoted post[/post]​
Sorry about that. The 100ohms was a starting point to work down from. If you try something around 18 to 33 ohms between the relay and supply it should work fine. Obviously if 150 is the smallest you have you will have to buy something.

I also think having the transistor (not darlington) in the cct would be a better option. And yes the transistor you had may have been dragging the supply down. he forward voltage Vce of a saturated darlington is about .2V which equates to a pretty low resistance. This maybe the problem. This is why we are suggesting to put a resistor in series.

The reason it is working just with the PIC is probably because the internal resistance of the PIC when it is switching the relay on is about right for the relay to operate correctly.
 

Thread Starter

Hurdy

Joined Feb 27, 2006
137
So windoze are you suggesting I scrap the 1K resistor I have connected between my PIC output pin and the base of the transistor? and put a resistor in series with my supply and relay?
 

Thread Starter

Hurdy

Joined Feb 27, 2006
137
Ok I bought a pot and done what windoze said. It works! I need a resistor around 70 ohms at my emitter. Thank you both ever so much for your assistance.

Do I still need the 1K resistor in series with my PIC output pin and my transistor Base?
 

Papabravo

Joined Feb 24, 2006
13,732
Originally posted by Hurdy@Mar 16 2006, 11:45 PM
I calculate this.

V = 5.5
I = 40ma

5.5 / (40x10^-3) = 137.5 ohms

I take it I have to take away my coil resistance from this?

137.5 - 125.7 = 11.8 ohms

Is this how you do it?
[post=15082]Quoted post[/post]​
Yes, I think that should work. You also might want to double check the diode polarity. The cathode should be connected to the supply, and the anode to the collector of the transistor. When the transistor turns off, the diode should absorb the energy from the coil and prevent it from going more than 0.7V above the supply. If your supply is 5.5V then this inductive kick should be limited to 6.2V

With respect to the base resistor. If the PIC port pin is at 5.5 volts and the pin can supply at least 1 mA of current, then the resistor should drop (5.5 - 0.7) Volts with 1 mA of current. This means the resistor should be about 4.8 KOhms. If the transistor has a DC beta of at least 40, then 1 mA of base current will control 40 ma of collector current.

If you make the resistor smaller, or the beta of the transistor exceeds 40, then more current into the base and the transistor will be driven harder into saturation. However, the external circuit has a load of 137.5 ohms which will limit the collector current to the 40 mA.

Hope this helps
Good Luck
 

Papabravo

Joined Feb 24, 2006
13,732
Originally posted by Hurdy@Mar 17 2006, 12:11 AM
The nominal power for the relay is 200mW.

Sorry Papa, what are you telling me to try?

Papa I have discarded the transistor, and resistor and all works fine.
Do you think maybe the transistor is pulling too much?

Is the transistor needed to protect the PIC, or is just the diode fine?
[post=15085]Quoted post[/post]​
I was trying to tell you that the 12 ohm resistor in series with the relay coil will dissipate 19.2 milliwatts when 40 mA flows through it.

The following bit of doggerel may amuse and entertain.

Twinkle, Twinkle, little star
Power's equal I squared R


A quarter watt (250 milliwatt) resistor will easily dissipate this amount of power.

In many circuit designs it is a common practice to calculate power dissipation for resistors and IC's that are likely to get hot. Some enlightened management types make you do it for all resistors: even 10K pullups in 5 Volt logic designs.
 

Gorgon

Joined Aug 14, 2005
113
Hi Hurdy,
You don't need any extra resistors in the circuit, but you should use a transistor to boost the output from your micro, a PIC is only rated for 25mA(and this at a much lower output voltage than 5V). Check that your relay is not internally protected with a diode. If you connect this wrong you will short the 5v when activating the output device. This may be the reason that you shorted the 5v with your first attempt with a transistor. Keep the + and - side as when it worked with the micro direct.

Note that 40mA and 125ohms is 5V dropped.

TOK ;)
 
Top