Serial data to USB


Closed Thread
Results 1 to 19 of 19
  1. #1
    Join Date
    May 2005
    Location
    Minnesota
    Posts
    31

    Default Serial data to USB

    I have good working code to transmit serial data to and from a PIC 16F628A and a VB6 application. Now the request for a USB connection has come up. Has anyone played with a serial to USB converter? The board with the PIC has been made, I'm stuck with serial in, serial out, and ground for data transfer. The data is transfered at a blistering 4800bps, but for the small amount of data it's just fine.
    Two bytes are first sent from the VB application to the PIC. The PIC acknowledges with a byte, then transfers less than 50 bytes and it's over.
    Soooo, anyway, has anyone played with a serial to USB converter? I have seen one or two that are built into a cable, which would be sweet if that worked out.
    Thanks to all.

    Brad

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Quote Originally Posted by cooksydesign View Post
    I have good working code to transmit serial data to and from a PIC 16F628A and a VB6 application. Now the request for a USB connection has come up. Has anyone played with a serial to USB converter? The board with the PIC has been made, I'm stuck with serial in, serial out, and ground for data transfer. The data is transfered at a blistering 4800bps, but for the small amount of data it's just fine.
    Two bytes are first sent from the VB application to the PIC. The PIC acknowledges with a byte, then transfers less than 50 bytes and it's over.
    Soooo, anyway, has anyone played with a serial to USB converter? I have seen one or two that are built into a cable, which would be sweet if that worked out.
    Thanks to all.

    Brad
    I have good luck with a Belkin F5U409.

    http://catalog.belkin.com/IWCatProdu...duct_Id=459431
    Last edited by mackrackit; - 28th October 2008 at 20:56.
    Dave
    Always wear safety glasses while programming.

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

    Default

    I'd never ever had any kind of problem 'till now. BUUUUUUUUT, most USB-2-serial may access COM up to 255/255. VB6 original component is usually able to work within COM1:COM15 range. With VB6, So the only kind of limitation is if you can't modify the COM port that your converter use.

    You could find some info over the net to modify the VB6 control, or, i'll suggest you to move on newer .Net version (express work great).

    In .NET you also could build a list of available COM port in 2-3 code lines.

    Now, i use PIC with USB.
    Steve

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

  4. #4
    Join Date
    May 2005
    Location
    Minnesota
    Posts
    31

    Default

    Mackrackit, what kind of handshaking is required with the Belkin cable?

    My '628A PIC is surface mount, the boards have been made. I think the boards were done before the PIC came out with USB, yep, a few years and I still have some stock.

    Many thanks.

    Brad

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

    Default

    I'm not Mackrackit, but handshaking is really up to you. You could have DTR line connected to the MCLR and play with it in VB, so your PIC fall in a SerialCom Test or Bootloading procedure for XYZ delay.

    I usually use USART interrupt without MCLR.
    Steve

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

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    What he said and..

    When the serial/usb converter is installed on XP/Vista, you will have a virtual com port number ?? in device manager.

    This virtual com port will have all of the settings of a regular com port.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    May 2005
    Location
    Minnesota
    Posts
    31

    Default

    It has occured to me that VB6 does not support USB ports, right?
    .NET does?
    The PIC end of this has a three pin, 0.100 centers, header; Gnd, transmit, and receive. The end I need to mess with is the PC/VB side.

    Thanks again all.

    B

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

    Default

    All language support USB, but there's no easy lunch

    If you have MicroCodeStudio, you should have a plug-in called EasyHID, this will create your code template for VB6. It will also give you a .DLL called mchid.dll or something like that, which is the core of the template.

    A while back, i've posted an example somewhere her called USBDemo. sure enough you will have everything to get you started with it.

    I also published here a Template to use VB.NET. Another guy on the net also used it, modified it a little bit and placed it on his website ( http://www.helmpcb.com/Software/USBHIDVB/USBHIDVB.aspx )


    I really suggest you to forget the outdated (but still usefull and workable) VB6, move on .NET. VBExpress is free to use.

    Jan Axelson's website also have tons of ressource and code template to work with HID devices.
    Steve

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

  9. #9
    Join Date
    May 2005
    Location
    Minnesota
    Posts
    31

    Red face

    First, thanks for the responses. Very informative.

    So, just so I have it straight, I should download MicroCodeStudio for the template for VB6. I also need to get MicroCodeStudio Plus for the 16F628A PIC, the MicroCodeStudio free version only cover 16F628. Is that correct?
    I don't think 628A has USB capabilities.

    I have a copy of .NET, I looked into the MSCOM part of it once and decided to stay with what I knew for rapid deployment. Now I'm paying for it. I will take your advice to move to .NET under consideration.

    I wonder, if plugging in the Belkin cable Mack mentioned earlier, helps the situation at all. Mack??

    Regards.

    B

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    All the Belkin serial to USB does is turn a USB port on the PC into a serial port (virtually)

    All communications are serial type. RS232 (sort of).

    Straight USB is a different thing altogether.

    The free version of MCS 3.0 does the 16F628A.

    What version of PBP and MCS are you using?
    Dave
    Always wear safety glasses while programming.

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

    Default

    In .NET you want to use SerialPort component instead, it's a Mscomm but with more rich feature.

    To start, simple serial com is probably the best way to go, the 16F628A is a good choice.
    Last edited by mister_e; - 29th October 2008 at 02:24.
    Steve

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

  12. #12
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by cooksydesign View Post
    It has occured to me that VB6 does not support USB ports, right?
    .NET does?
    The PIC end of this has a three pin, 0.100 centers, header; Gnd, transmit, and receive. The end I need to mess with is the PC/VB side.
    Thanks again all.
    B
    Ya could go with a CP2102/CP2103 type chip...
    http://www.sparkfun.com/commerce/pro...roducts_id=309
    Serial in one side, USB out the other side, virtual COM port on the PC.

  13. #13
    Join Date
    May 2005
    Location
    Minnesota
    Posts
    31

    Default

    I am using PIC Basic Pro, version I am unsure of. It does have USBIN, USBOUT, USBINIT, and USBSERVICES.

    I will investigate all your suggestions. Thanks again to all.

    B

  14. #14
    Join Date
    May 2005
    Location
    Minnesota
    Posts
    31

    Default

    Quote Originally Posted by mackrackit View Post
    All the Belkin serial to USB does is turn a USB port on the PC into a serial port (virtually)

    All communications are serial type. RS232 (sort of).

    Straight USB is a different thing altogether.

    The free version of MCS 3.0 does the 16F628A.

    What version of PBP and MCS are you using?
    Does this mean then in VB6 I can select a USB port just the same as a "normal" comm port?

    B

  15. #15
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Quote Originally Posted by cooksydesign View Post
    Does this mean then in VB6 I can select a USB port just the same as a "normal" comm port?

    B
    I do not use VB or .NET
    In other languages when using on of these converters, it is treated as a serial port.

    For example. One of my machines that does not have a serial port, only USB, add a hub and four serial to USB converters, device manager shows com 2 through 5. If I use hyperterminal, I pick one of these just as I would a real serial port. The same goes for Python and Liberty Basic (the two I use).

    So I would guess in VB you would do the same because the OS sees these converters as a serial port.
    Dave
    Always wear safety glasses while programming.

  16. #16
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Quote Originally Posted by cooksydesign View Post
    I am using PIC Basic Pro, version I am unsure of. It does have USBIN, USBOUT, USBINIT, and USBSERVICES.

    I will investigate all your suggestions. Thanks again to all.

    B
    Check the Read me file in the PBP directory.
    Dave
    Always wear safety glasses while programming.

  17. #17
    Join Date
    Aug 2005
    Posts
    57

    Default

    This demo was created for the serial to usb port selection problem.
    http://www.picbasic.co.uk/forum/showthread.php?t=7372

  18. #18
    Join Date
    Dec 2005
    Posts
    1,073

    Default

    The simplest solution is to keep your PIC application as RS232 and tell those who need USB to buy this http://www.byterunner.com/byterunner...ct_match=exact. It's inexpensive, it works and it eliminates the need for you to rewrite your PIC application, learning to use USB, .NET, etc.

  19. #19
    Join Date
    Oct 2008
    Posts
    14

    Default

    I'm using 18f2550, PBP and Visual Basic Express 2008 without any problem... With the usage of bootloader you can also programm your pic in a few seconds on your circuit over USB...

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Data EEPROM gets clobbered during programming
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2008, 02:46
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 1

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