However, if we use a relatively wide lead-in pulse as a sync or STX indicator, the pulse does two things. It resets the AGC and ATC based on the signal strength and it signals the start of a transmission. We can measure the amplitude of the pulse at point A and measure the amplitude of the space at point B. The difference, A-B, indicates modulation depth and is a good proxy for Received Signal Strength Indicator (RSSI).
A frequent suggestion is to use RS232 and train the receiver with a preamble consisting of several $55 (01010101 binary) which is roughly equivalent to the closely spaced pulses at point C above. The problem with this approach is that it is hard to detect the 01010101s emerging out of the normal noise. See the screenshot at the bottom of the page in the RF Noise vs. Signal page. It is simpler and more reliable to look for a wide lead-in pulse and use something like the NEC protocol which incorporates error detection. Here is an example of simple transmit and receive routines using 8-pin PICs and PicBasicPro and the TX/RX setup shown below.
The linear output is input to a data slicer circuit like the one shown below. The capacitor, C1, will charge to the average signal strength. When the signal is above the average, the output is +5V. When the signal is below the average, the output is 0V. The result is the clean digital signal shown below the data slicer.
Closely spaced data pulses will raise the charge on C1 which will raise the threshold, decreasing sensitivity. Widely spaced data pulses will lower the charge on C1 which will lower the threshold, increasing sensitivity. The data pulses at C are the same width as the spaces with the average being equal to 1/2 the pulse amplitude. At D, the pulse widths are 1/3 the width of the spaces and the average is 1/4 of the pulse amplitude. It is desirable to have DC balance with pulses and spaces approximately equal over a relatively short time range. This prevents biasing the threshold towards either high or low sensitivity.
The NEC protocol, a variation of which is used by X-10, sends each data byte twice in bitwise complementary form. Each 1-bit in the first byte of the pair becomes a 0-bit in the second and each 0-bit in the first becomes a 1-bit in the second. This maintains DC balance over over the span of each data/complement byte pair. This also provides built-in error detection as the byte pairs equal zero when ANDed and equal 0xFF when summed.
First, RS232 is asynchronous. The RS232 receiver code assumes the first pulse it sees is a start bit and then samples at the mid-point of where it expects each following bit period (104ÁS apart at 9600 bps). In the absence of a signal, it will interpret the random noise pulses that happen to occur at the sampling times as logic 1 bits and any spaces that coincide with sampling times as logic 0 bits, outputting meaningless garbage. We need a way to signal the start of a transmission (STX). Many people recommend transmitting a preamble of alternating logic 1 and logic 0 bits (e.g. 01010101 or hexadecimal 55). There is a better method. Starting each transmission with a lengthy (2-5mS) pulse followed by a space about 1/2 the width of the pulse will set the receiver's AGC level to suppress the random noise pulses. The space assures the next pulse seen is our RS232 start pulse. We can look for the lengthy pulse and then call SerIn to process the data that follows.
Second, with RS232 (without Manchester coding) there is no way to guarantee DC balance so we need to keep message packets relatively short and separated by sufficient time to allow the RF receiver to reset. You can experiment with the initial pulse/space width, the number of data bytes and trailing space but I suggest starting with 5mS/2.5mS with initial packet size limited to 5-6 bytes and a trailer of 10-20mS.
Copyright: No part may be reproduced except as authorized by written permission. This restriction extends to reproduction in all media.