PDA

View Full Version : PIC-PIC RF Comms



Kamikaze47
- 3rd November 2005, 11:42
Ive set up 2 16F84A's to talk to eachother via RF using a 433Mhz Trans/Recv pair running at 4800 baud.

My code is below, but something must be wrong becuase the range is a mere 1m. Any further than 1m and it just doesnt work.

Anyone have any ideas on what could be wrong?

These are the data sheets of my RF units:
http://www.altronics.com.au/download/Datasheets/Z6905.pdf
http://www.altronics.com.au/download/Datasheets/Z6900.pdf

Transmitter Code:



low PORTB.1 ' Initialise RB1

start:
Serout2 PORTB.1,16572,[$55,$55,$66,$95] ' Transmit "$95"
Pause 500 ' Wait
Serout2 PORTB.1,16572,[$55,$55,$66,$99] ' Transmit "$99"
Pause 500 ' Wait
Goto start ' Repeat
End


Reciever Code:



recvd var word ' variable decrarations
recvd=0 ' clear recvd
low PORTB.0 ' turn off LED
input PORTB.1 ' set RB1 to input

start:
Serin2 PORTB.1,16572,[wait ($66),recvd] ' wait for $66, then store data
if recvd=$95 then High PORTB.0 ' if recvd=1 turn on LED
if recvd=$99 then Low PORTB.0 ' if recvd=2 turn off LED
goto start ' loop

end

languer
- 3rd November 2005, 19:30
Can you qualify more the statement "it just doesnt work"?

Does it not receive anything? garbage?

The way you have it setup it will sit on "Serin2 PORTB.1,16572,[wait ($66),recvd]" until it receives $66. So you may want to have a timeout, and even here noise will probably cause the same problem (i.e. timeout will never occur).

A quick look at the receiver module says it supports 4800bps and 3kpbs as maximum data rates (this in itself is contradictory). Even if it did support 4800bps for maximum rate you probably do not want to excercise this. Try 1200bps to begin with.

This are just some ideas to get you going. There are many threads on RF comms here, search them as they have very useful information.

Kamikaze47
- 3rd November 2005, 19:38
Im not sure what its recieving once it gets past 1m. I dont have an LCD handy to send the recieved data to (I will pick one up tomorrow). Once its more than 1m away, the LED stops flashing, indicating that its not recieving the data that i am sending it.

I'll try reducing the baud to 1200 and see what happens.

Kamikaze47
- 3rd November 2005, 21:00
Reducing the baud to 1200 improved the range a fair bit. At 5v I now get about 15m line of sight. At 12v, about 30m... Still a fair way short of the 100m these units are supposed to achieve, but not too bad.

Ron Marcus
- 3rd November 2005, 22:56
Just for giggles, try increasing the number of $55s you send to..say 8. Next pick a more balanced header character like $AA. You can also put a small character delay using DEFINE (Maybe 1 mS). If this helps, you need more of a preamble to balance the data slicer.
What are you using for antennas? Usually the companies range test their units with twelve element Yagis. Well, maybe not that bad, but the test data is usually taken in an optimum noise free environment with no multipath. These parameters don't exist on our earth, and you should probably halve most manufacturers range estimates. I've had to test most offerings in the OOK market, and upgraded to FSK for my more serious work, and better impulse noise immunity.

Ron

Kamikaze47
- 3rd November 2005, 23:17
For antennas Ive tried using 1/2 Wavelength and 1/4 Wavelengh bits of coathanger wire, and found the 1/4 Wavelengh (6.47 inches) to give better range.

The reason I used $66 as a start character is becuase it is fairly balaced (same number of 1's and 0's). I will try $AA though, and will also try adding more $55s and see if it improves the situation.

Thanks for the advice guys.

Kamikaze47
- 3rd November 2005, 23:33
making it 8 $55s, and changing the start character to $AA dont seem to have made any difference unfortunately

Ioannis
- 4th November 2005, 08:07
For one thing, I would never try to transmit more then half the maximum baud rate of the specified Tx/Rx pair.

Also, a manchester encoding/decoding scheme is a must for such RF links.

More to this, check if the power supply to the Receiver is very clean. If necessary add extra R's and C's to filter more the power from your sepparate 78xx chip. Large capacitors are good thing to consider.

Ioannis

Kamikaze47
- 4th November 2005, 09:05
If you look at what im sending you will notice that it already in machester format:

$55,$55,$66,$95 = 01010101 01010101 01100110 10010101

BigWumpus
- 4th November 2005, 15:01
Hello,
try more preambel-characters,
Use "DEFINE CHAR_PACING 1000" at the transmitter

We use such simple receivers/transmitters... ;-)

Kamikaze47
- 4th November 2005, 16:52
so just add the line "DEFINE CHAR_PACING 1000" at the beginning of the transmitter program? no need to change anything else?

rhino
- 4th November 2005, 18:38
If you look at what im sending you will notice that it already in machester format:

$55,$55,$66,$95 = 01010101 01010101 01100110 10010101
Not sure I agree with this statement. I'm no RF engineer by any means, but I think the manchester equivelent for this would be:

0110011001100110 0110011001100110 0110100101101001 1001011001100110 Melanie explains it HERE (http://www.picbasic.co.uk/forum/showthread.php?p=679#post679) very well.

Kamikaze47
- 4th November 2005, 18:42
What im saything there is it is allready encoded. If you encode 1111 1111 1010 0111, you get 01010101 01010101 01100110 10010101 which is what im transmitting. The numbers you worked out is what you get if you encode 1111 1111 1010 0111 twice :)

rhino
- 4th November 2005, 20:46
OK... gotcha.... what, you don't want superdooper redundant encoding? Just kidding.

languer
- 5th November 2005, 00:13
You want to try and figure out if SERIN2 is hanging on the wait qualifier or if it is receiving garbage after the qualifier. You could try something like this:



start1:
Serin2 PORTB.1,16572,[qual] ' wait for $66, then store data
if qual=$66 then start2
goto start1

start2:
Serin2 PORTB.1,16572,[recvd] ' once qualifier is recieved store data new data
if recvd=$95 then High PORTB.0 ' if recvd=1 turn on LED
if recvd=$99 then Low PORTB.0 ' if recvd=2 turn off LED
goto start1 ' loop


This will not hang the SERIN2 command on waiting for $66, it's kind of crude and it will not be great if it misses sync (i.e. receives $95 before 66$). To properly do this you want to have what is referred to as a ring buffer (good topic for search).

Kamikaze47
- 5th November 2005, 04:46
Ive tried adding the "DEFINE CHAR_PACING 1000" line, but it dosnt seem to have made much difference either.

The range is still about 15m with obsticles, or 30m line of sight... That might be as good as it gets?

Ioannis
- 5th November 2005, 20:48
These modules you are using should get further but long time ago, I run a test on these and was disappointed by their behaviour. Then switch to Aurels and after that I am building my own modules for superegenarative and hyperodyne ones.

I would suggest if you don't need many, to try some other brand.

Ioannis

mikem
- 11th November 2005, 16:09
I'm using the same receiver transmitter combo and I reliably obtain 200 feet indoors and over 300 outdoors running the transmitter at 5 volts using 1/4 wave antennas at each end.

Here is what I found; in 2 installations that I did I found that the receiver needed to be tuned to the particular transmitter.

As a result I wrote a short program to continuously send a simple serial signal consisting of a pre-amble character, the letter H for example, and a data value such as a string of 01010101.

I sent these basic commands only to Keep things simple at first when tuning the receiver.

I then moved the receiver board away from the transmitter until the signal level as indicated by a flashing LED on the receiver board went away. Next I slowy adjusted the tuning coil on the receiver board until the LED came back on. This is a very very sensitive adjustment so do not move the tuning slug more than 1/2 turn in either direction.

I repeated this each time increasing the distance between the transmitter board and the receiver board until the LED went out. I found the tuning to be very very sensitive, even a 1/8 turn of the tuning slug resulted in a loss of the demodulated signal.

Next I took 2 untuned receivers to work and measured their input impedance on my HP network analyzer and I found a very narrow match on each one.

Both of the unalaigned receivers as they came from the factory were either tuned below 432.85MHz or above 434.5 Mhz. between 433.2 to 434 .25 Mhz they had a match of over 2.5 :1 VSWR which is a poor match for these modules.

I compared these to the 2 that were tuned using the method above and the 2 tuned receivers were showing a near 50 + J0 match at 433.75 and 433 .95 Mhz respectively.

When I get some more playing time I plan on running some further test using My HP spectrum analyzer to try and determine, dB wise, how sensitive the receivers tuning adjustment actually is.

Mike

Kamikaze47
- 12th November 2005, 04:06
ahh cool, thanks for that mikem... i'll give it a try

Squibcakes
- 12th November 2005, 06:19
Kamikaze,

I've just started palying with these RF modules too and might have some info that may help you.

I found that reception was very flakey when using serout instructions, fortunately I use 16F628 chips that have a built in USART. ie use the HSEROUT/HSERIN instructions.

Straight away i found a marked improvement.

The other thing I noticed, was that if the TX/RX modules are too close, ie less than a couple of inches, the RX module just doesn't work.

I have been able to get good range up to 30m indoors without using any antennas at all.

I haven't yet experimented with the max range but sure it will improve when an antenna is added.

BTW I have had no problems with 4800 baud or lower. Lately I have been playing with manchester codeing, which should be used for RF data... but still trying to get that to work. See code examples.

Cheers
J