Help Rqd - Driving 5Volt Relay using two pins


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Exclamation Help Rqd - Driving 5Volt Relay using two pins

    Hi

    I have a 16F627A and a 5 volt relay DPST (OMRON G5V-1).

    I can drive the the relay coil (167 ohms) ok using a single pin from the Pic.

    However, the max current the I/O pin can source is 25ma, and the coil really needs 28ma. Could this burn out the PIC if left driving the relay too long?

    I was hoping that I could parallel two I/O pins to drive the coil but when I do this, the relay does not throw at all.

    Is there a problem when paralleling two Pic I/O pins together?

    J

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Yes there is a problem.

    Potentially, if they don't switch at the same time, then pin.A (which has gone High) is now feeding a high current into pin.B (which is still Low).

    Ideally you need a series Diode on each PIC pin, but that would drop between 0.6 and 0.7v.

    An alternative if you are SOURCING the Relay (ie pins go HIGH to trigger it), then OFF would be High-Impedance input, and ON would be Output High eg...

    RelayPinA var PortB.0
    RelayPinB var PortB.7

    ' Example Toggles Relay One Second ON/OFF
    ' Don't forget the Back-emf Diode across the coil
    ' otherwise you'll damage the PIC

    Loop:
    TRISB.0=1
    TRISB.7=1
    Pause 1000
    HIGH RelayPinA
    HIGH RelayPinB
    Pause 1000
    Goto Loop

    If you're SINKING the relay rather than SOURCING it, then change the two HIGH statements to LOW.

  3. #3
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Default

    Thanks Mel. I Love your work.

    J

  4. #4
    TK5EP's Avatar
    TK5EP Guest


    Did you find this post helpful? Yes | No

    Default Switch with a transistor

    I think the best you can do is to switch your relay with a transistor and keep your PIC safe.
    You would need only a cheap one + 1 resistor.


    Patrick

  5. #5
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Loop:
    TRISB.0=1
    TRISB.7=1
    Pause 1000
    HIGH RelayPinA
    HIGH RelayPinB
    Pause 1000
    Goto Loop

    The only down side to this is if you use the Port B weak pull up option. There will be a small current going through the relay constantly. Mel, would ORing the two pins at once protect from one shorting the other out for an instant, or are the diodes absolutely necessary?

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    1. Personally I'd use a Transistor.. even one of those tiny SMD Digital Transistors with integral Base Resistors... takes next to zero board space and only one component...

    2. Second choice I'd put in series Diodes on each PIC pin leg. The Relay will still pull in.

    3. Pick a Relay with a higher coil Resistance and drive from one PIC pin. If I really must drive a Relay, then (obviously your application will dictate what you use), I tend to use Reed-Relays (500R coil) directly on PICs... some even have integral back-emf Diodes built-in. Anything bigger than that - see option 1. I don't like driving Relays (or any inductive loads) off the same power-rail as the PIC's supply anyway.

    4. Only if absolutely nescessary just parallel the PIC pins. I don't like this option... not at all. During Power-up, the PIC can come up with I/O's in a random state... Sods Law (like Ohms Law but different) states that your pins will come up in the most unfortunate combination to ruin your day. But who am I not to help along disaster...

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Question ?????????????????????????????????????????????????

    Quote Originally Posted by Melanie
    RelayPinA var PortB.0
    RelayPinB var PortB.7

    ' Example Toggles Relay One Second ON/OFF
    ' Don't forget the Back-emf Diode across the coil
    ' otherwise you'll damage the PIC

    Loop:
    TRISB.0=1
    TRISB.7=1
    Pause 1000
    HIGH RelayPinA
    HIGH RelayPinB
    Pause 1000
    Goto Loop
    Hi, Mel

    May be I'm a bit asleep ...but how does that achieve toggling an output ???

    woudn'it be better to write : PORTB = PORTB ^ %10000001 , to have simultaneous toggling on B.0 and B.7 ?

    Alain, back to sleep
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Need Help
    By PVBiljon in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th May 2009, 17:04
  2. Change On Interrupt, PIC16F884
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 14th November 2008, 17:25
  3. Replies: 24
    Last Post: - 7th November 2008, 04:41
  4. Serial Relays
    By tazntex in forum General
    Replies: 3
    Last Post: - 17th May 2007, 17:42
  5. Driving a 180ma relay from PIC port
    By Michael in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 10th May 2007, 00:46

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts