OK, this is what I came up for decoding rotary dialer. It reads and decodes the pulses and compares 3 digits from the EEPROM. If one has different needs just change the arrays accordingly.
IoannisCode:clear read 0,array[0],array[1],array[2] 'array holds the stored digits to compare. INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts 'wsave var byte $20 system 'depends on the PIC used '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _Timer1, PBP, yes endm INT_CREATE ENDASM @ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts goto main Timer1: time=time+1 'Interrupt every 0,131msec for a 4MHz PIC clock if time>7 then 'time resets every 0,8 sec approximately time=0 endif @ INT_RETURN main: digit[0]=0:digit[1]=0:digit[2]=0 'clear array every time it loops here for i=0 to 2 'three digit counter. Change this for more get_digit: while !dial:pause 10:wend 'wait for dial rotation get_next time=0 while dial if time>1 then main 'every digit takes around 10 ms. If times gets 1 wend 'then it sure timed out digit[i]=digit[i]+1 'increment digit value time=0 'reset time variable while !dial 'wait for next high edge if time>4 then next_digit 'if time is more than 500-600ms then wend 'next digit has arrived goto get_next next_digit: if digit[i]<>array[i] then error 'if digit and array are different then wrong number dialed next i high green:pause 1000:low green:goto main 'SUCCESS! error: high red:pause 1000:low red:goto main 'WRONG DIGITS!!! end




Bookmarks