This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Removing noise from TSOP1738 IR Receiver

I am trying to implement IR reception using TSOP1738, more specifically Vishay's SM0038.

I have set the GPIO pin to call an interrupt whenever there is any change in the GPIO pin. The problem is that, the TSOP generates some random pulse and so, the interrupts gets called, even if there is no IR signal. I tried changing TSOP, but still the TSOP generate some random pulse. The DK is connected to PC via USB, and power is taken from the PC. When I try to connect the DK to power bank, the rate of interrupt call is getting reduced considerably.

I have connected the TSOP directly to the GPIO pin, without any capacitor or resistor added to the circuit.

So the problem is the TSOP generates random pulses. How can I solve it?

Here is the code I've written. Can I make the interrupt sensitive to some range of voltage change?

void tsop_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
	printf("\ntsop pin handler working\n");
}

static void gpiote_init(uint32_t tsop_pin)
{
	uint32_t gpiote_event_addr;
	if(!nrf_drv_gpiote_is_init())
	{
    err_code = nrf_drv_gpiote_init();
	}
	
	nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
	config.pull = NRF_GPIO_PIN_PULLUP;
	
	err_code =  nrf_drv_gpiote_in_init(tsop_pin, &config, tsop_pin_handler);
	nrf_drv_gpiote_in_event_enable(tsop_pin, true);

}

Please help

  • Hello Insaf

    In the datasheet for the TSOP1738 there is a recommended reference schematic where a 4.7 uF capacitor and a 100 ohm resistor is included to reduce power supply disturbances. I would recommend you try adding the components to try to filter out the unwanted pulses you are seeing.

    Normal GPIO pins are not level sensitive beyond sensing level high or low, for this you would have to use a comparator to trigger at a certain voltage level, or use an ADC and analyze its results.

    Another possibility, if the random pulses have a short duration, is to use the GPIO to trigger a timer with a duration longer than the random pulses. Then make a second check of the GPIO level. If the GPIO level is still high after the timer expires, you can assume it is a real transmission pulse. This would be similar to how a button debounce would function. The datasheet for the TSOP1738 contains information on valid pulse durations you can use as reference.

    Best regards

    Jørn Frøysa

Related