Shop OBEX P1 Docs P2 Docs Learn Events
Usb2ser — Parallax Forums

Usb2ser

ElectronegativityElectronegativity Posts: 311
edited 2005-09-09 23:22 in General Discussion
It's me again. smile.gif

I'm about to buy a USB2ER device and try to communicate between my PC and an SX chip.

I'm a bit mystefied by the details though.

Does anyone have sample code I could look at?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I wonder if this wire is hot...

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-31 00:05
    Hello,

    ·· There really isn't any sample code...The device is simply meant to provide a COM Port to a computer via the USB Port.· So you plug the device into the USB Port on the computer, with the driver installed you have a COM Port.· Now you send your serial data to/from the device via the TTL level serial outputs on the other end.· Bringing DTR high will also pull the 4th line low, which can be used as a reset or something.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ElectronegativityElectronegativity Posts: 311
    edited 2005-08-31 00:14
    Bringing DTR high will also pull the 4th line low, which can be used as a reset or something. said...


    Umm... What's a DTR?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I wonder if this wire is hot...

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-31 00:19
    Data Terminal Ready.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-31 00:54
    I've used the USB2SER to connect an SX chip to a PC (using SX/B).· It's really pretty easy: use a True data mode (e.g., "T9600")·for SERIN and SEROUT.· I've attached a demo.· Conect the Sout pin (defined in the program) to the RX pin on the USB2SER, the Sin pin to the TX pin of the USB2SER, and connect the USB2SER.VSS pin to the SX.Vss connection.· Pretty simple, really.

    Also, make sure you have the FTDI driver installed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 8/31/2005 12:55:00 AM GMT
  • ElectronegativityElectronegativity Posts: 311
    edited 2005-08-31 01:12
    Ahh, good old hyperterminal, brings back some foggy memories from the Age of Dial-up Modems.

    This is perfect!
    You have saved me muchness of time I am sure.

    roll.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I wonder if this wire is hot...
  • Keith MKeith M Posts: 102
    edited 2005-08-31 03:17
    Chris or Jon,

    I sent a message into support yesterday, so I apologize if you are seeing this for a second time --- I've also emailed FTDI per Ryan's@parallax suggestion.

    Do you have any details on how to use the USB2SER with (custom) baud rates in excess of 1mbps? I'm not worried with the SX details perse as much as the Windows side of things. I've done serial programming on the Windows platform, and so I'm not a newbie in that regard. Can I just use

    handle = CreateFile("COMx", etc flags, params, etc);
    and use SetCommState(handle, dcb); where dcb is the windows data structure that defines baud rate, parity, etc?

    Using the VCP drivers that you redistribute, is it business as usual on the PC for accessing that port, except that I can pass high(and non-standard) baud rates? I've read some stuff on FTDI's site regarding modifying .ini's to setup the "default" baud rates to map to higher datarates.

    I'll be bit-banging data to the UART to achieve higher rates. Should be easy enough on the SX side "creating" a start/stop bit, and the data bits....

    Keith
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-08-31 13:23
    I don't know -- I've only worked with "standard" baud rates presented by Hyperterminal. There was another customer attempting high-speed comms; turned out his problem was the software he was using to write the Windows side of things.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-31 14:46
    Keith,

    ·· I don't know either...Never had a need to do something like this.·

    Electronegativity,

    ·· Have you gotten things working on your end?· Fortunately HyperTerminal won't adversly affect the USB2SER, however, HyperTerminal has settings that affect the DTR line, and thusly can affect the 4th output on the USB2SER if you use it for anything.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ElectronegativityElectronegativity Posts: 311
    edited 2005-08-31 16:01
    Hi Chris, I ordered the device last night, so it will be a week or so before I can try it out.
    I di manage to solder an SX20 onto a Sparkfun breakout board last night though. [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I wonder if this wire is hot...
  • Keith MKeith M Posts: 102
    edited 2005-08-31 16:38
    Thanks.· Got a good reply from FTDI though
    FTDI tech support said...

    You can simply input the required baud rate in to your code and the driver
    will automatically perform the division for you.
    Accessible baud rates are shown in the attached file.

    Aliasing baud rates allows existing VCP apps which use a table of standard
    baud rates e.g. HyperTerminal to select a speed such as 9600 baud but
    operate at another speed. This is defined in:

    http://www.ftdichip.com/Documents/AppNotes/AN232B-05_BaudRates.pdf
    I've attached that excel spreadsheet.· It lists all the acceptable baud rates you can pass to the driver.

    I'm also going to test these higher datarates, and I'll report back once I get some kind of conclusive result.

    It seems so simple, that something has to be wrong here! [noparse]:)[/noparse]
  • PJMontyPJMonty Posts: 983
    edited 2005-08-31 17:27
    Electronegativity,

    If you want to learn more about serial ports and USB, then go here:

    www.lvr.com/

    Jan Axelson has books on each subject, plus a ton of info available on the site itself.
      Thanks, PeterM
  • ElectronegativityElectronegativity Posts: 311
    edited 2005-08-31 18:12
    Wow, That man really fell in love with his USB port!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I wonder if this wire is hot...
  • Keith MKeith M Posts: 102
    edited 2005-09-08 16:14
    Keith M said...
    Can I just use

    handle = CreateFile("COMx", etc flags, params, etc);
    and use SetCommState(handle, dcb); where dcb is the windows data structure that defines baud rate, parity, etc?

    Using the VCP drivers that you redistribute, is it business as usual on the PC for accessing that port, except that I can pass high(and non-standard) baud rates?

    Keith
    I hate to reply to myself here, but for the benefit of the community :

    I got my USB2SER setup, and communicating with some software I wrote in VC++ in .net.

    The answer is a resounding YES.· Using FTDI's Virtual Com Port drivers, the device shows up as COMx where x is the next available number.· In my case, it's COM4.· It was just a matter of modifying the DCB structure that contains the baudrate and passing it to SetCommState() as usual.· You can pass literally any number you like, provided it's one of the ones listed on the supported spreadsheet I attached in my original message.

    It's surprisingly transparent.· Most apps seem to work fine with it.

    I've attached some sample VC++ code that I wrote just to test basic functionality.· This is a console app that opens the port, sets the port up with baud rate etc, and goes into an infinite loop reading from the serial port.· I also included a line which shows how to write to the port.

    Notice this is barebones code -- it doesn't rely or depend on any non-standard external headers, libraries, etc.· To build it, simply select "New Project", pick Visual C++ Projects, select the "Managed C++ Application" template, give it a name, and then just replace the default .cpp file with mine.

    FYI

    Keith
  • ElectronegativityElectronegativity Posts: 311
    edited 2005-09-09 23:17
    Hi all,

    Which pin on the FT232BM does the "reset" pinout on the USB2SER correspond to?

    I want to use the USB2SER in a USB powered device and need to handle the suspend mode.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I wonder if this wire is hot...
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-09 23:22
    According the schematic in the docs (hint), the RES\ pin is controlled by DTR -- but you'll see that it is pulsed (there is a series cap).· Also note that the output is a transistor circuit, so RES\ can only be pulled to Vss and can not be driven high.

    Docs: http://www.parallax.com/dl/docs/prod/acc/USB2SERDocs.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 9/9/2005 11:21:22 PM GMT
Sign In or Register to comment.