Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Switch between two USB sources without direct access to teensy; best way to...?

  1. #1
    Junior Member
    Join Date
    Feb 2016
    Posts
    2

    Switch between two USB sources without direct access to teensy; best way to...?

    Hey guys. I have a question that Iím hoping will be easy for someone to answer. Iíve been coming to this forum for the past couple years every time I have a teensy related issue but this is the first time Iíve felt the need to post something myself.

    I need to integrate a teensy into a custom computer project so the computer will have device access to the teensy and also be able to reprogram it. Once its built into the box access to it will be difficult so Iíll be connecting external push button switches for reset and boot loader access (incase theres a problem with the software loading a sketch automatically). In addition to this Iíll need to be able to disconnect it from the computers USB to allow external access to the teensy via a seperate USB port build into the case of the project.

    My idea was to wire a 4PDT switch to switch between the internal computers USB access to the teensy (D+/-, 5v, GND )and a separate USB port that will be build into the outside of the case. Power would be supplied from the computer when its attached internally via usb and then it will be powered by whatever device its connected to externally when I switch to the external USB port.

    Is there a better way of doing this? Thank you.

  2. #2
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    You only really need to switch two lines, D+ and D-. I wonder if you can't add a solid state switch that is enabled by power on the external USB bus power being present.

    Thus, when you connect the external USB cable, the internal data lines are automagically disconnected and switched to the external USB interface instead.

    I haven't used such a solid state switch but they must exist, I'd check digikey. I wonder if they would be classified as a mux/demux chip.

    I doubt the old Arduino serial trick with 1kOhm resistors on the serial line would work with USB signaling.

    Be sure to put a Schottky or similar on each USB 5v power line going to the teensy so the two power supplies don't potentially fight each other.

    A small Polyfuse (1/2a or less) for each power line is also a good idea. However even a single fuse post the Schottky diodes would likely suffice.

    Edit: checked digikey , they have them. Look for USB switch. Then fikter for a 2:2 configuration. Fsusb30 from Fairchild and many other options exist.
    Last edited by Constantin; 02-29-2016 at 12:38 PM.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,298
    Quote Originally Posted by Constantin View Post
    I haven't used such a solid state switch but they must exist, I'd check digikey. I wonder if they would be classified as a mux/demux chip.
    Here's one I've used before, with good results.

    https://www.fairchildsemi.com/produc...s/FSUSB30.html

  4. #4
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    You are faster than me! Was editing my post while you added yours! You are also up much too early!

  5. #5
    Junior Member
    Join Date
    Feb 2016
    Posts
    2
    Okay, wow. Thank you all for replying. I didn't even know there was such a thing as a solid state usb switch. Looking at the data sheet I think I'm getting there with the info I need but if someone could clarify a couple things. I've attached a quick drawing of the IC, the teensy and the two USB connections. Hopefully that helps with my question.

    The functionality I want is for the Teensy to be connected to the internal hardwired USB at all times UNLESS it detects a USB cable plugged into the external USB port. Based on the truth table of the IC, this would require me to pull the select pin 'S' high...which I suppose can be done using the 5V from the USB cable that was just plugged in? I'd like this still to work if the main computer attached to the internal hardwired USB is powered down.

    Where do I need to attach Schottky diodes to make sure the internal computer 5V and the 5V coming in from a external USB don't interfere with each other? How do I make the select pin go high only when 5V is coming in from the External USB port and not from the internal 5V if those two 5V lines connect together to each power the teensy. I have a feeling the answer to these two questions are related....I just have limited experience with custom circuits.

    Click image for larger version. 

Name:	teensyusb.jpg 
Views:	146 
Size:	87.0 KB 
ID:	6503

  6. #6
    I would use a pulldown resistor on S (10K from S to GND) to drive it to use your internal USB, and then hook only the 5V of the external USB to the S pin. If the external is not connected, you get a "low" on S, and if the external is connected, S will be "high". Looks like the control pin is spec'd up to VCC (5V), so that ought to work.

    A Schottky coming off each 5V USB port line will be needed before the two signals join. Similar to how the Vbat is hooked up on the Teensy, where it uses either a 3V coin cell or the 3V3 coming off the voltage regulator, without the two voltages fighting:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •