UTMonkey
New Member
Having brushed up Infrared using Nigel's tutorials, I thought I would have a crack at getting my JuneBug to interpret SIRC codes.
My approach "in code" was slightly different, heres how.
1. Use external interrupt on RB0 to detect the rising and falling edges of the output from the infrared module (Bill - Stroke of genius attaching the module on this port!)
2. when the interrupt trips on the falling edge start TIMER0
3. when the interrupt trips on the rising edge stop TIMER0 and take a reading.
This has worked really well (I'll post the code if anyone is interested - and when it is complete ).
With TIMER0 at 8 bit 256 prescale, the TMR0L reads:-
0x13 = SIRC Start Bit
0xA = SIRC "One" Bit
0x5 = SIRC "Zero" Bit
This works great at up to 2 meters, my code reads the command and device codes perfectly.
Any further away however and things look a bit odd, debugging my code shows that the TMR0L is different, for instance the "one" bit is now 0x9 and not 0xA.
Is this a property of infrared transmissions at distance? does my code need to compensate i.e.
0x12 - 0x14 = SIRC Start Bit
0x9 - 0xB = SIRC "One" Bit
0x4 - 0x6 = SIRC "Zero" Bit
Any help gratefully received.
Mark
My approach "in code" was slightly different, heres how.
1. Use external interrupt on RB0 to detect the rising and falling edges of the output from the infrared module (Bill - Stroke of genius attaching the module on this port!)
2. when the interrupt trips on the falling edge start TIMER0
3. when the interrupt trips on the rising edge stop TIMER0 and take a reading.
This has worked really well (I'll post the code if anyone is interested - and when it is complete ).
With TIMER0 at 8 bit 256 prescale, the TMR0L reads:-
0x13 = SIRC Start Bit
0xA = SIRC "One" Bit
0x5 = SIRC "Zero" Bit
This works great at up to 2 meters, my code reads the command and device codes perfectly.
Any further away however and things look a bit odd, debugging my code shows that the TMR0L is different, for instance the "one" bit is now 0x9 and not 0xA.
Is this a property of infrared transmissions at distance? does my code need to compensate i.e.
0x12 - 0x14 = SIRC Start Bit
0x9 - 0xB = SIRC "One" Bit
0x4 - 0x6 = SIRC "Zero" Bit
Any help gratefully received.
Mark