Here's the code until now, works perfect with a RC5 remote. It now act's like a sort of a IR RC5 to binary encoder. Just press the number buttons 0 to 7 on the remote and the 3 IO outputs will be set accordingly ... (Just one minor thing, still remains : the FLAG section has to be commented out in the pbppic12.ram file, for me to be able to fit TMP as byte)
And again: THANK YOU guys !Code:'==== Set fuses ===================================================== @ device pic10F202,wdt_off,mclr_off,protect_off '==== Set XTAL ===================================================== DEFINE OSC 4 ' int XTAL @ 4 Mhz '==== Set variables ================================================== Y VAR word ' To Hold the 12-bit RC5 code TMP var BYTE '==== Set IO ======================================================= IR_PIN VAR GPIO.3 ' GPIO.0 input pin reading IR data 'SERIAL var GPIO.1 ' GPIO.1 SEROUT 9600-8-n-1 output RES1 var GPIO.0 ' Binary 1 RES2 var GPIO.1 ' Binary 2 RES3 var GPIO.2 ' Binary 4 OPTION_REG.7 = 0 ' Internal pull-ups = on TRISIO = %00001000 ' Set TRIS register input's & output's OPTION_REG.5 = 0 ' Set Timer inc. on internal inst. GPIO = %00000000 ' Set all digital low '==== Signal information =============================================== 'Given the information found on http://www.sbprojects.com/knowledge/ir/rc5.htm 'bit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ' | | | | | | | | | | | | | | | 'uSec 1778 1778 1778 1778 1778 1778 1778 1778 1778 1778 1778 1778 1778 1778 '==== Main program ================================================== MAIN: IF IR_PIN = 1 THEN GOTO MAIN ' Wait for the first bit to arive y.13 = IR_PIN ' Incoming signal pauseus 889 ' In order to se this 0 we are in the second ' period of the first 1.778 msec, so we will ' wait another 889 usec to enter the 2nd period. pauseus 1600 ' Almost at the end of the second period, look for y.12 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.11 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.10 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.9 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.8 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.7 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.6 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.5 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.4 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.3 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.2 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.1 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period pauseus 1600 ' Almost at the end of this period, look for y.0 = IR_pin ' a high or low signal pauseus 178 ' Time to the end of this period y = ~y ' Invert y word if Y.lowbyte = 255 then goto ERROR ' If all lowbytes are 0xFF then noise is received '==== Parse received values ========================================= TMP.1 = Y.13 TMP.0 = Y.12 if not tmp = 3 then goto error TMP.4 = Y.10 TMP.3 = Y.9 TMP.2 = Y.8 TMP.1 = Y.7 TMP.0 = Y.6 if not tmp = 0 then goto error TMP.2 = Y.5 TMP.1 = Y.4 TMP.0 = Y.3 if tmp > 0 then goto error TMP.2 = Y.2 TMP.1 = Y.1 TMP.0 = Y.0 OPTION_REG.5 = 0 ' Internal pull-ups = on res3 = tmp.2 res2 = tmp.1 res1 = tmp.0 '==== End of main loop reset and go from top ============================ ERROR: Y=0 tmp=0 ' Clear key codes PAUSE 250 ' debounce GOTO MAIN ' Return to main loop END
Best Regards, UltiBlade




Bookmarks