SlideShare a Scribd company logo
1 of 7
RELAY INTERFACING WITH
8051
PRATIK PHADTE
COURSE : ELECTRICAL AND ELECTRONICS ENGINEERING
@pratikphadte19@gmail.com
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 o
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:
org 00h
setb P0.2 [output of port zero pin two is set to HIGH(one)]
acall 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>
sbit 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

More Related Content

What's hot

Microprocessor & microcontroller
Microprocessor & microcontroller Microprocessor & microcontroller
Microprocessor & microcontroller Nitesh Kumar
 
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
 INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER   INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER SIRILsam
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051Muthu Manickam
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language ProgrammingRavikumar Tiwari
 
DAC-digital to analog converter
DAC-digital to analog converterDAC-digital to analog converter
DAC-digital to analog converterShazid Reaj
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller NotesDr.YNM
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.pptDr.YNM
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller featuresTech_MX
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...NimeshSingh27
 
Week 17 digital control sytem
Week 17 digital control sytemWeek 17 digital control sytem
Week 17 digital control sytemCharlton Inao
 
Ic voltage regulators
Ic voltage regulatorsIc voltage regulators
Ic voltage regulatorsAnita Thattil
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adcPRADEEP
 
Schmitt trigger circuit
Schmitt trigger circuitSchmitt trigger circuit
Schmitt trigger circuittaranjeet10
 

What's hot (20)

Microprocessor & microcontroller
Microprocessor & microcontroller Microprocessor & microcontroller
Microprocessor & microcontroller
 
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
 INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER   INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
INTERFACING ANALAOG TO DIGITAL CONVERTER (ADC0808/09) TO 8051 MICROCONTROLLER
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051
 
Adc interfacing
Adc interfacingAdc interfacing
Adc interfacing
 
8255 PPI
8255 PPI8255 PPI
8255 PPI
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language Programming
 
Instruction Set of 8051 Microcontroller
Instruction Set of 8051 MicrocontrollerInstruction Set of 8051 Microcontroller
Instruction Set of 8051 Microcontroller
 
DAC-digital to analog converter
DAC-digital to analog converterDAC-digital to analog converter
DAC-digital to analog converter
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller Notes
 
8051 ch9-950217
8051 ch9-9502178051 ch9-950217
8051 ch9-950217
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
 
Power amplifiers
Power amplifiersPower amplifiers
Power amplifiers
 
8051 microcontroller features
8051 microcontroller features8051 microcontroller features
8051 microcontroller features
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...
 
Week 17 digital control sytem
Week 17 digital control sytemWeek 17 digital control sytem
Week 17 digital control sytem
 
Ic voltage regulators
Ic voltage regulatorsIc voltage regulators
Ic voltage regulators
 
Ditial to Analog Converter
Ditial to Analog ConverterDitial to Analog Converter
Ditial to Analog Converter
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
Schmitt trigger circuit
Schmitt trigger circuitSchmitt trigger circuit
Schmitt trigger circuit
 

Similar to Relay interfacing with 8051

digitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptxdigitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptxBijaySharma51
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic familiesBLESSINAR0
 
Digital integrated circuits
Digital integrated circuitsDigital integrated circuits
Digital integrated circuitsTamilarasan N
 
L6561 Power Factor Corrector
L6561 Power Factor CorrectorL6561 Power Factor Corrector
L6561 Power Factor CorrectorPremier Farnell
 
Logic families ppt eceb srp
Logic families ppt eceb srpLogic families ppt eceb srp
Logic families ppt eceb srpSaikat Dutt
 
Original Power Supply IC TNY254PN TNY254P TNY254 New
Original Power Supply IC TNY254PN TNY254P TNY254 NewOriginal Power Supply IC TNY254PN TNY254P TNY254 New
Original Power Supply IC TNY254PN TNY254P TNY254 NewAUTHELECTRONIC
 
Introduction to Integrated Circuits
Introduction to Integrated CircuitsIntroduction to Integrated Circuits
Introduction to Integrated CircuitsGurpawan Mand
 

Similar to Relay interfacing with 8051 (20)

Clap switch mini project using 555 timer IC
Clap switch mini project using 555 timer ICClap switch mini project using 555 timer IC
Clap switch mini project using 555 timer IC
 
digitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptxdigitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptx
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic families
 
Digital integrated circuits
Digital integrated circuitsDigital integrated circuits
Digital integrated circuits
 
Unit5 session 5
Unit5 session 5Unit5 session 5
Unit5 session 5
 
Unit 5 session 4
Unit 5 session 4Unit 5 session 4
Unit 5 session 4
 
Unit 5 session 4
Unit 5 session 4Unit 5 session 4
Unit 5 session 4
 
L6561 Power Factor Corrector
L6561 Power Factor CorrectorL6561 Power Factor Corrector
L6561 Power Factor Corrector
 
Logic families ppt eceb srp
Logic families ppt eceb srpLogic families ppt eceb srp
Logic families ppt eceb srp
 
Logic not gate tutorial with logic gate truth table
Logic not gate tutorial with logic gate truth tableLogic not gate tutorial with logic gate truth table
Logic not gate tutorial with logic gate truth table
 
Logic Gates & Family.pdf
Logic Gates & Family.pdfLogic Gates & Family.pdf
Logic Gates & Family.pdf
 
UNIT 3.pptx
UNIT 3.pptxUNIT 3.pptx
UNIT 3.pptx
 
Original Power Supply IC TNY254PN TNY254P TNY254 New
Original Power Supply IC TNY254PN TNY254P TNY254 NewOriginal Power Supply IC TNY254PN TNY254P TNY254 New
Original Power Supply IC TNY254PN TNY254P TNY254 New
 
Switches and LEDs interface to the 8051 microcontroller
Switches and LEDs interface to the 8051 microcontrollerSwitches and LEDs interface to the 8051 microcontroller
Switches and LEDs interface to the 8051 microcontroller
 
Logic families
Logic familiesLogic families
Logic families
 
PLC
PLCPLC
PLC
 
Logic families
Logic familiesLogic families
Logic families
 
Introduction to Integrated Circuits
Introduction to Integrated CircuitsIntroduction to Integrated Circuits
Introduction to Integrated Circuits
 
34866616-Relay.ppt
34866616-Relay.ppt34866616-Relay.ppt
34866616-Relay.ppt
 
Digital logic, an inverter or NOT gate
Digital logic, an inverter or NOT gateDigital logic, an inverter or NOT gate
Digital logic, an inverter or NOT gate
 

Recently uploaded

Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxakanksha16arora
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of PlayPooky Knightsmith
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 

Recently uploaded (20)

Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 

Relay interfacing with 8051

  • 1. RELAY INTERFACING WITH 8051 PRATIK PHADTE COURSE : ELECTRICAL AND ELECTRONICS ENGINEERING @pratikphadte19@gmail.com
  • 2. TOPICS • What`s a relay • Interfacing relay with 8051 • Assembly code for interfacing • C code for interfacing
  • 3. 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
  • 4. 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.
  • 5. 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 o 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.
  • 6. 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: org 00h setb P0.2 [output of port zero pin two is set to HIGH(one)] acall delay clr P0.2 [output of port zero pin two is set to LOW(zero)] END NOTE: delay code is not mentioned here
  • 7. C CODE FOR INTERFACING #include<reg52.h> sbit 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