cyborg5 / IRLib2

Library for receiving, decoding, and sending infrared signals using Arduino
GNU General Public License v3.0
384 stars 138 forks source link

Multiple receivers #109

Open soulsbysynths opened 2 years ago

soulsbysynths commented 2 years ago

I have a circuit that has 2 receivers with the idea that there's twice the chance of getting a correctly received message (the distance is 15+ metres, so chance of error is high). The circuit uses an Atmega328P with Uno bootloader running at 8Mhz using the internal clock and the receivers are on pins 2 & 3, so I should be able to use interrupts on both pins. I soon realised that this wouldn't be trivial because most of the work is handled by the recvGlobal struct. I then changed this to an array recvGlobal[2]. Receiver and decoder class constructors were changed to take an index_ variable. recvGlobal was changed to recvGlobal[index_] in the classes. I could then create 2 receiver and 2 decoder objects in my Arduino sketch. This all compiled and worked successfully. However..... I found that the results were significantly worse than using just 1 receiver. I have 2 theories about what could be happening: 1) Having 2 blocking interrupts triggering at the same time is causing timing inaccuracies in reading the incoming signal. This might be made worse by only running at 8Mhz using the flakey internal clock. 2) There's an error in my code or I've failed to understand part of your library!

I was wondering if anyone has successfully used 2 receivers with this library and has any tips for debugging my issues. Happy to upload any of my modified code. thanks, Paul