Problem with TSOP 31238

Thread Starter

buzaiandras

Joined Jul 18, 2011
54
Hello,

I have a problem with my TSOP31238 38Mhz IR receiver and I can't figure out what is causing it.
When I press a button on the remote control the TSOP31238 sets the OUT pin to low (this is ok), and this properly generates an interrupt on the PIC16F688 micro-controller (port RA2). The problem is that at random times the TSOP31238 generates random pulses (without me pressing any button on the remote control).
I tried to isolate the IR receiver (I put it inside a cardboard box) but this only increased a little the time between the random pulses, the pulses did not disappeared.
I do limit the current to the TSOP by using a 220R resistor in series with the Vs of the TSOP, and I have placed a 4.7uF filtering capacitor between the GND and Vs of the IR receiver (I have also tried with bigger capacitors but the result was the same).

Also I have tried the circuit also by using the power from the PicKit2 programmer (connected through USB to my PC) and also by using a separate +5V regulated power source. The result was the same. The random pulses were generated by the TSOP without me pressing any button on the remote.

I have attached my schematics to this post.

Is there something wrong with my circuit? Or this random pulses are just a result of noise from the environment picked up by the TSOP IR receiver?
If this is caused by the noise of the environment (my office is in a basement, no wireless connection near by ...etc ... only my PC ) is this normal?

If so how can I eliminate this noise?


Thank you,

Buzai
 

Attachments

praondevou

Joined Jul 9, 2011
2,942
How long is a random pulse?

Could it be radiation from a nearby smps?

Did you detach the receiver from the PIC (deactivate the PIC), put the receiver in the box and measured the output? Are there still random pulses?

If all fails try to connect it to 3 AAA batteries, turn everything else off, without PIC, in the box and see if it still gives you the random pulses.
 

Thread Starter

buzaiandras

Joined Jul 18, 2011
54
The "pulses" are very short and they occur at a random time interval.
I don't have an oscilloscope to measure this more exactly. By pulses I mean that at random time intervals the Vout from the TSOP31238 has a small drop (ex: from 4.5V it drops to 4.0V).
I measure this using an analog volt-meter connected to GND and Vo of TSOP31238.
I just stare at the volt-meter and notice the fluctuation.
When the PIC is connected this fluctuation causes an interrupt.

The only SMPS nearby is the one from my PC power supply. But I tried the circuit in another room and the same thing happened.

When the PIC is disabled and the TSOP31238 is in a box, the pulses still occur (at bigger intervals) but the drop in voltage on Vout of TSOP is smaller. It is barely noticeable.

Is the circuit ok? Or is something wrong with it? Is the behavior of the TSOP31238 normal?


Thank you,

Buzai
 

praondevou

Joined Jul 9, 2011
2,942
I don't think it's normal. Did you try the battery option? I mean a completely isolated circuit. An oscilloscope would be really helpful, though.
 

ErnieM

Joined Apr 24, 2011
8,377
I think you are saying you see these pulses even when there is no PIC connected, with the TSDP enclosed inside a box? If that is true then that is weird...

I do see a few things...

I do not see a bypass cap on the PIC itself. 0.1 uF is typical.

The TSDP may need a tiny cap too, another 0.1. The larger the cap the lower frequency it works at, so using a large and small cap may help.

R9 is not needed as the TSDP has an internal pull up, though making the pull up resistor larger makes it easier to drive the output low so maybe leave it there for now.

I suspect if you had a scope you would be seeing a series of pulses output that have an average of 4V when you see the "small drop" from 4.5 to 4V.

That said, you should see a solid output when inside the box with no PIC connected. Remove the PIC and the display from +5V and see if that helps. Until you see that output solid no sense in connecting the rest.

(I hate simple problems like this!)
 

Thread Starter

buzaiandras

Joined Jul 18, 2011
54
Thank you for your responses.

I don't think it's normal. Did you try the battery option? I mean a completely isolated circuit. An oscilloscope would be really helpful, though.
Yes, I tried also with batteries.

I spent some time trying to figure out if the TSOP31238 IR receiver sends out "pulses" even when it is isolated (in the cardboard box and with the PIC removed from the circuit - only the TSOP31238 - tried both with AAA batteries and also with a regulated power supply).
I know that previously I said that when in isolation the "pulses" still occur and they are barely noticeable but now I think that my eyes played tricks on me.
Now I am pretty sure that the pulses are not generated when the TSOP31238 IR receiver is isolated. I think that when isolated the output is a solid stable one. Unfortunately until I get an oscilloscope I can't be 100% sure.
Until I get my hands on an oscilloscope lets assume that the TSOP is working properly (at least it seems so from my observations).


So what could be causing the PIC to generate an interrupt in this case?


I do not see a bypass cap on the PIC itself. 0.1 uF is typical.
Yes. I have now added a bypass cap but when the PIC is connected the random pulses still occur.


Any suggestions?

Thank you,

Buzai
 

praondevou

Joined Jul 9, 2011
2,942
The PIC itself can cause noise on the power supply. Sometimes people put ferrite beads near Vcc (in series with Vcc) to avoid distributing this noise onto the power supply lines.
But you already have a filter for the Vcc of your TSOP...the RC.

How far is the PIC away from the TSOP? I mean length of wire/trace from PIC interrupt pin to TSOP?

Can you post a picture of your layout?
 

Thread Starter

buzaiandras

Joined Jul 18, 2011
54
Hello,

The wire length between the PIC and the TSOP 31238 is about 1 inch.
I have attached a picture with my circuit (on a breadboard).
I still couldn't find a solution to this :(.

Thank you,

Buzai
 

Attachments

praondevou

Joined Jul 9, 2011
2,942
I still couldn't find a solution to this :(.
Sorry to hear that.
So it doesn't seem to be a noise problem. I am actually not sure if there should be absolutely no signal at the output. Sure, no datasheet is mentioning them, but in general the signal will be decoded afterwards. So even if there was noise it wouldn't cause any trouble in a commercial device, because the noise wouldn't be decoded and therefore no action would be taken.

If nobody comes along with a solution I will try to measure the TSOP signal in an old defective DVD player this evening.

If u are using a common IR remote to trigger your circuit you could leave the TSOP output on the interrupt input of the PIC but you could measure the burst length that comes in.. This way I think you would know if it was noise or a real signal.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
AFAIK the TSOP works very hard to keep stray pulses from the output. It has internal filtering and all sorts of good stuff to make it only respond to IR pulses of the proper frequency.

All I can think of is your TSOP is defective. Radio Shack sells a similar device if you want to try it for comparison.

Also, you might want to try using your PIC as a scope: light a LED for a short time when the TSOP output changes. Don't do any decoding of the pulses, just an "I saw a change" indication. You can see a LED flash even in an incredibly brief interval as short as 10 mS, though it will look "ON" with a square wave of that period.
 

gerty

Joined Aug 30, 2007
1,305
Have you checked the junction where r9 (pull up resistor) connects? If it's bad the input could be floating causing what you describe...
 

debjit625

Joined Apr 17, 2010
790
buzaiandras said:
I don't have an oscilloscope to measure this more exactly. By pulses I mean that at random time intervals the Vout from the TSOP31238 has a small drop (ex: from 4.5V it drops to 4.0V).
I measure this using an analog volt-meter connected to GND and Vo of TSOP31238.


Using an analog volt-meter you can't measure small voltage drops like that, but lets think for a moment if their is something like that ,then also it can't cause interrupt for the PIC as per I think a difference of (4.5 - 4.0) = 0.5V which will not give you a low logic level. Their must be something other going on, here is what you can try...

First disconnect everything except the PIC stuffs, then write a program which will not use any interrupt ,only an I/O port to sense a switch (high and low) and output the status using a LED now if it works then just replace the switch with your photo module ,if it doesn’t work then the problem is with your photo module change it with another one, but if it works then you have some problem with your interrupt code.

Many times when programming for interrupts people forget to clear the interrupt flag after interrupt happens and that makes programs to cause interrupts repeated times. Post your code so we could help.

If nothing works it means you have problem with your PIC, check the oscillator, reset circuit and your configuration bits, they may also cause the PIC to behave like that.

Good Luck
 

praondevou

Joined Jul 9, 2011
2,942
AFAIK the TSOP works very hard to keep stray pulses from the output. It has internal filtering and all sorts of good stuff to make it only respond to IR pulses of the proper frequency.
I have to agree with Ernie. I just measured an TSOP output from my DVD-player, no pulses at all, not with ambient light nor near cell phones, nothing.

So either it's a defective device, bad contact from TSOP to PIC, wrong interrupt handling or some extrem strong noise generating source in your neighborhood (not very likely, though)

What will you be using as the transmitter? As I said , if it's a common remote control, do some decoding in the PIC and you should be good.
 

Thread Starter

buzaiandras

Joined Jul 18, 2011
54
Hello,

Thank you all for your responses.

What will you be using as the transmitter? As I said , if it's a common remote control, do some decoding in the PIC and you should be good.
Yes, I will use a common remote control and the signal will be decoded in the PIC.
The problem is that I do not know if this is a normal TSOP 31238 behavior or is there something wrong with my circuit :). If this is normal for the TSOP then it is Ok because the noise will be filtered out when the decoding is performed. But if there is something wrong with the circuit I would like to fix that. Unfortunately I can't figure out what is wrong :(.

I also tried with several different TSOP31238 modules and several different PICs (16F688) but the behavior was the same :( so I would rule out a defective TSOP or a defective PIC.

I am attaching the PIC code, maybe there is a problem with the software.
I am using the internal oscillator of the PIC and I reset the interrupt flag after the interrupt occurs.
The code is written using HI-TECH PICC.

Rich (BB code):
#include <htc.h>
#include <pic.h>
#define _XTAL_FREQ 4000000


__CONFIG(CP_OFF & CPD_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_INTOSCIO & MCLRE_OFF & FCMEN_OFF & IESO_OFF);


void displayNumber(short nr);


unsigned short cnt = 1;
unsigned short nr = 0;


void main()
{
	// set all pins to digital
	ANSEL = 0b00000000;
	// set direction of all PORTC pins to OUT.
    TRISC = 0b00000000; 
	// set RA3/MCLR/VPP and RA2 to IN and the rest to OUT;
	TRISA = 0b00001100;
	// disable comparators
	CMCON0 = 0x07;


	// enable global and RA2 external interrupts;
	INTCON = 0b10010000;    

	// set PORTC and RA4 to 0
	PORTC = 0b00000000;
	PORTA = PORTA & 0b11101111;

	// interrupt on falling edge;
	INTEDG = 0;
	
    do
    {
			displayNumber(nr);
			__delay_ms(1);

    } while (1);

}


void interrupt isr() {

	if (INTF == 1) {
		__delay_ms(15);

		if (RA2 == 1) {
			// blink the "0" for 5 times when an interrupt occurs on RA2 then
			// increment the number to be displayed on the LED display
			for (int iii=0; iii<5; iii++) {
				displayNumber(0);
				__delay_ms(100);
				// reset PORTC;
				PORTC = 0b00000000;
				// reset RA4;
				PORTA = PORTA & 0b11101111;				
				__delay_ms(100);
			}

			if (cnt < 10) {
				nr ++;
			} else {
				nr = cnt % 10;
			}
			cnt++;
		}
	}

	// reset interrupt flags	
	INTF = 0;
	RAIF = 0;
}


void displayNumber(short nr) {
		
		// reset before new number is displayed;
		PORTC = 0b00000000;
		// reset RA4;
		PORTA = PORTA & 0b11101111;

		switch (nr) {
			case 0: RC0=1; RC1=1; RC2=1; RC3=1; RC4=1; RC5=1;
					break;
	
			case 1: RC1=1; RC2=1;
					break;
			
			case 2: RC0=1; RC1=1; RA4=1;  RC4=1; RC3=1;
					break;

			case 3: RC0=1; RC1=1; RC2=1;  RA4=1; RC3=1;
					break;

			case 4: RA4=1; RC1=1; RC2=1; RC5=1;
					break;

			case 5: RC0=1; RA4=1; RC2=1; RC3=1; RC5=1;
					break;
	
			case 6: RC0=1; RA4=1; RC2=1; RC3=1; RC4=1; RC5=1;
					break;
	
			case 7: RC0=1; RC1=1; RC2=1;
					break;

			case 8: RC0=1; RC1=1; RC2=1; RC3=1; RC4=1; RC5=1; RA4=1;
					break;

			case 9: RC0=1; RC1=1; RC2=1;  RA4=1; RC3=1; RC5=1;
					break;
		}
}

Thank you all,

Buzai.
 

Thread Starter

buzaiandras

Joined Jul 18, 2011
54
Hello,

No problem praondevou :)

But, I would greatly appreciate if there would be somebody who could look over the code to identify possible software faults that could produce the described behavior.

Many thanks :),

Buzai
 
Top