Author Topic: Safe to apply positive voltage to an output GPIO held low?  (Read 2943 times)

0 Members and 1 Guest are viewing this topic.

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Safe to apply positive voltage to an output GPIO held low?
« on: October 30, 2017, 02:28:00 am »
I've got an ESP8266 (ESP-12F) that I would configure some GPIOs to be an output held low, connected to an L9110S H bridge. And I also have a SPDT switch with +3.3V that will also activate the H bridge manually. This is to provide a manual override for the logic coming from the ESP, so that the user can manually operate the motor in whatever direction.

According to the datasheet the L9110S can handle this situation, but what about the ESP? Can the positive voltage coming in to the GPIOs held low fry the chip, or should I add diodes to the GPIOs to protect against this situation?

Here is the Falstad schematic. Also attached a screenshot of the Falstad.
« Last Edit: October 30, 2017, 04:42:10 pm by SlowBro »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #1 on: October 30, 2017, 02:50:00 am »
You can't pull an output pin high if its set low without risking damaging it.  If the current you apply is less than the maximum current its rated to sink when low, the pin wont go high enough to reach a valid '1' level, and if its greater you risk blowing it.  Switching a 3.3V rail directly to the pin will probably blow it.   

You'll have difficulty meeting the L9110S input threshold requirements if you use diodes.  Noise immunity will certainly suffer.  Either put a logic gate in between the ESP8266  and the H-bridge to combine the MCU and switch signals, or use a DPDT switch to switch between applying the output pin and 3.3V to the H-bridge input.
 
The following users thanked this post: SlowBro

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #2 on: October 30, 2017, 05:39:58 am »

Unless you have a lot more things going on just connect the switch to the ESP on a different IO line and have your software drive the H bridge.

I just abandoned using the L9110. Even with a 4.7 K resistor in series with the two PWM lines the H bridge blew the ESPs. I had a quick look to see why, that's why I ended up going as high as 4.7K but couldn't find why, I just went for BTN7060s instead.
 
The following users thanked this post: SlowBro

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #3 on: October 30, 2017, 12:09:21 pm »
By the way the switch is to be a manual override for the logic control coming from the ESP. I'll update the OP to reflect this.

It does make sense to have the ESP listen to the switch. Ties up two more GPIOs but I should have juuuuuuuust enough.

Also I'm not married to that particular H-Bridge. I'll consider alternatives such as the BTN7060.
 

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #4 on: October 30, 2017, 12:17:59 pm »

Why two IO lines? It only needs one unless I am not understanding what you are doing which is quite likely.
 

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #5 on: October 30, 2017, 12:24:36 pm »
I just abandoned using the L9110. Even with a 4.7 K resistor in series with the two PWM lines the H bridge blew the ESPs. I had a quick look to see why, that's why I ended up going as high as 4.7K but couldn't find why, I just went for BTN7060s instead.

I don't understand why you had an issue. The L9110 is used by many people. I myself have run it a few times on an ESP, a Pi, and an Arduino Pro Mini 3.3V. Its input is CMOS, according to the datasheet. Maybe needed more than 4.7K? I just put it bare on my Pi the other day, no resistors, and it ran like the wind.
 

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #6 on: October 30, 2017, 12:50:00 pm »

Why two IO lines? It only needs one unless I am not understanding what you are doing which is quite likely.

The manual override switch permits running the motor in either direction, up or down. (The motor controls a door that goes up and down.) So there are three states: Up, down, or off.
« Last Edit: April 10, 2018, 08:47:04 pm by SlowBro »
 

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #7 on: October 30, 2017, 01:58:10 pm »
I see where there was some confusion. Newbie error. I said DPST switch when I meant SPDT. Edited the OP.
 

Offline ahbushnell

  • Frequent Contributor
  • **
  • Posts: 738
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #8 on: October 30, 2017, 02:11:06 pm »
I've got an ESP8266 (ESP-12F) that I would configure some GPIOs to be an output held low, connected to an L9110S H bridge. And I also have a SPDT switch with +3.3V that will also activate the H bridge manually. This is to provide a manual override for the logic coming from the ESP, so that the user can manually operate the motor in whatever direction.

According to the datasheet the L9110S can handle this situation, but what about the ESP? Can the positive voltage coming in to the GPIOs held low fry the chip, or should I add diodes to the GPIOs to protect against this situation?

use two diodes to make a diode "OR" gate.  Connect one to the switch and one to the output of the ESP.

Andy
 
The following users thanked this post: SlowBro

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #9 on: October 30, 2017, 04:34:59 pm »
use two diodes to make a diode "OR" gate.  Connect one to the switch and one to the output of the ESP.

That was my initial thought, but Ian.M said, "You'll have difficulty meeting the L9110S input threshold requirements if you use diodes.  Noise immunity will certainly suffer."

However, the input threshold is 2.5V and if I use a Schottky such as this which has a Vf Max of 340mV @ 1A (and even more at these lower currents) which gives me an input minimum of 2.84V. The output from the ESP is 3.3V, which gives 0.46V of buffer, at least.

That leaves me with the second comment of noise immunity. I don't know if I'm vulnerable to this? The motor isn't driven by PWM; it's just full on, full off. Does running at the low end of the L9110S input voltage range mean that my motor will run at a lower speed? Both the GPIO and the motor are rated for 3.3V.

A concern with an OR gate the manual override can set one side of the bridge to high and the other side can be set by the ESP as well, leading to both being high at the same time. This is generally not recommended with H-bridges but the truth table in the datasheet doesn't seem to have a problem with it. It describe a situation with both high and the output is both are low.

I should have posted a schematic. Will update the OP.
« Last Edit: October 30, 2017, 05:11:33 pm by SlowBro »
 

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #10 on: October 30, 2017, 05:01:33 pm »
I just abandoned using the L9110. Even with a 4.7 K resistor in series with the two PWM lines the H bridge blew the ESPs. I had a quick look to see why, that's why I ended up going as high as 4.7K but couldn't find why, I just went for BTN7060s instead.

I don't understand why you had an issue. The L9110 is used by many people. I myself have run it a few times on an ESP, a Pi, and an Arduino Pro Mini 3.3V. Its input is CMOS, according to the datasheet. Maybe needed more than 4.7K? I just put it bare on my Pi the other day, no resistors, and it ran like the wind.

I don't understand either but it was getting expensive trying to work out why. :)

I will go back to it and work out what it was but like all the things that are £1 off ebay there is a high possibility that the thing is not built / designed correctly so first stage would be to draw out the PCB of the ones I have. Not something I can feel any enthusiasm for right now.
 
The following users thanked this post: SlowBro

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #11 on: October 30, 2017, 05:08:29 pm »
Here may be an option. I added some P-FETs on the switch inputs to cancel out the GPIOs, and the aforementioned Schottky diodes protect the GPIO from back feed on the switch.

Voltage drop across the FET will be minimal because of the two 1MOhm resistors.

Falstad circuit. See also the attached.

Still have the question about noise immunity as mentioned by Ian.M. I don't know if I'm vulnerable to this? The motor isn't driven by PWM; it's just full on, full off. Does running at the low end of the L9110S input voltage range mean that my motor will run at a lower speed? Both the GPIO and the motor are rated for 3.3V.
« Last Edit: October 30, 2017, 05:12:04 pm by SlowBro »
 

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #12 on: October 30, 2017, 05:10:06 pm »
I will go back to it and work out what it was but like all the things that are £1 off ebay there is a high possibility that the thing is not built / designed correctly so first stage would be to draw out the PCB of the ones I have. Not something I can feel any enthusiasm for right now.

There you go, it may have been faulty from the start. Anyways I'm not expecting you to work it out. If you have something that works go for it.

I may switch out the driver for a ZXBM5210-SP-13. Looks like it has a lot of intelligence built-in, for not much more cost.
« Last Edit: October 30, 2017, 07:42:43 pm by SlowBro »
 

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #13 on: October 30, 2017, 09:51:54 pm »

Making assumptions here that you are using the ESP for a daylight open, nighttime close automatic operation with a manual override for whatever reason, foxes about etc etc.

If so then as you have the wifi in there anyway why not use an android app to allow the manual override.
 

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #14 on: October 31, 2017, 12:20:32 am »
I will do that too, but the idea is the person standing next to the device can control it right there. I think it will work to setup listeners on the pins and just run them through that.
 

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #15 on: October 31, 2017, 09:50:53 am »

So a three way rotary switch then, up, down, auto and just disconnect the IO lines when in the appropriate positions.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #16 on: October 31, 2017, 10:22:12 am »
So add a single button and a beeper or LED for confirmation and handle it in software.
The operator on the spot can see the door state so you don't need multiple controls.
Use a short press to interrogate the system and it reports its status by a LED flash code or beep code. Medium press for open/close (it reverses the current door state) and resumes the program at the next scheduled events, very long press to lock out the program and hold the door in the current state, and medium press again to return to the program from previously locked out, without changing the door state
 

Offline SlowBroTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #17 on: October 31, 2017, 01:52:13 pm »

So a three way rotary switch then, up, down, auto and just disconnect the IO lines when in the appropriate positions.

How would you disconnect the IO lines?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Safe to apply positive voltage to an output GPIO held low?
« Reply #18 on: October 31, 2017, 02:07:43 pm »
If you want to go the rotary switch route,  you'd need a two pole three way break before make switch (probably a 5 or 6 way one with the end stop set for three ways).  You'd use one pole for each H-bridge input, and switch it between logic '1' or logic '0' (tied low) in the end positions for up and down and connected to the MCU output pin in the center position for auto.  Depending on your limit switch setup, you might need to run the up and down position logic '1' feeds via a pole in the limit switch with a pulldown resistor so it cuts off at the end of the door movement.

You can also get DP3T toggle switches which are electrically equivalent to the above rotary switch, and far easier to weather seal - just add a rubber boot over the toggle, though its advisable to protect the boot from direct sunlight.
 
The following users thanked this post: SlowBro


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf