1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

Infrared Receiver Interfacing 1.0

Interfacing Infrared Receiver (TSOP 1738) with 8051 microcontroller

  1. Binu
    This section describes how to interface an Infrared Receiver (TSOP 1738) to the microcontroller AT89S51/52
    and to control 8 LED's through a RC5 Remote control.
    [​IMG]
    The circuit explains how to connect an Infrared Sensor to the Microcontroller, the program to control 8 devices through a standard RC5 Remote control.

    Program
    Code (Text):
    1. INCLUDE reg_51.pdf
    2.  
    3. INPUT  EQU    P3.2    ; Port3,Bit2 is used as input. The demodulated signal    
    4.                                   ; with active low level is connected to this pin                            
    5. RB0    EQU    000H    ; Select Register Bank 0
    6. RB1    EQU    008H    ; Select Register Bank 1  ...poke to PSW to use
    7.                                
    8.                                  
    9. DSEG            ; This is internal data memory
    10. ORG    20H    ; Bit adressable memory
    11.  
    12. FLAGS:  DS      1
    13. CONTROL BIT    FLAGS.0  ; toggles with every new keystroke
    14. NEW    BIT    FLAGS.1  ; Bit set when a new command has been received
    15.  
    16.  
    17. COMMAND: DS    1      ; Received command byte
    18. SUBAD:  DS      1      ; Device subaddress
    19. TOGGLE: DS    1        ;Toggle every bit
    20. ANS: DS        1        ;
    21. ADDR:        DS        1
    22. STACK:  DS      1      ; Stack begins here
    23. CSEG            ; Code begins here
    24. ;---------==========----------==========---------=========---------
    25. ;              PROCESSOR INTERRUPT AND RESET VECTORS
    26. ;---------==========----------==========---------=========---------
    27.         ORG    00H    ; Reset
    28.         JMP    MAIN
    29.         ORG    0003H  ; External Interrupt0
    30.         JMP    RECEIVE    
    31.      
    32. ;---------==========----------==========---------=========---------
    33. ;  ---------==========----------==========---------=========---------
    34. ;  Interrupt 0  routine
    35. ;  ---------==========----------==========---------=========---------
    36. RECEIVE:
    37.                       CPL P2.2
    38.               MOV  2,#235              ; Time Loop (3/4 bit time)
    39.             DJNZ 2,$                  ; Waste Time to sync second bit
    40.                 MOV  2,#235              ; Time Loop (3/4 bit time)
    41.             Djnz 2,$                  ; Waste Time to sync second bit
    42.       Mov  2,#134              ; Time Loop (3/4 bit time)
    43.             Djnz 2,$                  ; Waste Time to sync second bit            
    44.       clr        a
    45.       mov        r6,#07h
    46.  
    47. pol1:        mov        c,Input
    48.       rlc        a
    49.       Mov  2,#235              ; Waste time for next BIT
    50.             Djnz 2,$  
    51.       Mov  2,#235              ; Time Loop (3/4 bit time)
    52.             Djnz 2,$                  ; Waste Time to sync second bit
    53.       Mov  2,#235              ; Time Loop (3/4 bit time)
    54.             Djnz 2,$                  ; Waste Time to sync second bit
    55.       Mov  2,#105              ; Time Loop (3/4 bit time)
    56.             Djnz 2,$                  ; Waste Time to sync second bit
    57.       djnz        r6,pol1
    58.       MOV SUBAD,A
    59.      
    60.       mov        r6,#06h
    61. pol2:      
    62.       mov        c,Input
    63.       rlc        a
    64.  
    65.       Mov  2,#235              ; Waste time for next BIT
    66.             Djnz 2,$  
    67.       Mov  2,#235              ; Time Loop (3/4 bit time)
    68.             Djnz 2,$                  ; Waste Time to sync second bit
    69.       Mov  2,#235              ; Time Loop (3/4 bit time)
    70.             Djnz 2,$                  ; Waste Time to sync second bit
    71.       Mov  2,#105              ; Time Loop (3/4 bit time)
    72.             Djnz 2,$                  ; Waste Time to sync second bit
    73.       djnz        r6,pol2
    74.       Mov  COMMAND,A            ; Save Command at IRData memory
    75.      
    76.  
    77.       MOV A,SUBAD
    78.       MOV ADDR,A
    79.       ANL A,#0FH
    80.       MOV SUBAD,A
    81.       CJNE A,#03H,ZXC1
    82.       MOV A,COMMAND
    83.       CPL A
    84.       MOV COMMAND,A
    85.       AJMP ASZ
    86. ZXC1:        MOV A,SUBAD
    87.       CJNE A,#00H,ANSS
    88.       AJMP ASZ
    89.  
    90. ASZ:        MOV A,ADDR
    91.       ANL A,#20H
    92.       MOV TOGGLE,A
    93.       CJNE A,ANS,ANSS
    94.       AJMP WAR
    95. ANSS:        JMP ANS1      
    96. WAR:      
    97.      
    98.               MOV A,COMMAND
    99.               CJNE A,#01H,DSP1
    100.               CPL P0.0
    101. DSP1:        CJNE A,#02H,DSP2
    102.               CPL P0.1
    103. DSP2:        CJNE A,#03H,DSP3
    104.               CPL P0.2
    105. DSP3:        CJNE A,#04H,DSP4
    106.               CPL P0.3
    107. DSP4:        CJNE A,#05H,DSP5
    108.               CPL P0.4
    109. DSP5:        CJNE A,#06H,DSP6
    110.               CPL P0.5
    111. DSP6:        CJNE A,#07H,DSP7
    112.               CPL P0.6
    113. DSP7:        CJNE A,#08H,DSP8
    114.               CPL P0.7
    115. DSP8:        CJNE A,#0CH,DSP9
    116.               MOV P0,#0FFH
    117. DSP9:      
    118.                      
    119.               MOV ANS,TOGGLE
    120.               MOV A,ANS
    121.               CPL ACC.5
    122.               MOV ANS,A
    123.               SETB  NEW          ; Set flag to indicate the new command
    124.  
    125. ;################################################################      
    126. ANS1:  
    127.       RETI
    128.      
    129. ;  ---------==========----------==========---------=========---------
    130. ;  Main routine. Program execution starts here.
    131. ;  ---------==========----------==========---------=========---------
    132. MAIN:
    133.       MOV SP,#60H
    134.  
    135.       SETB  EX0                          ; Enable external Interrupt0
    136.   CLR    IT0                          ; triggered by a high to low transition
    137.      
    138.       SETB EA; /* Enable global interrupt */
    139.   MOV ANS,#00H                ;clear temp toggle bit
    140.          
    141.       CLR  NEW
    142.              
    143.      
    144. LOO:      
    145.       JNB NEW,LOO
    146.       CLR NEW
    147.       AJMP LOO            
    148.      
    149.       END
Loading...