HSEROUT question


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2007
    Posts
    59

    Default HSEROUT question

    I have a current board and am using the HSEROUT command. The settings are:
    DEFINE HSER_RCSTA 90h ' Serial Input Enabled
    DEFINE HSER_TXSTA 24h ' Serial Output Enabled (High Speed)
    DEFINE HSER_BAUD 9600 ' Serial Baud Rate (9600 BPS)
    and the output commands are
    HSEROUT [dec2 RID, " "] ' Decimal 2 Characters, Space
    HSEROUT [dec2 RUD, " "] ' Decimal 2 Characters, Space

    Now I want to output do a different device that operates at 2400 buad and follows the the following protocol: Cntrl-A "p" "+" "01" Cntrl-C
    I have hooked the new device to my computer and via hyperterminal I can send this and it receives and performs its function. Now I'm tying to get my board to do the same. So I changed the settings to:
    DEFINE HSER_RCSTA 90h ' Serial Input Enabled
    DEFINE HSER_TXSTA 24h ' Serial Output Enabled (High Speed)
    DEFINE HSER_BAUD 2400 ' Serial Baud Rate (2400 BPS)
    and I tried several outputs including:
    HSEROUT [1] ' Decimal character 1 for SOH "Cntrl-a"
    HSEROUT ["p"] ' ASCII letter p
    HSEROUT ["+"] ' ASCII character +
    HSEROUT ["01"] ' ASCII number "01"
    HSEROUT[3] ' Decimal character 3 for EOH "Cntrl-c"


    I'm trying to hard code what I can type into my keyboard and output the same thing from my board and am missing something.

    Please help me out.
    Thank you,
    Hylan

  2. #2
    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

  3. #3
    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

  4. #4
    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

  5. #5
    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.

  6. #6
    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

  7. #7
    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

  8. #8
    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.

  9. #9
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    For your board to talk to the device, you will need to stop using the FTDI converter. you have interface incompatibilities here.

    As I understand it, this is you setup:
    PIC ->non-inverted serial->FTDI->usb->PC (with virtual com driver prolly)
    Other device->true serial->USB adaptor->PC (with virtual com driver prolly)

    Just connecting the USB to USB will not work.
    connecting non-inverted serial <->true serial will not work

    I see 2 choices:

    Add a level converter (MAX232) to the PIC serial then connect that to the other device true serial
    or
    Use 2 new pins and SERIN/SEROUT so you can make true serial data without the converter. I think this should work unless the other device needs RS232 levels (-12 to 12 V). In that case you will have to use a MAX or simular converter.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  10. #10
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    Bert you are correct in your description. I was wondering if the FTDI chip was causing a problem. I had posed that question to the audio device tech group and hadn't gotten an answer yet. When I plug my device into a computer, it has to load the drivers in order to function. However, with the audio device, it has no way to do this.

    I'll check my schematics and board layout and see if I have another pair of pins I can output to or if I can tap into the trace at a via before the FTDI chip to get the raw signal.

    Thank you,
    Hylan

  11. #11
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: HSEROUT question

    Update: unfortunately not a good one.

    I have two versions of my hardware, one of which actually has direct pic to pin access. I used this board to bypass the USB chip and try to go directly to the other audio device with no luck. My device is already in production and this is just a single variant I'm trying to create for a single test, so changing the board is not an option.

    I haven't fully given up but am close. This seemed simple in concept but has proven otherwise. I'm currently looking into a small linux based single app computer that could basically function as a host just to capture and pass the signals betweent the two devices using a java program.

Members who have read this thread : 1

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