topics
1: what is a relay
2: relay interfacing with 8051
3:assembly code
4:c code
Size: 241.25 KB
Language: en
Added: Apr 02, 2020
Slides: 7 pages
Slide Content
RELAY INTERFACING WITH 8051 PRATIK PHADTE COURSE : ELECTRICAL AND ELECTRONICS ENGINEERING @ [email protected]
TOPICS What`s a relay Interfacing relay with 8051 Assembly code for interfacing C code for interfacing
What`s a relay A relay is nothing but a switch, it can be controlled(ON/OFF) by a low power signal(ex: current in microamps ). Its mainly used as a switch in high power circuits(230v,50hz). When control signal is given ( ex:HIGH ) ,then the switch is CLOSED Similarly when control signal is LOW ,then switch in OPEN
What`s a relay The figure shows practical internal operation of a relay. Here ,when the small switch is closed ,the coil gets energized becoming an ELECTROMAGNET Thus ,attracting the metallic plate and hence CLOSING the main switch. When the small switch is open, the coil is de-energized ,hence the SPRING pulls the metallic plate back therefore OPENING the main switch.
Interfacing relay with 8051 For interfacing with the controller we need a setup like below: Here the 8051 uc can be programmed to to set its any port pin as output(HIGH/LOW). (one /zero) A HIGH signal from port pin P0.1 will turn on transistor and energize the coil, hence MAIN switch will CLOSE thus the bulb GLOWS. When LOW signal is given by 8051 uc , the transistor is off and the coil gets de-energized via the free wheeling diode hence the metallic plate is lifted and main switch is OPEN.
Assembly code for interfacing For assembly code we need to just send a high signal to the used Port PIN High signal=LOGIC ONE CODE: o rg 00h setb P0.2 [output of port zero pin two is set to HIGH(one)] a call delay clr P0.2 [ output of port zero pin two is set to LOW(zero)] END NOTE: delay code is not mentioned here
C code for interfacing #include<reg52.h> s bit relay_pin = P0^2; [naming port zero pin two] Void delay( int ); [Define delay function] Void main( ) { do { relay_pin =0; [relay switched ON] delay( ); relay_pin =1; [ relay switched ON] delay( ); } while(1); } NOTE: delay code is not mentioned here