1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ The RF receiver needs a good band-pass filter to improve reception. Check that the filter is matched to signal \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jan 31 '17 at 4:11
  • \$\begingroup\$ So I actually can get away without processing on the receiving side with a bandpass? \$\endgroup\$ – Shawn Volpe Jan 31 '17 at 5:34
  • \$\begingroup\$ Which 'really cheap rf chips' do you have? \$\endgroup\$ – Bruce Abbott Jan 31 '17 at 5:51
  • \$\begingroup\$ @Bruce I added the chip names in an edit, for ya. \$\endgroup\$ – Shawn Volpe Jan 31 '17 at 5:59
  • \$\begingroup\$ add links without http \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jan 31 '17 at 6:00
4
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Incredible answer thank you. This is plenty of information to get me started reading all types of stuff on my own. \$\endgroup\$ – Shawn Volpe Jan 31 '17 at 17:21
  • \$\begingroup\$ What do you mean by "unequal pulse rise and fall times)"? Can you give an example maybe when this will be the case? \$\endgroup\$ – Shawn Volpe Feb 1 '17 at 0:51
  • \$\begingroup\$ If I have unequal rise and fall time wouldn't I have trouble reading the period also? \$\endgroup\$ – Shawn Volpe Feb 1 '17 at 1:00
  • \$\begingroup\$ No, because period measurement is between two rising or falling edges, so unequal rise/fall time is irrelevant. This is how radio control PPM (Pulse position modulation) encoding works. abottravel.blogspot.co.nz/2011/12/… \$\endgroup\$ – Bruce Abbott Feb 1 '17 at 1:13
0
\$\begingroup\$

The UART MAY oversample during each bit time, and perform a majority-vote on whether a solid 1 or a solid 0 was actually transmitted.

Older UARTS sampled 16 times during each bit interval. Then a 1/0 decision was made.

To further assist this, use an R*C filter with speed adequate to settle to several TAU within the bit time.

If bittime is 100uS, then go for 3 Tau (just my gut, having worked on Bit-syncs) and implement as 33uS R*C; 33 ohms and 1uF, 3.3Kohm and 0.01UF, etc.

One benefit of the UART is its ability to identify the "START" bit; you'd need to implement that yourself, otherwise.

\$\endgroup\$
  • \$\begingroup\$ That seems like a valid answer to my last question but I am also looking for more information on why UART fixes my noise problem. \$\endgroup\$ – Shawn Volpe Jan 31 '17 at 6:07
  • \$\begingroup\$ Do I need bandpass filtering if I use UART? \$\endgroup\$ – Shawn Volpe Jan 31 '17 at 6:11
  • \$\begingroup\$ no but you do need carrier started before tx using correct logic.. check datasheet to ensure correct polarity is used. otherwise Start bit does not give Rx enough time to lock onto carrier. \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jan 31 '17 at 6:23
  • \$\begingroup\$ "The UART MAY oversample during each bit time, and perform a majority-vote on whether a solid 1 or a solid 0 was actually transmitted" That's not how most UART work, AFAIK. They oversample and check the data line at the middle of the samples (the 8th sample in case of sampling 16 times) \$\endgroup\$ – m.Alin Feb 27 '17 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.