Quote Originally Posted by Dennis View Post


@ 4 Mhz PULSIN returns a value with a 10uS resolution/increments.
So for the SONY protocol header the returned PULSIN value should be around 240 not so ?
Yes. About 240.

So if testing a SONY remote I should be testing for an incoming PULSIN value of between say 190 and 290 not so ?
I have some lighting devices here that "speak Sony" and use a 16F684 running @ 8MHz, and I have my "limits" set at 450 and 520.
That seems to work reliably with all 3 remotes I use... RCA, Universal, and Phillips.

One question here:
What tolerance value should I be using ? Is 20% ok or should I use 30% just to be safe ?
Mine are more like 10% and that works fine with all 3 remotes I use.

So i figure the header test would be something like

Code:
IRpulse_length var word(13)
IRpin var GPIO.0

getheader:

PULSIN IRpin,0,IRpulse_length(0)

if IRpulse_length <190 then getheader

if IRpulse_length >290 then getheader

goto getheader
If the IR pulse passes the test , the next step is to collect the bits and then to possibly use an AND to mask the received data to split into device and commands .. not so ?
Yeah. I use this:
Code:
IRIN:     
    IR_Dev=255:IR_But=255 ' Preset the Return variables
    Pulsin IRinput,0,Header ' Measure the header length.
    If Header < 450 then Return' If the result is less than 450 toss it out
    If Header > 520 then Return' If the result is greater than 520 toss it out  
' Receive the 12 data bits and convert them into a packet
    For Bitcnt=0 to 11 ' Create a loop of 12
    Pulsin IRinput,0,P_Val ' Receive the IR pulses
    If P_Val >= 190 then ' If >= 190 then we've received a 1
        Packet.0[Bitcnt]=1 ' So set the appropriate bit
        Else
        Packet.0[Bitcnt]=0 '...or clear the appropriate bit
        Endif
    Next     
    IR_But=Packet & %01111111 'Extract the 7 BUTTON bits
    IR_Dev=(Packet >>7) & %00011111 'Right shift and extract the 5 DEVICE bits     
    return
Another question :
How do I test the second pulse as in the case for the RC5 protocol
I haven't fooled with RC5 yet, only Sony.
I'm hoping you'll become an expert soon.

steve