Hi,
I'm working on a line following robot. Direction is managed with a small servo SG90 and the movement with a small DC motor (the ones you find in toy cars). When the bot has to turn I bring it's speed to a half with a PWM signal. The problem is that my servo then starts to do this little twitches.
When the DC motor isn't connected, servo works fine.
When the DC motor is connected, but there is no PWM signal, just normal 5v, servo works fine.
So it seams to me that the power that is drawn by the DC motor in pulses somehow messes up the servo.
I don't no should I get separated power supplies or put some kind of a filter between the servo and the power source...?
This sounds like a power supply issue, but you haven't provided enough information to know that for certain. How are the Arduino, the DC motor and the servo powered, and what circuit do you have between the Arduino and the DC motor?
Yes, sounds like you are trying to draw too much current from the arduino 5V pin. Servos and motors should always utilize external DC power supply, battery or other voltage source. Also never drive a motor directly from a arduino output pin, use a transistor driver between output pin and motor.
Well, actually I'm using a PIC16F627 micro controller for this project.
Everything is powered from the same source, DC - 5v and max. current of 2250 mA. I think that's more than enough to power both the servo and the DC motor, otherwise it wouldn't work when I feed the motor with 5v and not the PWM signal. (but it does work)
The DC motor is driven using an H-bridge L293D.
PIC -> L293S -> DC motor
We are not going to get parochial about which chip you are using (well I am not ...) but if you want any sense made of it, you need to show the actual, complete circuit so we can advise on power supply "stiffness", regulation, isolation, bypassing and such.
Anyway, it seams to be working fine now, I just put a 10uF capacitor over the power source (to which the servo is connected and everything else). I'm guessing that the power has a short oscillation whenever the power is drained by the DC motor, so the cap now neutralizes this. And it doesn't effect the motor 'cause it's driven threw an H-bridge L293D.
Hi, good to see you have solved the problem yourself, well done.
What was happening was the current used by the servo is not continuous and an be very high for short periods, the capacitor helps smooth this current out.
You have done what a number of us would have suggested with the capacitor.
I would advise that you also place a 0.1uF across the gnd and 5V supply pins of the PIC as close to the chip as possible, this is called bypassing and is very critical in digital circuits where the power supply is shared and comprises of low and high current loads.
For example , without a circuit diagram, I would suggest you get your servo and motor supply directly from the power source and not via any wires or tracks that supply current to your PIC.
Thank you Tom for answering.
The capacitor that I've put goes across gnd and the 5v power supply that is going to the servo and the PIC and the motor driver. But I don't think that the current used by the servo was the one causing problems, it just seams to me that the current that was drawn by the DC motor in pulses was the one causing the current applied to the servo to oscillate. Or voltage.
Everything seamed to be working fine with the an adapter as a power supply, but now I've tried it it 4 AA batteries and it just all went down the drain. Servo is all twitchy and slow, the DC motor is slow and not consistent. It's a mess. :~
I don't know why isn't it working with batteries? Any explanation?
Everything is power by the same power supply in this case 4 AA batteries.
By now I'm pretty sure it's the servos fault, 'cause the DC motor seams to work fine when servo isn't plugged in...
Paul__B:
Looks good, but maybe 100µF just in case.
Did you write "2004" on that diagram?
I wrote the 2004 on the hand drawn diagram then took a pix with an old web cam. I had a servo based pan/tilt webcam that operated with that setup for ~7 years. Supplying the servos with 5.7v instead of 5v makes a noticeable improvement in servo performance.
duje:
I don't know why isn't it working with batteries? Any explanation?
Time to get out a voltmeter and see whether the Arduino, motor and servo are each getting the voltage they need under load. Maybe the battery has insufficient rating, or is flat, or there is a fault in the circuit.