I want to be able to rotate the motor both clockwise and counter clockwise while also controlling the speed of rotation of said motor. This is a small dc motor and the whole thing is running on 5V the motor draws about 2A when its straining. Less under normal operation (about 1A).

Is the diode labeled motor diode protecting my mosfet from potential damage? If the motor is spun my some force do I need any other protection to prevent this circuit from being damaged?


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ When you use the CircuitLab button on the editor toolbar an editable schematic gets saved inline with your question. No screengrab. No image upload. No background grid. That makes it easy for us to copy the schematic into our answers for editing. \$\endgroup\$ – Transistor Dec 30 '18 at 14:25
  • \$\begingroup\$ RLY1 has no way to energise the coil. See if you can fix it and leave it editable for us. Do you have access to one 2-pole relay rather than your 2 x 1-pole relays? \$\endgroup\$ – Transistor Dec 30 '18 at 14:27
  • \$\begingroup\$ RLY1 and RLY2 have their positive coil side connected in parallel do they not? At least that is my intention with this diagram. I have the transistor between coils - and ground. They are both switched with the samem transistor \$\endgroup\$ – flips Dec 30 '18 at 14:52
  • \$\begingroup\$ Nope. The transistor wire jumps the RLY1 negative wire. Your schematic is difficult to follow. If you make it editable we'll help tidy it up. \$\endgroup\$ – Transistor Dec 30 '18 at 14:57
  • \$\begingroup\$ I will remake it. I didnt end up getting an account with circuitlab which is why I copied it into gimp and pasted it here. I will find a way to make it easier for people to help me. Thanks for the patience I am very new to all of this. \$\endgroup\$ – flips Dec 30 '18 at 14:59

Let's redraw the schematic in a more conventional fashion. It should read well with some sort of input to output logic from left to right (which you had managed) and voltages decreasing from top to bottom (which you hadn't). Use GND symbols where possible to eliminate wires and you can do the same with the positive supply if it helps.


simulate this circuit – Schematic created using CircuitLab

Figure 1. Circuit redrawn and R2 added.

I've also split the circuit into logic - the ESP32 and relays - and power - the motor and switching circuit as, to some extent, they are separate. A few things now become clear:

  • The relay coils are in parallel.
  • D2 is redundant. D1 will protect Q1 from both relays.
  • Q1 is operating as a common emitter switch. It needs some base current limiting so R2 has been added.
  • The motor polarity reversal scheme should be a bit easier to follow.
  • M1 is switching the motor negative (for your PWM control).
  • The IN5408 is providing freewheel protection for M1.

The RFP30N06LE is designed for switching with a logic-level gate signal so it should be fine.

Is the diode labeled motor diode protecting my MOSFET from potential damage?


If the motor is spun my some force do I need any other protection to prevent this circuit from being damaged?

That depends. Force won't matter but speed will as the output voltage will be speed dependent.

  • With the relays de-energised as shown in Figure 1, if the induced current flows from left to right in the motor it will, in effect be shorted out by Motor Diode and a high resistance to motion will be felt.
  • If spun the opposite direction then the motor voltage will rise with the right side negative. Now the left-side is held at +9 V by the battery. As the motor speed increases the right side voltage (and that on the drain of M1) will decrease from +9 V to +8 V, etc. If you keep speeding it up it will eventually drive the drain of M1 negative with respect to the battery. At that stage the built-in (intrinsic) diode between the source and drain (see the first page of the datasheet) will begin to conduct and protect M1. You will now be charging the battery which may or may not be OK, depending on chemistry and duration of this condition.
  • \$\begingroup\$ +1 You have also added a common ground that return transistor emitter, MOSfet source back to ESP32: too many users forget this common connection. \$\endgroup\$ – glen_geek Dec 30 '18 at 19:24
  • \$\begingroup\$ Batteries are two lithium ions in series. The time of rotation and amount of rotation is relatively small. The motor open and closes a door lock. The only way it gets spun is when a person opens and closes the lock. I can't see without opening the enclosure how many rotations of the motor that is. \$\endgroup\$ – flips Dec 30 '18 at 21:12
  • \$\begingroup\$ I can't imagine it would be much of a problem. Put an ammeter on it and try it out. \$\endgroup\$ – Transistor Dec 30 '18 at 21:29

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.