Unstable values while using servo motor

Hey guys,

I'm new to this Arduino world (and by now I love it!) so I don't understand the following issue:

I created a project from the Startkit Project Book ("mood barometer"?) where I control a servo with a potentiometer (see screenshot).

I'm wondering why the values aren't stable even when the motor is in position. So I made a measurement of the values (potential and angle) over a duration of about 10 seconds where I started at a potential of 0 (the values fluctuated a bit [from 0 to about 5]), held this for five seconds and raised it abruptly to the maximum of 1023. I held this level for 5 more seconds, then I stopped the measurement. The values at the maximum level fluctuated from 1023 down to 1011, back up and so on (see diagram) without any new input from the potentiometer!

Can anyone please explain me this?

Many thanks in advance!

Best regards
Stefan

schaltkreis_stimmungsparameter.png

schema_stimmungsparameter.png

Firstly its not a good idea to power a servo from the Arduino 5V, the peak current required by
a servo can be an amp or more.

But the most likely reason for you observations is that the servo current is running through the
same wires that go to your potentiometer, injecting IR voltages drops directly onto your measurements,
or put another way the analog input is measuring a combination of potentiometer position and servo current,
which you didn't intend.

Sensor power/ground should never share wiring with anything taking large currents, use a star-ground
configuration with the Arduino as the central point. You can mitigate by using much thicker wires and
soldering them in place (contact resistance needs to be eliminated), but that's pretty messy and
undesirable.

Probably easily explained by realizing your analog reading is a comparison between the voltage you are measuring and the 5 volts you are powering the Arduino with. IF YOU ARE POWERING the servo with the same voltage source, then, of course, the voltage will vary when the servo draws current from the 5 volt supply.

To eliminate this, power ALL motors from their own power supply, with all grounds connected together.

Paul

Thank you both for your quick replies! I think it makes sense what you're writing (and I will pay attention to this for future projects, thanks!), but why does the starter guide contain such a "imperfect" and bad configuration?

The more interesting question now is: I expect the motor to stand still when it reaches it desired position but sometimes it stands still and sometimes for a few seconds it's still "buzzing" (that's when the values aren't stable). Is my expectation wrong?

alve89:
Thank you both for your quick replies! I think it makes sense what you're writing (and I will pay attention to this for future projects, thanks!), but why does the starter guide contain such a "imperfect" and bad configuration?

The more interesting question now is: I expect the motor to stand still when it reaches it desired position but sometimes it stands still and sometimes for a few seconds it's still "buzzing" (that's when the values aren't stable). Is my expectation wrong?

Probably buzzing because the servo has reached the limit of it's movement and you are trying to send it beyond that limit.

Paul

No, it happens at any position / angle between 0 and 179.

alve89:
No, it happens at any position / angle between 0 and 179.

Until its properly powered, there is little point worrying about any symptoms...