Ultra-Low Power TV IR Remote Control

advertisement
Application Report
SLLA175 – October 2005
Ultra-Low Power TV IR Remote Control Transmitter
Neal Brenner .................................................................................................... AEC MSP430 Products
ABSTRACT
This application report describes how to create a low cost and low power IR remote
control featuring the new MSP430F2xx family of ultra-low power microcontrollers. The
transmitter design described in this report is completely interrupt driven and consumes
0.1µA while waiting for the user’s button-press. The software provided implements the
RC5 protocol on the MSP430F21x1, but can easily be modified to implement any other
IR standard on any MSP430.
1
Introduction
The low cost and low power MSP430-based TV IR remote control described in this application report
contains a minimum of external components. The design uses two Timer_A3 capture/compare blocks and
5 digital I/O ports of the MSP430F21x1 with less than 700 bytes of code. An external IR LED, transistor,
capacitor, 3V CR2032 Lithium coin cell battery, 3 diodes, 3 resistors, and 6 switches complete the system.
With this implementation, the MSP430 remains in LPM4 most of the time where the chip consumes 0.1
µA.
2
IR Remote Control Theory
A TV infrared remote control must receive user commands through button-presses and output the
appropriate IR signal through the air to an IR receiver. To allow the receiver to distinguish between the
remote’s IR signal and all the other sources of infrared light, IR remote controls modulate their signals,
usually between 30–60 kHz. In this application report, 40 kHz is used. A mark is defined as the presence
of a 40 kHz modulated IR signal and a space is the lack of an IR signal. The specific IR protocol defines
the how the series of marks and spaces translate to a user command
3
RC5 Protocol
The RC5 protocol is a type of Manchester encoded data packet. Manchester data is unique in that a data
is signified by a transition in the middle of the bit. A one is transmitted as a space-to-mark transition and a
zero as a mark-to-space transition. The RC5 IR packet consists of 14 bits: two start bits (S1, S0), one
control bit (C), five address bits (A4 to A0), and a six bit command code (C5 to C0). The entire 14-bit
packet is received MSB first, starting with two start bits.
Figure 1 shows the RC5 packet transmitted by the MSP430 through the IR LED. The start bits are always
transmitted as ones. The control bit toggles whenever a new key is received. The five address bits
represent 32 different potential addresses of the equipment for which the packet is intended. The six
command bits represent 64 commands that can be transmitted. The bit period for RC5 is 1.78 ms long,
with half of that period high and the other half low. The duration for the complete 14-bit packet is
approximately 25 ms.
SLLA175 – October 2005
Ultra-Low Power TV IR Remote Control Transmitter
1
www.ti.com
Clock Selection
CCR1
CCR0
25 us
0.9 ms
“1”
“1”
“0”
“0”
“1”
“0”
1.8 ms
S1
S0
Start
C
Control
A4
A3
A2
Address Code
A1
A0
C5
C4
C3
C2
C1
C0
Command Code
Figure 1. RC5 Data Packet Transmitted by the MSP430
4
Clock Selection
Figure 1 shows the timing required for an RC5 packet transmission. During a transmission, the 0.89ms
half bit time needs to be counted, and while transmitting a mark a 40 kHz PWM signal must be generated.
The MSP430F2xx family features an internal digitally controlled oscillator (DCO) that is stable without an
external crystal, allowing faster wake-up times from LPM4 (less than 1 µs) and lower overall system cost.
The CALDCO registers of the MSP430F2xx devices contain DCO calibration data for several operating
frequencies. The application described here uses the calibration data corresponding to a 1 MHz DCO
operating frequency. CALDCO_1MHZ and CALBC1_1MHZ contain the appropriate values for DCOCTL
and BCSCTL1 respectively.
To achieve the 40 kHz PWM output, Timer_A3 is used in Up Mode sourced by the DCO. A value of 24 in
CCR0 sets the period to 40 kHz. CCR1 determines the duty cycle. A lower duty cycle will extend battery
life, but the duty cycle must be long enough for the LED to adjust to it and the receiver to recognize it. A
value of 7 in CCR1 produces a 29% duty cycle.
When a mark is being transmitted Timer_A3 is configured to produce the 40 kHz PWM output as
described above and the TACCR0 interrupt is enabled. In order to move to the next half bit after 0.89 ms,
the number of TACCR0 interrupts must be counted. When a space is being transmitted TACCR0 is given
a value of resulting in an interrupt after 0.89 ms. The number of TACCR0 interrupts counted for a mark
and the value in TACCR0 for a space is dependent on the software overhead in between finishing a
mark/space and determining what the next half bit should be. The code supplied uses values to generate
0.89 ms marks and spaces.
2
Ultra-Low Power TV IR Remote Control Transmitter
SLLA175 – October 2005
www.ti.com
Demonstration Circuit
402Ω
R3
5Ω
R2
IR LED
200 µF +
P1.7/TA2/TDO/TDI
TEST
C1
0.1 µF
R6
P1.6/TA1/TDI
VCC
MMBT2222
P2.5
P1.5/TA0/TMS
VSS
P1.4/SMCLK/TCK
XOUT
47kΩ
XIN
RST/NMI
P2.0/ACLK
MSP430F2131
C2
3V
CR2032
P1.3/TA2
P1.2/TA1
P1.1/TA0
P1.0/TACLK
P2.1/INCLK
P2.4/CA1/TA2
P2.2/CAOUT/TA0
P2.3/CA0/TA1
1N4148
1N4148
1N4148
SW1
SW2
SW3
SW4
SW5
SW6
Figure 2. MSP430 TV IR Remote Control Schematic
5
Demonstration Circuit
The design trade-offs for the application include cost, size, battery life, and transmission distance. The
schematic for the MSP430 TV IR remote control is shown in Figure 2. The design uses a low cost CR2032
3V Lithium coin cell battery. Because the application requires short bursts of relatively high current and a
Lithium coin cell battery cannot source high levels of current, capacitor C1 is used to source the IR LED.
This capacitor is charged through resistor R3 and discharged through resistor R2 when the LED is turned
on.
SLLA175 – October 2005
Ultra-Low Power TV IR Remote Control Transmitter
3
www.ti.com
Current Consumption Analysis
The choice of values for C1, R2 and R3 is very important. R2 determines how much current will be drawn
through the LED, which determines the range of the remote control. R3 determines how fast capacitor C1
is charged. The value must be small enough to charge capacitor C1 in a reasonable amount of time, but
large enough to not overstress the battery. Depending on the values of R2 and R3, the capacitor must be
large enough to retain most of its charge through a complete data packet.
In this remote control demo application, the MSP430F2xx family eliminates the need for many external
components. Because the internal DCO is stable on its own, there is no need for an external crystal. Also,
the MSP430F2xx family devices have software-selectable internal pull-up and pull-down port pin resistors,
saving board space and cost.
6
Current Consumption Analysis
The CPU is active for less than 1,500 clock cycles each transmission. While running at 1 MHz this takes
less than 1.5 ms. During this time the MSP430 consumes approximately 170 µA. The rest of the time
during a transmission, approximately 114 ms (including delay to determine if button remains pressed), the
MSP430 operates in LPM0 consuming approximately 55 µA. While the MSP430 is waiting for the user to
press a button it is consuming only 0.1 µA (LPM4).
7
The Software
The software main loop flow is shown in Figure 3, and the transmission flow is shown in Figure 4.
Functionally identical C and assembly source code are available on the MSP430 website
When the MSP430 is started, the initialization routine is run to setup the MSP430 and peripherals
appropriately. Then the device enters LPM4. When it receives an interrupt from Port 1.0 or 1.1, the
MSP430 wakes up, debounces the button press, and determines which key has been pressed as
described in the application report titled Implementing an Ultralow-Power Keypad Interface With the
MSP430 (SLAA139).
After the MSP430 determines which button has been pressed, it loads the proper command bits then adds
the start, toggle and address bits. The marks and spaces are transmitted as described in the Clock
Selection section. While the mark or space is being transmitted, the MSP430 is operating in LPM0.
When all bits have been sent, the Timer A is reconfigured to produce an interrupt in 89 ms. When the
interrupt occurs the MSP430 determines whether a button is still being pressed. If it is still pressed, the
toggle bit is toggled and the command is transmitted again. If it is no longer pressed, the program returns
to the main loop where the MSP430 is placed in LPM4.
4
Ultra-Low Power TV IR Remote Control Transmitter
SLLA175 – October 2005
www.ti.com
The Software
Reset
Initialization And
Setup
Enter LPM4
P1.0, P1.1
Interrupt
From Key
Press
Clear Flag(s),
Clear LPM4
Disable Further
P1.x Interrupts
S/W Debounce
Scan Keypad
N
Key
Pressed?
Y
Determine Which
Key is Pressed
Setup For Key
Release
Transmit
Figure 3. Software Main Loop Flow
SLLA175 – October 2005
Ultra-Low Power TV IR Remote Control Transmitter
5
www.ti.com
References
Transmit
Determine
Command for Key
Pressed
Add Start Bits,
Toggle Bit, and
Address Bits to
Command
Initialize Bit
Counter
N
Y
Mark
Next?
Configure TA1 for
Reset/Set and
Configure TA for
40kHz PWM,
CCR0
Interrupt
Interrupt
Count
Done?
Y
Clear LPM0, Turn
Off Timer_A3
Enter LPM0
N
Reset TA1 to Low,
Configure TA for
0.89ms Interrupt,
Enter LPM0
CCR0
Interrupt
Clear LPM0, Turn
Off Timer_A3
Increment Bit
Counter
Last Bit
N
Sent?
Y
Set Timer_A3 for
89ms, Enter LPM0
Timer_A3
Interrupt
Clear LPM0, Stop
Timer_A3, Toggle
The Toggle Bit
Button
Y
Still
Pressed?
N
Return to Mainloop
Figure 4. Transmission Softwae Flow
8
References
1. Decode TV IR Remote Control Signals Using Timer_A3 (SLAA134)
2. Implementing an Ultralow-Power Keypad Interface With the MSP430 (SLAA139)
6
Ultra-Low Power TV IR Remote Control Transmitter
SLLA175 – October 2005
IMPORTANT NOTICE
Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications,
enhancements, improvements, and other changes to its products and services at any time and to discontinue
any product or service without notice. Customers should obtain the latest relevant information before placing
orders and should verify that such information is current and complete. All products are sold subject to TI’s terms
and conditions of sale supplied at the time of order acknowledgment.
TI warrants performance of its hardware products to the specifications applicable at the time of sale in
accordance with TI’s standard warranty. Testing and other quality control techniques are used to the extent TI
deems necessary to support this warranty. Except where mandated by government requirements, testing of all
parameters of each product is not necessarily performed.
TI assumes no liability for applications assistance or customer product design. Customers are responsible for
their products and applications using TI components. To minimize the risks associated with customer products
and applications, customers should provide adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right,
copyright, mask work right, or other TI intellectual property right relating to any combination, machine, or process
in which TI products or services are used. Information published by TI regarding third-party products or services
does not constitute a license from TI to use such products or services or a warranty or endorsement thereof.
Use of such information may require a license from a third party under the patents or other intellectual property
of the third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of information in TI data books or data sheets is permissible only if reproduction is without
alteration and is accompanied by all associated warranties, conditions, limitations, and notices. Reproduction
of this information with alteration is an unfair and deceptive business practice. TI is not responsible or liable for
such altered documentation.
Resale of TI products or services with statements different from or beyond the parameters stated by TI for that
product or service voids all express and any implied warranties for the associated TI product or service and
is an unfair and deceptive business practice. TI is not responsible or liable for any such statements.
Following are URLs where you can obtain information on other Texas Instruments products and application
solutions:
Products
Applications
Amplifiers
amplifier.ti.com
Audio
www.ti.com/audio
Data Converters
dataconverter.ti.com
Automotive
www.ti.com/automotive
DSP
dsp.ti.com
Broadband
www.ti.com/broadband
Interface
interface.ti.com
Digital Control
www.ti.com/digitalcontrol
Logic
logic.ti.com
Military
www.ti.com/military
Power Mgmt
power.ti.com
Optical Networking
www.ti.com/opticalnetwork
Microcontrollers
microcontroller.ti.com
Security
www.ti.com/security
Telephony
www.ti.com/telephony
Video & Imaging
www.ti.com/video
Wireless
www.ti.com/wireless
Mailing Address:
Texas Instruments
Post Office Box 655303 Dallas, Texas 75265
Copyright  2005, Texas Instruments Incorporated
Download