output interfacing device

Output Interfacing Circuits

As we saw in the previous input interfacing tutorial, an interface circuit allows one type of circuit to be connected to another type of circuit that may be of a different voltage or current rating.

But as well as interfacing input devices such as switches and sensors we can also interface output devices such as relays, magnetic solenoids and lights. Then interfacing output devices to electronic circuits is known commonly as: Output Interfacing.

Output Interfacing of Electronic circuits and micro-controllers allows them to control the real world by making things move for example, the motors or arms of robots, etc. But output interfacing circuits can also be used to switch things ON or OFF, such as indicators or lights. Then output interface circuits can have a digital output or an analogue output signal.

dc motor output device

DC Motor is an Output Device

Digital logic outputs are the most common type of output interfacing signal and the easiest to control. Digital output interfaces convert a signal from a micro-controllers output port or digital circuits into an ON/OFF contact output using relays using the controllers software.

Analogue output interfacing circuits use amplifiers to produce a varying voltage or current signal for speed or positional control type outputs. Pulsed output switching is another type of output control which varies the duty cycle of the output signal for lamp dimming or speed control of a DC motor.

While input interfacing circuits are designed to accept different voltage levels from different types of sensors, output interfacing circuits are required to produce larger current driving capability and/or voltage levels. Voltage levels of the output signals can be increased by providing open-collector (or open-drain) output configurations. That is the collector terminal of a transistor (or the drain terminal of a MOSFET) is normally connected to the load.

The output stages of nearly all micro-controllers, PIC’s or digital logic circuits can either sink or source useful amounts of output current for switching and controlling a large range of output interfacing devices to control the real world. When we talk about sinking and sourcing currents, the output interface can both “give out” (source) a switching current or “absorb” (sink) a switching current. Which means that depending upon how the load is connected to the output interface, a HIGH or LOW output will activate it.

Perhaps the simplest of all output interfacing devices are those used to produce light either as a single ON/OFF indicator or as part of a multi-segment or bar-graph display. But unlike a normal light bulb that can be connected directly to the output of a circuit, LEDs being diodes need a series resistor to limit their forward current.

Output Interfacing Circuits

Light emitting diodes, or LEDs for short, are an excellent low power choice as an output device for many electronic circuits as they can be used to replace high wattage, high temperature filament light bulbs as status indicators. An LED is typically driven by a low voltage, low current supply making them a very attractive component for use in digital circuits. Also, being a solid state device, they can have an operational life expectancy of over 100,000 hours of operation making them an excellent fit and forget component.

Single LED Interface Circuit

single led interface circuit

We saw in our Light Emitting Diode Tutorial that an LED is a unidirectional semiconductor based device which when forward biased, that is when its cathode is sufficiently negative with respect to its anode, can produce a whole range of coloured light and brightnesses.

The semiconductor materials used to construct their PN-junction will determine the colour of the light emitted, and their turn-on voltage. The most common LED colours being red, green, amber or yellow light.

Unlike a conventional signal diode which has a forward voltage drop of about 0.7 volts for Silicon or about 0.3 volts for Germanium, a light-emitting diode has a greater forward voltage drop than does the common signal diode. But when forward biased produces visible light.

A typical LED when illuminated can have a constant forward voltage drop, VLED of about 1.2 to 1.6 volts and its luminous intensity varies directly with the forward LED current. But as the LED is effectively a “diode” (its arrow like symbol resembles a diode but with little arrows next to the LED symbol to indicate that it emits light), it needs a current limiting resistor to prevent it from shorting out the supply when forward biased.

LEDs can be driven directly from most output interfacing ports as standard LEDs can operate with forward currents of between 5mA and 25mA. A typical coloured LED requires a forward current of around 10 mA to provide a reasonably bright display. So if we assume that a single red LED has a forward voltage drop when illuminated of 1.6 volts, and will be operated by the output port of a 5 volt microcontroller supplying 10mA. Then the value of the current limiting series resistor, RS required is calculated as:

led series resistor


However, in the E24 (5%) series of preferred resistor values, there is no 340Ω resistor so the nearest preferred value chosen would be 330Ω or 360Ω. In reality depending upon the supply voltage ( VS ) and the required forward current ( IF ), any series resistor value between 150Ω and 750Ω’s would work perfectly well.

Also note that being a series circuit, it does not matter which way around the resistor and LED are connected. However, being unidirectional the LED must be connected the correct way. If you connect the LED the wrong way, it will not be damaged, it just will not illuminate.

Multi LED Interface Circuit

multi led interface circuit

As well as using single LEDs (or lamps) for output interfacing circuits, we can also connect two or more LEDs together and power them from the same output voltage for use in optoelectronic circuits and displays.

Connecting together two or more LEDs in series is no different from using a single LED as we saw above, but this time we need to take into account the extra forward voltage drops, VLED of the additional LEDs in the series combination.

For example, in our simple LED output interfacing example above we said that the forward voltage drop of the LED was 1.6 volts. If we use three LEDs in series then the total voltage drop across all three would be 4.8 (3 x 1.6) volts. Then our 5 volt supply could just about be used but it would be better to use a higher 6 volt or 9 volt supply instead to power the three LEDs.

Assuming a supply of 9.0 volts at 10mA (as before), the value of the series current limiting resistor, RS required is calculated as: RS = (9 - 4.8)/10mA = 420Ω. Again in the E24 (5%) series of preferred resistor values, there is no 420Ω resistor so the nearest preferred value chosen would be 430Ω’s.

Being low voltage, low current devices, LEDs are ideal as status indicators which can be driven directly from the output ports of micro-controller and digital logic gates or systems. Micro-controller ports and TTL logic gates have the ability to either sink or source current and therefore can light an LED either by grounding the cathode (if the anode is tied to +5v) or by applying +5v to the anode (if the cathode is grounded) through an appropriate series resistor as shown.

Digital Output Interfacing an LED

output interfacing an led


The output interfacing circuits above work fine for one or more series LEDs, or for any other device whose current requirements are less than 25 mA (the maximum LED forward current). But what happens if the output drive current is insufficient to operate an LED or we wish to operate or switch a load with a higher voltage or current rating such as a 12v filament lamp. The answer is to use an additional switching device such as a transistor, mosfet or a relay as shown.

Output Interfacing High Current Loads

output interfacing high currents

Common output interfacing devices, such as motors, solenoids and lamps require large currents so they are best controlled or driven by a transistor switch arrangement as shown. That way the load, (lamp or motor) can not overload the output circuit of the switching interface or controller.

Transistor switches are very common and very useful for switching high power loads or for the output interfacing of different power supplies. They can also be switched “ON” and “OFF” several times a second if required, as in pulse width modulation, PWM circuits. But there are a few things we need to consider first about using transistor as switches.

The current flowing into the base-emitter junction is used to control the larger current flowing from the collector to the emitter. Therefore, if no current flows into the base terminal, then no current flows from the collector to the emitter (or through the load connected to the collector), then the transistor is said to be fully-OFF (cut-off).

Switching the transistor fully-ON (saturation), the transistor switch effectively acts as a closed switch, that is its collector voltage is at the same voltage as its emitter voltage. But being a solid state device, even when saturated, there will always be a small voltage drop across the transistors terminals, called VCE(SAT). This voltage ranges from about 0.1 to 0.5 volts depending upon the transistor.

Also, as the transistor will be switched fully-ON, the load resistance will limit the transistors collector current IC to the actual current required by the load (in our case, the current through the lamp). Then too much base current can overheat and damage the switching transistor which somewhat defeats the objective of using a transistor which is to control a bigger load current with a smaller one. Therefore, a resistor is required to limit the base current, IB.

The basic output interfacing circuit using a single switching transistor to control a load is shown below. Note that it is usual to connect a freewheel diode, also known as a flywheel diode or back-emf suppression diode such as a 1N4001 or 1N4148 to protect the transistor from any back emf voltages generated across inductive loads such as relays, motors and solenoids, etc. when their current is switched off by the transistor.

Basic Transistor Switch Circuit

transistor switch circuit


Lets assume we wish to control the operation of a 5 watt filament lamp connected to a 12 volt supply using the output of a TTL 5.0v digital logic gate via a suitable output interfacing transistor switch circuit. If the DC current gain (the ratio between collector (output) and base (input) current), beta (β) of the transistor is 100 (you can find this Beta or hFE value from the datasheet of the transistor you use) and its VCE saturation voltage when fully-ON is 0.3 volts, what will be the value of the base resistor, RB required to limit the collector current.

The transistors collector current, IC will be the same value of current that follows through the filament lamp. If the power rating of the lamp is 5 watts, then the current when fully-ON will be:

filament lamp current


As IC is equal to the lamp (load) current, the transistors base current will be relative to the current gain of the transistor as IB = IC. The current gain was given previously as: β = 100, therefore the minimum base current IB(MIN) is calculated as:

transistor base current


Having found the value of base current required, we now need to calculate the maximum value of the base resistor, RB(MAX). The information given stated that the base of the transistor was to be controlled from the 5.0v output voltage (Vo) of a digital logic gate. If the base-emitter forward bias voltage is 0.7 volts, the the value of RB is calculated as:

transistor base resistor


Then when the output signal from the logic gate is LOW (0v), no base current flows and the transistor is fully-off, that is no current flows through the 1kΩ resistor. When the output signal from the logic gate is HIGH (+5v), the base current is 4.27mA and turns ON the transistor putting 11.7V across the filament lamp. Base resistor RB will dissipate less than 18mW when conducting 4.27mA, so a 1/4W resistor will work.

Note that when using a transistor as a switch in an output interfacing circuit, a good rule of thumb is to choose a base resistor, RB value so that the base drive current IB is approximately 5% or even 10% of the required load current, IC to help drive the transistor well into its saturation region thereby minimizing VCE and power loss.

Also, for a quicker calculation of the resistor values and to reduce the maths a little, you could ignore the 0.1 to 0.5 voltage drop across the collector emitter junction and the 0.7 volt drop across the base emitter junction if you wanted to in your calculations. The resulting approximate value will be close enough to the actual calculated value anyway.

Single power transistor switching circuits are very useful for controlling low power devices, such as filament lamps or for switching relays which can be used to switch much higher power devices, for example, motors and solenoids.

But relays are large, bulky electromechanical devices that can be expensive or take up a lot of room on a circuit board when being used to output interface an 8-port micro-controller for instance.

One way to over come this and switch heavy current devices directly from the output pins of a micro-controller, PIC or digital circuit, is to use a darlington pair configuration formed from two transistors.

One of the main disadvantages of power transistors when used as output interfacing devices is that their current gain, (β) especially at switching high currents, can be too low. As little as 10. To overcome this problem and to reduce the value of the base current required is to use two transistors in a Darlington configuration.

Darlington Transistor Configuration

darlington transistor configuration

Darlington transistor configurations can be made from two NPN or two PNP transistors connected together or as a ready made Darlington device such as the 2N6045 or the TIP100 which integrates both transistors and some resistors, to assist in rapid turn-off, within a single TO-220 package for switching applications.

In this darlington configuration, transistor, TR1 is the control transistor and is used to control the conduction of the power switching transistor TR2. The input signal applied to the base of transistor TR1 controls the base current of transistor TR2. The Darlington arrangement, whether individual transistors or as a single package has the same three leads: Emitter (E), Base (B) and Collector (C).

Darlington transistor configurations can have DC current gains (that is the ratio between collector (output) and base (input) current) of several hundred to several thousand depending upon the transistors used. Then it would be possible to control our filament lamp example above with a base current of only a few micro-amperes, (uA) as the collector current, β1IB1 of the first transistor becomes the base current of the second transistor.

Then the current gain of TR2 will be β1β2IB1 as the two gains are multiplied together as βT = β1×β2. In other words, a pair of bipolar transistors combined together to make a single Darlington transistor pair will have their current gains multiplied together.

So by choosing suitable bipolar transistors and with the correct biasing, double emitter follower darlington configurations can be regarded as a single transistor with a very high value of β and consequently a high input impedance into the thousands of ohms.

Fortunately for us, someone has already put several darlington transistor configurations into a single 16-pin IC package making it easy for us to output interface a whole range of devices.

The ULN2003A Darlington Transistor Array

The ULN2003A is a inexpensive unipolar darlington transistor array with high efficiency and low power consumption making it extremely useful output interfacing circuit for driving a wide range of loads including solenoids, relays DC Motor’s and LED displays or filament lamps directly from the ports of micro-controllers, PIC’s or digital circuits.

The family of darlington arrays consist of the ULN2002A, ULN2003A and the ULN2004A which are all high voltage, high current darlington arrays each containing seven open collector darlington pairs within a single IC package. The ULN2803 Darlington Driver is also available which contains eight darlington pairs instead of seven.

Each isolated channel of the array is rated at 500mA and can withstand peak currents of up to 600mA making it ideal for controlling small motors or lamps or the gates and bases of high power transistors. Additional suppression diodes are included for inductive load driving and the inputs are pinned opposite the outputs to simplify the connections and board layout.

ULN2003 Darlington Transistor Array

uln2003 darlington transistor array


The ULN2003A Darlington driver has an extremely high input impedance and current gain which can be driven directly from either a TTL or +5V CMOS logic gate. For +15V CMOS logic use the ULN2004A and for higher switching voltages up to 100V it is better to use the SN75468 Darlington array.

If more switching current capability is required then both the Darlington pairs inputs and outputs can be paralleled together for higher current capability. For example, input pins 1 and 2 connected together and output pins 16 and 15 connected together to switch the load.

Power MOSFET Interfacing Circuits

As well as using single transistors or Darlington pairs, power MOSFETs can also be used to switch medium power devices. Unlike the bipolar junction transistor, BJT which requires a base current to drive the transistor into saturation, the MOSFET switch takes virtually no current as the gate terminal is isolated from the main current carrying channel.

Basic MOSFET Switch Circuit

mosfet switch circuit

N-channel, enhancement-mode (normally-off) power MOSFETs, (eMOSFET) with its positive threshold voltage and extremely high input impedance, makes it an ideal device for direct interfacing to micro-controllers, PICs and digital logic circuits that are capable of producing a positive output as shown.

MOSFET switches are controlled by a gate input signal and because of the extremely high input (gate) resistance of the MOSFET, we can parallel, almost without limit, many power MOSFETs together until we achieve the power handling capabilities of the connected load.

In the N-channel enhancement type MOSFET, the device is cut-off (Vgs = 0) and the channel is closed acting like a normally open switch. When a positive bias voltage is applied to the gate, current flows through the channel. The amount of current depends upon the gate bias voltage, Vgs. In other words, to operate the MOSFET in its saturation region, the gate-to-source voltage must be sufficient to maintain the required drain and therefore the load current.

As discussed previously, n-channel eMOSFETS are driven by a voltage applied between the gate and source so adding a zener diode across the MOSFETs gate-to-source junction as shown, serves to protect the transistor from excessive positive or negative input voltages such as those for example, generated from a saturated op-amp comparator output. The zener clamps the positive gate voltage and acts as a conventional diode which begins to conduct one the gate voltage reaches –0.7V, keeping the gate terminal well away from its reverse breakdown voltage limit.

MOSFETs and Open-collector Gates

output interfacing a mosfet switch

Output interfacing a power MOSFET from TTL poses a problem when we use gates and drivers with open-collector outputs as the logic gate may not always give us the required VGS output. One way to overcome this problem is to use a pull-up resistor as shown.

The pull-up resistor is connected between the TTL supply rail and the logic gates output which is connected to the MOSFETs gate terminal. When the TTL logic gates output is at logic level “0” (LOW), the MOSFET is “OFF” and when the logic gates output is at logic level “1” (HIGH), the resistor pulls the gate voltage up to the +5v rail.

With this pull-up resistor arrangement, we can fully switch the MOSFET “ON” by tying its gate voltage to the upper supply rail as shown.

Output Interfacing Motors

We have seen that we can use both bipolar junction transistors or MOSFETs as part of an output interfacing circuit to control a whole range of devices. One common output device is the DC motor which creates a rotational movement. There are hundreds of ways motors and stepper motors can be interfaced to micro-controllers, PICs and digital circuits using a single transistor, darlington transistor or MOSFET.

The problem is that motors are electromechanical devices that use magnetic fields, brushes and coils to create the rotational movement and because of this, motors, and especially cheap toy or computer fan motors generate a lot of “electrical noise” and “voltage spikes” which can damage the switching transistor.

This motor generated electrical noise and overvoltage can be reduced by connecting a freewheel diode or non-polarised suppression capacitor across the motors terminals. But one simple way of preventing the electrical noise and reverse voltages from affecting semiconductor transistor switches or the output ports of micro-controllers is to use separate power supplies for the control and motor via a suitable relay.

A typical connection diagram for output interfacing an electromechanical relay to a DC motor is shown below.

ON/OFF DC Motor Control

dc motor control


The NPN transistor is used as tn ON-OFF switch to provide the desired current to the relay coil. The freewheeling diode is required, the same as above, as the current flowing through the inductive coil when de-energised cannot instantaneously reduced to zero. When the input to the base is set HIGH, the transistor is switched “ON”. Current flows through the relay coil and its contacts close driving the motor.

When the input to the transistors base is LOW, the transistor is switched “OFF” and the motor stops as the relay contacts are now open. Any back-emf generated by deactivating the coil flows through the freewheeling diode and slowly decays to zero preventing damage to the transistor. Also, the transistor (or MOSFET) are isolated and unaffected by any noise or voltage spikes generated by the operation of the motor.

We have seen that a DC motor can be turned ON and OFF using a pair of relay contacts between the motor and its power supply. But what if we want the motor to rotate in both directions for use in a robot or some other form of motorised project. Then the motor can be controlled using two relays as shown.

Reversible DC Motor Control

reversible dc motor control


A DC motor’s direction of rotation can be reversed by simply changing the polarity of its supply connections. By using two transistor switches, the motors rotational direction can be controlled via two relays each with a single-pole double-throw (SPDT) contacts connected powered from single voltage supply. By operating one of the transistor switches at a time, the motor can be made to rotate in either direction (forward or reverse).

Whilst the output interfacing of motors via relays allows us to start and stop them, or to control the direction of rotation. The use of relays prevents us from controlling the speed of rotation as the relays contacts would be continually opening and closing.

However, a DC motors rotational speed is proportional to the value of its power supply voltage. A DC motors speed can be controlled by either adjusting the average value of its DC supply voltage or, by using pulse width modulation. That is by varying the mark-space ratio of its supply voltage from as little as 5% up to over 95%, and many motor H-bridge controllers do just that.

Output Interfacing Mains Connected Loads

We have seen previously that relays can electrically isolate one circuit from another, that is they allow one smaller powered circuit to control another possibly larger powered circuit. Relays also at the same time provide protection to the smaller circuit from electrical noise, over voltage spikes and transients that could damage the delicate semiconductor switching device.

But relays also allow the output interfacing of circuits with different voltages and grounds such as those between a 5 volt microcontroller or PIC and the mains voltage supply. But as well as using transistor (or MOSFET) switches and relays to control mains powered devices, such as AC motors, 100W lamps or heaters, we can also control them using opto-isolators and power electronics devices.

The main advantage of the opto-isolator is that it provides a high degree of electrical isolation between its input and output terminals, as it is optically coupled and as such requires minimal input current (typically only 5mA) and voltage. This means that opto-isolators can be easily interfaced from a microcontroller port or digital circuit that offers sufficient LED drive capabilities on its output.

The basic design of an opto-isolator consists of an LED that produces infra-red light and a semiconductor photo-sensitive device that is used to detect the emitted infra-red beam. Both the LED and photo-sensitive device which can be a single photo-transistor, photo-darlington or a photo-triac are enclosed in a light-tight body or package with metal legs for the electrical connections as shown.

Different Types of Opto-isolator

optocoupler types


As the input is an LED, the value of the series resistor, RS required to limit the LED current can be calculated the same as above. The LEDs of two or more opto-isolators can also be connected together in series to control multiple output devices at the same time.

Opto-triac isolators allow AC powered equipment and mains lamps to be controlled. Opto-coupled triacs such as the MOC 3020, have voltage ratings of about 400 volts making them ideal for direct mains connection and a maximum current of about 100mA. For higher powered loads, the opto-triac may be used to provide the gate pulse to another larger triac via a current limiting resistor as shown.

Solid State Relay

solid state relay


This type of optocoupler configuration forms the basis of a very simple solid state relay application which can be used to control any AC mains powered load such as lamps and motors directly from the output interface of a mico-controller, PIC or digital circuit.

Output Interfacing Summary

Solid-state software control systems that use micro-controllers, PICs, digital circuits and other such microprocessor based systems, need to be able to connect to the real world to control motors or to switch LED indicators and lamps ON or OFF, and in this electronics tutorial we have seen that different types of output interfacing circuits can be used for this purpose.

By far the simplest interfacing circuit is that of a light emitting diode or LED acting as a simple ON/OFF indicator. But by using standard transistor or MOSFET interfacing circuits as solid state switches we can control a much larger flow of current even if the output pins of the controller can only supply (or sink) a very small amount of current. Typically, for many controllers their output interface circuit may be a current sinking output in which the load is generally connected between the supply voltage and the output terminal of the switching device.

If for example, we wish to control a number of different output devices in a project or robotic application, then it can be more convenient to use a ULN2003 Darlington driver IC that consists of several transistor switches within a single package. Or of we wish to control an AC actuator we could output interface a relay or opto-isolator (optocoupler).

Then we can see that both input and output interfacing circuits give the Electronics Designer or Student the flexibility to use small signal or microprocessor based software systems the ability to control and communicate with the real world via its input/output ports whether its a small school project or a large industrial application.


Join the conversation!

Error! Please fill all fields.

What's the Answer *

  • s
    sebastian scott

    Output Interfacing Circuits
    A very well written article and exceptionaly well explained, many thanks, Seb

  • D

    I think led is not working in both colors due to back emf because it is connected in parallel to forward backward motor. So today i tried to add a in4002 diode in series with led. But still led is not working in bi color.

  • D

    I found on internet this circuit for txm8d423c. But how to attach it here.


  • D

    Sir How can i add transiator switch to run motor or bi color led to a circuit that drive motor directly from ic txm8d423c.
    Actually i tried red blue bi color led with series 100ohm resister. But it change color for just 1-2 second at start. Once toy car pick its top speed, it glows in blue color only. when car stops it glows red for 1-2 second. I tried 10ohm but same happend. The led works in bicolor when tested with normal dc supply.

  • N
    Nikitas Paschalis

    Thank you for your article.
    I am writing a project for automated bottle cap inspection and injection. I am using laser measurement sensors (for example omron zx-gt) and a stepper motor for the rejection plant. Is it possible to connect directly laser sensor’s interface to uln2003 by which the stepper motor is also controlled? Or I need another controller unit which collects data from uln2003 and laser controllers ?

Looking for the latest from TI?
Looking for the latest from TI?