Close
0%
0%

USB Interruptor

Press the button to momentarily disconnect a USB device

Similar projects worth following
This simple board plugs inline with a USB cable. It always passes the 5V power and normally passes the USB data signals. But when you press the button, the USB data signals are momentarily disconnected.

Why would anyone want or need such a thing?

Well, for the last few months I’ve been developing a USB Host Library for powerful but complex EHCI USB port in Teensy 3.6. After several false starts and re-reading the USB 2.0 and EHCI 1.0 specs and datasheet over and over (did I mention this 480 Mbit/sec USB host port is powerful but really complex), it’s finally starting to come together.

Now I’m at the stage where it’s time to begin work on code to handle USB disconnect events. When you unplug the cable, the ECHI work queues need to be removed, periodic schedule bandwidth allocation/planning needs to be undone, memory needs to be freed (hopefully it’s all findable from linked lists), hub/port status needs to be updated, and probably a ton of other stuff needs to happen that I haven’t even considered yet…

Reaching over to physically unplug the USB cable gets old quickly! Really, really old, both hands off my keyboard… right when trying to focus. With 12 Mbit/sec USB ordinary switches can usually work, but this is 480 Mbit/sec and I’m already running it through a USB protocol analyzer and a few cables plugged in tandem, leaving not much signal quality margin left. So I made this handy little board with a proper USB 2.0 high speed mux chip. The control signal is just 3.3V logic, so I might even wire it up to something to automate the process.

Admittedly, not many people develop USB host drivers and software stacks (it’s turning out to be probably the toughest coding I’ve ever done), so this little board might not have really wide applications. But here’s all the details anyway. ;-)

usbinterruptor.zip

PCB Gerber Files

Zip Archive - 5.83 kB - 02/26/2017 at 10:28

Download

  • 1 × Diode, Schottky, B120 B120-E3/5ATGICT-ND
  • 1 × MCP1700 3.3V regulator MCP1700T3302ETTCT-ND
  • 1 × FSUSB30 USB Mux Switch FSUSB30MUXCT-ND
  • 1 × USB Connector, Mini-B 609-4701-1-ND
  • 1 × USB Connector, Std A ED90065-ND

View all 10 components

  • PCB Layout Image

    Paul Stoffregen03/15/2018 at 21:05 0 comments

    Like pretty much every quick project I make, there's no schematic.  I just put the parts into the PCB layout and wire them together.  Very quick, but not the best for documentation.


    For anyone who wants to see how this board is wired, here's an image showing the routing of both sides.

    For anyone who believe this is terrible practice, I'd like to point out nearly all the "open hardware" schematics on the internet are just the parts dropped into a schematic sheet with short wires & net names.

  • USB Disconnect Leaks Fixed

    Paul Stoffregen02/26/2017 at 22:40 0 comments

    Exciting news: with this commit (and several others just before it), I've finally managed to free all the memory resources when a USB device disconnects.

    I just disconnected and re-enumerated a USB keyboard 60 times in a row. Previously I could only do this a few times (and a week ago not at all due to other limitations) before all the slots in the memory for devices & pipes were used up.

    Now all the resources are being returned, or at least all the ones in use for this simple test. Still so many more cases to consider....

View all 2 project logs

Enjoy this project?

Share

Discussions

Dave's Dev Lab wrote 03/16/2018 at 12:21 point

Updated the design... Added power LED, a capacitor to debounce the button, a two pin header for the disable control (in case you want to automate it or have an external button), and shrank the board size to 1.3 inch by 2.3 inch: https://photos.app.goo.gl/ZvKacEnVrjnjEOOg1

  Are you sure? yes | no

Dave's Dev Lab wrote 03/15/2018 at 22:38 point

@Paul Stoffregen - i've generated a schematic from the gerbers, bill of materials and additional screen capture. have a look to see if it is accurate: https://drive.google.com/file/d/1KNf6qjK4GeeccKZ_qf5VLGinSVR5P3qI/view?usp=sharing

  Are you sure? yes | no

Dave's Dev Lab wrote 03/16/2018 at 00:04 point

  Are you sure? yes | no

Dave's Dev Lab wrote 03/16/2018 at 00:11 point

just a few notes, i changed the USB-B to a full sized one. the mini-usb-b is not rated for many insertions and removals, and isn't too strong to be used on the desktop. the USB-B I used is a through hole part, only because that is what i have a large qty of. I changed the diode from the B120 to a MBR0520L since it is much more widely available... oh and added M2 mounting holes...

  Are you sure? yes | no

Paul Stoffregen wrote 03/16/2018 at 10:43 point

Looks pretty similar.  I don't see VBUS or GND connections in the layout.  Maybe GND gets connected by flood fill or plane connections?  How about VBUS?  Looks like you've swapped the sides on the mux chip (USB-A connector goes to pins 3 & 7 on your's, the USB-MicroB on mine routes to those pins), but I can't see any reason why that would matter.

  Are you sure? yes | no

Dave's Dev Lab wrote 03/16/2018 at 11:36 point

GND is on the top layer fill, and VBUS is bottom layer fill. Yea i did a swap on the signals to make the layout easier and cleaner. 

  Are you sure? yes | no

Dave's Dev Lab wrote 03/16/2018 at 11:53 point

@Paul Stoffregen - i'll order some pcbs for testing in the next week or two. i'll post the files as CC-BY-NC. do you want me to put your name in the credits for it?

  Are you sure? yes | no

Jarrett wrote 03/15/2018 at 21:23 point

Hah, that's funny, I think this use-case is more common than you think :)

I used a USB Isolator, hacked together with a USB controlled relay to turn on and off power.

More recently, however, I found this:

https://github.com/mvp/uhubctl

Turns out power control is defined in the USB hub spec, and there are Amazon Basic hubs that support it! Have not yet test it, myself.

  Are you sure? yes | no

Dave's Dev Lab wrote 03/15/2018 at 19:47 point

any chance you could post a PDF schematic?

  Are you sure? yes | no

Paul Stoffregen wrote 03/15/2018 at 21:07 point

Nope, sorry, there is no schematic.  I never made one.  But I have added a project log with a better image showing the PCB layout, so you can see how it's connected.  Hope that helps?

  Are you sure? yes | no

Dave's Dev Lab wrote 03/15/2018 at 21:09 point

wow so you just cranked-out the layout manually?

  Are you sure? yes | no

Johnny wrote 03/05/2018 at 22:56 point

You sound like a USB guru! It's hard enough writing a USB stack for devices... You might know how to solve an issue I ran into? I made a mass storage device bootloader and whenever I write to it, windows does "Discovering Items" and adds a 2 second delay to the transfer. I've tried many things. So annoying.

  Are you sure? yes | no

Paul Stoffregen wrote 03/05/2018 at 22:58 point

Yeah, Windows has lots of annoying delays with USB stuff.  Apparently some are in response to buggy USB devides.  Windows 10 seems to be much better than earlier versions.  Regardless, I can't get directly involved in your project.

  Are you sure? yes | no

Johnny wrote 03/05/2018 at 23:01 point

All good. Wasn't sure if there was one known cause for it.

  Are you sure? yes | no

Johnny wrote 03/06/2018 at 05:02 point

Found the cause. I feel kind stupid now. Wasn't a USB issue. I erase the user space in flash before loading the new program, 119KB worth. The erasing starts when a hex file is detected being written. It takes a few seconds to erase all that memory page by page. This leaves that computer hanging for a few seconds mid write transfer.

  Are you sure? yes | no

Josh 'Acecool' Moser wrote 07/11/2017 at 15:54 point

This looks very useful - I may order one... I'm currently working on another project, the Logitech G series Pedals and Shifter USB Adapter, and when I'm finished flashing, despite having the reset wire hooked up to STLinkV2 and the device, I have to manually unplug or plug in... I finally used some breakouts and DuPont wires, plus a clicker switch I had in a flashlight to interrupt the power which does the same thing ( I tried using an external power-source, but Windows keeps saying the device malfunctions, but it isn't true because I have a USB standard to DuPont female connectors I made, and I used a neighbor usb port for power and got the same issue... BUT, if I use a USB HUB then I can use a neighbor power source so I believe it is giving that error because Windows wants to be in control of power management - with the external it would've been so easy and clean [ I have a dentist light above my desk with a few other lamps for working, and a power-bar.. From the powerbar I have a 1 foot 3 prong single plug extension hanging down, and plugged into that I have a 1 plug Belkin toggle switch { white with clear switch, green LED } and I could just reach over by my left monitor and toggle ] but that didn't work out... right now this switch works but it creates a few extra wires I'm not a fan of... ) but I'd like a cleaner solution - so I may end up getting a USB hub with the toggle switches..

Although, this could be made to look nice, if I get a 3D printer, because it could be made into a plug with a case and a larger button - usb male to female so I may modify your design a little bit to do this... Cheers for this!

  Are you sure? yes | no

Arsenijs wrote 05/18/2017 at 01:14 point

That mess of wires in the picture... Why plug wires in parallel like that? =D Also, what is the keyboard connected to, and what does the MicroUSB cable provide - power only? (I guess the Teensy-to-analyzer wires could be shortened to a single cable...)

Nice board! What are the clearances on this? I often order stuff from DirtyPCBs, am wondering if I could panel one of these boards on a 10x10 panel - maybe the via annular rings would be too small though...

  Are you sure? yes | no

Jose Daniel wrote 03/13/2017 at 11:59 point

Admittedly, it is true that not many people develop USB host drivers and software stacks, but this project may be the basis for a programmable USB switch I am looking for. Thanks for sharing your work.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates