As you know, interfacing microcontroller with 5 VDC, 2mA load is so simple and no need to any extra components... just connect the micrcontroller to the load directly.
But if you have a load that exceeds the rating voltage or rating current,what can you do then?
If exceeds rating voltage ==> then you need a relay
If exceeds rating current ==> then you need a transistor
Code:
void main() {
TRISD.F0 = 1 ;
TRISB.F0 = 0 ; PORTB.F0 = 0 ;
while(1)
{
if(PORTD.F0 == 0)
{
PORTB.F0 = ~ PORTB.F0 ;
while(PORTD.F0 == 0) ;
Delay_ms(20) ;
}
}
}
A
relay is an electrically activated switch. It consists of a coil
internally which will creates a magnetic field that attracts a movable
lever and then changes switch contacts when a current is flowing through
it. The typical usage of relay is to allow a low DC voltage circuit
(circuit #1) to switch on or off a high voltage (DC or AC) circuit
(circuit #2) without direct electrical connection between them. This
means circuit #1 and circuit #2 are magnetically and mechanically linked
but not electrically connected. There are some designations normally
used in describing a relay based on its internal structure and pins
distribution as shown in the following
i)
Single Pole Single Throw (SPST) – Such relay has 4 terminal pins which
consists of a pair of coil pins and a pair of pins which can be made
connected or disconnected by activating or deactivating the relay. Such
relay can categorized into normally open or normally closed type.
ii)
Single Pole Double Throw (SPST) – Such relay has 5 terminal pins which
consists of a pair of coil pins, a common pin, a normally open (NO) pin
and a normally closed (NC) pin. When the relay is not activated, the
common pin is in contact with the NC pin and when it is activated, the
common pin will break away from contact with the NC pin and subsequently
makes contact with the NO pin. Also, when the relay is deactivated
(from activated state), the common pin will conversely break away from
contact with the NO pin and return back in contact with the NC pin.
iii)
Double Pole Single Throw (DPST) – Such relay has 6 terminal pins which
consist of a pair of coil pins and two pairs of pins, where pins in each
pair can be made connected or disconnected by activating or
deactivating the relay. Such relay is actually a combination of two SPST
relay structures with only one coil pins pair.
iv)
Double Pole Double Throw (DPDT) – Such relay has 8 terminal pins which
consist of a pair of coil pins, two 3 pins group for each group consists
of a common pin, normally open (NO) pin and normally (NC) pin . Such
relay is actually a combination of two SPDT relay structures with only
one coils pin pair
No comments:
Post a Comment