> From: myke predko > > Hi Gang, > > Last night, I spent a couple of hours working through my idea of creating a > CRC of an I/R input by sampling the serial line coming in. > > The code for creating the CRC is: > [cut] > > Using this code, I got the following information from the I/R transmitter > (set to "Sony" format): > [cut] > The code above waits for a Port Change Interrupt (the I/R line going low > from it's nominal state of "1") and once that happens, the line is sampled > every 200 usec and a CRC is generated. After 150 samples (30 msec) the CRC > is output on an LCD in Hex format. > > The CRC generated is rock solid (none of this 60% repeatability I had with > just sampling bits). I don't know if I'm going to go back and update my I/R > tank code (lack of initiative more than anything else), but this is clearly > a *much* more elegant method of handling I/R codes. I wish I'd thought of this! However, I think you are a bit lucky that the CRC is 'rock solid'. What happens if a state change of the input occurs very near to one of your 200us sampling intervals? I have noticed that the exact timing obtained from an IR receiver module depends somewhat on the intensity of the received signal and probably on other variables. This means that the CRC could flip between several possible values. A CRC which did not change under slight timing variations would be more robust. > > I did a limited amount of checking for invalid code rejection by > reprogramming the Universal Remote I used to Panasonic and RCA. The CRC's > generated were different from the Sony ones above. Perhaps an 8-bit CRC is not enough if one has a lot of devices. What about this idea: keep two independent 8-bit CRCs; one for off->on transitions and the other for on->off transitions. Since the possible IR module timing variations would presumably be less for transitions in the same direction, this might be more robust in the face of variable transmission strength. Also, you get 16 bits which should reduce spurious signals. Regards, SJH Canberra, Australia