On Mon, 24 Feb 2003, Peter L. Peres wrote: > Correlation: A simple way is to XOR incoming data with data-to-be-tested > and count the 1's in the result. The fewer 1's the better the correlation. > XOR is modulo-2 multiply without carry out (or in) and one (the?) > correlation function is Fc=SumOf|Ai*Bi|. XOR produces this result when Ai > and Bi are binary bits, but the sum is zero for high correlation because > the carry in the XOR multiply is lost. In this case Fc=0 means 'all bits > caused carry' (which was lost). Otherwise one would use an analog > multiplier to check for correlation with analog signals, and aim for high > Fc (not zero). Notice that in a binary XOR correlator an all 1's result > means input and reference are 180 degrees out of phase, or complementary. See: http://www.dattalo.com/technical/theory/dtmf.html Here the pulse stream "decoded" is a 50% duty cycle square wave. In the real code implementation, it's actually faster to perform sequences of: BTFSC port,bit INCF Fc Instead of performing a sequence of XOR's For frequency decoders, you really need quadrature sampling. Fortunately, only 3/4'ths of the time is spent sampling and 1/4'th spent processing. (Sampling all 8 DTMF freqeuncies simultaneously is challenging!) Scott -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body