I tried to decode a UM3750/MM53200/HT12 type encoder with this either as subroutine or as Interrupt Driven Routine:
Code:
GET_CODE:
PULSIN DIN,0,NUMS
IF NUMS > 8200 and NUMS<12000 then 'Detect Header
goto get_pulses
else
RETURN
endif
get_pulses:
FOR X = 0 TO 11 ' read 12 pulses
PULSIN DIN,1,NUMS '
if NUMS>220 then
if NUMS<300 then
code.0[x]=1
endif
endif
if NUMS>450 then
if NUMS<560 then
code.0[x]=0
endif
endif
if NUMS=0 then
loops=0:code=0:flag=0
RETURN ' temp=0:
endif
next x
if loops<3 then
if prev_code=code then
loops=loops+1
else
prev_code=code
loops=0
endif
endif
return
But I got a delay in decoding. It just gets one every 4 transmissions. So for a 4 times check of equall transmitted codes, it takes more than 250ms to give a valid. With the Logic Digital Analyser it is confirmed that it takes 1st transmission, then 4th etc.
The numbers in NUM are PIC and OSC clock dependant.
If anyone can spot why, please reply.
Ioannis
Bookmarks