PIC-PIC RF Comms


Closed Thread
Results 1 to 20 of 20
  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default PIC-PIC RF Communication - Range of 1m ??

    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...eets/Z6905.pdf
    http://www.altronics.com.au/download...eets/Z6900.pdf

    Transmitter Code:

    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:

    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
    Last edited by Kamikaze47; - 3rd November 2005 at 15:23.

  2. #2
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156


    Did you find this post helpful? Yes | No

    Thumbs up Be more specific

    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.

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    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.

  4. #4
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    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.

  7. #7
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    making it 8 $55s, and changing the start character to $AA dont seem to have made any difference unfortunately

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    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

  9. #9
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    If you look at what im sending you will notice that it already in machester format:

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

  10. #10
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Hello,
    try more preambel-characters,
    Use "DEFINE CHAR_PACING 1000" at the transmitter

    We use such simple receivers/transmitters... ;-)
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  11. #11
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    so just add the line "DEFINE CHAR_PACING 1000" at the beginning of the transmitter program? no need to change anything else?

  12. #12
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by Kamikaze47
    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:
    Code:
    0110011001100110 0110011001100110 0110100101101001 1001011001100110
    Melanie explains it HERE very well.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  13. #13
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    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
    Last edited by Kamikaze47; - 4th November 2005 at 18:47.

  14. #14
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Red face

    OK... gotcha.... what, you don't want superdooper redundant encoding? Just kidding.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  15. #15
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156


    Did you find this post helpful? Yes | No

    Cool

    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:

    Code:
    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).

  16. #16
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    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?

  17. #17
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    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

  18. #18
    Join Date
    Oct 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    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

  19. #19
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    ahh cool, thanks for that mikem... i'll give it a try

  20. #20
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Talking

    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

Similar Threads

  1. RF transmiter reciever using PIC
    By drama in forum mel PIC BASIC
    Replies: 5
    Last Post: - 4th October 2007, 16:26
  2. Generating RF from a PIC
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 26th January 2006, 20:26
  3. PIC to PIC serial comms
    By damiko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th July 2005, 17:40
  4. Pic to Pc Comms
    By Darrenmac in forum General
    Replies: 2
    Last Post: - 21st May 2005, 01:44
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts