`
`
`
`
`
`User Interface - Infrared Learner
`(Remote Control)
`
`AN2092
`Author: Mehmet Zeki SONMEZ
`Associated Project: Yes
`Associated Part Family: CY8C25xxx, CY8C26xxx
`GET FREE SAMPLES HERE
`Software Version: NA
`Associated Application Notes: None
`
`Application Note Abstract
`This project allows you to copy an IR signal from a remote controller to the RAM address of PSoC® and then transmit it later.
`It will work for most remote control applications such as TVs, VCDs, DVDs, etc. Once you understand, you’ll be able to teach
`different remote-controller functions to the IR learner and combine them in one device. In this project the PSoC device can
`learn one function. For example, TV OFF.
`Required Parts:
`(cid:131) 1 x IR Receiver Module (38 kHz): One of the following can be used. (fo=38 kHz)
`(Tested, OK) (Recommended)
`(cid:137) Vishay / Telefunken TSOP1238 or TSOPxx38
`(cid:137) Sanyo SPS-440
`
`
`
`
`(Tested, OK)
`(cid:137) Sharp IS1U60 / IS1U60L
`
`
`
`(Not Tested, Probably OK)
`(cid:137) GP1U58X
`
`
`
`
`(Not Tested, Probably OK)
`(cid:137) Any Other Module with fo=38 kHz and inverted output
`(cid:131) 1 x NPN Transistor: General Purpose NPN Transistor (ex: BC556, 2N2222)
`(cid:131) 1 x LED
`(cid:131) 1 x IR LED
`(cid:131) 3 x 1 kOhm Resistor, 1x100 Ohm Resistor
`(cid:131) 1 x 100n CAPACITOR
`(cid:131) 2 x PUSH BUTTON or SWITCH
`
`
`VCD, etc. remote controllers are appropriate with the IR
`receiver module.
`
`
`Introduction
`There are two main stages in this project. The first of
`these stages is capturing/copying the signal and the
`second is transmitting the captured signal.
`Before explaining these stages, the theory of operation will
`be described.
`The IR receiver module produces a high level voltage (5V)
`when there is no incoming signal. When a signal has just
`come in, the IR receiver module will produce the same but
`inverted output of the incoming signal. Note that this signal
`has to operate within the defined limits of IR receiver
`module specified in the data sheet. Generally, TV, DVD,
`
`November 11, 2002
`
`Document No. 001-41063 Rev. **
`
`1
`
`[+] Feedback
`
`Roku EX1013
`U.S. Patent No. 7,589,642
`
`
`
`AN2092
`
`Figure 2: Process Flow
`
`The frequency of the IR signals from remote controllers is
`generally in the range of 38 kHz. Transmitting a 38 kHz
`signal in some limits (generally 300-800 microseconds)
`will produce a low level output (0V) in the receiver module.
`The objective is to capture the low level (0V) and high
`level (5V) signals and then transmit them to the target
`device (TV) with a frequency of 38 kHz.
`Capturing IR Signal (First Phase)
`The objective of this phase is to count every small duration
`(26.3 microseconds in this project) of the incoming signal
`until it changes its state. Then store the value of the
`counter to the RAM address.
`Figure 1: Example Signal Received from the IR Receiver
`Module
`
`
`
`26.3 us
`(Sampling Period)
`
`We should see the counter value at the end of the high
`level signal to be 600 us / 26.3 us = 22. The counter will
`keep the value (22) = 16h and store it to the RAM address.
`We should see the counter value at the end of the low
`level signal to be 400 us / 26.3 us = 15 = 0Fh.
`If the counter reaches FFh, the capturing process will end.
`If the counter is FFh, the duration of low level or high level
`signal will be = 255*26.3 us = 6.7 milliseconds, which is
`enough for us to end the process because standard TV
`remote controls don’t send a signal with a pulse width of
`6.7 miliseconds or greater.
`A detailed description for assembler codes is included in
`the assembler file (main.asm) in the project.
`If you teach the IR signal and want to teach another signal
`you must reset the system by pushing on the button that is
`connected to the Xres pin. See for the schematic at the end
`of this document for details.
`
`
`
`November 11, 2002
`
`Document No. 001-41063 Rev. **
`
`2
`
`[+] Feedback
`
`
`
`AN2092
`
`As shown in Figure 5, the first data of the incoming signal
`(first low level) is written to RAM address 0x0B(11). Then,
`the high level, then the low level… is written to the next
`RAM address until a value of FFh for the counter has
`occurred. This occurs when
`the
`incoming signal
`is
`stopped.
`Transmitting Captured Signal
`(Second Phase)
`As described in the introduction section, logic 1 can be
`sent by 38 kHz pulses.
`Figure 6: Logic 1, 38 kHz Pulses
`
`Logic 1
`
`Logic 0
`
`f=38 kHz
`
`
`38 kHz pulses can be achieved by simple code as follows
`(detailed description is in main.asm):
`G_38KHZ:
`
`
`
`mov
`A,4h
`
`mov reg[PRT2DR],A
`mov
`[COUNTER1],[COUNTER2] ;No mean
`mov
`[COUNTER1],[COUNTER2] ;No mean
`mov
`[COUNTER1],[COUNTER2] ;No mean
`mov
`A,0h
`
`
`mov reg[PRT2DR],A
`
`mov
`[COUNTER1],[COUNTER2] ;No mean
`ADD
`[COUNTER1],8 ;No mean
`dec
`[TEMP2]
`
`
`
`JNZ
`G_38KHZ
`
`
`
`
`The main objective of this stage is to create code that
`consumes 26.3 microseconds and repeat it until the value
`of the RAM address (the counter value stored in the
`previous stage) is zero. (We will decrement the value
`inside the RAM address until it is zero).
`Because each G_38KHZ loop lasts 26.3 microseconds,
`we do not need to add extra time consuming code when
`sending logic 1s. This is why we sample each signal with
`26.3 microseconds. (1/38KHZ=26.3 microsecond!)
`We will add time consuming code when sending logic 0’s.
`(Actually we don’t send anything; logic 0 is 0 volts. We
`make a delay of 26.3 microseconds.)
`
`
`
`Captured Signal at RAM Address
`The captured signal will be stored in RAM addresses by
`using the Index register (X). Consider the following
`incoming signal from the IR receiver module:
`Figure 3: Incoming Signal
`
`1
`
`2
`
`3
`
`4
`
`5
`
`6
`
`400 us
`
`200 us
`
`26.3 us
`(Sampling Period)
`
`600 us
`
`200 us
`
`500 us
`
`1
`
`2
`
`3
`
`4
`
`5
`
`6
`
`
`
`X
`
`
`Figure 4: Counter Values
`
`Counter = 600 us / 26.3 = 16h
`
`Counter = 400 us / 26.3 = 0Fh
`
`Counter = 200 us / 26.3 = 07h
`
`Counter = 200 us / 26.3 = 07h
`
`Counter = 500 us / 26.3 = 13h
`
`Counter = FFh (pulse width >
`6.7 ms incoming signal has
`stopped)
`
`
`Figure 5: Address Writes
`
`16h
`0Fh
`
`07h
`
`07h
`
`13h
`
`FFh
`
`0x0B
`0x0C
`
`0x0D
`
`0x0E
`
`0x0F
`
`0x10
`
`1
`2
`
`3
`
`4
`
`5
`
`6
`
`Low Level
`High Level
`
`Low Level
`
`High Level
`
`Low Level
`
`High Level
`
`
`
`
`
`
`
`November 11, 2002
`
`Document No. 001-41063 Rev. **
`
`3
`
`[+] Feedback
`
`
`
`AN2092
`
`Figure 7: Process Flow
`
`Note the following:
`(cid:131) Because the output of the IR receiver module is
`inverted, we will send logic 1 for duration of low-level
`values in the RAM and we will send logic 0 for
`duration of high-level values in the RAM. In brief, we
`send Logic 1 for low-level signals and we send Logic
`0 for high-level signals.
`(cid:131) When you press the button connected to P1[0], the
`captured signal will be sent. (GPIO interrupt is used
`for this button.)
`
`
`
`
`
`November 11, 2002
`
`Document No. 001-41063 Rev. **
`
`4
`
`[+] Feedback
`
`
`
`Figure 8: Transmitting Received Signal to Target Device
`
`AN2092
`
`
`
`1
`
`2
`
`3
`
`4
`
`5
`
`6
`
`400 us
`
`200 us
`
`600 us
`
`200 us
`
`500 us
`
`Received Signal
`
`Transmitting signal from
`PSoC to the target device
`
`38 kHz pulses, period = 26.3 microsecond period
`
`Note that the transmitting signal of the received signal is inverted because the
`output of the receiver module is inverted. Therefore the transmitting signal is the
`exact copy of the remote controller (teacher).
`
`
`
`November 11, 2002
`
`Document No. 001-41063 Rev. **
`
`5
`
`[+] Feedback
`
`
`
`Schematic
`Configuration:
`Configure System Clock to 3 MHz.
`Configure Port1_2 as input.
`Configure Port1_0 as input and configure interrupt type as RISING EDGE in pinout view.
`Configure Port2_1 as output.
`Configure Port2_2 as output.
`(cid:131) 1 x IR Receiver Module (38 kHz): One of the following can be used. (fo=38 kHz)
`(Tested, OK) (Recommended)
`(cid:137) Vishay / Telefunken TSOP1238 or TSOPxx38
`(cid:137) Sanyo SPS-440
`
`
`
`
`(Tested, OK)
`(cid:137) Sharp IS1U60 / IS1U60L
`
`
`
`(Not Tested, Probably OK)
`(cid:137) GP1U58X
`
`
`
`
`(Not Tested, Probably OK)
`(cid:137) Any Other Module with fo=38 kHz and inverted output
`
`
`
`AN2092
`
`
`
`November 11, 2002
`
`Document No. 001-41063 Rev. **
`
`6
`
`[+] Feedback
`
`
`
`AN2092
`
`About the Author
`Name: Mehmet Zeki SONMEZ
`Title: Yeditepe University: Electrical &
`Electronics Engineering Student &
`Student Assistant (last year).
`Background: M.Zeki Sonmez is interested in
`design of both analog and digital
`(including microcontrollers) circuits.
`In the near future his area of interest
`will be RF Identification.
`Contact: zeki@sonmezticaret.com
`mzsonmez@hotpop.com
`http://electronicsclub.cjb.net
`
`
`
`
`
`
`
`
`
`
`
`
`
`
`In March of 2007, Cypress recataloged all of its Application Notes using a new documentation number and revision code. This new documentation
`number and revision code (001-xxxxx, beginning with rev. **), located in the footer of the document, will be used in all subsequent revisions.
`PSoC is a registered trademark of Cypress Semiconductor Corp. "Programmable System-on-Chip," PSoC Designer, and PSoC Express are trademarks
`of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners.
`
`
`
`
`
`
`Cypress Semiconductor
`198 Champion Court
`San Jose, CA 95134-1709
`Phone: 408-943-2600
`Fax: 408-943-4730
`http://www.cypress.com/
`
`
`© Cypress Semiconductor Corporation, 2002-2007. The information contained herein is subject to change without notice. Cypress Semiconductor
`Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any
`license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or
`safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as
`critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The
`inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies
`Cypress against all charges.
`This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide
`patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a
`personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative
`works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress
`integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
`Code except as specified above is prohibited without the express written permission of Cypress.
`Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT
`NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the
`right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or
`use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a
`malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems
`application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
`Use may be limited by and subject to the applicable Cypress software license agreement.
`
`November 11, 2002
`
`Document No. 001-41063 Rev. **
`
`7
`
`[+] Feedback
`
`