oPossum 1,083 Posted May 26, 2011 Share Posted May 26, 2011 The following posts describe a simple method of CIR capture that can be done with almost any MSP430. The prototype shown uses the Launchpad with a MSP430G2211. This device that will show in detail the signal sent by IR remote controls. It measures the carrier frequency, on duration, off duration, and pulse count per burst. The Launchpad fitted with a MSP430G2211 running at 1 MHz sends all this information to a PC where a Windows program is used for graphic display. Capture is done in real time and there is no limit to the duration. The following screen captures are from a remote using RC5 and another using NEC protocol. The top line shows the carrier frequency and a summary of the first 300 milliseconds. The following lines show the details - on duration, off duration, and pulse count. How does a 1 MHz G2211 do this? More info soon... Kman 1 Quote Link to post Share on other sites
oPossum 1,083 Posted May 26, 2011 Author Share Posted May 26, 2011 To measure the CIR carrier frequency, each individual pulse of IR must be detected. Common IR demodulator modules can not do this - they respond to a burst of IR, not each pulse. There are parts made for this specific application such as the Vishay TSOP98200 and TSOP98260. Unfortunately these parts are difficult to obtain. There are general purpose IR detectors like the Fairchild QSE159 and Osram SFH5140, but they require 5 volts. A photodiode and a transimpedance amplifier works well, but requires careful construction (not a breadboard) to work well. I used an ordinary IR LED as a detector. Here is a video showing how it works... Here is the code... #include "msp430g2211.h" main(void) { volatile unsigned d; unsigned n, p; P1DIR = 0xDA; // Setup I/O P1REN = 0x25; // Pullup on P1.0 - counter input P1OUT = 0x07; // Ground on P1.3 - IR LED ground P1SEL = 0x11; // Enable external counter input TACTL = 0x0024; // Continuous count up, no prescale p = 0; // Reset previous count for(; { n = TAR; // Get current count if(n != p) { // Compare to previous P1OUT |= 0x40; // Turn on green LED if count has changed } else { P1OUT &= ~0x40; // Turn off green LED if count is the same } p = n; // Set previous count to current count d = 10; // Wait a while do { --d; } while(d); // } } Measuring the carrier frequency requires counting pulses in a specific time period. Next post will show how that is done. RobG 1 Quote Link to post Share on other sites
bluehash 1,581 Posted May 26, 2011 Share Posted May 26, 2011 Thanks Opossum. I had no idea that a TX'mitting IR LED and be used as a receiver as well. I'm going to paste back the Video post. Just a bit mis-understanding, but don;t worry about it. Quote Link to post Share on other sites
cde 334 Posted May 26, 2011 Share Posted May 26, 2011 Thanks Opossum. I had no idea that a TX'mitting IR LED and be used as a receiver as well. I'm going to paste back the Video post. Just a bit mis-understanding, but don;t worry about it. Regular leds can also be used like photodetectors. bluehash 1 Quote Link to post Share on other sites
oPossum 1,083 Posted May 26, 2011 Author Share Posted May 26, 2011 There is a cool trick that can be used with LEDs (IR and visible) when repetition rate is low ( a few Hz at most). Charge the LED with reverse bias (diodes have a small capacitance) and then measure the time it takes for the charge to drop below the logic threshold of the micro. The small photocurrent generated by the LED discharges the small charge stored in it. The shorter the discharge time, the brighter the light. Elegant and effective. jbremnant, bluehash and RobG 3 Quote Link to post Share on other sites
Mac 67 Posted May 26, 2011 Share Posted May 26, 2011 There is a cool trick that can be used with LEDs (IR and visible) when repetition rate is low ( a few Hz at most). Charge the LED with reverse bias (diodes have a small capacitance) and then measure the time it takes for the charge to drop below the logic threshold of the micro. The small photocurrent generated by the LED discharges the small charge stored in it. The shorter the discharge time, the brighter the light. Elegant and effective. I've done this on a PIC project to detect ambient light. Purpose was to dim a clock display at night and brighten it during the day. The only disadvantage is tying up two pins. Quote Link to post Share on other sites
Mac 67 Posted May 26, 2011 Share Posted May 26, 2011 There are parts made for this specific application such as the Vishay TSOP98200 and TSOP98260. Unfortunately these parts are difficult to obtain. What do you mean by "difficult to obtain"? Does it have something to do with supply or with your particular location (you didn't post location info')? I received TSOP4838 samples from Vishay last year without problem. Regards, Mike Quote Link to post Share on other sites
oPossum 1,083 Posted May 26, 2011 Author Share Posted May 26, 2011 No stock at Digikey, Mouser, Newark, Future, Arrow or Avnet. I don't sample parts that I can't buy. Quote Link to post Share on other sites
Mac 67 Posted May 26, 2011 Share Posted May 26, 2011 Just looked up TSOP4836 (36-kHz) and TSOP4838 (38-kHz) on Mouser and both are available (single quantity, $1.10 and $0.95, respectively). Perhaps it's just the particular part numbers you're looking for that are difficult to obtain. Quote Link to post Share on other sites
oPossum 1,083 Posted May 26, 2011 Author Share Posted May 26, 2011 Yes, most TSOPxxxx demod modules are readily available. It is just the code learning modules that are not in stock anywhere. Quote Link to post Share on other sites
Mac 67 Posted May 26, 2011 Share Posted May 26, 2011 Yes, most TSOPxxxx demod modules are readily available. It is just the code learning modules that are not in stock anywhere. Thank you for your patience. Looking at the TSOP98200 data sheet, I can see now that there's a significant difference in the output signal of these "code learning" modules which allows you to measure frequency. Exactly what you were saying but it must have gone over my head. My apologies Sir... Cheerful regards, Mike Quote Link to post Share on other sites
oPossum 1,083 Posted May 27, 2011 Author Share Posted May 27, 2011 A typical frequency counter will count cycles for a period of one second and display the resulting count. This will not work for measuring the IR remotes's carrier frequency because the carrier is being keyed on and off (OOK - on off keying). A much shorter gate time is required to get a proper measurement. A 100 us gate time is used as shown in this diagram... The first and last non-zero counts will be excluded from the carrier frequency calculation because the carrier was probably not on for the entire period. The inner counts are summed and the period durations are also summed. The carrier frequency can then be calculated as: sum of counts / sum of periods For this example: 20 counts / .0005 seconds = 40000 Hz The period of the carrier is simply the reciprocal: 500 us / 20 counts = 25 us To determine the carrier on duration for the first and last period, the pulse count is multiplied by the pulse period. So the first period with one pulse has a duration of 25 us, and the last period with three pulses has a duration of 75 us. So the total duration of the burst is 25 + (100 * 5) + 75 = 600 us This will be shown like this: Here is a real remote using the Sony protocol - it is very close to the above idealized example. Next post will explain how the pulse counts are sent to the PC. (hint) Quote Link to post Share on other sites
Mac 67 Posted May 27, 2011 Share Posted May 27, 2011 May I ask what is the purpose of your CIR capture device, please? Is it to help you identify an unknown protocol being used by a remote control? Quote Link to post Share on other sites
fj604 34 Posted May 31, 2011 Share Posted May 31, 2011 I have made some code for AVR Attiny2313 that could read NEC and Sony remotes. A version for MSP430 is near the top of my todo list - as soon as I confirm that the 38kHz IR detector that I have can work off 3.3V, or find another one that does. The details of many CIR protocols are here: http://www.sbprojects.com/knowledge/ir/ Each one will need a different state machine to decode. Quote Link to post Share on other sites
oPossum 1,083 Posted May 31, 2011 Author Share Posted May 31, 2011 May I ask what is the purpose of your CIR capture device, please? Is it to help you identify an unknown protocol being used by a remote control? It provides all the necessary info needed to reproduce a remote's transmission or respond to a remote control. So, if you want to make your own remote or make something that responds to an existing remote, then this device will provide essential information. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.