0
\$\begingroup\$

I have a circuit like one on scheme. I would like to drive 12V/3A DC motor with PWM from ESP8266 pin output. Circuit works just fine (FET is only little bit heating), but on ESP startup, engine turns on (for less then a second), probably until the pin is initialized with full value (1023 = 3.3 V - this makes engine off). I am looking for a circuit modification which would keep motor off during ESP startup.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ Do you have a pullup on the ESP8266 output? \$\endgroup\$ – vofa Jan 22 '18 at 20:33
  • \$\begingroup\$ Which pin are you using? There are internall pullups for some pins. However, GPIO 0, 2, and 15 are typically reserved for special functions and are limited in capability. \$\endgroup\$ – Bort Jan 22 '18 at 20:51
  • 1
    \$\begingroup\$ use GPIO 4 and 5, which are low from reset, through boot, and until activated; other inputs can screw up boot order or go haywire with floating and unexpected voltages. \$\endgroup\$ – dandavis Jan 26 '18 at 5:54
1
\$\begingroup\$

How about making the input positive logic? When ESP8266 starts up, IO is set as input according to this website. In the circuit below, if input is floating then the motor is off.

Plus, PWM duty-cycle would be "right-side up". 100% PWM = fully on, whereas in your original circuit, 100% PWM = fully off.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ Thank you, this works wery well. Just let me an additional question: Since R1 and R2 forms voltage divider, for IRF540N, is 6V einough for full saturation and 3A current flow for motor? \$\endgroup\$ – Jan Novák Jan 27 '18 at 15:28
  • \$\begingroup\$ Datasheet shows 4.5V Vgs is enough for 10 Amps at 12V at room temp. I thought I saw one datasheet say 15V abs max Vgs so 12V close. On second look I see 20V abs max Vgs. You can adjust the values of R1 and R2 as you see fit. If you want to make it really robust, you can add a zener diode to clamp Vgs to 12V or whatever. It's the most sensitive part of the circuit and a zener would help prevent glitches on 12V supply from damaging the gate. Auto 12V can be very glitchy. \$\endgroup\$ – Vince Patron Jan 29 '18 at 18:23
1
\$\begingroup\$

Put a pull up resistor (~10K) from the base of Q1 to the 3V3 of your CPU. The CPU output is probably low or floating during reset & start-up.

\$\endgroup\$

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.