MicroController Pros Home Page
My Account  Cart Contents  Checkout  
  Store » PCAM+ 8051 Tutorial 8 My Account  |  Cart Contents  |  Checkout   
Quick Find
 
Enter keywords to find the product you are looking for in the Quick Find field above

or use
Advanced Search
Categories
Accessory Boards->
8051->
ADI Blackfin
Arduino->
ARM->
Atmel AVR->
Cypress PSoC
Freescale->
FTDI->
Fujitsu
Locktronics
Maxim
Microchip PIC->
MIPS
National Semiconductor
Parallax->
Renesas->
Silicon Labs
ST Microelectronics->
Texas Instruments->
Tibbo->
Zilog
Books->
Displays->
E-Blocks
EEPROM/EPROM/FLASH
Embedded Ethernet->
Embedded Software->
I/O Modules->
Parts & Components->
Pick & Place Tools
Programmable Logic (PLD)
Prototype PCBs->
Robotics
ROM/Flash Emulators
Test & Measurement->
Tutorial CD-ROMs
Universal Programmers->
Wireless->
Information
Intro to Embedded Tools
Embedded News Digest
Useful Resources
Shipping & Returns
Warranty & Liability
Privacy Notice
Conditions of Use
Contact Us
PCAM+ 8051 Tutorial 8: TSOP1738 RC5 IR Receiver

Back to PCAM+ page.


Back to Chapter 7

TSOP1738 RC5 Interfacing with 8051 Microcontroller

The TSOP1738 is an Infrared receiver.

RC5 is the IR transmission protocol developed by Philips. This is used for remote controls of TVs and other equipment.

The PCAM+ kit is equipped with an on-board TSOP1738. The code below is used to decode the RC5 signal transmitted by the TV remote included PCAM+ product.

Start by wiring the following connections:

  • Connect Port pin P3.3 of the 89S52 microcontroller to the output pin of TSOP1738, which is marked as IR38 on the PCAM+ board.
  • Connect the row of 8 LEDs to the Port P2 pins (P2.0 to LED pin 1; P2.1 to LED pin 2; etc.).
This project will cause the the LEDs to display the binary value of the buttons pressed on the TV remote.

Use only remote that is supplied with the kit. Other remotes will not work.

Below is the source code you need to write in 8051IDE:

VAR1 equ 07h         ;Variable for delay
VAR2 equ 08h         ;Variable for delay
TEMP equ 10H         ;Temp variable
COUNT equ 11H        ;Count variable
ADDR equ 12H         ;Device address received from RC5
CMD equ 13H          ;Command value received from RC5
FLIP bit 00H         ;Flip bit
TOG bit 01H          ;Temp bit for flip
IR equ P3.3          ;IR Receiver connected to this pin

MOV SP,#60H          ;Stack pointer initialization
CLR TOG              ;Clear temp bit

MAIN:
       JB IR,$               ;Wait for first bit
       MOV VAR2,#6h
       Delay3024:
               MOV VAR1,#229           ;3.024mS delay
               DJNZ VAR1,$
       DJNZ VAR2,Delay3024

       MOV C,IR              ;Read Flip bit

       MOV FLIP,C
       CLR A
       MOV COUNT,#5          ;Count for address
       Get_Address:
               ACALL DELAY_1728ms
               MOV C,IR
               RLC a
               DJNZ COUNT,Get_Address
               MOV ADDR,A              ;Save the address
               CLR A

       MOV COUNT,#6         ;Count for Command
       Get_COMMAND:
               ACALL DELAY_1728ms
               MOV C,IR
               RLC A
               DJNZ COUNT,Get_COMMAND
               MOV TEMP,CMD            ;Save the old command
               MOV CMD,a               ;Save the new command
               MOV A,ADDR              ;Check for valid address
               CJNE A,#00,INVALID
               MOV A,TEMP
               CJNE A,CMD,VALID        ;Check for valid command

       INVALID:
               LJMP MAIN
       VALID:
               CLR A
               MOV C,FLIP
               RLC A
               MOV TEMP,A
               CLR A
               MOV C,TOG
               RLC A
               CJNE A,TEMP,VALID1
       SJMP INVALID
       VALID1:
               MOV C,FLIP
               MOV TOG,C
               MOV A,CMD
               CLR C
               MOV P2,CMD
       LJMP MAIN

DELAY_1728ms:
MOV VAR2,#6d
Loop1728:
MOV VAR1,#128              ;1.728mS delay for each bit
DJNZ VAR1,$
DJNZ VAR2,Loop1728
RET

Save this code, assemble it and flash it to the PCAM+ kit using the HandyProgUSB programmer.

Once done and with PCAM+ powered, you should see the row of LEDs light up the binary value for each button pressed on the TV remote.

Proceed to Chapter 9


Back to PCAM+ page.

Shopping Cart more
0 items
What's New? more
TFT Plus Professional Kit 2 - STM32: MMB+, Debugger, Pascal
TFT Plus Professional Kit 2 - STM32: MMB+, Debugger, Pascal
US$549.00
Bestsellers
01. 2x10 Pin male header, 2.54mm, 7.5mm plastic spacer
02. 2x5 (10-pin) 0.1" pitch IDC Connector Flat Ribbon Cable, 15cm
03. 2x5 (10-pin) 0.05" pitch IDC Connector Flat Ribbon Cable, 20cm
04. 2x10 (20-pin) 0.1" pitch IDC Connector Flat Ribbon Cable, 15cm
05. PIC16F877A-I/P Microcontroller, 40 DIP, 20 MHz
06. USB-to-Serial Cable: 5V TTL, Audio Plug Connector, Reverse RX/TX
07. LCD 4-mux, 7.1 digits x 7 segments, progress bar, arrows
08. Power Supply 3-12V DC, U.S. plug, 6 connection tips
09. 2x3 (6-pin) 0.1" pitch IDC Connector Flat Ribbon Cable, 15cm
10. PIC16F628A-I/P Microcontroller, 18 DIP, 20 MHz
Specials more
LED, Red 5mm 632nm, pack of 10
LED, Red 5mm 632nm, pack of 10
US$1.30
US$0.90
Reviews more
Flex Sensor 4.5"
crap... Design flaw where the metal terminals meet the plast ..
1 of 5 Stars!
  Thursday 24 April, 2014   List of all our Products

Copyright © 2003-2014 MicroController Pros LLC
Powered by osCommerce