Maker Pro
Maker Pro

Quality Pot for Servo

rfresh737

Jul 25, 2023
3
Joined
Jul 25, 2023
Messages
3
I'm using an Ardunio Mega board and a pot to control a 180 servo. The problem I am experiencing is that the pin read on the pot jumps around from 0 to 600 or so and I don't get a smooth 0 to 1024 range. I don't know if this is because the pot I am using is a cheap hobby pot and I need to higher quality pot or if it's something in my Ardunio code, or maybe my wiring is at fault?

Any comments appreciated. Thank you.
 

Bluejets

Oct 5, 2014
7,059
Joined
Oct 5, 2014
Messages
7,059
Here's a thought.
Include a couple of photos of your layout and wiring diagram and your code so some may be able to give an educated opinion.
 

crutschow

May 7, 2021
861
Joined
May 7, 2021
Messages
861
The Pot output can be noisy when it is being rotated.
What is the pot resistance?
How fast is the pot moving?
What is the voltage on the pot?
What is the load on the pot output?
Can you filter the pot output to reduce the noise?
 

rfresh737

Jul 25, 2023
3
Joined
Jul 25, 2023
Messages
3
#include <Servo.h>
int yokePin = A0;
int yokePinValue

// Create a servo object
Servo yoke;


void setup() {
Serial.begin(9600);
yoke.attach(yokePin);
}
void loop(){
yokePinValue = analogRead(yokePin);
Serial.println(yokePinValue);
delay(200);
}
 

Attachments

  • Untitled Sketch 2_bb.png
    Untitled Sketch 2_bb.png
    467.5 KB · Views: 4

rfresh737

Jul 25, 2023
3
Joined
Jul 25, 2023
Messages
3
The Pot output can be noisy when it is being rotated.
What is the pot resistance?
How fast is the pot moving?
What is the voltage on the pot?
What is the load on the pot output?
Can you filter the pot output to reduce the noise?
I turn the pot fairly slow. Not fast at all.
I can filter the pot and I would have to look up how to do that.
I don't know the readings you ask about as I don't know how to do that.
 

Bluejets

Oct 5, 2014
7,059
Joined
Oct 5, 2014
Messages
7,059
I don't know the readings you ask about as I don't know how to do that.
Multimeter readings...........

Aside from that, usual approach with analog input is to take seval readings over a short period of time and then take an average reading.
Plenty of detail on the web on how to do that without having to repeat here.
Also, use code tags when submitting code (also how to do on the web).

You will also need to map your pot readings to the range requirements for the servo signal in your code.
#again, see line 3 ....

wiring diagrams are not fritzing displays as you submitted.......
Wiring diagram should also include whatever power supply you are using and how everything is connected.
Pencil/paper sketch is fine as long as you follow conventional layout.
#again, see line 3

Finally, using a "mega" is an absolute overkill for what you are doing.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,773
Joined
Nov 17, 2011
Messages
13,773
#include <Servo.h>
int yokePin = A0;
int yokePinValue

// Create a servo object
Servo yoke; // see comment below: The servo OUTPUT needs to be on another pin than the potentiometer INPUT. Rename the variable.


void setup() {
Serial.begin(9600);
yoke.attach(yokePin); // -> makes no sense at all. The attach() function is used to assign a pin to a servo control OUTPUT. Here you want to read the servo's position. Remove this line from the code
}
void loop(){
yokePinValue = analogRead(yokePin);
Serial.println(yokePinValue);
delay(200);
}
See my comments in the code.

Why do you read the servo position at all? In a standard servo the potentiometer is internally connected to the servo electronics and used to control the position. All you do is send positional info to the servo. See the documentation of the servo library.
 

kellys_eye

Jun 25, 2010
6,514
Joined
Jun 25, 2010
Messages
6,514
If ever you need 'quality' from a servo you fit an EXTERNAL pot to the 'lever' that has the most importance i.e. in a ships rudder control system the feedback pot is coupled directly to the rudder stock (shaft). You need a feedback pot with the largest length of track possible to attain good resolution and you can't do that in the confines of a small servo mechanism.
 

bidrohini

Feb 1, 2023
200
Joined
Feb 1, 2023
Messages
200
I think the issue is in the wiring. usually any ordinary pot works. If you want to be sure, you can test the POT separately.
 

Bluejets

Oct 5, 2014
7,059
Joined
Oct 5, 2014
Messages
7,059
You need a feedback pot with the largest length of track possible to attain good resolution
Again, I am fairly certain the Op simply wants to turn an external pot and have the servo follow the pot settings......much like a servo tester...... nothing to do with feedback.
 

crutschow

May 7, 2021
861
Joined
May 7, 2021
Messages
861
usual approach with analog input is to take seval readings over a short period of time and then take an average reading.
That and ignoring any large outlier (spike) voltages when you do the average.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,773
Joined
Nov 17, 2011
Messages
13,773
Again, I am fairly certain the Op simply wants to turn an external pot and have the servo follow the pot settings
A plausible assumption. One more reason not to use "yoke.attach", see post #7.
 

Bluejets

Oct 5, 2014
7,059
Joined
Oct 5, 2014
Messages
7,059
A plausible assumption. One more reason not to use "yoke.attach", see post #7
yes, and now the OP has disappeared........probably confused as ever.:)
Code tries to do something but wiring tries something different (no idea what)
 
Top