RX / TX duo


Closed Thread
Results 1 to 20 of 20

Thread: RX / TX duo

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Posts
    76

    Default RX / TX duo

    I am fairly new to PIC's so I would love if I got some help to see if this code would work. I am making a remote control car and I have a receiver and transmitter that both use the 16f84. The four pushbuttons on the transmitter control two motors that are connected to an H-Bridge (on the receiving end) which in turn control both directions for the motors. Can someone tell me if this code is valid for the schematics? Thanks a million...

    Both schematics are attached and the code is below...

    Transmitter Code

    ------------------------------------------

    INCLUDE "modedefs.bas"

    output PORTB.4

    start:
    'Check if buttons are pressed
    if (PORTB.0 = 1) then one
    if (PORTB.1 = 1) then two
    if (PORTB.2 = 1) then three
    if (PORTB.3 = 1) then four

    goto start

    one:
    serout PORTB.4,N2400,["1"]
    goto start

    two:
    serout PORTB.4,N2400,["2"]
    goto start

    three:
    Serout PORTB.4,N2400,["3"]
    goto start

    four:
    serout PORTB.4,N2400,["4"]
    goto start

    Receiver Code

    ----------------------

    INCLUDE "modedefs.bas"

    output PORTA.0
    output PORTA.1
    output PORTA.2
    output PORTA.3

    start:

    in VAR BYTE

    serin PORTB.1,N2400,in
    'PORTA.0 receives signal at 2400 baud rate and places
    'input at variable in

    'Testing serial input
    if in == "1" then one

    if in == "2" then two

    if in == "3" then three

    if in == "4" then four

    goto start

    'Turn on PORTA.x for 100 milliseconds and then turn off (motors)
    one:
    high PORTA.2
    PAUSE 100
    low PORTA.2
    goto start

    two:
    high PORTA.3
    PAUSE 100
    low PORTA.3
    goto start

    three:
    high PORTA.1
    PAUSE 100
    low PORTA.1
    goto start

    four:
    high PORTA.0
    PAUSE 100
    low PORTA.0
    goto start

    --------------------------------
    Thanks again!!!

    -Mike
    Attached Images Attached Images   
    Last edited by mbw123; - 17th July 2006 at 17:44.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    First off, your serial input/output code won't work as it's set up. I use that particular pair of transmitter/receivers a lot, I know a bit about them. All you'll get at the output is a bunch of noise.

    Do a search on "manchester encoding" for use with this type of Tx/Rx pair.

    Basically what has to happen is this:

    You have to 'train' the receiver to 'know' what the difference between a '1' and a '0' is.
    You do this by sending a 'preamble' of 0's and 1's, a few milliseconds of each. This charges up a capacitor to 1/2 the voltage needed to detect if the input is actually a '1' or a '0'. This is actually what's called a 'data slicer'.

    After the preamble is sent, you can start sending data.

    The problem is, if the data you send has too many '1's or '0's, the capacitor in the 'data slicer' will either charge up all the way to the '1' trip-point or the '0' trip-point and pretty soon all your data is either '1's or '0's.

    The trick is to try and send an equal number of '1's and '0's. The closer you are to an equal number of each, the better the quality of the data sent.

    So, what you do is, you break apart your input byte into individual '1's and '0's, a binary '0' becomes a '01' and a binary '1' becomes a '10'. This has a side effect of doubling the amount of data you have to send, no biggie. If you only need 4 codes (actually this single byte method works up to 16 individual codes), you can just use a look up table.

    For instance:
    To send a binary 0000, send 01010101, ($55)
    To send a binary 1010, send 10011001, ($99)

    Relatively easily done. You can do it in a loop, parsing every bit out at both the Tx and Rx end, or just use bytes that have an equal number of '1's and '0's, but no more than 2 '1's or '0's in a row.
    0 = 0000 = 0101 0101
    1 = 0001 = 0101 0110
    2 = 0010 = 0101 1001
    3 = 0011 = 0101 1010
    4 = 0100 = 0110 0101
    5 = 0101 = 0110 0110
    6 = 0110 = 0110 1001
    7 = 0111 = 0110 1010
    ...and so on...

    BTW = a good preamble sequence is a bunch of $55 and $AA back to back for about 5ms with the TWS-434/RWS-434 pair.

    Have fun...break something...or make it work...
    JDG

  3. #3
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    I don't have any experience with these modules but I do have two questions about them regarding something I read a while ago:

    1. Is it true that you don't need an FCC certification to use these?

    2. What is the typical range for the pair?

    Thanks,

    Chris

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    You don't need an FCC certification in the U.S. as far as I know. If it's a commercial device to be sold in bulk, then you probably will, I'm not sure. I've got 10 different 'things' I've built running around the house/yard/garage, I don't have any certifications, then again, I live out in the sticks.

    Range...
    Well, it varies wildly. The best I've gotten is about 1/4 mile on 12v on the Tx at about 9600 baud (4800 if you use manchester encoding), big tuned antenna at both ends, etc. Generally, I can easily get about 100-200 feet on 5v on the Tx, 12-15 wire antennas at both ends at 2400 baud.

    JDG

  5. #5
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    FCC certification doesn't matter whether you live in the "sticks" or in a big city. I have many RF devices around my house also but they are not certified because I am not selling them. However, I have made one device that needed FCC certification because I am selling it.

    I use the Linx LR series chips and they work very well. No need for Manchester encoding and they are pretty cheap. I'm not sure how much the TWS is but you can get a pair of Linx chips for about $15 depending on where you get them. They have pretty good range (100-3000 feet) depending upon the antenna and board design, and have very little noise. Furthermore, if you want to send a decimal 1, then you send a decimal 1....no need for 10101010.

    My reason for asking the questions was money. There are many devices (quantites of 1 or 2) that I want to make for customers but I can't legally sell them because they need FCC certification. It's simply not worth it to go for a certification on a product that costs $100 to build but $5000 to certify and never sell it again. If the FCC certification is in fact not required, it would be very advantageous for me to use them.

    I was told they work on AM frequency and this is why it does not need FCC certification. If anyone knows if this is true, please let me know.

    Thanks,

    Chris

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Certification - I know it doesn't matter where I live, but it doesn't hurt when what somebody doesn't know doesn't hurt them....

    The TWS/RWS-434 pair work in the 432Mhz band, On/Off keying (A.S.K.???). Still I don't think it matters. If you sell them as a commercial product, I think they have to be certified.

    Now if you sell them as a hobby/experimental type deal, that's a different story.

    Range on the TWS, I suppose I could get longer if I put more effort into the antenna efficiency at both ends. But like I said, the ranges stated above were with simple wire whip antennas, not even the stuff kind, just a chunk of wire hanging out in the wind.

    JDG

Similar Threads

  1. Replies: 67
    Last Post: - 8th December 2009, 02:27
  2. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 00:13
  3. RX - TX timming
    By ruijc in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th February 2009, 00:06
  4. TX RX Buffer Question
    By shawn in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th January 2005, 01:49
  5. Tx and Rx of Single Pin PIC's
    By Dwayne in forum Code Examples
    Replies: 0
    Last Post: - 26th May 2004, 14:55

Members who have read this thread : 1

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