Relay is an electrically operated switch that uses electromagnet induction to mechanically turn a switch ON/OFF. Relays are used wherever it’s necessary to control a high power or high voltage circuit with low power circuit. A microcontroller operates at 3.3V or 5V can turn ON/OFF several 220V AC equipments by using relays. In this project I’ll be using SONGLE 5V SPDT (Single Pole Double Throw) mechanical relay.
Below is a pin diagram of it:
VCC, GND = where to apply nominal coil voltage (5V in this case)
CO = common
NO = normally open
NC = normally connect
The SONGLE relay has specification as follows: nominal working voltage 5 V, nominal current 89.3 mA, coil resistance 55 Ohm, power consumption 0.45 W, pull-in voltage 75%Max.
How it works:
When no or not enough voltage is applied at pin VCC & GND, the relay is OFF, and CO is connected to NC. When 5V voltage is applied at pin VCC & GND, the relay is turned ON, then the switching pole moved/thrown, and now CO is connected to NO.
How do we drive relay?
A relay can be driven by transistor, either BJT or MOSFET will do. But BJT is cheaper in my place, so I’ll go with it instead. The basic circuit is shown below:
Vin can be connected to microcontroller pin, when Vin = 1 it will turn on the NPN, current will flow through relay coil and turn ON the relay. A fast switching diode is connected in reverse between the coil of the relay. The coil of a relay acts like an inductor, we know that inductor doesn’t like sudden change in current. When the supply is turned off, the coil will respond by producing sudden very large voltage across its leads, causing a large surge of current through it, a voltage spike can be as high as 1000V (what? seriously?). Placing a diode in reverse bias across a relay coil will eliminates that voltage spike by going into conduction before the voltage spike can grow large enough across the coil.
What will we use the relay for?
An AC powered equipment (those which we use everyday at home) usually has two wire, if we pry open the cable isolator then we can see inside. We take one of the wire then cut it into two lead, then connect one of the lead to CO (Common), and the other lead we connect to NO (Normally Open) pin of the relay. Therefore with that connection established, we now able to control the equipment state ON/OFF by turning the relay ON/OFF.
Optocoupler
In the diagram we can see that Vin is connected directly to microcontroller pin. But, relay circuit can be so noisy, especially when turned ON. Being skeptical and just play in the safe zone, we don’t want the noises to travel and enter microcontroller circuitry, it’s a good idea to provide isolation between them. This is when the optocoupler become useful.
An optocoupler, also called opto-isolator or photocoupler is an electronic device that capable to transfer electrical signal between two isolated circuits by using light. An optocoupler usually consist of a LED and a phototransistor inside it’s package, just like shown below:
In short, we provide current flow from anode to cathode to turn the LED ON, the LED then shine some light, and the base of the transistor will catch it, hence the transistor is turned ON, connecting the collector and the emitter pin.
The optocoupler that I’m going to use is from 817 series, came with 4 pin DIP package just like the top diagram.
(Note: There's also an optocoupler IC that came with 6 pin, 1 of the extra pin is connected to the transistor base which usually connected to ground with a MOhm resistor to make the charge stored at transistor base junction discharged quicker. And 1 extra pin usually left unconnected)
Complete Circuit:
A 5V LDO regulator is added there, to prevent damage to the circuit in case some users that have no idea connecting too high supply voltage to the system. Ideally with regulator drop out voltage 1-1.5V, a good input voltage should be 6-6.5V. Too high value wasted more power dissipation.
Did some measurement on breadboard:
Above measurement was performed on circuit implemented on breadboard, when the circuit transferred to PCB implementation the result should be more satisfying of course. :)
Altium Schematic:
Altium PCB Layout:
PCB manufactured by CV MPI (local PCB manufacture at Sidoarjo, East Java):
PCB assembled by my own skillful hand:
VCC, GND = where to apply nominal coil voltage (5V in this case)
CO = common
NO = normally open
NC = normally connect
The SONGLE relay has specification as follows: nominal working voltage 5 V, nominal current 89.3 mA, coil resistance 55 Ohm, power consumption 0.45 W, pull-in voltage 75%Max.
How it works:
When no or not enough voltage is applied at pin VCC & GND, the relay is OFF, and CO is connected to NC. When 5V voltage is applied at pin VCC & GND, the relay is turned ON, then the switching pole moved/thrown, and now CO is connected to NO.
How do we drive relay?
A relay can be driven by transistor, either BJT or MOSFET will do. But BJT is cheaper in my place, so I’ll go with it instead. The basic circuit is shown below:
Vin can be connected to microcontroller pin, when Vin = 1 it will turn on the NPN, current will flow through relay coil and turn ON the relay. A fast switching diode is connected in reverse between the coil of the relay. The coil of a relay acts like an inductor, we know that inductor doesn’t like sudden change in current. When the supply is turned off, the coil will respond by producing sudden very large voltage across its leads, causing a large surge of current through it, a voltage spike can be as high as 1000V (what? seriously?). Placing a diode in reverse bias across a relay coil will eliminates that voltage spike by going into conduction before the voltage spike can grow large enough across the coil.
What will we use the relay for?
An AC powered equipment (those which we use everyday at home) usually has two wire, if we pry open the cable isolator then we can see inside. We take one of the wire then cut it into two lead, then connect one of the lead to CO (Common), and the other lead we connect to NO (Normally Open) pin of the relay. Therefore with that connection established, we now able to control the equipment state ON/OFF by turning the relay ON/OFF.
Optocoupler
In the diagram we can see that Vin is connected directly to microcontroller pin. But, relay circuit can be so noisy, especially when turned ON. Being skeptical and just play in the safe zone, we don’t want the noises to travel and enter microcontroller circuitry, it’s a good idea to provide isolation between them. This is when the optocoupler become useful.
An optocoupler, also called opto-isolator or photocoupler is an electronic device that capable to transfer electrical signal between two isolated circuits by using light. An optocoupler usually consist of a LED and a phototransistor inside it’s package, just like shown below:
In short, we provide current flow from anode to cathode to turn the LED ON, the LED then shine some light, and the base of the transistor will catch it, hence the transistor is turned ON, connecting the collector and the emitter pin.
(Note: There's also an optocoupler IC that came with 6 pin, 1 of the extra pin is connected to the transistor base which usually connected to ground with a MOhm resistor to make the charge stored at transistor base junction discharged quicker. And 1 extra pin usually left unconnected)
Complete Circuit:
A 5V LDO regulator is added there, to prevent damage to the circuit in case some users that have no idea connecting too high supply voltage to the system. Ideally with regulator drop out voltage 1-1.5V, a good input voltage should be 6-6.5V. Too high value wasted more power dissipation.
Did some measurement on breadboard:
Above measurement was performed on circuit implemented on breadboard, when the circuit transferred to PCB implementation the result should be more satisfying of course. :)
Altium Schematic:
Altium PCB Layout:
PCB manufactured by CV MPI (local PCB manufacture at Sidoarjo, East Java):
PCB assembled by my own skillful hand:
No comments:
Post a Comment