Hi all I’m learning nigels IR coding. I have some small doubts regarding that.
In SIRC if there is signal (one) the duration is 1.2mS & if there is no signal (Zero) the duration is 0.6mS.
Can Nigel or anybody tell me why its detecting 60 for zero in the LoX register?
It should be 50 isnt’t it?
Calculation 12 (nop) X 50 = 600uS exactly 0.6uS.
Tell me why its detecting 112 for one in the LoX register ?
It should be 100 isnt’t it?
Calculation 12 (nop) X 100 = 1200uS exactly 1.2mS.
Help me
In SIRC if there is signal (one) the duration is 1.2mS & if there is no signal (Zero) the duration is 0.6mS.
Can Nigel or anybody tell me why its detecting 60 for zero in the LoX register?
It should be 50 isnt’t it?
Calculation 12 (nop) X 50 = 600uS exactly 0.6uS.
Tell me why its detecting 112 for one in the LoX register ?
It should be 100 isnt’t it?
Calculation 12 (nop) X 100 = 1200uS exactly 1.2mS.
Help me
Code:
Next nop
nop
nop
nop
nop ;waste time to scale pulse
nop ;width to 8 bits
nop
nop
nop
nop
nop
nop
incf LoX, f
btfss IR_PORT, IR_In
goto Next ;loop until input high again
; test if Zero, One, or Start (or error)
Chk_Pulse clrf Flags
TryError movf LoX, w ; check if pulse too small
addlw d'255' - d'20' ; if LoX <= 20
btfsc STATUS , C
goto TryZero
bsf Flags, ErrFlag ; Error found, set flag
retlw 0x00
TryZero movf LoX, w ; check if zero
addlw d'255' - [COLOR="Red"]d'60' [/COLOR] ; if LoX <= 60
btfsc STATUS , C
goto TryOne
bsf Flags, Zero ; Zero found, set flag
retlw 0x00
TryOne movf LoX, w ; check if one
addlw d'255' - [COLOR="Red"]d'112[/COLOR]' ; if LoX <= 112
btfsc STATUS , C
goto TryStart
bsf Flags, One ; One found, set flag
retlw 0x00