I have a motor and a servo hooked up to my uno r3, they both work fantastically independently, but when I turn them both on at the same time, the motor is fine but the servo turns as far as it can and stops.
The motor and servo are powered by 4x 1.5v AA batteries (6v total).
What I think is happening is the motor is stealing the power, as it is of lower resistance than the servo?
If so, how can I stop this? My first thought are resistors but I don't have any high enough, I have up to 10M.
A multimeter attached to the supply while they are operating would show if the
voltage is dipping. If it isn't dipping then the issue might be noise or EMI from
the motor.
I've measured the voltage going to the servo, it is around 5.38V when the motor isn't running, and 4.9V when the motor is running. It's very strange, its as if I have set the servo to go to 0 degree's, but I haven't. Here is a pic of circuit and my code.
it is around 5.38V when the motor isn't running, and 4.9V when the motor is running.
So that says that your batteries are not supplying enough voltage at the current you are asking of it. So you need a better power supply or two sets of batteries.
This is nothing to do with your software.
Also you have no decoupling capacitors around your motor, this allows a lot of interference to be generated. See attached.
I've hooked up another 4x 1.5v AA batteries, I'm still at the same voltage which is really strange?
I can run the motor and the servo on separate supplies, but I really don't want to. It's only a small car thing, I don't want loads of batteries to power it where possible!!
I'm still at the same voltage which is really strange?
Are these fresh batteries? Have you measured them without the load?
Also what type are they? The zinc carbon types can not supply much current.
Better current is from the NiMh type but they tend to be a lower voltage.
Marshiewoo:
I can run the motor and the servo on separate supplies, but I really don't want to. It's only a small car thing, I don't want loads of batteries to power it where possible!
"No such thing as a free lunch."
You need the correct - adequate - batteries to power what you have. Alkaline AA cells would be the absolute minimum to power a small toy car, but even then will only have an hour or so of capacity, if that. NiMH maintain voltage better under load. There is a reason why model cars nowadays tend to use lithium rechargeables.
I have 4x 1.2v ni-MH AA batteries, 4x 1.5v Alkaline AA batteries, and 1x 9v rectangular battery to power the uno (which I've now been told is junk).
All batteries are fresh, checked them all individually and also when they are in the cradle.