8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.



Similar documents
8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

8-bit Microcontroller. Application Note. AVR314: DTMF Generator

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

Tag Tuning/RFID. Application Note. Tag Tuning. Introduction. Antenna Equivalent Circuit

Quick Start Guide. CAN Microcontrollers. ATADAPCAN01 - STK501 CAN Extension. Requirements

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT89C5131A Starter Kit... Software User Guide

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

General Porting Considerations. Memory EEPROM XRAM

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

AVR241: Direct driving of LCD display using general IO. 8-bit Microcontrollers. Application Note. Features. Introduction AVR

8-bit Microcontroller. Application. Note. AVR204: BCD Arithmetics. Features. Introduction. 16-bit Binary to 5-digit BCD Conversion bin2bcd16

AVR442: PC Fan Control using ATtiny13. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

AVR120: Characterization and Calibration of the ADC on an AVR. 8-bit Microcontrollers. Application Note. Features. Introduction

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

8-bit Microcontroller. Application Note. AVR410: RC5 IR Remote Control Receiver

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

USB 2.0 Full-Speed Host/Function Processor AT43USB370. Summary. Features. Overview

How To Prevent Power Supply Corruption On An 8Bit Microcontroller From Overheating

Application Note. 8-bit Microcontrollers. AVR091: Replacing AT90S2313 by ATtiny2313. Features. Introduction

Application Note. Migrating from RS-232 to USB Bridge Specification USB Microcontrollers. Doc Control. References. Abbreviations

ATF15xx Product Family Conversion. Application Note. ATF15xx Product Family Conversion. Introduction

8-bit Microcontroller. Application Note. AVR461: Quick Start Guide for the Embedded Internet Toolkit. Introduction. System Requirements

Application Note. USB Mass Storage Device Implementation. USB Microcontrollers. References. Abbreviations. Supported Controllers

AVR444: Sensorless control of 3-phase brushless DC motors. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Two-wire Automotive Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 (1) AT24C16 (2)

Application Note. 8-bit Microcontrollers. AVR307: Half Duplex UART Using the USI Module

USB Test Environment ATUSBTEST- SS7400. Summary

2-wire Serial EEPROM AT24C1024. Advance Information

2-Wire Serial EEPROM AT24C32 AT24C64. 2-Wire, 32K Serial E 2 PROM. Features. Description. Pin Configurations. 32K (4096 x 8) 64K (8192 x 8)

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Step Motor Controller. Application Note. AVR360: Step Motor Controller. Theory of Operation. Features. Introduction

DIP Top View VCC A16 A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 I/O0 I/O1 I/O2 GND A17 A14 A13 A8 A9 A11 A10 I/O7 I/O6 I/O5 I/O4 I/O3. PLCC Top View VCC A17

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Table of Contents. Section 1 Introduction Section 2 Getting Started Section 3 Hardware Description

STK 500, AVRISP, AVRISP

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR318: Dallas 1-Wire master. 8-bit Microcontrollers. Application Note. Features. Introduction

Two-wire Serial EEPROM AT24C1024 (1)

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

Application Note. 8-bit Microcontrollers. AVR280: USB Host CDC Demonstration. 1. Introduction

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

8-bit RISC Microcontroller. Application Note. AVR335: Digital Sound Recorder with AVR and DataFlash

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

256K (32K x 8) OTP EPROM AT27C256R 256K EPROM. Features. Description. Pin Configurations

AT86RF230 (2450 MHz band) Radio Transceiver... User Guide

2-wire Serial EEPROM AT24C512

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

AVR1003: Using the XMEGA Clock System. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

HANDLING SUSPEND MODE ON A USB MOUSE

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR441: Intelligent BLDC Fan Controller with Temperature Sensor and Serial Interface. 8-bit Microcontrollers. Application Note.

AVR068: STK500 Communication Protocol. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

All-band AM/FM Receiver and Audio Amplifier IC U2510B

tinyavr Microcontrollers White Paper is the registered trademark of Atmel Corporation, 2325 Orchard Parkway, San Jose, CA Rev.

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

Tire pressure monitoring

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

AN974 APPLICATION NOTE

AVR040: EMC Design Considerations. 8-bit Microcontrollers. Application Note PRELIMINARY. Scope. 1 Introduction

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

AVR2004: LC-Balun for AT86RF230. Application Note. Features. 1 Introduction

Application Note Microcontrollers. Guidelines to Keep ADC Resolution within Specification. Introduction. ADC Resolution

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

Transcription:

AVR415: RC5 IR Remote Control Transmitter Features Utilizes ATtiny28 Special HW Modulator and High Current Drive Pin Size Efficient Code, Leaves Room for Large User Code Low Power Consumption through Intensive Use of Sleep Modes Cost Effective through Few External Components Figure 1. RC5 Transmitter R1 8-bit Microcontroller Application te C1 RESET PORT B XTAL1 ATtiny28 PA2 R2 D1 D2 IL R3 Q1 C2 XTAL1 PORT D GND Introduction Use of IR (infrared) light as a method for wireless communication has become popular for remote control applications. There are a number of different standards for such communication. In this application note the widely used RC5 coding scheme from Philips will be described, and a fully working remote control solution will be presented. This application will use the ATtiny28 AVR microcontroller for this purpose. This powerful unit contains a hardware modulator, a high current LED driver and interrupt options which makes it especially well suited for these kinds of applications. Figure 2. RC5 Frame Format St 1 St 2 Ctrl S 4 S 3 S 2 S 1 S 0 S 5 S 4 S 3 S 2 S 1 S 0 Figure 3. Bi-phase Coding 1 0 Rev. 1

Figure 4. Example of Transmission Figure 5. Signal Before and After Modulation HM 1 1 0 0 1 1 0 0 Carrier Frequency RC5 Coding Scheme ATtiny28: The Ideal Solution for Intelligent Remote Control Systems Implementation The RC5 code is a 14-bit word bi-phase coded signal (see Figure 2). The two first bits are start bits, always having the value 1. The next bit is a control bit, which is toggled every time a button is pressed on the remote control transmitter. This gives an easy way of determining whether a button is pressed and held down, or pressed and released continuously. Five system bits hold the system address so that only the right system responds to the code. Usually, TV sets have the system address 0, VCRs the address 5 and so on. The command sequence is six bits long, allowing up to 64 different commands per address. The bits are transmitted in bi-phase code (also known as Manchester code) as shown in Figure 3. An example where the command 0x35 is sent to system 5 is shown in Figure 4. te that Figure 3 and Figure 4 show the signal that enters the ATtiny28 hardware modulator. The actual signal emitted by the IR-LED will be modulated with a certain carrier frequency as shown in Figure 5. ATtiny28 is a low cost, high-performance 8-bit AVR RISC microcontroller with a number of features that makes it well suited for remote control applications. The built-in hardware modulator eases the task of generating the carrier frequency on which a data signal can be modulated. Frequency and duty-cycle are both easily changed by modifying the value residing in the Modulation Control Register MODCR. The high current driver on pin two of port A (PA2) is capable of driving a LED with a minimum of external components. This reduces size and system cost. In Power-down mode, the microcontroller can be configured to wake up on a low level from any pin on Port B. This provides an easy solution for waking up, scanning the keyboard, sending the command and returning to Power-down mode. This application implements an easy keyboard scanning routine using Port B and Port D. Figure 1 shows the complete schematics for a remote control transmitter. The 455 khz resonator gives the application a reliable and flexible clock base. The external LED driver circuit provides a constant current for the IR-LED. Resistor R3 determines the driver strength, and is in this application chosen to 7Ω giving a drive capability of approximately 100 ma. Higher resistor values will reduce current, and lowering the resistor value will increase driver strength. The diodes, D1 and D2, are present to ensure a close to constant driving current and to compensate for temperature variations in the transistor. 2 AVR415

AVR415 In this application note two different implementations will be presented; One low cost solution requiring only a minimum of external components, and one using an external resonator and circuitry for driving the LED. The supplied code will work for both designs. Low Cost Implementation For cost sensitive applications with high tolerance on accuracy, a solution utilizing the internally calibrated RC Oscillator of the ATtiny28 could be used. The high current drive capabilities of PA2 can sink the LED directly giving a solution with only a few external components as shown in Figure 6. By using an external resonator and a driver circuit for the LED, a more flexible solution is achieved. The main advantage is higher driver capabilities and higher frequency stability over voltage range. If however the receiver is self-synchronized, it will adapt to the changing frequency of the transmitter, and a solution using the internal RC Oscillator could be used with good results. Table 1. Components Type Comment R1 3 kω External pull-up resistor present to make the system less susceptible to external noise. Without this component, noise might Reset the microcontroller. R2 3 kω R3 7Ω R3= 0.7/I L C1 100 pf Resonator dependant C2 100 pf Resonator dependant D1 1N4148 Small signal diode D2 1N4148 Small signal diode D3 V R2 = IR LED CC min 2I Q1 BC807-40TD I MAX = 0,5A, β = 250-600 Xtal 455 khz Resonator Figure 6. Lowcost RC5 Transmitter L 1,4 β PORTB[0..7] D3 PA2 PORTD[0..3] GND 3

The Software Main The assembly code found in the AVR415.ASM file contains the latest RC5 Transmitter software. The main program flow is shown in the flowchart in Figure 7. The program execution can be divided into two routines. Both of them are interrupt driven, and use different Powerdown modes to reduce power consumption. The program is designed to use only one level of hardware stack, leaving two levels for user code. The main program loop is shown in Figure 7. First all registers are initiated; The hardware modulator is configured for correct frequency and duty-cycle. In this application 38 khz is used as the carrier frequency. This differs from the RC5 standard, which specifies 36 khz for the carrier wave. The RC5 signal will however be the same, and most standard RC5 Receivers should have no problem receiving and decoding the signal. Once the IO modules are initialized the purpose of the main loop is to decide what sleep mode to use after the next wake-up. Figure 7. Main Loop Flowchart Start Init Registers. Init Port Pins to Idle State. Enable IR Driver. Enable Hardware Modulator. Execute Interrupt Code Is Last Transmission Finished? Enable Low Level Interrupt. Enable Power-down Enable Idle Mode Enable Interrupts. Enter Sleep 4 AVR415

AVR415 The program execution can roughly be divided into two states: Transmitting a RC5 code and Waiting for a key to be pressed. While waiting for a key to be pressed, the ATtiny28 is put in Power-down mode. In this mode the current consumption for the device is at a minimum, and the wake-up time is slightly longer than for the Idle mode. Since the wake-up condition is caused by physically pressing a key, the longer wake-up time will not cause a noticeable delay in the system. Low Level Interrupt When the ATtiny28 is in Power-down mode, a low level on any of the Port B pins will generate a Low Level interrupt, waking the device and executing the code illustrated by the flowchart in Figure 8. The main purpose of this routine is to scan through the keyboard, and determine if a valid key is pressed. If two or more buttons are pressed simultaneously the routine returns the value 0xFF indicating an error. The checksum ensures that 63 of 64 combinations of row and column lines are high that only one unique combination, representing the key, is low. If only one key is pressed, the column and row bit pattern is decoded into a pointer, which is used to perform a look-up in the Command table. Further, the Low Level interrupt also controls the toggling of the control bit, indicating if a new instance of a command is present, or if the same command should be retransmitted. At the end of this routine, the hardware modulator is started preparing the transmission. 5

Figure 8. Low Level Interrupt Flowchart Low Level Interrupt A B Disable Low Level Interrupts Set Checksum = 193 Set Column = 1 Load Address to Start of Table. Add Pointer 2 (Word table) Activate Column Load Low Byte of Command. Load High Byte of Command. Select Next Column Wait for Signal Propagation Has Command Changed? Any Keys Pressed? Invert Toggle Bit Checksum += 8 Deselect Column Store Column Store Row Transfer Toggle Bit to Transmit Byte Next Column All Columns Tested? Is bit "1"? Checksum += 1 Select Next Bit Start Transmission by Starting Hardware Modulator. Load Number of Bits to Transmit. Reset Keyboard Has Entire Byte Been Tested? Save Command Pointer Load no Button (0xFF) Return Is Only Button Pressed (Checksum = 0x00)? Pointer + = 1 Shift Row Byte Right Is LSB of Row Byte "0"? Pointer + = 8 Is LSB of Column Byte "1"? Shift Column Byte Right A B 6 AVR415

AVR415 Timer Interrupt Routine Figure 9 shows the flowchart for the Timer Overflow interrupt. The main task of the Timer Interrupt routine is to keep track of the bit pattern that will be modulated on the IR- LED, i.e., make sure that the transmitted signal is in accordance with the bi-phase coding scheme. Once a complete frame has been transmitted, the routines also generate a necessary delay before a new transmission is to be started. Figure 9. Timer Overflow Interrup Flowchart Timer Interrupt Decrease Number of Bits to Transmit Have All Bits Been Transferred? Reload Timer with Number of 38 khz Pulses to Transmit Has Holdoff between Transmissions Occured? Is this Second Half of Bit Space? Disable Modulator Output Set Pointer = 0xFF ( Command) Stop Timer Key Pressed? Reload Counter to Give 12 ms Delay Shift Command Left (Select Next Bit to Transfer) Set Modulator to Transmit Bit Value on Next Interrupt Set Output to Invert om Next Interrupt (Transmit Second Half of Bit Space) Return Transmission Complete Return Transmission t Complete Summary This application note describes how to make a simple RC5 Transmitter. Due to the flexible hardware of the ATtiny28, other IR coding schemes could easily be implemented. It is also possible to change the duty cycle of the transmitted signal, further decreasing the power consumption and thus extending battery life. This application note acts as a foundation upon where the user can implement features giving a power efficient intelligent Remote Control Transmitter. 7

Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 e-mail literature@atmel.com Web Site http://www.atmel.com Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company s standard warranty which is detailed in Atmel s Terms and Conditions located on the Company s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel s products are not authorized for use as critical components in life support devices or systems. Atmel Corporation 2003. All rights reserved. Atmel and combinations thereof and AVR are the registered trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be the trademarks of others. Printed on recycled paper. 0M