USB Serial Communication Continuous


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Feb 2007
    Posts
    11

    Default

    I havre tried all the above statements....

    DEFINE HSER_CLROERR 1 is now inculded...

    however im still getting errors...
    i transmit : 239 65 66 67
    I receive : 254 254 6 134 128
    (5 chars for tx of 4 chars)

    maybe its because i used SEROUT in conjunction with HSERIN ?

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

    Default

    And... do you get always the same results or they are always different?
    Steve

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

  3. #3
    Join Date
    Feb 2007
    Posts
    11

    Default

    Differnet results each time...


    Anyway I have finally got the TX/RX to work !

    Heres the section of the TX code which works:

    IF USBBufferIn[7]=239 then
    SEROUT PORTC.0,T2400,[USBBUFFERIN[7]]
    gosub DoLow
    USBBufferin[7]=0

    if USBBufferIn[1]<>0 then
    SEROUT PORTC.0,T2400,[USBBufferIn[1]]
    gosub DoLow
    USBBufferIn[1]=0
    endif
    USBService
    if USBBufferIn[2]<>0 then
    SEROUT PORTC.0,T2400,[USBBufferIn[2]]
    gosub DoLow
    USBBufferIn[2]=0
    endif
    USBService
    if USBBufferIn[3]<>0 then
    SEROUT PORTC.0,T2400,[USBBufferIn[3]]
    gosub DoLow
    USBBufferin[3]=0
    endif
    USBService
    if USBBufferIn[4]<>0 then
    SEROUT PORTC.0,T2400,[USBBufferIn[4]]
    gosub DoLow
    USBBufferin[4]=0
    endif
    USBService
    if USBBufferIn[5]<>0 then
    SEROUT PORTC.0,T2400,[USBBufferIn[5]]
    gosub DoLow
    USBBufferin[5]=0
    endif
    USBService
    if USBBufferIn[6]<>0 then
    SEROUT PORTC.0,T2400,[USBBufferIn[6]]
    gosub DoLow
    USBBufferin[6]=0
    endif
    USBService
    endif

    gosub dousbin


    goto start

    DoLow:
    USBSERVICE
    PAUSE 65
    USBSERVICE
    return

    Notes:
    1. You need to use the T mode if you are directly connecting PIC's.
    2. Notice the Pause 65 - It now works great with a longer delay...and has no effect on the USB connection.


    Heres part of the modified RX code :

    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    Define HSER_RCSTA 90h
    Define HSER_BAUD 2400

    The oscillator is set to 20Mhz in both cases using : DEFINE OSC 20
    __________________________________________________ _______________

    Now that the wired link is working....I checked it using a FSK TX/RX pair
    and the problems are endless....
    Completely random characters etc
    Characters appear when i move my hand in the air !
    I have tried a passive Bandpass filter around 2400hz but it doesnt sove the problem...
    I have connected a Schottky TTL gate to the DataOut...for maintaining proper level transitions...
    Also when I connect a LED to the DataOut of the RX it keeps flickering at a fast rate (around 10kz on the oscilloscope),even when the Tx is off...which is probably whats causing the errors..

    Any ideas on how to fix this ? or is the RF module faulty ?

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default

    pic-ker, I bet the RF receiver module you are trying to use has no squelch control and the toggling of the receiver output is the data slicer trying to interpret noise. You will have to put some kind of sync and preamble bytes in place before you transmit the data and, if the sync and preamble bytes are not received in order and correctly you should not accept the data. This is the common problem people have when using inexpensive rx and tx modules. Even with more expensive modules the same sync/preamble techniques should be used. Also you should send a computed checksum as the last byte and this checksum should be checked at the receiver end before using the data received.

    Dave Purola,
    N8NTA

  5. #5
    Join Date
    Feb 2007
    Posts
    11

    Default

    Quote Originally Posted by Dave View Post
    pic-ker, I bet the RF receiver module you are trying to use has no squelch control and the toggling of the receiver output is the data slicer trying to interpret noise. You will have to put some kind of sync and preamble bytes in place before you transmit the data and, if the sync and preamble bytes are not received in order and correctly you should not accept the data. This is the common problem people have when using inexpensive rx and tx modules. Even with more expensive modules the same sync/preamble techniques should be used. Also you should send a computed checksum as the last byte and this checksum should be checked at the receiver end before using the data received.

    Dave Purola,
    N8NTA
    Yeah, youre right, the module was really cheap ... it doesnt have a crystal based oscillator, rather there is an inductor coil which can be adjusted by a screwdriver....

    I think it would be better if I get another module :-) instead of doing all that syncing/CRCing etc

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default

    pic-ker, Even if you buy a more expensive rf module pair you will still have the same problem. I speak of a squelch circuit that mutes the data line from the receiver when there is no received carrier. However you will still have to send some kind of sync byte for the program to lock onto for the data stream. Also if you don't send some kind of checksum with the data packet you will have no idea of the data bytes in the packet are valid.

    Dave Purola,
    N8NTA

  7. #7
    Join Date
    Feb 2007
    Posts
    11

    Default

    I am sending a sync packet of '239' in a frame of 6 characters, But I find that there is no need for error checking as I am using this mainly for text messaging..

    dave, do you have any kind of squelch circuit in mind ? and how do I detect when the carrier is present ?

Similar Threads

  1. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 17:03
  2. Serial data to USB
    By cooksydesign in forum USB
    Replies: 18
    Last Post: - 29th October 2008, 15:10
  3. USB and serial cable connection(s)
    By ardhuru in forum Schematics
    Replies: 3
    Last Post: - 18th August 2008, 15:26
  4. Bafo USB to serial adapter
    By ardhuru in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 29th July 2006, 18:48
  5. Serial to USB converter
    By jrt4fun in forum USB
    Replies: 6
    Last Post: - 8th August 2005, 15: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