--Message-Boundary-31745 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Hi, Just an update on where I got to with the RF remote decoder question I posted a few weeks back. Got it working good, finally! I ended up sampling the waveform at 90us intervals and implementing a very simple digital filter. This approximates the RC filter I tried. Attached waveforms show the data as sent by the transmitter (2 button key-fob type, 433MHz) at the bottom. There are 24 address/data pulses which are typically 400us for a "short" pulse and 3 times that (1200us) for a "long" pulse, plus a final sync pulse of 400us. In practice the data varies a lot with battery voltage and temperature etc, so a short pulse usually ranges from 400-500us. It's not real complicated but I wont go into the details of the data format unless someone asks. I set up the PIC16F877 to interrupt every 90us using TMR0. The input is sampled and the last 4 samples are examined. If there are 3 or 4 1's the input is considered a 1. If there are 0 or 1 's the input is considered a 0. In between these states there is no change. That's the filter. TMR2 is used to measure the length of the filtered pulse (using a div by 16 prescaler). Looks like this in C: // Timer 0 overflow ----------------------------------------------- ------- if(T0IF){ // Timer 0 interrupt TMR0 = (255 - 90) + 21; // Reload the timer for 90us intrpt T0IF = 0; // clear flag to re-enable rfdata <<= 1; // Shift the data samples left by 1 if(RXDATAIN) // and bring in the new sample rfdata |= 0b00000001; rfsum = 0; // Calculate number of 1's in the if(rfdata & 0b00001000) rfsum += 1; // last 4 samples if(rfdata & 0b00000100) rfsum += 1; if(rfdata & 0b00000010) rfsum += 1; if(rfdata & 0b00000001) rfsum += 1; if(rfoldstate == 0 && rfsum >= 3){ // Filter says input now 1 rfnewstate = 1; TMR2 = 0; // ...reset Pilot period timer } if(rfoldstate == 1 && rfsum <= 1){ // or filter says input now 0, rfnewstate = 0; // so check what pulse length was if((TMR2 >= SHORTMIN) && (TMR2 <= SHORTMAX)) pulse = SHORT; // SHORT, gets saved as 0 else if((TMR2 >= LONGMIN) && (TMR2 <= LONGMAX)) pulse = LONG; // LONG, gets saved as 1 else{ pulse = OTHER; // Invalid length, reset rfbits = 0; } .... more code for deteting end of frame and checking against stored code. The waveforms attached show the receiver output which is just noise before the transmitter begins (expected), and a comparison of how the digital filter compares with the RC filter followed by a schmitt trigger. In reality there are cases where the "noise" on the received signal appears not just before there is a transmitter signal but actually during transmission. In that case the filter cleans up the data and increases the usuable range of the system. Just what I wanted! I started out with a 80us sampling period but this was cutting things fine. Programming in Hi-Tech C there is about a 21 instruction overhead in entering the interrupt routine (and similar on exit I presume). With a 4MHz clock this means the CPU is kept pretty busy. I increased the sample period to 90us and it lets my main application run much more smoothly, without noticeably affecting filter performance. Another thing that made a big difference (not shown in the code above) was how I detect when the data has been received. Previously I read in the first 25 pulses that passed the short or long test and compared that to the stored code. Now I wait for at least 25 valid pulses to be received and trigger on the period of silence that follows the sync bit to check the data. This is done with the TMR2 interrupt, not shown. You can pretty much guarantee that you will see the silence period immediately following the data but not before the data (as noise creeps in). Waveform shows decoded output going high a little after one "long" bit time of silence. Many thanks to James Hillman, Richard Prosser and others, whose ideas really helped. -- Brent Brown, Electronic Design Solutions 16 English Street, Hamilton, New Zealand Ph/fax: +64 7 849 0069 Mobile/txt: 025 334 069 eMail: brent.brown@clear.net.nz --Message-Boundary-31745 Content-type: Application/Octet-stream; name="new4.pdf"; type=Acrobat Content-disposition: attachment; filename="new4.pdf" Content-transfer-encoding: BASE64 JVBERi0xLjIKJcfsj6IKNiAwIG9iago8PC9MZW5ndGggNyAwIFIvRmlsdGVyIC9GbGF0ZURl Y29kZT4+CnN0cmVhbQp4nLVSy07DMBC871fsMSDFWT/i2D3ykDhRWixx6a00pagBFQ79fdaJ o7qQCxLEirwe765nxj4gCamQ4hiDdQcHqJYGt58gccv/DmRNKK0V1jZoSNVYN0YKrfFjA+0l LLgipWDXR7Unh3tQxqqzOGbs4QWe8A0O6LgFf/2xebzu8CowB48SQwvcWAuvsBwmQuWVcKTR KiWswdBBSYLIWUXWYzhCgRfhFW4DLnJuPf3ETzoneBVpafd9OeaemHIFcZnSFPlJ7QSbkCY2 rFpKwpt3SMcl15IzsaL7teIoN2qtGyXIMSfHU5RatFEbCS29944zwjNE9QrDGordftit69Nu s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yZWYKNTUzMgolJUVPRgo= --Message-Boundary-31745-- -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.