Poor maker’s Infrared receiver #2 - feedback

Everything related to protocols and IR codes
Post Reply
mattgb
Posts: 2
Joined: Sun Jun 11, 2017 2:58 am

Poor maker’s Infrared receiver #2 - feedback

Post by mattgb »

Wow, great bit of Arduino coding with your https://www.analysir.com/blog/2014/05/2 ... eceiver-2/ project. I got it working and just had a couple of comments/questions:
  • I think there's a typo in sketch. This line refers to pin 2 but pin 0 is being used just after the open bracket:

    Code: Select all

    //default definition for ISR
    #define enableIRrx attachInterrupt(0, rxIR_Interrupt_Handler, FALLING) //set up interrupt handler for IR rx   on pin 2 - demodulated signal
    
  • You may want to mention that the serial monitor baud should be set to 115200, to match your Arduino sketch serial setting.
  • I happened to have a photodiode with the black coating to filter most non-IR wavelengths and it works a lot better than the clear emitter. I ended up getting a range of 50cm using TV remote with new batteries!
  • In the blog you state "this software will just report the signal timings on the serial port" - but when I look at the output, some results are negative and some really large. Can you explain what the numbers mean (example below)?
  • Any idea how I'd convert the output into a HEX code?
Here's what I get after pressing "1" on TV remote three times:

, +2308548516, +2308546340, +60, -1720, +4294965576, -2556, +44, -0, +64, -0, +4294967020, -300, +4294966996, -304, +4294966992, -292, +4294967004, -292, +4294967004, -304, +4294966992, -812, +52, -292, +4294967004, -812, +44, -1712, +36, -284, +4294967012, -848, +24, -276, +20, -272, +40, -300, +4294966996, -296, +4294967000, -1148, +4294966148, -280, +4294967016, -276, +4294967020, -540, +20, -300, +40, -296, +4294967000, -836, +48, -288, +4294967008, -840, +4294967000, -1696, +36, -816, +48, -316, +4294966980, -832, +4294967000, -828, +32, -816, +4294966988, -1728, +32, -828, +40, -816, +52, -1700, +52, -77644, +4294889652, -79816, +4294887480, -0, +40, -1684, +52, -0, +4294967008, -288, +4294967008, -316, +4294966980, -284, +24, -528, +28, -832, +36, -832, +32, -0, +4294966988, -816, +36, -832, +32, -820, +4294966996, -832, +48, -1684, +36, -812, +44, -824, +52, -816, +56, -292, +4294967004, -280, +44, -544, +4294966752, -832, +32, -1700, +36, -0, +4294966992, -856, +20, -804, +60, -292, +4294967004, -824, +44, -860, +20, -284, +4294967012, -848, +24, -304, +36, -840, +24, -1700, +36, -0, +4294966992, -300, +40, -844, +20, -288, +4294967008, -292, +4294967004, -832, +40, -1712, +4294967000, -828, +36, -1188, +4294966108, -170036
Modulation Period: 16500 (nano seconds)
Modulation Frequency: 60606 (Hz)

, +2307040684, +2307038508, +44, -1732, +4294965564, -2564, +44, -832, +24, -0, +4294967004, -292, +4294967004, -836, +24, -824, +56, -0, +4294967012, -820, +28, -816, +48, -836, +32, -508, +32, -292, +48, -848, +4294966448, -2536, +52, -292, +4294967004, -288, +52, -296, +4294967000, -828, +48, -832, +24, -304, +4294966992, -840, +24, -272, +20, -292, +4294967004, -824, +28, -284, +4294967012, -820, +48, -300, +4294966996, -836, +44, -804, +48, -288, +4294967008, -800, +52, -1732, +4294965564, -816, +48, -292, +4294967004, -844, +4294966988, -832, +4294967008, -1700, +24, -828, +40, -836, +4294966996, -1684, +40, -0, +32, -77668, +4294889628, -79844, +4294887452, -80708, +4294886588, -308, +4294966988, -816, +36, -840, +52, -0, +4294967000, -824, +32, -852, +20, -832, +32, -0, +40, -288, +4294967008, -812, +44, -844, +36, -828, +24, -828, +48, -1164, +4294966132, -836, +28, -296, +4294967000, -816, +60, -304, +4294966992, -832, +40, -288, +4294967008, -1176, +4294966120, -824, +52, -832, +24, -292, +4294967004, -296, +44, -308, +4294966988, -832, +36, -816, +48, -304, +4294966992, -828, +44, -1168, +4294966128, -312, +4294966984, -856, +24, -804, +44, -304, +4294966992, -832, +40, -1168, +20, -304, +4294966992, -820, +48, -1172, +4294966124, -171220
Modulation Period: 16937 (nano seconds)
Modulation Frequency: 59042 (Hz)

, +2305832356, +2305830184, +44, -1732, +4294965564, -2564, +44, -828, +40, -0, +4294966996, -812, +52, -808, +60, -832, +36, -812, +52, -800, +68, -0, +4294966992, -304, +4294966992, -864, +4294966432, -828, +4294966992, -1684, +40, -856, +4294966440, -804, +4294967008, -832, +4294966464, -308, +4294966988, -812, +44, -0, +32, -1176, +36, -304, +28, -296, +4294967000, -300, +4294966996, -296, +4294967000, -836, +36, -832, +32, -816, +48, -1176, +4294966120, -820, +60, -1156, +48, -800, +4294967004, -288, +4294967008, -1668, +48, -292, +4294967004, -852, +28, -1168, +4294966128, -828, +52, -0, +64, -1144, +4294966152, -0, +40, -77668, +4294889628, -79840, +4294887456, -80704, +4294886592, -308, +4294966988, -816, +36, -840, +52, -0, +4294967000, -824, +32, -852, +20, -832, +32, -0, +28, -288, +4294967008, -812, +44, -844, +36, -828, +24, -828, +48, -1160, +4294966136, -840, +28, -296, +4294967000, -816, +60, -304, +4294966992, -832, +40, -304, +4294966992, -1164, +4294966132, -824, +52, -832, +24, -292, +4294967004, -296, +44, -308, +4294966988, -832, +36, -816, +48, -304, +4294966992, -828, +44, -1164, +4294966132, -312, +4294966984, -856, +44, -804, +44, -828, +52, -320, +4294966976, -832, +40, -304, +4294966992, -820, +48, -1164, +4294966132, -168448
Modulation Period: 27625 (nano seconds)
Modulation Frequency: 36199 (Hz)

Thanks!
User avatar
AnalysIR
Site Admin
Posts: 776
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: Poor maker’s Infrared receiver #2 - feedback

Post by AnalysIR »

Code: Select all

//default definition for ISR
#define enableIRrx attachInterrupt(0, rxIR_Interrupt_Handler, FALLING) //set up interrupt handler for IR rx   on pin 2 - demodulated signal
The '0' here refers to INT0, which is exposed on pin 2 on arduinos (UNO etc).
There is a more recent function to make this portable, but wasn't common at the time of the original post.

Code: Select all

//default definition for ISR
#define enableIRrx attachInterrupt(digitalPinToInterrupt(2), rxIR_Interrupt_Handler, FALLING) //set up interrupt handler for IR rx   on pin 2 - demodulated signal
This would be the updated version....but both will work OK.


If you changed that to 2 or connected to pin 0, it may explain your weird output!.....let me know.

Also, the 50CM range seems too far......it really needsto be up-close!
However, a photo-diode may work better than an IR emitter/LED. The target in this post was an IR emitter, as it is more common to have available than a photo-diode.
FYI: IR LEDs can also come with inbuilt filters, depending on model.

If you continue to have issues, post a photo of your setup including how you use the remote.
mattgb
Posts: 2
Joined: Sun Jun 11, 2017 2:58 am

Re: Poor maker’s Infrared receiver #2 - feedback

Post by mattgb »

Thanks for the speedy response! Attached is a picture of my setup. FYI, I had to use a couple of 10k ohm resistors in parallel to make a 5k and a couple of 10ks in series to make 20k.

Regarding INT0 = pin 2, it all makes sense now. Looks like I'd only changed the #define enablelRrx under "//default definition for ISR" which coincided with output appearing on the serial monitor for the first time - but it was probably because of some other change I'd made. I'd forgotten about the test for ArduinoUno further in the code which re-asserts INT0:

Code: Select all

#if Arduino328 || ArduinoUNO
  #define enableIRrx attachInterrupt(0, rxIR_Interrupt_Handler, FALLING) //set up interrupt handler for IR rx   on pin 2 - demodulated signal
Strange results above might be because of the IR receiver diode I used. When I switched back to an IR emitter diode, I had to hold it less than 1cm from the emitter, and when pressing 1 on the TV remote twice, I now get:

, +80, -80, +4294967216, -728, +4294966568, -2460, +56, -812, +28, -1020, +4294966276, -1836, +28, -100, +4294967196, -920, +48, -680, +4294966616, -1548, +52, -868, +28, -784, +108, -864, +4294966432, -1732, +48, -80, +56, -0, +4294967216, -860, +4294964916, -2436, +132, -0, +4294965724, -820, +4294966476, -2468, +4294964828, -3332, +28, -188, +4294966588, -788, +4294966508, -76, +24, -920, +4294966536, -844, +4294966560, -56, +28, -0, +4294966512, -2540, +24, -868, +4294966428, -144, +4294966424, -1768, +4294965528, -2660, +4294964636, -708, +56, -56, +4294966456, -976, +48, -0, +28, -80, +4294967216, -56, +24, -4992, +4294962304, -5912, +4294961384, -7772, +4294959524, -8508, +52, -0, +4294966484, -1652, +4294965644, -4224, +28, -916, +4294966380, -1732, +48, -1736, +4294963040, -4308, +28, -784, +4294966512, -1648, +4294965648, -2516, +52, -868, +24, -25444294964752
Modulation Period: 2549125 (nano seconds)
Modulation Frequency: 392 (Hz)

, +164, -136, +4294967216, -136, +4294967160, -160, +28, -84, +48, -548, +4294967080, -156, +4294966460, -1052, +4294966244, -1944, +48, -0, +116, -148, +4294967148, -240, +4294967240, -840, +4294966456, -704, +4294966592, -0, +24, -268, +4294967164, -188, +28, -208, +4294967244, -1104, +52, -56, +4294966616, -212, +60, -212, +4294967084, -56, +4294967240, -52, +4294967244, -840, +4294966456, -56, +52, -212, +4294967244, -576, +24, -52, +4294967244, -1736, +4294964964, -2520, +4294967200, -888, +24, -132, +4294966540, -972, +32, -52, +4294967244, -108, +28, -0, +76, -108, +28, -240, +24, -1056, +4294966320, -244, +4294967104, -0, +4294967052, -52, +28, -52, +28, -0, +80, -728, +4294966752, -0, +28, -80, +4294967216, -864, +4294966432, -1784, +4294964700, -0, +24, -840, +48, -820, +72, -656, +4294965720, -1632, +28, -1784, +4294965512, -3484, +4294963812, -240, +4294967056, -184, +4294967112, -0, +24, -80, +4294967216, -1648, +4294965648, -2516, +4294964780, -104, +4294967192, -0, +4294966404, -80, +4294965568, -1780, +4294965516, -0, +28, -80, +4294967216, -868, +4294966400, -1760, +4294965536, -52, +48, -164, +4294967132, -972, +4294966324, -1840, +4294965456, -3540, +4294963756, -5224, +4294961260, -0, +4294961208, -184, +4294967112, -736, +4294966560, -524294967244
Modulation Period: 58375 (nano seconds)
Modulation Frequency: 17130 (Hz)
You do not have the required permissions to view the files attached to this post.
User avatar
AnalysIR
Site Admin
Posts: 776
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: Poor maker’s Infrared receiver #2 - feedback

Post by AnalysIR »

Sorry about the delay....

The sensor in the photo looks like a photo diode and not an IR LED.

As I mentioned, the circuit is designed to work with an IR LED emitter (not a photo sensor).

Also, please check that the LED is connected with correct polarity and also check it with the diode tester on a DMM, if available.
Post Reply