Interfacing 12V relay with AT89C51

Discussion in 'Embedded Systems and Microcontrollers' started by aamirali, Feb 9, 2014.

  1. aamirali

    Thread Starter Member

    Feb 2, 2012
    1. I have to interface 12V relay & used circuit attached.
    I have used R2=1K & R3=4.7K. Relay is operating fine but I have seen my pin gets loaded.
    When logic is +5V at AT89C51, due to loading voltage across it reduces to 1V or less.

    What should be correct values I should select.

    2. I have to connect relays to PORT0 also. Now for using port0, first I needed external 10K sip after which I will connect the circuit. Is this correct??

    Because I think this created two pull-ups across port0. One is 10K from sip & other is 4.7K(R3). Should I remove 10K sip from port0 in this case.

    3. What should be max IOH & IOL for AT89C51.
    I was reading:

    On Page 10, maximum Iol per 8 bit port is 26mA(port 0) & 15mA other ports.

    What should be Ioh per port or per pin
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
  3. aamirali

    Thread Starter Member

    Feb 2, 2012
    I am using transistor to drive relay. Circuit shown in link given by you cannot drive transistor into saturation to does not work with AT89C51.
  4. MikeML

    AAC Fanatic!

    Oct 2, 2009
    The circuit you are using didn't get posted. Try again.
  5. aamirali

    Thread Starter Member

    Feb 2, 2012
  6. MaxHeadRoom


    Jul 18, 2013
    Use a 2N7000 'Fetlington'
    No base current required!
    Last edited: Feb 10, 2014
  7. Gorgon

    AAC Fanatic!

    Aug 14, 2005
    The key to answer this is the transistor you use. The necessary base current to drive the transistor Depends on the transistors hFE, or gain, and the current needed by the relay.

    If the resistors in question is pure pullups, and the less than 1V(mayby around 0.7V) is correct, since this is the transistors Vbe.

    For port0 this is not a loading voltage, it's only the value of the external pullup over the transistors Vbe. If you manage to pull this value to 5V, you will have the Magic smoke from the transistor, destroying it, and possibly the output, if activating it at the same time.

    The resulting value of the pullup is again depending on your selected transistor. A 10k resistor in parallel will only add some 0.5mA to the load of the output driving low, or 4mA for all pins on the port, if all are low at the same time.

    Since port0 is an open drain port there is no Ioh for this port related to the MCU. All high drive is comming from the external pullup resistors. You should take car to remain inside the max Voh for the output, since overvoltage may ruin the MCU.

    For the other ports there are internal pullups, and you have to check their value before you define the external pullups on these ports. If you use all 8 pins on the ports you can only sink with less than 2mA on each, at the same time.
  8. AfdhalAtiffTan

    Active Member

    Nov 20, 2010
    Have you tried "darlington" before?