Arduino + Motor Shield + Servo

My question is this: can I control 2 DC motors as well as an external servo (2 wires only needed to connect servo)? I think there are enough digital pins to do it, but I wanna get more opinions.

Thanks... :-/

Yes - you will need four pins for the DC motors (to control the h-bridges), and one pin for the servo (PWM to control it); if you use a motor-controller/driver board (for two motors) and servo-driver board (which will generally allow you to control many servos at once - generally between 8-24, depending on how much you spend), you could conceivably reduce that down to two pins (serial or I2C).

Currently, I have the Motor Controller Shield. I know that I can control the 2 DC motors, because Im currently doing that. Is it possible to attach an actuator to the Motor Controller as well, or am I asking too much of the Arduino?

Without knowing what "motor shield" you are using, I can't tell whether you can hook servos up to it - my initial guess would be "no". I only say this because I have looked around for a combo dual-h-bridge controller with servo control for a while, and have not found one yet.

With that said, though, you should be able to just select one of the other open PWM output pins, and hook the servo to that. As I noted, I don't know what shield you are using for the DC motors - whether it takes PWM signals to control the motors, or whether it uses digital levels to control them, i2c bus, or serial comms; regardless, though, there should be an open PWM pin available to you to control a servo (provided you aren't using them all already!).

Your motor control shield should have power for the motors as a separate input on the shield (likely as a 2 screw header); the Arduino is just sending a logic-level signal to the board, not much in the way of curent drain. For the servo, however, you don't want to try to power this directly from the Arduino; the built in regulator can't source enough current - if you try to do it, you might get lucky with no load on the servo, but as soon as you add some load, the voltage level will drop on the Arduino, and it will reset (or the regulator will burn out, one of the two).

Instead, just wire the PWM signal from the Arduino to the control pin on the servo, then hook up a separate 5-6 volt power supply (a 4-cell AA battery holder is fine - or, if you have a higher source of power in your application, like a 12 volt battery pack or something, then run it into a 7805, and run the output of the 7805 to the servo) to the servo's positive and negative power input pins; finally, tie the ground (negative) of the power supply to the ground on the Arduino.

The separate battery pack will supply enough juice to the servo without causing a reboot or worse to the Arduino; the Arduino now only has to supply the logic-level PWM output, which the servo needs minimal current to utilize.

Does this help explain things better? :slight_smile:

Yes, that totally helps. The Motor Controller that Im using is the Arduino Motor Controller v3.0. But, you have in essence detailed to me that it wont do what I need it to do. It looks like Ill have to find another way to do this, which your suggestion might be the best way. I may use another Arduino and just run 2 separate windows for the project Im doing.

Thanks for the help.

Re-read what cr0sh. You can drive the servo from the Arduino with the motor shield. You just can't POWER the servo from the Arduino. You might be able to power it from the same power source that is powering the motors, depending on that power source's voltage and your servo's voltage.

Triggering the servo from the same Arduino that has the motor shield is easy. The control of the servo does not require a lot of current, so the Arduino is quite happy driving the servo. Just remember to connect the servo and Arduino grounds.

Controlling one Arduino from the computer will be easier than trying to control two Arduinos on different serial ports.

I dont understand the first part of you statement. "Re-read what crOsh?" LOL Like Ive said in other posts, Im already using the pins on the motor shield to control 2 DC motors. If I can drive a servo as well, then Im a happy camper! The power supply right now is run through the USB cable to the Arduino. Im thinking about changing that to use the DC plug with 8-AA batteries. That would give me around 12V of power, which should be plenty to drive the servo plus the 2 DC motors.

Comments?

a. Most servos run at 6 VDC max - try to run them on 12 volts, magic smoke will come out.

b. Even putting in 12 volts to the Arduino, you are only going to see a regulated 5 volts running it, with very low amperage current available.

c. You could use two four-cell battery holders wired in parallel (for double current output) to run the Arduino and the servos.

d. Hook the ground (negative) terminal of the holder to the Arduino's ground, hook the ground (black) wire of the servo to the Arduino's ground, hook the V+ (red) wire of the servo to the battery holder's positive terminal, and hook the signal (white) wire of the servo to a PWM pin on the Arduino; you can then control the servo without excess current drain on the Arduino.

Does this make things clear, or is this what you were planning on doing?

Ya, I was thinking of going that route. I wanted to be sure about driving 2 DC motors as well as 1 Servo with only 1 Arduino. The whole thing is a final project that Im doing for my degree, so I gotta figure this out. Everyone here is being really helpful and I appreciate it TOTALLY!

Thanks and Ill let everyone know how it goes.

Ahhh, this would certainly explain why I was only getting a weak twitching out of my Blue-bird 705 servo ::slight_smile:

I tried both direct off of my Ardy328 and off of my Arduino sensor shield v 4.0... same result.

Question... regarding your method. I get the first part

<Instead, just wire the PWM signal from the Arduino to the control pin on the servo, then hook up a separate 5-6 volt power supply (a 4-cell AA battery holder is fine - or, if you have a higher source of power in your application, like a 12 volt battery pack or something, then run it into a 7805, and run the output of the 7805 to the servo) to the servo's positive and negative power input pins; finally, tie the ground (negative) of the power supply to the ground on the Arduino.>

Not sure why this needs to be done???

Oh man, I hope I haven't damaged my little Ardy by trying to run the servo off of USB. :cry:

That has to be done so there is a return path from the servo's control signal to ground; you have to tie the grounds together that serve for signaling. Sometimes that ground is the same as for loads (like motors and relays), other times you can keep the grounds separate.

Sometimes you want to design (or may have to redesign) a system to separate out as much as possible the load grounds and the signal grounds, because sometimes power spikes and noise from loads can cause issues with signaling (leading to spurious signals, or signals being swamped). Also, there is an art to properly tying signals grounds, load grounds, and multiple power source systems together, so that everything works smoothly and properly.

Too often, designers neglect the structuring of their power supply system until very late in the design; sometimes the design has to be scrapped and done over to incorporate a working power supply system in place (when it should have been designed and tested early in the process). The same thing happens in software development and IT, in that security of a system is left to dead last on the requirements chart, when it should be first in line to be developed.

Hope that explains it! :slight_smile:

That totally explains it as I am a network/systems Engineer :sunglasses:
If I understand correctly, it is not too far off from a form of network traffic load balancing, as it sounds similar to a big F5 load balancer I had to set up for a massive SUN/Solaris IPTV deployment.

hi im new to the rduino i have been using the piaxe for so time
i have a arduino now with the motor shield kit v1.0 from oomlout dose any one know if i can run one stepper motor from the bord and at the same time run two relays from the dc motor side thanks for your time

hi all what im trying to do is open a set of gates you can see here what im trying to do the gate i have been trying difrent ways to control them I have two motors and each motor has a clutch on it what im trying to do is get a key fob to open the lock and then open the gates keep the clutches on to keep the Gates open when you drive in then you can close the gate with the key fob and the gates will claose and lock i was going to use the motor shield but i need to drive 4 mps max for the motros and im going to use a stepper motor to unlock the gate and i have found that you can not stack the motor shield so can you drive one stepper motor and run two relays from one motor shield or dose any no if you can get 4mps from a shield thanks