Driving a relay

Started by spikey_sa January 26, 2003
Hi,

I'm new to PIC programming, and even newer to this group, I'm
using a PIC16F84A to handle a project I am doing, I've managed to get
4 inputs working, which drive 4 LED's, but now I want to use four
output to energise 4 12v relays, I'm using RB0 - RB4 as the output
pins, I am struggling a little to find info on how to trigger the
relays, the circuit I am using (poached from the Internet) triggers
the relays OK, but when the RB0 goes 'off' the relay doesn't go 'off'
(until I power off altogether)

Relay Pin 1 (Coil) <------- +12v
Relay Pin 10 (Coil) ------> Collector (BC547)
From RB0 -----> Base (BC547)
Emitter (BC547) -----> Ground( -12v)

I've got a diode across the relay pins to protect from back EMF.

Any help would be appreciated, really I'm just looking for a simple
way to 'drive' a 12v relay coil from a PIC output.

Thanks in advance

Brad Woolley



Brad,
 
Your circuit just needs a couple changes to help transistor turn off. 
(First, be sure the emitter is connected to GROUND and not to -12V as you indicated.)
 
1. Connect a 22K resistor between the base and emitter.  This will pulldown the base when the PIC output goes low and ensure that the transistor turns off.
 
2. Suggest you removed the direct connection between RB0 and the base, and connect them together with a 1K series resistor instead.  Although not absolutely necessary, this series resistor serves 2 purposes: it limits the base current under normal operation, and it helps isolate the PIC from damage should the transistor fail with the base shorted to the collector.
 
(note: resistor values are not critical.  you should be able to use anything from a 10K to 100K for the pulldown resistor)
 
 
 
 -----Original Message-----
From: spikey_sa <b...@ridge.co.za> [mailto:b...@ridge.co.za]
Sent: Sunday, January 26, 2003 9:25 AM
To: p...@yahoogroups.com
Subject: [piclist] Driving a relay

Hi,

   I'm new to PIC programming, and even newer to this group, I'm
using a PIC16F84A to handle a project I am doing, I've managed to get
4 inputs working, which drive 4 LED's, but now I want to use four
output to energise 4 12v relays, I'm using RB0 - RB4 as the output
pins, I am struggling a little to find info on how to trigger the
relays, the circuit I am using (poached from the Internet) triggers
the relays OK, but when the RB0 goes 'off' the relay doesn't go 'off'
(until I power off altogether)

Relay Pin 1 (Coil) <------- +12v
Relay Pin 10 (Coil) ------> Collector (BC547)
            From RB0 -----> Base (BC547)
     Emitter (BC547) -----> Ground( -12v)

I've got a diode across the relay pins to protect from back EMF.

  Any help would be appreciated, really I'm just looking for a simple
way to 'drive' a 12v relay coil from a PIC output.

   Thanks in advance

Brad Woolley

    


to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

">Yahoo! Terms of Service.