Imagine a tiny computer microcontroller or Arduino that can not control strong currents directly.
A relay is like a switch that can handle strong currents for things like lights, motors or heaters.
To connect them safely, we use a translator transistor and a special isolator optocoupler.
This lets the tiny computer tell the relay switch what to turn on or off, even though they use different kinds of power.
Circuit Working:
Parts List:
Type | Value | Quantity | Note |
---|---|---|---|
Resistors (all resistors are 1/4 watt) | 1k | 1 | |
10k | 1 | ||
33k | 1 | ||
Capacitors | Electrolytic 100µF | 1 | 25V |
Semiconductors | Optocoupler PC817 | 1 | |
Transistor BC547 | 1 | ||
Diode 1N4007 | 1 | ||
Other | Relay 12V | 1 |
Many microcontroller designs often combine various interfacing methods.
A microcontroller µC system functions by reading inputs, processing them and then writing outputs.
Microcontrollers are valuable because they can communicate with other devices, such as sensors, motors, switches, keypads, displays memory and even other microcontrollers.
There is often a need to connect the microcontrollers output to an electromagnetic relay EMR.
Relays are devices that allow low power circuits to switch high currents and/or voltages on and off.
Below is a simple microcontroller relay interface circuit with ‘galvanic isolation.’
Galvanic isolation refers to the separation between two circuits without any metal conduction between them.
This isolation can be achieved through optical or inductive methods.
“Galvanic” refers to direct current DC, and galvanic isolation ensures that DC current cannot bridge the connection.
The most common method for achieving galvanic isolation is using an optical isolator optocoupler/photocoupler.
The PC817 Semiconductor is an optically coupled pair consisting of a gallium arsenide infrared emitting diode optically coupled to a silicon NPN phototransistor.
This device can transmit signal information while maintaining a high degree of electrical isolation between its input and output.
Connecting this circuit to a µC is basic.
The circuits input can be connected to a selected output port of the µC through the input terminals.
However, it is essential to observe the supply polarity.
The entire circuit can be powered by any DC source capable of delivering about 50 mA at 12V DC.
Formulas:
The circuit shown above is a simple setup for connecting a microcontroller and Arduino to a relay and amplifying it with a transistor BC547.
Below are some general electrical formulas are involved:
Transistor Base Current Calculation: to guarantee sufficient driving of the transistor toward saturation.
Ib = (Vcc – Vbe) / R3
where,
- The base current is denoted by Ib.
- The supply voltage, or 12V in this example, is Vcc.
- The transistors base emitter voltage, Vbe is normally around 0.7V.
- Our base resistor is R3.
Transistor Collector Current Calculation: to make sure the load current can be handled by the transistor.
Ic = hfe * Ib
where,
- Ic stands for the transistors collector current and
- According to datasheet hfe for its current gain.
- The base current is denoted by Ib.
Relay Coil Current Calculation: To verify the relay is properly driven.
Ir = Vr / Rcoil
- The relay coil current is Ir.
- The voltage of the relay coil, Vr is usually 12V.
- According to the datasheet, Rcoil is the relay coil resistance.
Using the given circuit arrangement, you may successfully connect a microcontroller and Arduino with a relay by comprehending these fundamental ideas and choosing components with care.
How to Build:
To build a Interface Microcontroller with Relay follow the below mentioned connections steps:
- Connect the anode of the diode D1 to the collector of the transistor T1.
- Connect the cathode of D1 to the positive supply.
- Connect the emitter of the relay driver transistor to ground.
- Connect the base of the relay driver transistor to the output pin of the optocoupler PC817 through a R2 and R3.
- Connect the anode of the infrared LED inside the PC817 to a current limiting resistor R1 and connect the other end of R1 to the microcontrollers output pin.
- Connect the cathode of the LED to the microcontroller’s ground.
Note:
- Ensure that the relay coil voltage matches the voltage of your power supply 12V in this case.
- Use appropriate transistor ratings and relay specifications based on your relay’s coil current requirements.
- Double check all connections before applying power to avoid damaging the components.
Conclusion:
Interfacing a microcontroller with a relay is a simple process that involves using components like transistors and optocouplers to safely control high voltage devices.
Understanding the relays specifications and the microcontrollers output requirements is crucial for a successful interface design.
Leave a Reply