7

I came across this instructable about using no external hardware but two pwm pins to control a motor in both directions. Usually you would use an H bridge. However, ever since I have had my Arduino I have heard that you are not supposed to connect a pin to another pin. So how does this circuit works. It looks like he sends a signal from one pin and in my experience it would fry the board. So basically, my question is this circuit ok with an Arduino Nano and if so how does it work? Below is a picture of the setup he gave: enter image description here

3 Answers 3

4

This is a bad idea, but not because two pins seem to be connected directly. They're not; there is a load (the motor) between the pins, and that motor will take care of different levels between the pins. High and low will make the motor turn one way, low and high the other way, and the same level on both pins will stop the motor.

Why is this bad? An I/O pin can only supply a limited current, and even for a small motor that will peak rather high. If you run the motor for some time this way you will damage the I/O ports. An H-bridge, like you mention, is the solution.
Note that electric motors cause a lot of noise in the power supply, which may cause the microcontroller to reset all the time, so that your program doesn't work. (The motor may seem to start/stop all the time.) You need to decouple the power supply with capacitors.

4
  • Does that mean put like a 10uf cap between 5v and ground? If I wanted to do this setup but correctly could I use a transistor instead of an h-bridge? I am trying to minimize external hardware.
    – NULL
    Commented May 8, 2015 at 16:53
  • 1
    If you want to have your motor turn both left and right an H-bridge is the only way. With discrete transistors you'll need more parts but it will be cheaper than an integrated H-bridge, where everything is in one component. Commented May 8, 2015 at 16:57
  • 1
    There's no such thing as too much decoupling. A 10 uF cap between ground and 5V is good, a 100 nF in parallel is better, real close to the microcontroller is best. Also place a capacitor across the connections of the motor, also as close as possible. Commented May 8, 2015 at 16:59
  • Your first comments are somewhere between mistaken and self-contradicting. If your concern is simply over current, then what you are essentially saying is that the two I/O pins are very nearly directly connected, or at least connected with too low an impedance between them. In practice, the bigger concern may well be inductive kickback spikes from when the motor is turned off, and from the brushes, which may be stronger than the protection diodes are designed to handle. Commented Jul 3, 2016 at 15:51
1

You are not supposed to connect one pin directly to another pin because the current will destroy the electronics connected to the pins. The motor provides a small impedance and limits the current flowing (although the amount of current will increase if the motor stalls).

As to the other reason you missed for the MCU possibly being damaged, the answer is that it is absorbed by the input protection diodes and subsequently the supply.

0

Another problem here is when running a motor you want to include a 'flyback diode' to prevent damage from voltage spikes, which is a problem with loads like motors.

See this article for details.

2
  • 2
    While you are correct about the need to deal with the inductive spikes, a flyback diode across the motor is only suitable if the motor is run in a single direction. It is more complex for bi-directional motor control, usually accomplished with 4 diodes (similar to the input protection diodes mentioned in Ignacio's answer).
    – Tut
    Commented May 14, 2015 at 14:47
  • Good point, thanks for the additional info.
    – sdcharle
    Commented May 15, 2015 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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