1
\$\begingroup\$

I'm making a device that will have contact with water, so the electronics are encapsulated in epoxy. I want to have the option to reprogram the microcontoller, so I want to add contact points that I can connect USB micro lines to. Problem is I obviously can't have current leaking out of those points when not connected to USB and it's in the water. I can stop the vin from reverse flow using a diode, but I can't figure out how to stop current from the tx line of the micro.

I tried a diode there too, but when connecting the tx line to the USB, I need current to flow from the micro. I tried an n channel mosfet using an I/o pin to control the gate and had the tx line divided between drain and source, but it didn't seem to work quite right.

Ideally I'd like the gate to be automatic, where it opens when the USB is connected/detected, but I could use an I/o pin to control a gate too because the micro has Bluetooth. The voltages are low--5v from USB, micro is 3.3v.

How do I stop the USB from leaking current when its not in use?

\$\endgroup\$
  • \$\begingroup\$ There are waterproof connectors, and some may even work with USB type signals. USB version < 3.0 does not have a dedicated Tx line. \$\endgroup\$ – Turbo J Mar 30 '17 at 15:33
  • 2
    \$\begingroup\$ Why can't you use a software solution? On some micro-controllers you can configure the USB pins as general GPIOS and turn on pulldown resistors. You could run the 5V from the USB to the micro and detect when the USB is plugged in. When it does detect 5V, then enable the usb ports. \$\endgroup\$ – Voltage Spike Mar 30 '17 at 16:17
  • 2
    \$\begingroup\$ First, USB does not have any "Tx" line. Second, a USB device must not leak anything out, VBUS is an INPUT, and D+/D- are inputs as well, and should not have any potential. If they do have any pulls when no input to VBUS, then the USB device is broken. \$\endgroup\$ – Ale..chenski Mar 30 '17 at 16:20
  • 1
    \$\begingroup\$ I guess the problem is that some MCU with USB interface are pulling up D+ (signal to connect) regardless if the VBUS is applied (meaning plugged into a host) or not. This is exactly one of cases why USB specifications explicitly state that if a USB device is not connected to a host, it should have no voltage on the interface on any pin. \$\endgroup\$ – Ale..chenski Mar 30 '17 at 16:24
  • 1
    \$\begingroup\$ @Kirkx060, re: why there is voltage on D+. I do know. This is a brutal disrespect for USB specifications. Most of cheap MCU have this design flaw, mostly because they assume that their IC will be used solely as "bus powered" device (no host VBUS - no power - no D+ pullup), and rarely have internal battery power. \$\endgroup\$ – Ale..chenski Mar 30 '17 at 23:21
2
\$\begingroup\$

Most USB-capable microcontrollers use general purpose I/Os for this function, so you can assign them as inputs and put weaking pulling resistors on them. Contrary to what was previously stated a pulldown would be preferable to a pullup, as that would put the I/Os at the same potential as the ground which is presumably also exposed. Having them at a different potential could mean a small leakage path, which would both waste power and potentially promote electrochemical corrosion or contact etching. Even with wetted contacts at the same potential, you want to make sure they are all the same metal.

You should similarly disable the USB speed detect pullup.

However you face a more serious problem in that it is extremely difficult to get a truly immersion-grade waterproof seal between wires and some random epoxy compound. If you strip the wires first, you have to get the metal perfectly sealed to the epoxy, and if you run the insulation through, you will probably get water migrating between the wire and its insulation.

Something like a connector under a screw-off cap with a compressed gasket may be preferable. Or you could use a bootloader with some sort of inductive or even optical serial interface.

But of course you have to solve the problem of getting power in there without moisture leakage, too.

\$\endgroup\$
  • \$\begingroup\$ I'll check into this but I don't know if I can control the USB pins on this one. It's an Adafruit feather ble. I'm not worried about sealing the contacts...it's not subject to any pressure, just water contact. Also, I've used this epoxy in the past to seal flexible joints subject to heavy pressure and never had a problem. The connector below a bolt with gasket is my back-up plan. \$\endgroup\$ – Kirkx060 Mar 30 '17 at 21:50
  • 1
    \$\begingroup\$ @Chris, can you support your statement that "most MCU" with USB interface implement USB pins as GPIO? My experience is that most of MCU do have a dedicated USB PHY, and use dedicated pins for D+ and D- that are not re-configurable? \$\endgroup\$ – Ale..chenski Mar 30 '17 at 23:28
  • \$\begingroup\$ Try reading some data sheets... I struggle to think an MCU with a full speed interface that doesn't support GPIO on the USB pins, though I'm sure they exist somewhere. The "issue" you seem to be hinting at is probably one unique to USB high speed phys, which are fairly uncommon on MCUs (which generally couldn't do anything useful with such data rates). USB high speed is more commonly found on SoCs than MCUs, though there are a small number of MCUs with high speed USB implementations designed to move data to/from other interfaces rather than the low powered MCU core. \$\endgroup\$ – Chris Stratton Apr 24 '17 at 4:58
  • \$\begingroup\$ If you know what does it take to receive USB signaling even at FS, you wouldn't be "struggling to think". To receive the FS serial data right, you need ~5X oversampling of the 83-ns-long bit pattern, or 16ns cycle for bit-banging over GPIO. If you ever did any real-time embedded programming, you would know that a program loop with 16 ns cycle is not possible on ordinary MCU, the Parallax Propeller (with 8 specially cascaded 32-bit processors) being an exception. Therefore I would strongly advise you to retract your statements about GPIO use for FS USB interface. \$\endgroup\$ – Ale..chenski Jun 1 '17 at 2:54
  • \$\begingroup\$ You seem to be a bit confused about how ordinary MCUs work. The mention is of the normal case of MCU's where the pins which implement USB can alternately be used as a GPIO. That does not mean that the USB is being implemented by bit-banging the GPIO port, only that there is a function selection between the two possible uses (or more often today, quite a few possibilities for each pin) \$\endgroup\$ – Chris Stratton Jun 1 '17 at 4:22
0
\$\begingroup\$

Why not using Bluetooth? It may be UART on the inside, so easy to use, easy to seal, supported by any device, definitely cheaper and easier than switching USB or sealed connectors.

\$\endgroup\$
  • \$\begingroup\$ Good question, but I don't think I can. I'll look into it a little more though. \$\endgroup\$ – Kirkx060 Mar 30 '17 at 21:51
  • \$\begingroup\$ Take BT module from ST or Murata or TI \$\endgroup\$ – Gregory Kornblum Mar 30 '17 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.