Electronic – arduino – How to use arduino to control 4 motors speed and direction

arduinodc motorliposervo

I consider this question different from others because of the variety of things I need this setup to be able to do.

Description:
I want to build a minimalistic motor controller capable of controlling the speed and direction of 2 servos and 2 brushed dc motors. That is to say that I have size and weight constraints that I do not think would be satisfied by off-the-shelf solutions.

The Problem:
I have an arduino board (all/any model) that can only output 40mA per pin which is not enough to power even the tiny dc motor I am using. If I power the dc motors directly from the 3.7v 150mA/h 25C LiPo battery it seems to spin at the top speed I need to be able to achieve from the arduino. I need to be able to controller the speed and direction of each of the motors from the arduino PWM output using power from 1 or more LiPo batteries. The battery I have came with the motors so I know it can power them.

Story:
I salvaged the motors and battery from a small rc heli and I want to rebuild it as a UAV replacing the onboard chip with my small arduino (pro mini or teensy).

Update 1:
Apparently I may have been overcomplicating the problem and a simple H-Bridge is all I need. I will post back if this turns out to be the case. Thanks for the helpful comments. I will upvote once I have enough rep.

Thank you!

Best Answer

You have 2 questions here:

  • How to drive a servo motor?
  • How to drive a brushed DC motor?

Servos

Servos can be driven using a PWM signal. That's pulses between 1ms and 2ms at 50Hz, the length of the pulses controls the angle of the servo. There are 3 wires: GND, VCC, and one for the control signal.

Brushed DC motors

Brushed DC motors can be driven regulating the input voltage. This can be achieved by low-pass filtering the output of an open-loop op-amp driven by a PWM signal. This is a different PWM than for driving the servos, the high-level/low-level ratio determines the fraction of the input voltage you want to use to drive the motor.

A H-bridge might work but I am not familiar with this type of circuit.

I am not sure what kind of UAV you are making, sounds like a bi-copter. If this is the case you don't need to be able to control the direction of the rotation of the motors. You only need to hard-wire the motors to run in different directions, but the direction does not need to change in flight which greatly simplifies the problem.

This should give you enough leads to get going. If anything wasn't clear just shout :)