Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem in relay interfacing with PIC18F252(urgent)

Status
Not open for further replies.

aasimzee

Junior Member level 1
Joined
Aug 5, 2016
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
184
hello guys!!
I urgently need your help. I am working on relay interfacing with PIC microcontroller. I am attaching a pic of the circuit i am using. CHECK my circuit and help me. My circuit worked properly one and now its not working. i think transistor is not switching. I am using BC547 AND DIODE i am using is IN4148 across realy to avoid back emf.PLZZZZZZZZZZZ see the attached pic and help so that it start working continiously. forum.PNG
 

Hi,

17V to supply the PIC? are you sure? A simple resistor is no solution to limit the voltage.
No capacitors (bulk and high speed) at VCC?

Like every switching bjt circuit it needs a limited base current. Usually this is made with a resistor in the base line.

Swtiching applications always need a proper layout / signal routing. Show us a picture of your PCB where we can see the complete current flow of the relay current.


Klaus
 

I think the '17' may refer to the temperature as it's an LM35!

Reagardless, the transistor MUST have a base resistor or either it, or the PIC output pin will be damaged.

Personally, I would drop R1 considerably, maybe to 10K and I wouldn't drive the LED from AC, even if you did add the required series resistor to it!

Brian.
 

Hi,

17V to supply the PIC? are you sure? A simple resistor is no solution to limit the voltage.
No capacitors (bulk and high speed) at VCC?

Like every switching bjt circuit it needs a limited base current. Usually this is made with a resistor in the base line.

Swtiching applications always need a proper layout / signal routing. Show us a picture of your PCB where we can see the complete current flow of the relay current.


Klaus
No its is not 17 volts. i am giving five volts this 17 is temperature sensor's value. Yeah i know for bjt we need resistor. but what should be the value of that resistor for bc547?
I Dont have pcb
 

I think the '17' may refer to the temperature as it's an LM35!

Reagardless, the transistor MUST have a base resistor or either it, or the PIC output pin will be damaged.

Personally, I would drop R1 considerably, maybe to 10K and I wouldn't drive the LED from AC, even if you did add the required series resistor to it!

Brian.

I am not using led as a load. I am using fan inplace of led and yes you are right its sensor not 17 volts, can u tell me the value of resistor meant for bjt

- - - Updated - - -

17 volts in Temperature sensor.
What should be the value of resistor used with BJT?
load i am gonna drive is dc fan.
 

It depends on how much current is needed to operate the relay but assuming it isn't a huge one, 470 Ohms is probably a good compromise.

The actual calculation is:
Voltage drop across the resistor is the PIC pin high voltage minus the B-E junction drop in the transistor (typically: VCC - 0.65V)
Current through the resistor is the transistor base current, that's the collector current divided by it's Hfe. (typically: relay current/100)
Resistor value = Rv/Ri = 4.35V/(0.1A/100) = 4350 Ohms if we assume the relay needs 100mA.

However, that value will bias the transistor to about half conduction, you want it to 'hard switch' so it behaves more like a mechanical on/off switch so the rule of thumb is to allow 10 times more base current, that drops the value to 435 Ohms. 470 Ohms is near enough!


Brian.
 

The value of R1 is so high that when the PIC tries to turn on the transistor then the supply voltage to the PIC will drop to about 0.7V and it will shut down. Get rid of R1 and add the correct resistor to the base of the transistor.
 

It depends on how much current is needed to operate the relay but assuming it isn't a huge one, 470 Ohms is probably a good compromise.

The actual calculation is:
Voltage drop across the resistor is the PIC pin high voltage minus the B-E junction drop in the transistor (typically: VCC - 0.65V)
Current through the resistor is the transistor base current, that's the collector current divided by it's Hfe. (typically: relay current/100)
Resistor value = Rv/Ri = 4.35V/(0.1A/100) = 4350 Ohms if we assume the relay needs 100mA.

However, that value will bias the transistor to about half conduction, you want it to 'hard switch' so it behaves more like a mechanical on/off switch so the rule of thumb is to allow 10 times more base current, that drops the value to 435 Ohms. 470 Ohms is near enough!


Brian.

yes you aare right and its works but with 350 ohm resistor like a proper switch. I am worried that 350ohms resistor means 12mA current to transistors base. Dont you think it will destroy transistor?

- - - Updated - - -

The value of R1 is so high that when the PIC tries to turn on the transistor then the supply voltage to the PIC will drop to about 0.7V and it will shut down. Get rid of R1 and add the correct resistor to the base of the transistor.

I will check this out. Thanks
 

Hi,

yes you aare right and its works but with 350 ohm resistor like a proper switch. I am worried that 350ohms resistor means 12mA current to transistors base. Dont you think it will destroy transistor?
Before you had no current limiting resistor... and you were not worried about destroying the bjt. (I wonder)
Now it is limited to 12 mA (Where do you have the 350R from?), but now you are worried? (I wonder even more)

IF you are worried, why don´t you look into the datasheet and check how much base current the bjt can survive?

Klaus
 

Hi,


Before you had no current limiting resistor... and you were not worried about destroying the bjt. (I wonder)
Now it is limited to 12 mA (Where do you have the 350R from?), but now you are worried? (I wonder even more)

IF you are worried, why don´t you look into the datasheet and check how much base current the bjt can survive?

Klaus

I have not used resistor in pic but practically i was using 10k resistor and relay was not working. Datasheet i dont understand it properly thats y i have asked.
 

Hi,

Which datasheet are you using for the BC547? There are differences between BC547A, BC547B and BC547C.

Also, could be worth looking at the 1N4148 specifications (maybe the simulator says it's max. continuous current and max. peak current, I don't know), different ones can carry higher or lower amounts of current.

If you prefer to ignore transistor BETA = hFE values (check differences for hFE for BC547A, B and C types in any datasheet), then the rule of thumb is to make the base current 1/10th of the required collector current, so you can divide 3.3V/xmA to find the right resistor value, assuming the PIC output is 3.3V.
 

The diode rating is almost irrelevant, it only conducts at the instant the relay turns off and it will never have more than the relay voltage across it in reverse bias mode or 0.6V in forward mode.

The BC547 is perfectly capable of handling 12mA base current but you probably don't need that much. Using a lower value resistor than I suggested will not improve performance but it will force the PIC to supply more output current than necessary.

Brian.
 

When the PIC has a 5V supply its output will go to +5V only when there is no load current. With a load current of 10mA (the base of the transistor with a series current-limiting resistor) then it might go only to +4V. Then the series base resistor is 330 ohms for 10mA.
 
The diode rating is almost irrelevant, it only conducts at the instant the relay turns off and it will never have more than the relay voltage across it in reverse bias mode or 0.6V in forward mode.

The BC547 is perfectly capable of handling 12mA base current but you probably don't need that much. Using a lower value resistor than I suggested will not improve performance but it will force the PIC to supply more output current than necessary.

Brian.

i used the resistor of 470 ohms as suggested by you but relay was changing contacts slowly. i mean slow sound was coming then i changed it to 330 and it was working like a proper switch.
PIC output current cant exceed 20mA right?
 

20mA is the limit for a single PIC pin but try to aim for less than that.

What do you mean by 'slow sound'? You should just get one click as the relay energizes and another when it turns off. If you are getting more clicks or they are delayed, it points to a different problem.

To be sure, we need to know what kind of relay you are using. It may be that a different way of driving it would work better. Can you tell us the relay part number or if you don't know it, can you measure the resistance across the coil pins (with it disconnected from the circuit!). From the resistance, measured or from the data sheet, we can see how much current it needs and from that the transistor bias current.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top