Electronic – How does using UART reduce noise when doing wireless communication

picuartwireless

I am in the process of designing something that needs to do wireless communication across about 6 inches and control a servo. Since I do not have line of sight I am using some really cheap RF chips.

I am a noob at wireless so I threw some stuff together to just see what happens. I hooked up the RF transmitter to a pin on the PIC and wrote to it and then hooked up the RF receiver output to a servo and tried to move it around. This did not work but now I am trying to understand why. It works fine with no wireless comm.

After doing some reading I think it's because there is lots of interference. So I think the fix is to use some data transfer protocol like UART and read it on another PIC and then output to a servo. From what I read this allows me to distinguish my data from the noise. My question is, how does UART allow me to do this? I understand that UART is a way to convert parallel data to serial data with start and stop bits and then to turn it back into parallel to be used on the receiving end but how does this give me the ability to ignore noise? How are the start and stop bits distinguished from the noise?

Is there a way to just use some capacitors for filtering to avoid having any processing on the receiving end? It would be really nice if I could have just a simple circuit on the receiving end with receiver, filters and the servo without any PIC.

Thanks you!

Edit: The transmitter chip is FS1000A and the receiver is XY-MK-5V.

Best Answer

The FS1000A is a 433MHz OOK (On Off Keying) transmitter. It produces a continuous 433MHz carrier wave when the digital input signal is high (keyed 'ON'), and no carrier when the input is low (keyed 'OFF'). OOK is a form of Amplitude Modulation suitable for transmitting digital signals.

This transmission could be received with a simple tuned circuit and diode detector (ie. a 'crystal set') to recreate the original digital signal, but only at close range because RF signal strength drops off rapidly with distance (and the FS1000A only puts out a few milliwatts, so the range would be extremely short!).

Most users want more than a few cm of range, so the XY-MK-5V uses a simple but very effective superregenerative circuit, which has an inherent AGC (Automatic Gain Control) action that amplifies even extremely weak RF signals. However it has two problems:-

  1. when the RF signal is keyed OFF the receiver 'winds up the gain' trying to detect the nonexistent signal between the carrier wave pulses. If the carrier is OFF for too long then noise pulses will start to appear between the ON periods. When no signal is being transmitted the receiver's output is just a mess of noise.

  2. The output of a superregenerative detector is AC, so the 0-5V DC digital signal becomes an audio signal whose average DC voltage varies depending on the ratio of high to low pulse times. The XY-MK-5V has a data slicer which attempts to regenerate the digital signal, but it only works properly when the high/low ratio is not too far away from 50%.

Your servo pulse signal is high for 1~2ms and low for 18~19ms, an ON/OFF ratio of only 5~11%. This is probably too low for the data slicer to work reliably, and the long OFF time may be enough to cause noise as the receiver 'winds up the gain'. The end result is that your digital signal is not received cleanly.

To solve these problems you need to 'encode' the servo pulse into a digital signal whose average ON/OFF ratio is not too far way from 50% (to keep the data slicer happy) and with short times between pulses (to keep the receiver's AGC happy). Then at the receiving end you need to 'decode' it back to a 1~2ms servo pulse.

One simple way to do it might be to produce a 50% PWM signal whose period varies from 1 to 2ms. At the receiver you could use another PIC which measures the period and uses it to control its own servo pulse generator. (the reason for using period rather than pulse width is to avoid timing errors due to unequal pulse rise and fall times).

A more complicated protocol might send digital data via Manchester coding or some other rf friendly encoding scheme, with a corresponding decoder at the receiver. Digital data usually needs synchronization bits to identify where the data packets start and end, and more bits (parity/checksum/CRC) to detect and possibly correct errors. This can make the coding of digital data protocols quite complex.

A UART is designed to send and receive asynchronous serial data over wires. The data format is not normally RF friendly because the signal can spend long periods of time being high or low with no attempt to maintain a 50% average. This can be fixed by carefully selecting which data patterns to transmit, or by further encoding the output. However unless you need to transmit and receive a lot of digital data it might be easier to just 'bit-bang' your own protocol.

UARTS have a very basic error detection system which uses a 'parity' bit to check that the number of '1's in a byte is even or odd, and they can detect 'framing' errors caused by missing start and stop bits. However this is often not enough to trap all errors caused by RF noise.