[quote author="Ytsirk"]Since fixing the LED I've made several attempts (short of removing the LED again) at trying to get the thing to fail the self test with no success. Bright sunny rooms, covering the LED and receiver with everything I can think of to block out the light, and every time it passes. I can't see anything in the code that would lead it to pass, but I'm not very good at debugging code.[/quote]
I only very briefly skimmed the code. Could someone make a comment here as to how the self-test works? I don't think that I even see a self-test, at least not anything which loops. Where should I look in the source files for the self-test section?
(other IR circuit details):
I only recently noticed that the IRRX signal connects to 2 port pins instead of just 1. One is RB2/INT2 and the other is RB4/KBI0. I assume that the purpose is to allow firmware which uses either INT2 (External interrupt 2) or KBI0 (Interrupt-on-change) for various potential firmware options.
For true analog testing, it might have been interesting to loop back both pins on the IR LED to RB1/AN10 and RB3/AN9, respectively, to test for reasonable voltages on those circuit nodes. Since those are analog inputs, the PIC could actually serve as a VOM for electrical self test. Of course, this assumes anyone could have predicted that the LED might be reversed, otherwise it's extreme overkill.
selftest() is in main.c:
http://code.google.com/p/dangerous-prot ... main.c#192 (http://code.google.com/p/dangerous-prototypes-open-hardware/source/browse/trunk/USBIRtoy/IRtoy-firmware/main.c#192)
It's a simple test. It checks that the PIC pin is high (RX internal pull-up resistor powered and working). It then activates the PWM at 38khz (and the LED) so it activates the reciever, the PIC pin should now be low.
The best way I found to make it fail is to put some putty or clay around the RX or TX elements. Also, removing any of the resistors (R3, R4, R5) does the trick.
Yes, the RX connects to two pins with different interrupt types. Using an analog pin to measure voltage too is a really good idea. From the how-to:
The receiver connects to a PIC pin with an edge selectable interrupt (RB2/INT2) so we can detect the start of IR activity. RB2 has a Schmidt trigger to ‘clean up’ a noisy signal. The RX output is also connected to one of the interrupt-on-change pins (RB4) if you want to experiment with a different interrupt type and a TTL pin buffer.