fast + accurate packet and baud rate


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    76

    Default fast + accurate packet and baud rate

    Thanks to mister_e and keithdoxey (and many others) I was able to make the following code that allows to PIC16F628A's to communciate serially. There are four buttons on the transmitter that turn on four pins on the receiver. The code works, but does anyone have any suggestions on making it faster and more accurate (many packets are lost and sometimes there are delays between packets)? Thanks for the help. (I need the $A5 and the "~" as a synch byte because it will eventually be hooked up to a rf link)

    -Mike

    Transmitter code:
    -----------------

    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 2400

    cmcon = 7

    Current var byte
    Laststate var byte
    input PORTA.0
    input PORTA.1
    input PORTA.2
    input PORTA.3

    Main:

    current.0 = PORTA.0
    Current.1 = PORTA.1
    Current.2 = PORTA.2
    Current.3 = PORTA.3

    if (Current <> Laststate) then
    hserout [$A5,"~",Current]
    Laststate = Current
    endif

    goto main

    -------------
    Receiver code
    -------------
    define HSER_CLROERR 1
    define HSER_RCSTA 90h
    define HSER_BAUD 9600

    cmcon = 7

    Current var byte
    output PORTA.0
    output PORTA.1
    output PORTA.2
    output PORTA.3
    low PORTA.0
    low PORTA.1
    low PORTA.2
    low PORTA.3

    Main:

    Hserin 20,Main,[WAIT("~"),Current]

    Current = ~ Current

    PORTA.0 = Current.0
    PORTA.1 = Current.1
    PORTA.2 = Current.2
    PORTA.3 = Current.3

    goto main

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i'm sure you already know but your baudrate don't match on both side.

    With RF, using higher baudrate may work... or not. Tell us what kind of RF stuff you're using.

    Code:
    current.0 = PORTA.0
    Current.1 = PORTA.1
    Current.2 = PORTA.2
    Current.3 = PORTA.3
    Code:
    current = PORTA & $0F
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jul 2006
    Posts
    76


    Did you find this post helpful? Yes | No

    Default

    Sorry, the mismatching baud rates was just a typo. I am going to use the RX433 and TX433 duo from Qkits.

    http://store.qkits.com/moreinfo.cfm/RX433
    http://store.qkits.com/moreinfo.cfm/tx433

    I have 4Mhz oscillators. Can I go at a faster baud rate?
    Thanks.

    -Mike

  4. #4
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    You need to check the manufacturer's datasheets for that transmitter and receiver to see the maximum bps they can handle. If QKits doesn't have the data sheet check the Wen Shing web page (Wen Shing manufactures the RF modules.)The receiver max is 4800bps.

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