Did I get the right device? USB-Serial


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262

    Default Did I get the right device? USB-Serial

    I just ordered a USB TTL cable on ebay, hoping its what I hope will let me connect USB from PC directly to PIC with serial communication, if someone could give me an idea on the Code I should use or any links. also with this unit is it possible to send say 32bits of data into 4bytes of variables? Eventually I want to use the USB Option on the 18F4550 but I need to learn to Interface with a serial port first.

    The Ebay item I just ordered LINK

    I dont want to have to use and translation chips, I want to go strait from usb to PIC. So did I order the right kind of cable?
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Did I get the right device? USB-Serial

    Hi Chris,
    I can't look at the link you've posted as I'm currently on a restricted network so this is more in general. If I'd venture a guess that cable is a "standard" USB to serial converter. When connected to the PC and its drivers are installed it'll look to Windows as just another COM-port. The software on the PC and on the PIC will be exactly the same as if you were using a real COM-port.

    You say that you don't want to use any converter chips but that's exactly what that sort of cable is - it contains a USB-serial converter (like the FT232 for example). Now, some cables/converters outputs true RS232 levels meaning you'd need a RS232<->TTL level translator chip (like the MAX232) but since you mention USB to TTL I'd think your particular one outputs TTL so it should be OK to connect it directly to the PIC.

    As for going "true" USB that's a completely different thing compared to "serial over USB". I haven't yet ventured in the world of USB (I tried once and failed...) so I'm not the right guy to give advise on the subject.

    /Henrik.

  3. #3
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Did I get the right device? USB-Serial

    thanks for the quick reply henrik,

    heres the data on it.

    1m PL2303HX Download Cable USB To COM USB to TTL Converter Cable
    Features:
    •Built-in TTL COM PC-PL2303HX Chip.
    •Standard USB type A male and TTL 4 pin connector
    •Simple and Easy way to give USB support to your designs
    •Available for Linux, Mac, WinCE and Windows (XP, 2003), Vista Win 7

    Pin Definition:
     Black cable GND
     Green cable TXD 
     White cable RXD
    Red cable VCC
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Did I get the right device? USB-Serial

    Hi Chris,
    Yes, now I'm on a "better" network so I took a look at the EBAY-link.
    When you plug that cable into the PC and install the device driver it'll appear as another COM-port in Windows. You can find the driver on the Prolific PL-2303 site (which is the USB<-> chip used in the cable).

    /Henrik.

  5. #5
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Did I get the right device? USB-Serial

    thanks, i will be using VB.net to build the interface program, but I was wondering just to test it out.. I remember back in the days of DOS, you could do a command like

    c:\12345678 >com1 ???
    or
    c:\copy test.txt >com1

    something like that, I cant remember it exactly, but you could send a text string or file directly to a com port or lpt port. can you still do that?

    also is it possible to send a large number of bits, say 32,48,64 and have it store them in a set of variables, for example

    Code:
    MYBYTE0 VAR BYTE
    MYBYTE1 VAR BYTE
    MYWORD0 VAR WORD
    MYWORD1 VAR WORD
    
    LOOPME:
    SerialIN????
    code to break up string in pieces and store in variables
    GOTO LOOPME
    my textbox on PC has 48 "1 & 0's" no spaces to be sent as an example
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Did I get the right device? USB-Serial

    Hi Chris,
    Can't help with the command line interface to the COM-port, never seen that before. Doing serial coms in VB.net using the supplied serial port object is quite easy though. Just beware that Microsoft removed the serial port object from VB when they introduced .net and put it back in some later version. I believe all the Express versions have it if that's what you're using. It's been a long time since I played with VB.

    On the PIC side there's no problem to receive "any" number of bytes. HSERIN can split the bytes up properly as it receives them or, if you're using an interrupt driven routine you can store the data in an array and split them up when everything is in. It all depends on how the data is formated, high or low byte first etc.

    /Henrik.

  7. #7
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Did I get the right device? USB-Serial

    ok Thanks, Ive got .net enterprise 2010, and Ive confirmed I do have the serial control, will have to do a bit of searching for some example code to start.
    as for the pic side thats great news, I need to send a word at a time, the high byte determines which variable to store the low side byte. it would be great to be able to split it at 6/10 bits and convert the high 6bits to a single byte, and the low 10 to a single word. So...
    "0000110000001111" would end up split up at "000011/0000001111"
    Byte0 = 00000011
    Word0 = 0000000000001111
    Does this look like it might work?
    Last edited by wdmagic; - 20th June 2013 at 08:59.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Did I get the right device? USB-Serial

    Hi,
    Something like this might work then:
    Code:
    RawWord VAR WORD
    Adress VAR BYTE
    Value VAR WORD
    
    HSERIN[RawWord.Byte1, RawWord.Byte0]   ' Receive two bytes and store them in RawWord, high byte first
    Adress = (RawWord.Byte1 & 252) >> 2    ' Get the 6 top bits and store them in variable Adress, 0-63. (The &-operation may not be needed)
    Value = RawWord & 1023                 ' Get the bottom 10 bits and store them in variable Value, 0-1023
    /Henrik.

  9. #9
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Did I get the right device? USB-Serial

    thanks, I will try that as soon as part gets here!
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  10. #10
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Did I get the right device? USB-Serial

    If you are running Windows XP, then Hyper terminal will work. Alternatively, you can download a simple terminal program for free called Terminal (V1.9b is the latest). I would not recommend trying to start with developing both ends of the link at the same time. When it doesn't work first time (you know it won't), troubleshooting will be significantly easier if you know one end of the link is correct. YMMV

Similar Threads

  1. Replies: 1
    Last Post: - 5th October 2011, 08:59
  2. USB Device Communication
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th January 2008, 21:22
  3. usb - device not recognised
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th January 2007, 17:47
  4. USB device
    By Haitham Rifai in forum USB
    Replies: 2
    Last Post: - 5th December 2005, 09:07
  5. usb device not recognized
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd June 2005, 05:22

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