Jump to content
43oh

Consumer IR (CIR) capture


Recommended Posts

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...

post-2341-13513550038_thumb.png

post-2341-135135500649_thumb.png

Link to post
Share on other sites

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.

Link to post
Share on other sites

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.

Link to post
Share on other sites
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.

Link to post
Share on other sites
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

Link to post
Share on other sites
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

Link to post
Share on other sites

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...

post-2341-13513550066_thumb.png

 

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:

post-2341-13513550067_thumb.png

 

Here is a real remote using the Sony protocol - it is very close to the above idealized example.

post-2341-135135500664_thumb.png

 

Next post will explain how the pulse counts are sent to the PC. (hint)

Link to post
Share on other sites

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.

Link to post
Share on other sites
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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...