Electronic – arduino – How to use relays and deal with reverse polarity with the Arduino

arduinopolarityrelay

I have a toy car that I wanted to make autonomous.

Arduino-powered Car

It has a motor for rear drive (seen in the bottom of the photo hidden in the gear-box) and a motor for rack and pinion steering (located just above the webcam in the photo). Reversing the polarity allows the car to reverse, as well as steer in the opposite direction.

I have successfully added break out cables from these two motors, hooked up in addition to the toy's original wires to them. These cables (red/black for drive motor and light/dark green for steering motor in photo) have been hooked up to an Arduino. I was able to control both motors with relative ease using Node.js.

However, the toy car has four 1.5v batteries to power it. When I check how much power arrives at the motors using the Arduino, it's under 1v, and the toy car can't drive when placed on the ground, nor can it steer the wheels (I just hear a click and see the rack move about 1mm each way).

If I check with a multimeter, the lines seem to get ~5v, but once they're connected to the motors, they drop to under 1v.

I tried desoldering the original lines that went from the car's PCB to the motors, but it didn't seem make a difference. If I use the car's original remote control, the wheels fly along and receive the normal ~5v.

I am wondering if it's possible to use relays to let the Arduino control the switching and polarity, but have the car's original power source provide the final power. I'm aware how relays work, but I'm curious if they're compatible with requiring the polarity switch. If it's possible, would I need special relays or just one of the normal Arduino ones?

In case you couldn't tell, I'm new to Arduino, with this as my first project.

Best Answer

Your Arduino output ports can't supply the kind of current needed by your motors. Worse, they are not prepared to take the inductive spikes that can be caused by brushed DC motors.

The solution to both problems is to use either a relay, or an H-bridge (with kickback diodes). Unfortuantely most H-bridges are not optimized for 6V, most prefer 12V or higher. For low currents you might check an LD293D, although it won't do that well at 6V.

If you use a relay note that you can't connect a relay directly to the Arduino pins. There are plenty of relay boards for Arduino that combine a relay with a transistor and the kickback diode (which is now needed for the relay coil).

Note that it might not be a good idea to use the same power for both the motors and the Arduino. Start with two separate battery sets. If you get everything working you might try combining the batteries, maybe with some spike suppression. If anything goes wrong then you know the likely cause.