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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












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
    3 hours ago










  • @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
    1 hour ago
















up vote
1
down vote

favorite












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
    3 hours ago










  • @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
    1 hour ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











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 1 hour ago

























asked 3 hours ago









monty

8017




8017











  • 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
    3 hours ago










  • @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
    1 hour ago
















  • 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
    3 hours ago










  • @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
    1 hour ago















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
3 hours ago




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
3 hours ago












@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
1 hour ago




@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
1 hour ago










2 Answers
2






active

oldest

votes

















up vote
2
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






















  • I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
    – monty
    1 hour ago

















up vote
1
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 wifi 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
    1 hour ago










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






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
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






















  • I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
    – monty
    1 hour ago














up vote
2
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






















  • I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
    – monty
    1 hour ago












up vote
2
down vote



accepted







up vote
2
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 1 hour ago

























answered 1 hour ago









Tom Carpenter

35.8k262107




35.8k262107











  • I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
    – monty
    1 hour ago
















  • I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
    – monty
    1 hour ago















I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
– monty
1 hour ago




I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
– monty
1 hour ago












up vote
1
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 wifi 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
    1 hour ago














up vote
1
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 wifi 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
    1 hour ago












up vote
1
down vote










up vote
1
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 wifi 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 wifi or a different connection type.







share|improve this answer












share|improve this answer



share|improve this answer










answered 3 hours ago









Passerby

53.8k447141




53.8k447141











  • 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
    1 hour ago
















  • 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
    1 hour ago















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
1 hour ago




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
1 hour ago

















 

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













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

List of Gilmore Girls characters

Confectionery