USB device with 2 ports - how to protect against user plugging in both
Clash 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?
protection usb-device
add a comment |Â
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?
protection usb-device
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
add a comment |Â
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?
protection usb-device
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
protection usb-device
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
add a comment |Â
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
add a comment |Â
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.
I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
– monty
1 hour ago
add a comment |Â
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.
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
add a comment |Â
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.
I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
– monty
1 hour ago
add a comment |Â
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.
I didn't consider the stubs - that multiplexer (combined with power multiplex) looks ideal!
– monty
1 hour ago
add a comment |Â
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.
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.
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
add a comment |Â
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
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
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.
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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