Skip to main content
Graduate II
February 18, 2024
Solved

Single USB Host to Multiple USB Virtual Ports

  • February 18, 2024
  • 2 replies
  • 5055 views

Hello,

I have an STM32F373 and have successfully enabled a USB virtual com port.

I currently send data packets from a PC host to the slave device and include a 'deviceId' in the packet data header.

I would  like to support the single PC host communicating with multiple slave devices.   There would be no more than 12 slave devices, and I would like to add new devices. 

I plan on enabling a USB virtual com port for each slave device, and have them ignore packets not addressed to their deviceId.  Each device would only send a response if the packet is addressed to it.  The single host would ensure it only attempts to communicate with 1 device at a time.  

I recall seeing that STM32 allows the USB port to connect to multiple devices in this way. ( not sure though )  

What is the best way to connect each slave device to the USB connection?  Should I just split the 2 USB input (DM,DP) and send them to each slave device directly, or should I investigate a better circuit/components. ( eg. should I worry about current draw, diodes or isolation )

I could also have 1 slave device acting as 'master' for all other slave devices and have the PC host only communicate with that 1 slave device. ( use SPI or USART connection between slave devices instead of USB virtual host )

Lastly, I am looking at a USB hub controller IC, such as the TUSB1046.

Any advice will help.

Thank you,

 

    This topic has been closed for replies.
    Best answer by TDK

    A usb hub is going to be the easiest and probably most robust solution. You can create a composite USB device that embeds many different VCPs, but they do not really show up as independent devices and it can be hard find out which is which.

    My preferred approach is to have as many devices as you need. Prefix their serial number with some value so you can tell them apart.

    2 replies

    TDKAnswer
    Super User
    February 18, 2024

    A usb hub is going to be the easiest and probably most robust solution. You can create a composite USB device that embeds many different VCPs, but they do not really show up as independent devices and it can be hard find out which is which.

    My preferred approach is to have as many devices as you need. Prefix their serial number with some value so you can tell them apart.

    LMorr.3Author
    Graduate II
    February 19, 2024

    Good to know this is your approach as it seems to be the best solution for my case.  I see benefits like being able to communicate with devices in parallel instead of using device addressing through a 'master' uC using I2C SS or packet header deviceId.  Adding a 'type' prefix to the uC's built-in serial number will allow the client to 'discover' USB devices and build a lookup table for future auto re-connections.

    Do you use an external USB hub or do you build a usb hub circuit board ( ie. using TUSB1046 ) and connect devices into that board using custom non-usb cables/connectors?  My 'modules' will sit next to each other and I would like to minimize the USB cables required if possible. ( replacing them with small PCB->PCB cables like I do with my SPI/I2C )

    Thanks!

    Super User
    February 19, 2024

    An external hub will certainly be quicker. A custom PCB will take considerably more time/effort. You'd have to weigh if that effort is worth the convenience of a smaller form factor.

    Super User
    February 18, 2024

    Hi,

    Basically your idea to connect some USB host and slaves via hubs is possible, BUT :

    this is some kind of a network, so why not use something like RS485, UART , SPI, or CAN , whats (all of them ) is widespread used for network ?  And much more easy to realize !

    To do it with USB is much more difficult , but ok, if you searching for a real challenge - good idea ! :)