• 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.

Urgent, relay problem, please help

Status
Not open for further replies.

chkok85_oi

New Member
I am using PIC 16F877A digital output pins to energise/deenergise 4 relays. But i wonder even i output high to only a pin connected to a relay (because i want one relay ON, all other OFF), all 4 relays will be energised all together. May i know what is the problem? urgent.. Thank you.
 

arunb

Member
1. Are you driving the relays directly from the PIC without transistors??
2. Test the hardware , make one of the pins high (remove the PIC before doing this), then see what happens?


thanks
aa
 

Sceadwian

Banned
We can't help you without a schematic, and code would help too.
 

chkok85_oi

New Member
Thanks much arunb, Gayan Soyza, and Sceadwian, i get this circuit from web PIC Controlled Relay Driver . The circuit is as attached except i replace 820R as 4700 ohm and BC141 as BD237 and my relay is 5Vdc unlike the 12V, so i supply the relays 5V. and Arunb, i do connect to transistors and code as attached and when i make one of the pins high (5V) ie without the PIC, all the 4 relays ON also as long as there is 5V supply to relays. So, i can say my relays such like not controlled by the program. Can point me a way coz i have been headache and urgent trying this all whole night and today afternoon.
 

Attachments

Sceadwian

Banned
I don't see any obvious problem, the circuit looks good, and the code looks like it waits 1 second after turn on then cycles through each relay after a 5 second wait.
Isn't
for(i=0;i<4;i++)
delay_ms(250);
Supposed to be all on one line?
 
Last edited:

Sceadwian

Banned
Try changing #byte portb=6
to #byte portb=0x06

Don't know if it'll make a difference.
Yes Gayan, it's needed, it defines the portb I/O address start as 0x06 without that the compiler doesn't know where portb is.
 

chkok85_oi

New Member
Ya, thanks everyone here. I checked the transistor polarity ad, it is not wrong, cz when i purposely reversed the polarity for all 4 transistors, the circuit didn't respond at all. What seems to be the prob? and may i ask if i connect 10 relays to the PIC, cn PIC support so many relays? Pls....
 

dknguyen

Well-Known Member
Most Helpful Member
I see nothing wrong with your circuit either. Are you at least able to turn on an off your relay with your PIC (all at once, even if you can't control them individually?) Or are they just always on, all the time if there is power?

The PIC can support as many relays as it can provide base current for the transistors for. At 6mA base current per transistor, you are at your maximum for the PIC. If you used MOSFETs you could get a lot more since MOSFET take much less control current than BJTs.
 
Last edited:
Status
Not open for further replies.

EE World Online Articles

Loading

 
Top