I have a circuit that has 2 IR 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'm using IRLib2.
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. Receiver and decoder class constructors were changed to take an
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:
- 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.
- There's an error in my code or I've failed to understand part of the 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 if required. Obviously there's a lot of it, as
recvGlobal is used in a lot of places.