USB device with 2 ports - how to protect against user plugging in both

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
11
down vote

favorite
1












I've got a Full speed USB device which I want to provide 2 ports for - one each on opposite ends of the enclosure. This is so the cable can be connected wherever is most convenient. My MCU (atmega32u4) has only one interface, so the physical ports will shared, but only one should be plugged in at one time.



Of course users can't be trusted to not plug in both sides at once. How to protect against this?



Ideas I've come up with:



  • Just wire them up "as-is" and hope the host can deal with joined D+/D- pins

  • NAND gate with separate 5V pins as input, output to a MOSFET that disconnects Vcc when both are plugged in.

Does the second option sound reasonable, or is a more complex solution required?










share|improve this question























  • How do you propose wiring the two ports to connect D+ and D- together? You should add a diagram explaining the layout you propose.
    – Solar Mike
    Sep 16 at 7:23










  • @SolarMike Shared between the two - in the "correct" scenario, with only one cable connected, the other connector's D+/D- will be left dangling.
    – monty
    Sep 16 at 8:58






  • 7




    You should also consider designing the case with a moving cover so that only one usb port is exposed at once. That way you clearly communicate to the user that they are only allowed to plug in to one of the ports at once instead of confusing them when they plug in two hosts and one doesn't work.
    – Nonny Moose
    Sep 16 at 13:48






  • 3




    don't forget about the user who manages to find a male-male usb cable and plugs the device into itself !!!
    – RozzA
    Sep 16 at 21:59














up vote
11
down vote

favorite
1












I've got a Full speed USB device which I want to provide 2 ports for - one each on opposite ends of the enclosure. This is so the cable can be connected wherever is most convenient. My MCU (atmega32u4) has only one interface, so the physical ports will shared, but only one should be plugged in at one time.



Of course users can't be trusted to not plug in both sides at once. How to protect against this?



Ideas I've come up with:



  • Just wire them up "as-is" and hope the host can deal with joined D+/D- pins

  • NAND gate with separate 5V pins as input, output to a MOSFET that disconnects Vcc when both are plugged in.

Does the second option sound reasonable, or is a more complex solution required?










share|improve this question























  • How do you propose wiring the two ports to connect D+ and D- together? You should add a diagram explaining the layout you propose.
    – Solar Mike
    Sep 16 at 7:23










  • @SolarMike Shared between the two - in the "correct" scenario, with only one cable connected, the other connector's D+/D- will be left dangling.
    – monty
    Sep 16 at 8:58






  • 7




    You should also consider designing the case with a moving cover so that only one usb port is exposed at once. That way you clearly communicate to the user that they are only allowed to plug in to one of the ports at once instead of confusing them when they plug in two hosts and one doesn't work.
    – Nonny Moose
    Sep 16 at 13:48






  • 3




    don't forget about the user who manages to find a male-male usb cable and plugs the device into itself !!!
    – RozzA
    Sep 16 at 21:59












up vote
11
down vote

favorite
1









up vote
11
down vote

favorite
1






1





I've got a Full speed USB device which I want to provide 2 ports for - one each on opposite ends of the enclosure. This is so the cable can be connected wherever is most convenient. My MCU (atmega32u4) has only one interface, so the physical ports will shared, but only one should be plugged in at one time.



Of course users can't be trusted to not plug in both sides at once. How to protect against this?



Ideas I've come up with:



  • Just wire them up "as-is" and hope the host can deal with joined D+/D- pins

  • NAND gate with separate 5V pins as input, output to a MOSFET that disconnects Vcc when both are plugged in.

Does the second option sound reasonable, or is a more complex solution required?










share|improve this question















I've got a Full speed USB device which I want to provide 2 ports for - one each on opposite ends of the enclosure. This is so the cable can be connected wherever is most convenient. My MCU (atmega32u4) has only one interface, so the physical ports will shared, but only one should be plugged in at one time.



Of course users can't be trusted to not plug in both sides at once. How to protect against this?



Ideas I've come up with:



  • Just wire them up "as-is" and hope the host can deal with joined D+/D- pins

  • NAND gate with separate 5V pins as input, output to a MOSFET that disconnects Vcc when both are plugged in.

Does the second option sound reasonable, or is a more complex solution required?







protection usb-device






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 16 at 9:13

























asked Sep 16 at 6:57









monty

13019




13019











  • How do you propose wiring the two ports to connect D+ and D- together? You should add a diagram explaining the layout you propose.
    – Solar Mike
    Sep 16 at 7:23










  • @SolarMike Shared between the two - in the "correct" scenario, with only one cable connected, the other connector's D+/D- will be left dangling.
    – monty
    Sep 16 at 8:58






  • 7




    You should also consider designing the case with a moving cover so that only one usb port is exposed at once. That way you clearly communicate to the user that they are only allowed to plug in to one of the ports at once instead of confusing them when they plug in two hosts and one doesn't work.
    – Nonny Moose
    Sep 16 at 13:48






  • 3




    don't forget about the user who manages to find a male-male usb cable and plugs the device into itself !!!
    – RozzA
    Sep 16 at 21:59
















  • How do you propose wiring the two ports to connect D+ and D- together? You should add a diagram explaining the layout you propose.
    – Solar Mike
    Sep 16 at 7:23










  • @SolarMike Shared between the two - in the "correct" scenario, with only one cable connected, the other connector's D+/D- will be left dangling.
    – monty
    Sep 16 at 8:58






  • 7




    You should also consider designing the case with a moving cover so that only one usb port is exposed at once. That way you clearly communicate to the user that they are only allowed to plug in to one of the ports at once instead of confusing them when they plug in two hosts and one doesn't work.
    – Nonny Moose
    Sep 16 at 13:48






  • 3




    don't forget about the user who manages to find a male-male usb cable and plugs the device into itself !!!
    – RozzA
    Sep 16 at 21:59















How do you propose wiring the two ports to connect D+ and D- together? You should add a diagram explaining the layout you propose.
– Solar Mike
Sep 16 at 7:23




How do you propose wiring the two ports to connect D+ and D- together? You should add a diagram explaining the layout you propose.
– Solar Mike
Sep 16 at 7:23












@SolarMike Shared between the two - in the "correct" scenario, with only one cable connected, the other connector's D+/D- will be left dangling.
– monty
Sep 16 at 8:58




@SolarMike Shared between the two - in the "correct" scenario, with only one cable connected, the other connector's D+/D- will be left dangling.
– monty
Sep 16 at 8:58




7




7




You should also consider designing the case with a moving cover so that only one usb port is exposed at once. That way you clearly communicate to the user that they are only allowed to plug in to one of the ports at once instead of confusing them when they plug in two hosts and one doesn't work.
– Nonny Moose
Sep 16 at 13:48




You should also consider designing the case with a moving cover so that only one usb port is exposed at once. That way you clearly communicate to the user that they are only allowed to plug in to one of the ports at once instead of confusing them when they plug in two hosts and one doesn't work.
– Nonny Moose
Sep 16 at 13:48




3




3




don't forget about the user who manages to find a male-male usb cable and plugs the device into itself !!!
– RozzA
Sep 16 at 21:59




don't forget about the user who manages to find a male-male usb cable and plugs the device into itself !!!
– RozzA
Sep 16 at 21:59










5 Answers
5






active

oldest

votes

















up vote
22
down vote



accepted










As pointed out, you can't directly connect two hosts to a device - so if you just wired them together and somebody plugged it in on both ends, you'd have a problem.



However you also have a problem if only one end is plugged in. USB, especially high-speed (480Mbps) mode is controlled impedance. If you wire both connectors data lines together you end up with what is known as a stub in high frequency design. The cable going to the unused connector will degrade the performance of the active connector.



To do this properly, you want a multiplexer IC. You can buy dedicated USB2.0 multiplexers designed specifically for this sort of application - something like the TS3USB30. That would allow you to connect the data lines from both ports to the mux inputs, and connect the output to your device internally. The mux will disconnect the unused connector which will disconnect the transmission line stubs.



For power I would probably use a power multiplexer such as a diode OR-ing circuit. The VBUS line from one of the ports (before the power multiplexer) can then be used as the input to the data multiplexer.



Ground would be common (connected) between the two USB ports and your device.






share|improve this answer


















  • 1




    I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
    – monty
    Sep 16 at 9:16






  • 3




    Stubs shouldn't be a problem at Full Speed, which is all you asked about in your question.
    – Dave Tweed♦
    Sep 16 at 12:45






  • 1




    @DaveTweed I added the Full Speed clarification after I realised this answer covered High Speed. Knowing I can "get away with it" is good for this design, but I definitely appreciate knowing the implications at higher speeds.
    – monty
    Sep 16 at 15:08










  • Now I'm genuinely interested how to make atmega32u4 support 480Mbps :)
    – Dmitry Grigoryev
    Sep 17 at 7:15

















up vote
9
down vote













Multiplexer as suggested by Tom Carpenter is a good solution.



But for full speed USB (12 Mbps), the stubs in the signals are not particularly important. If the distance between the stub ends remain below 1/10th of wavelength, i.e. below ~2 meters, the reflections will not distort the waveform much.



Also, the voltage levels on D+ and D- pins will remain within the acceptable range, so there is not much risk of electronic damage to either host.



The main problem that remains is if you connect the +5V pins from both hosts together, there could be large currents involved. You could use a diode from each USB connector's +5V pin to only let current come in, never out.






share|improve this answer



























    up vote
    3
    down vote













    The lazy electronical design way would just be to use a physical multi connector switch to choose between which one is used.



    Note that this would have the added benefit of being able to leave them both plugged in and use the switch to select which input is to be used.






    share|improve this answer



























      up vote
      2
      down vote













      There is no USB compliant way of doing this. USB is not designed to be shared between two hosts and attempting to do so will lead to potentially disastrous situations.



      At best, you can use a USB multiplexer or switch IC, with GPIO to determine which connector is connected. You'll have to decide which USB connection has precedence, because both cannot be connected to your USB interface at the same time.



      Or look at alternatives. Have one computer communicate to the other. Or use Bluetooth or use Wi-Fi or a different connection type.






      share|improve this answer






















      • I've added clarification to the question - only one port will ever be used at once, and (hopefully) the NAND gate can solve the precedence issue by simple denying the "both plugged in" scenario.
        – monty
        Sep 16 at 8:56










      • What kind of disastrous situations do you think it could lead to?
        – jpa
        Sep 16 at 11:59






      • 1




        @jpa suppose the two systems have "ground" potentials that are 50V different, for example. Connecting them both to D- could be "interesting". Even if the potentials are only 50mV different, you may have created a noise-generating "ground loop".
        – alephzero
        Sep 16 at 13:07










      • @alephzero Sure, but even a typical multiplexer or switch IC wouldn't handle that. The ground connecting first in USB connector, however, mostly eliminates that problem.
        – jpa
        Sep 16 at 14:14

















      up vote
      0
      down vote













      Perhaps it would be easier to leave the USB connector at one side of the enclosure and duplicate and / or relocate all other user-facing elements symmetrically. Then the enclosure can be rotated so that the USB port is facing the connector, while all other elements are still conveniently accessible.



      Another option is to locate both ports on one side of the enclosure (at the opposite ends) and add a sliding stub inside the enclose which the user can move to open one port or the other. 12 MHz USB has a good chance of working with an extra disconnected port attached to it.






      share|improve this answer






















        Your Answer




        StackExchange.ifUsing("editor", function ()
        return StackExchange.using("mathjaxEditing", function ()
        StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
        StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
        );
        );
        , "mathjax-editing");

        StackExchange.ifUsing("editor", function ()
        return StackExchange.using("schematics", function ()
        StackExchange.schematics.init();
        );
        , "cicuitlab");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "135"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        convertImagesToLinks: false,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













         

        draft saved


        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f396328%2fusb-device-with-2-ports-how-to-protect-against-user-plugging-in-both%23new-answer', 'question_page');

        );

        Post as a guest






























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        22
        down vote



        accepted










        As pointed out, you can't directly connect two hosts to a device - so if you just wired them together and somebody plugged it in on both ends, you'd have a problem.



        However you also have a problem if only one end is plugged in. USB, especially high-speed (480Mbps) mode is controlled impedance. If you wire both connectors data lines together you end up with what is known as a stub in high frequency design. The cable going to the unused connector will degrade the performance of the active connector.



        To do this properly, you want a multiplexer IC. You can buy dedicated USB2.0 multiplexers designed specifically for this sort of application - something like the TS3USB30. That would allow you to connect the data lines from both ports to the mux inputs, and connect the output to your device internally. The mux will disconnect the unused connector which will disconnect the transmission line stubs.



        For power I would probably use a power multiplexer such as a diode OR-ing circuit. The VBUS line from one of the ports (before the power multiplexer) can then be used as the input to the data multiplexer.



        Ground would be common (connected) between the two USB ports and your device.






        share|improve this answer


















        • 1




          I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
          – monty
          Sep 16 at 9:16






        • 3




          Stubs shouldn't be a problem at Full Speed, which is all you asked about in your question.
          – Dave Tweed♦
          Sep 16 at 12:45






        • 1




          @DaveTweed I added the Full Speed clarification after I realised this answer covered High Speed. Knowing I can "get away with it" is good for this design, but I definitely appreciate knowing the implications at higher speeds.
          – monty
          Sep 16 at 15:08










        • Now I'm genuinely interested how to make atmega32u4 support 480Mbps :)
          – Dmitry Grigoryev
          Sep 17 at 7:15














        up vote
        22
        down vote



        accepted










        As pointed out, you can't directly connect two hosts to a device - so if you just wired them together and somebody plugged it in on both ends, you'd have a problem.



        However you also have a problem if only one end is plugged in. USB, especially high-speed (480Mbps) mode is controlled impedance. If you wire both connectors data lines together you end up with what is known as a stub in high frequency design. The cable going to the unused connector will degrade the performance of the active connector.



        To do this properly, you want a multiplexer IC. You can buy dedicated USB2.0 multiplexers designed specifically for this sort of application - something like the TS3USB30. That would allow you to connect the data lines from both ports to the mux inputs, and connect the output to your device internally. The mux will disconnect the unused connector which will disconnect the transmission line stubs.



        For power I would probably use a power multiplexer such as a diode OR-ing circuit. The VBUS line from one of the ports (before the power multiplexer) can then be used as the input to the data multiplexer.



        Ground would be common (connected) between the two USB ports and your device.






        share|improve this answer


















        • 1




          I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
          – monty
          Sep 16 at 9:16






        • 3




          Stubs shouldn't be a problem at Full Speed, which is all you asked about in your question.
          – Dave Tweed♦
          Sep 16 at 12:45






        • 1




          @DaveTweed I added the Full Speed clarification after I realised this answer covered High Speed. Knowing I can "get away with it" is good for this design, but I definitely appreciate knowing the implications at higher speeds.
          – monty
          Sep 16 at 15:08










        • Now I'm genuinely interested how to make atmega32u4 support 480Mbps :)
          – Dmitry Grigoryev
          Sep 17 at 7:15












        up vote
        22
        down vote



        accepted







        up vote
        22
        down vote



        accepted






        As pointed out, you can't directly connect two hosts to a device - so if you just wired them together and somebody plugged it in on both ends, you'd have a problem.



        However you also have a problem if only one end is plugged in. USB, especially high-speed (480Mbps) mode is controlled impedance. If you wire both connectors data lines together you end up with what is known as a stub in high frequency design. The cable going to the unused connector will degrade the performance of the active connector.



        To do this properly, you want a multiplexer IC. You can buy dedicated USB2.0 multiplexers designed specifically for this sort of application - something like the TS3USB30. That would allow you to connect the data lines from both ports to the mux inputs, and connect the output to your device internally. The mux will disconnect the unused connector which will disconnect the transmission line stubs.



        For power I would probably use a power multiplexer such as a diode OR-ing circuit. The VBUS line from one of the ports (before the power multiplexer) can then be used as the input to the data multiplexer.



        Ground would be common (connected) between the two USB ports and your device.






        share|improve this answer














        As pointed out, you can't directly connect two hosts to a device - so if you just wired them together and somebody plugged it in on both ends, you'd have a problem.



        However you also have a problem if only one end is plugged in. USB, especially high-speed (480Mbps) mode is controlled impedance. If you wire both connectors data lines together you end up with what is known as a stub in high frequency design. The cable going to the unused connector will degrade the performance of the active connector.



        To do this properly, you want a multiplexer IC. You can buy dedicated USB2.0 multiplexers designed specifically for this sort of application - something like the TS3USB30. That would allow you to connect the data lines from both ports to the mux inputs, and connect the output to your device internally. The mux will disconnect the unused connector which will disconnect the transmission line stubs.



        For power I would probably use a power multiplexer such as a diode OR-ing circuit. The VBUS line from one of the ports (before the power multiplexer) can then be used as the input to the data multiplexer.



        Ground would be common (connected) between the two USB ports and your device.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 16 at 9:16

























        answered Sep 16 at 9:10









        Tom Carpenter

        36.2k263108




        36.2k263108







        • 1




          I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
          – monty
          Sep 16 at 9:16






        • 3




          Stubs shouldn't be a problem at Full Speed, which is all you asked about in your question.
          – Dave Tweed♦
          Sep 16 at 12:45






        • 1




          @DaveTweed I added the Full Speed clarification after I realised this answer covered High Speed. Knowing I can "get away with it" is good for this design, but I definitely appreciate knowing the implications at higher speeds.
          – monty
          Sep 16 at 15:08










        • Now I'm genuinely interested how to make atmega32u4 support 480Mbps :)
          – Dmitry Grigoryev
          Sep 17 at 7:15












        • 1




          I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
          – monty
          Sep 16 at 9:16






        • 3




          Stubs shouldn't be a problem at Full Speed, which is all you asked about in your question.
          – Dave Tweed♦
          Sep 16 at 12:45






        • 1




          @DaveTweed I added the Full Speed clarification after I realised this answer covered High Speed. Knowing I can "get away with it" is good for this design, but I definitely appreciate knowing the implications at higher speeds.
          – monty
          Sep 16 at 15:08










        • Now I'm genuinely interested how to make atmega32u4 support 480Mbps :)
          – Dmitry Grigoryev
          Sep 17 at 7:15







        1




        1




        I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
        – monty
        Sep 16 at 9:16




        I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
        – monty
        Sep 16 at 9:16




        3




        3




        Stubs shouldn't be a problem at Full Speed, which is all you asked about in your question.
        – Dave Tweed♦
        Sep 16 at 12:45




        Stubs shouldn't be a problem at Full Speed, which is all you asked about in your question.
        – Dave Tweed♦
        Sep 16 at 12:45




        1




        1




        @DaveTweed I added the Full Speed clarification after I realised this answer covered High Speed. Knowing I can "get away with it" is good for this design, but I definitely appreciate knowing the implications at higher speeds.
        – monty
        Sep 16 at 15:08




        @DaveTweed I added the Full Speed clarification after I realised this answer covered High Speed. Knowing I can "get away with it" is good for this design, but I definitely appreciate knowing the implications at higher speeds.
        – monty
        Sep 16 at 15:08












        Now I'm genuinely interested how to make atmega32u4 support 480Mbps :)
        – Dmitry Grigoryev
        Sep 17 at 7:15




        Now I'm genuinely interested how to make atmega32u4 support 480Mbps :)
        – Dmitry Grigoryev
        Sep 17 at 7:15












        up vote
        9
        down vote













        Multiplexer as suggested by Tom Carpenter is a good solution.



        But for full speed USB (12 Mbps), the stubs in the signals are not particularly important. If the distance between the stub ends remain below 1/10th of wavelength, i.e. below ~2 meters, the reflections will not distort the waveform much.



        Also, the voltage levels on D+ and D- pins will remain within the acceptable range, so there is not much risk of electronic damage to either host.



        The main problem that remains is if you connect the +5V pins from both hosts together, there could be large currents involved. You could use a diode from each USB connector's +5V pin to only let current come in, never out.






        share|improve this answer
























          up vote
          9
          down vote













          Multiplexer as suggested by Tom Carpenter is a good solution.



          But for full speed USB (12 Mbps), the stubs in the signals are not particularly important. If the distance between the stub ends remain below 1/10th of wavelength, i.e. below ~2 meters, the reflections will not distort the waveform much.



          Also, the voltage levels on D+ and D- pins will remain within the acceptable range, so there is not much risk of electronic damage to either host.



          The main problem that remains is if you connect the +5V pins from both hosts together, there could be large currents involved. You could use a diode from each USB connector's +5V pin to only let current come in, never out.






          share|improve this answer






















            up vote
            9
            down vote










            up vote
            9
            down vote









            Multiplexer as suggested by Tom Carpenter is a good solution.



            But for full speed USB (12 Mbps), the stubs in the signals are not particularly important. If the distance between the stub ends remain below 1/10th of wavelength, i.e. below ~2 meters, the reflections will not distort the waveform much.



            Also, the voltage levels on D+ and D- pins will remain within the acceptable range, so there is not much risk of electronic damage to either host.



            The main problem that remains is if you connect the +5V pins from both hosts together, there could be large currents involved. You could use a diode from each USB connector's +5V pin to only let current come in, never out.






            share|improve this answer












            Multiplexer as suggested by Tom Carpenter is a good solution.



            But for full speed USB (12 Mbps), the stubs in the signals are not particularly important. If the distance between the stub ends remain below 1/10th of wavelength, i.e. below ~2 meters, the reflections will not distort the waveform much.



            Also, the voltage levels on D+ and D- pins will remain within the acceptable range, so there is not much risk of electronic damage to either host.



            The main problem that remains is if you connect the +5V pins from both hosts together, there could be large currents involved. You could use a diode from each USB connector's +5V pin to only let current come in, never out.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 16 at 11:58









            jpa

            1,384611




            1,384611




















                up vote
                3
                down vote













                The lazy electronical design way would just be to use a physical multi connector switch to choose between which one is used.



                Note that this would have the added benefit of being able to leave them both plugged in and use the switch to select which input is to be used.






                share|improve this answer
























                  up vote
                  3
                  down vote













                  The lazy electronical design way would just be to use a physical multi connector switch to choose between which one is used.



                  Note that this would have the added benefit of being able to leave them both plugged in and use the switch to select which input is to be used.






                  share|improve this answer






















                    up vote
                    3
                    down vote










                    up vote
                    3
                    down vote









                    The lazy electronical design way would just be to use a physical multi connector switch to choose between which one is used.



                    Note that this would have the added benefit of being able to leave them both plugged in and use the switch to select which input is to be used.






                    share|improve this answer












                    The lazy electronical design way would just be to use a physical multi connector switch to choose between which one is used.



                    Note that this would have the added benefit of being able to leave them both plugged in and use the switch to select which input is to be used.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Sep 17 at 4:48









                    Lassi Kinnunen

                    1311




                    1311




















                        up vote
                        2
                        down vote













                        There is no USB compliant way of doing this. USB is not designed to be shared between two hosts and attempting to do so will lead to potentially disastrous situations.



                        At best, you can use a USB multiplexer or switch IC, with GPIO to determine which connector is connected. You'll have to decide which USB connection has precedence, because both cannot be connected to your USB interface at the same time.



                        Or look at alternatives. Have one computer communicate to the other. Or use Bluetooth or use Wi-Fi or a different connection type.






                        share|improve this answer






















                        • I've added clarification to the question - only one port will ever be used at once, and (hopefully) the NAND gate can solve the precedence issue by simple denying the "both plugged in" scenario.
                          – monty
                          Sep 16 at 8:56










                        • What kind of disastrous situations do you think it could lead to?
                          – jpa
                          Sep 16 at 11:59






                        • 1




                          @jpa suppose the two systems have "ground" potentials that are 50V different, for example. Connecting them both to D- could be "interesting". Even if the potentials are only 50mV different, you may have created a noise-generating "ground loop".
                          – alephzero
                          Sep 16 at 13:07










                        • @alephzero Sure, but even a typical multiplexer or switch IC wouldn't handle that. The ground connecting first in USB connector, however, mostly eliminates that problem.
                          – jpa
                          Sep 16 at 14:14














                        up vote
                        2
                        down vote













                        There is no USB compliant way of doing this. USB is not designed to be shared between two hosts and attempting to do so will lead to potentially disastrous situations.



                        At best, you can use a USB multiplexer or switch IC, with GPIO to determine which connector is connected. You'll have to decide which USB connection has precedence, because both cannot be connected to your USB interface at the same time.



                        Or look at alternatives. Have one computer communicate to the other. Or use Bluetooth or use Wi-Fi or a different connection type.






                        share|improve this answer






















                        • I've added clarification to the question - only one port will ever be used at once, and (hopefully) the NAND gate can solve the precedence issue by simple denying the "both plugged in" scenario.
                          – monty
                          Sep 16 at 8:56










                        • What kind of disastrous situations do you think it could lead to?
                          – jpa
                          Sep 16 at 11:59






                        • 1




                          @jpa suppose the two systems have "ground" potentials that are 50V different, for example. Connecting them both to D- could be "interesting". Even if the potentials are only 50mV different, you may have created a noise-generating "ground loop".
                          – alephzero
                          Sep 16 at 13:07










                        • @alephzero Sure, but even a typical multiplexer or switch IC wouldn't handle that. The ground connecting first in USB connector, however, mostly eliminates that problem.
                          – jpa
                          Sep 16 at 14:14












                        up vote
                        2
                        down vote










                        up vote
                        2
                        down vote









                        There is no USB compliant way of doing this. USB is not designed to be shared between two hosts and attempting to do so will lead to potentially disastrous situations.



                        At best, you can use a USB multiplexer or switch IC, with GPIO to determine which connector is connected. You'll have to decide which USB connection has precedence, because both cannot be connected to your USB interface at the same time.



                        Or look at alternatives. Have one computer communicate to the other. Or use Bluetooth or use Wi-Fi or a different connection type.






                        share|improve this answer














                        There is no USB compliant way of doing this. USB is not designed to be shared between two hosts and attempting to do so will lead to potentially disastrous situations.



                        At best, you can use a USB multiplexer or switch IC, with GPIO to determine which connector is connected. You'll have to decide which USB connection has precedence, because both cannot be connected to your USB interface at the same time.



                        Or look at alternatives. Have one computer communicate to the other. Or use Bluetooth or use Wi-Fi or a different connection type.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Sep 16 at 20:15









                        Peter Mortensen

                        1,56131422




                        1,56131422










                        answered Sep 16 at 7:29









                        Passerby

                        54.3k448142




                        54.3k448142











                        • I've added clarification to the question - only one port will ever be used at once, and (hopefully) the NAND gate can solve the precedence issue by simple denying the "both plugged in" scenario.
                          – monty
                          Sep 16 at 8:56










                        • What kind of disastrous situations do you think it could lead to?
                          – jpa
                          Sep 16 at 11:59






                        • 1




                          @jpa suppose the two systems have "ground" potentials that are 50V different, for example. Connecting them both to D- could be "interesting". Even if the potentials are only 50mV different, you may have created a noise-generating "ground loop".
                          – alephzero
                          Sep 16 at 13:07










                        • @alephzero Sure, but even a typical multiplexer or switch IC wouldn't handle that. The ground connecting first in USB connector, however, mostly eliminates that problem.
                          – jpa
                          Sep 16 at 14:14
















                        • I've added clarification to the question - only one port will ever be used at once, and (hopefully) the NAND gate can solve the precedence issue by simple denying the "both plugged in" scenario.
                          – monty
                          Sep 16 at 8:56










                        • What kind of disastrous situations do you think it could lead to?
                          – jpa
                          Sep 16 at 11:59






                        • 1




                          @jpa suppose the two systems have "ground" potentials that are 50V different, for example. Connecting them both to D- could be "interesting". Even if the potentials are only 50mV different, you may have created a noise-generating "ground loop".
                          – alephzero
                          Sep 16 at 13:07










                        • @alephzero Sure, but even a typical multiplexer or switch IC wouldn't handle that. The ground connecting first in USB connector, however, mostly eliminates that problem.
                          – jpa
                          Sep 16 at 14:14















                        I've added clarification to the question - only one port will ever be used at once, and (hopefully) the NAND gate can solve the precedence issue by simple denying the "both plugged in" scenario.
                        – monty
                        Sep 16 at 8:56




                        I've added clarification to the question - only one port will ever be used at once, and (hopefully) the NAND gate can solve the precedence issue by simple denying the "both plugged in" scenario.
                        – monty
                        Sep 16 at 8:56












                        What kind of disastrous situations do you think it could lead to?
                        – jpa
                        Sep 16 at 11:59




                        What kind of disastrous situations do you think it could lead to?
                        – jpa
                        Sep 16 at 11:59




                        1




                        1




                        @jpa suppose the two systems have "ground" potentials that are 50V different, for example. Connecting them both to D- could be "interesting". Even if the potentials are only 50mV different, you may have created a noise-generating "ground loop".
                        – alephzero
                        Sep 16 at 13:07




                        @jpa suppose the two systems have "ground" potentials that are 50V different, for example. Connecting them both to D- could be "interesting". Even if the potentials are only 50mV different, you may have created a noise-generating "ground loop".
                        – alephzero
                        Sep 16 at 13:07












                        @alephzero Sure, but even a typical multiplexer or switch IC wouldn't handle that. The ground connecting first in USB connector, however, mostly eliminates that problem.
                        – jpa
                        Sep 16 at 14:14




                        @alephzero Sure, but even a typical multiplexer or switch IC wouldn't handle that. The ground connecting first in USB connector, however, mostly eliminates that problem.
                        – jpa
                        Sep 16 at 14:14










                        up vote
                        0
                        down vote













                        Perhaps it would be easier to leave the USB connector at one side of the enclosure and duplicate and / or relocate all other user-facing elements symmetrically. Then the enclosure can be rotated so that the USB port is facing the connector, while all other elements are still conveniently accessible.



                        Another option is to locate both ports on one side of the enclosure (at the opposite ends) and add a sliding stub inside the enclose which the user can move to open one port or the other. 12 MHz USB has a good chance of working with an extra disconnected port attached to it.






                        share|improve this answer


























                          up vote
                          0
                          down vote













                          Perhaps it would be easier to leave the USB connector at one side of the enclosure and duplicate and / or relocate all other user-facing elements symmetrically. Then the enclosure can be rotated so that the USB port is facing the connector, while all other elements are still conveniently accessible.



                          Another option is to locate both ports on one side of the enclosure (at the opposite ends) and add a sliding stub inside the enclose which the user can move to open one port or the other. 12 MHz USB has a good chance of working with an extra disconnected port attached to it.






                          share|improve this answer
























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            Perhaps it would be easier to leave the USB connector at one side of the enclosure and duplicate and / or relocate all other user-facing elements symmetrically. Then the enclosure can be rotated so that the USB port is facing the connector, while all other elements are still conveniently accessible.



                            Another option is to locate both ports on one side of the enclosure (at the opposite ends) and add a sliding stub inside the enclose which the user can move to open one port or the other. 12 MHz USB has a good chance of working with an extra disconnected port attached to it.






                            share|improve this answer














                            Perhaps it would be easier to leave the USB connector at one side of the enclosure and duplicate and / or relocate all other user-facing elements symmetrically. Then the enclosure can be rotated so that the USB port is facing the connector, while all other elements are still conveniently accessible.



                            Another option is to locate both ports on one side of the enclosure (at the opposite ends) and add a sliding stub inside the enclose which the user can move to open one port or the other. 12 MHz USB has a good chance of working with an extra disconnected port attached to it.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Sep 17 at 7:42

























                            answered Sep 17 at 7:20









                            Dmitry Grigoryev

                            16.7k22770




                            16.7k22770



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f396328%2fusb-device-with-2-ports-how-to-protect-against-user-plugging-in-both%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Popular posts from this blog

                                Peggy Mitchell

                                Palaiologos

                                The Forum (Inglewood, California)