Hi STRONG, (STRONG, Neil -Syntegra), in <350085AC@guidion1.syntegra.bt.co.uk> on Mar 6 you wrote: > I've written PIC code to decode a serial 12 bit word received via a radio > module. > > My problem is noise - I'm decoding the signal by looking for a start bit > of 2ms high, then sampling in the middle of the data bit, then > re-synchronising on the start of the next data bit by waiting for the > signal to go high > > Unfortunately, if there is a noise spike in the middle of all this I see > it as a state change and lose synchronisation. > > Anyone got advice on how signals of this sort are best processed - am I > approaching this from the wrong direction - should I be measuring the > length of each pulse and throwing away anything shorter than a data bit? There's a lot you can do, but it'll take processing power. You should examine the noise characteristics before selecting a counter measure. One way is to lowpass filter the incoming data stream. That's actually quite similar to your idea of measuring pulse length. Always look at several samples instead of one. If 3 out of the last 5 samples are 1, act like you've read a 1. If it's 2/5 max you have a 0. Also, you can implement a PLL. It generates the bit clock (when to sample each bit), and synchronizes to the senders' bit clock. The PLL expects the bit to change at a certain point of time, and hunts for actual bit changes near that point. If the actual signal changes a bit earlier, the PLL is late and shortens its next bits' period. If the PLL is early, it can relax during the next bit. Because the PLL is not "hard" locked, you can determine how fast the PLL phase shifts towards the input signal phase. A slow shift rate is more robust against noise.