HSEROUT question


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    You will need a digital to RS232 translator as MAX232. Check also if your device is a DCE or a DTE, this matter for Rx & Tx connections.

    Cheers

    Al.
    All progress began with an idea

  2. #2
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    My current board has a USB output on it controlled by an FTDI FT232RL contoller and outputs fine to a compter. So now I'm using a usb to db9 serial adapter to go to the new device.

    It sounds like I have a setting issue, but also is my code correct?

    Thank you,
    Hylan

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    It sounds like I have a setting issue, but also is my code correct?
    Yes your code will output @ 2400 bauds the string equivalent of [Cntrl-A "p" "+" "01" Cntrl-C], but you should tell the frequency of your clock to check it completely.

    Assuming your clock to be 4 MHz then the setting should be:

    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 25 ' 2400 Baud @ 4MHz, 0,17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically


    Now if your board Tx & Rx fine with your PC and your device as well then you will need a crossed cable to communicate from board to device. Check the RS232 cable you are using to communicate from your PC to the Device and see if pin 2 (DB9) correspond to pin 2 on the other side and if pin 3 correspond to pin 3. In this case your device is wired as a DCE and you are using correctly a straight cable since your PC is a DTE. In this case also your bord is a DCE so to communicate between two DCEs you will need to cross the Pin2 with Pin 3 (DB9) on one side, so that Rx ----> Tx & Tx ----> Rx Ground -----> Ground.

    You should then have the serial communication you desire.

    Cheers

    Al.
    Last edited by aratti; - 22nd February 2011 at 18:03.
    All progress began with an idea

  4. #4
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    Al,
    I think the cable connection is probably my problem as you mentioned, going from device to device without the computer. I'm in India at the moment and due to some strikes and other stuff going on, I'm limited to be able to get a actual cable. So I took regular USB cable, cut it open and then crossed the green and white wires (D+ and D-) and left the red and black alone. I then plugged this into the usb to serial cable and I still didn't get anything.
    I then put the white and green back just to make sure it still worked normally when hooking the device to the computer and it did.
    So did I miss something? Logically this made complete sense when you mentioned it and I was dissappointed when it did't work. I've also got some questions in to the tech support group for the other device to see what their take on this is.
    Thank you,
    Hylan
    Last edited by Hylan; - 24th February 2011 at 05:21.

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    Hylan, I am a little lost! Let 's do step by step an analysis of your system.

    1) Very likely your PC (laptop) has no serial port so you are using an USB to serial converter.

    2) Your different device that operates at 2400 bauds is a RS232 serial device, which means that you will connect it to the PC via a serial cable. This serial cable should have two DB9 connectors, one to be inserted into the corresponding DB9 on your device and the other into the DB9 (male) of your USB/RS232 converter.

    3) Your PIC board MUST have a RS232 connection since you are using the HSEROUT command, so I assume also this board has a DB9 connector.

    It is possible that you plug the USB/RS232 converter directly (via DB9M to DB9F) to your boards, so you are not using a serial cable.

    Now you need to made a serial cable for connecting your pic board to device that operates at 2400 bauds. This is not very difficult. You have to obtain two DB9 connectors that plug respectively into the pic board and into the 2400 bauds device board (these two boards should have a female conectors, if so you will need a males couple. But you do better check)

    Once you have the correct DB9 connectors you should wire them in this way :

    DB9 (pic device) DB9 (2400 bauds device)
    --------------------------------------------------------
    Pin 2 ----------------------> Pin 3
    Pin 3 ----------------------> Pin 2
    Pin 5 ----------------------> Pin 5
    ---------------------------------------------------------

    Make the cable long as you desire, but not longer than 2 meters, plug this cable into the two devices, power up both devices and run your code, 2400 bauds device should receive the serial string you have coded.

    Please note that a RS232 serial cable is not an USB cable.

    Good luck

    Al.
    Last edited by aratti; - 24th February 2011 at 06:15.
    All progress began with an idea

  6. #6
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    My device has a USB B female connector on it. The hserout command goes to an FTDI (FT232) chip which then outputs over the USB connector. Normally my device functions as a client feeding information to a computer.

    However, I would like to feed control information over to another device(audio file player) that normally functions as a client when connected to a computer. The audio player has a serial (db9) connector.

    So what I tried to do initially was plug a standard USB cable into my device (using the USB B connector). Then I put a gender bender on the other end of the cable and plugged a USB to serial adapter into the gender bender and plugged the db9 into the audio player. This didn't work.

    So the last thing I tried was to switch the D+, D- lines in the USB cable. And that didn't work either.

    I just looked up the pinnout for the DB9 and I don't see a vcc pin like the usb. So I'm wondering if there is a problem with leaving the USB #1 and #4 pins connected the way they are. Unfortunately I don't even have a multimeter with me. I will try to get out and find one today and test this to make sure pin 5 on the db9 is to gnd.

    let me know what you think.
    Thank you,
    Hylan

  7. #7
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    USB and RS232 are both called serial ports because they send data serially, but they are VERY different interfaces and can NOT be connected to each other. HSEROUT has nothing to do with USB. Please look up the specs for both of these interfaces, then you'll need to return to square 1.

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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