# PIC Manchester coding for use with 433MHz modules

Thread Starter

#### marti184

Joined May 10, 2016
1
The code with example programs is at https://github.com/marti184/PIC433

Hello,

I've recently done a project involving 433.92MHz cheap transmitters (the ones that cost approx. 1\$ for a pair), and since I didn't find a good sample code or library for using them, I've written my own.
Since these modules need a quite balanced stream of bits (about 50% of time high signal and low), then I've chosen the Manchester encoding. Since the cheap 433MHz modules need a header, it is also implemented, as is the automatic clock speed measurement from header (which is quite simple, but could be modified if need be).

I used PIC12F675 for Tx side and PIC16F628A for Rx, written it in C-language and compiled with SDCC (which is a free and open-source compiler).

The code sends a 3-byte packet, from which the first is header, others data. In the example code (txuse and rxuse), a LED will shine upon correct data.

You can modify, test, improve. If you find mistakes, you can let me know.

In a dense urban environment I've gotten 30m range through several walls of solid wood and brick. Initially I used 1/4 wavelength monopole, then switched to half-wavelength dipole when range wasn't quite enough.

The code with example programs is at https://github.com/marti184/PIC433

The 1/4-wave monopole that i've initially used was quite good, but not good enough. It is cheap and easy. The length of antenna is

1/4 * c/f * vf= 1/4 * 299792458[m/s] / 433.92E6[Hz] * 0.951 = 0.164 [m],

where c is speed of light, f is frequency and vf is velocity factor which shows how much slower than light speed does the information travel through the wire. It would be good to add an artificial ground plane, preferably at the base of the antenna wire. Be sure to strip the insulation from the antenna wire, as it changes the vf!

More complex but better is half-wave dipole, total tip-to-tip length 2*0.164 = 0.328 m. It needs a balun (the loop of co-ax in the image), which delays the signal for half a wavelength for the other side of antenna ( https://en.wikipedia.org/wiki/Balun ). The signal wire of co-ax goes to antenna hole, the shielding to GND pin. The other side of signal wire goes to one side of dipole, and through the 1/2-wavelenght balun to other side of dipole. The length of balun made of co-ax where the signal is slower, so the balun loop length is

1/2 * c/f * vf = 1/2 * 299792458[m/s] / 433.92E6[Hz] * 0.66 = 0.228 [m]

You can use any 50-ohm co-axial cable, I've used RG 58 C/U. Its vf = 0.66 and it has high attenuation, so keep the length from board to antenna as short as possible!

Regards,
Hope it helps others.

#### Attachments

• 294 KB Views: 4
• 28.7 KB Views: 4
Similar threads