Tracking the value of a potentiometer by stepping motor

Hi, I need to track the value of a 500 Ohm potentiometer with a stepper motor.
I start by saying I'm not very good at programming.
I also hope I have centered the correct forum, in which case can you tell me where I can post this question.

Basically I have to follow the resistive value of a potentiometer that moves from 0 to 500 Ohm doing from 0 to 360 degrees and vice versa.
The potentiometer moves slowly, makes one revolution in about 1.3 minutes.
I would like the stepper motor to track the movement of the potentiometer as it changes its value.
I have tried in several ways, but unfortunately with no appreciable results, I cannot.
If any of you are aware of such a project, could you please indicate where I can find it.
If not, it might help me make it happen.

Many thanks in advance

I think this video can help you
(https://www.bilibili.com/video/BV1YB4y1F7DK?from=search&seid=9943829065798224107&spm_id_from=333.337.0.0)

1 Like

Which motor? Post datasheet link or full part number.
Which motor driver?
Which Arduino?
Which power supply?

1 Like

Post one of these several ways, a complete program that compiles and runs but doesn't yet do what you want.

As you may have seen in the linked video, it is an easy problem to solve.

a7

1 Like

Does the potentiometer rotate back and forth smoothly between 0 and 500 ohms or is it a "continuous rotation potentiometer" that will rotate past 360° to 0° and discontinuously from 500ohms to 0 ohms like a sawtooth?

Does your project differ from Arduino/File/Examples/Stepper/MotorKnob ?

https://docs.arduino.cc/learn/electronics/stepper-motors

Wow Hah,
thanks Hah, yes it was what I was looking for, too bad I can't find how to download the code and the connection diagram, it tells me that the link sharing has expired.
Many thanks

JCA34F,
these are the possible stepper motors.
Stepper
Stepper2
I would like to use an arduino nano and the power supply can be both 5V and 12V.
Many thanks

Hi DaveX,
it seems that it could do for me, but I have to try it first to see if it works, in the week I will do some tests and I will be able to tell you.
The potentiometer is linear it goes from 0 to 500 Ohm it does not rotate continuously it has an end stop in practice it is 340 degrees but I think that the map I can change the degrees to 360.
Many thanks

I took the link and see wiring and code and explanations.

I also see a 9 volt smoke detector battery, please don't try use that for any power you need supplied to you circuitry.

a7

A stepper motor doesn't have a 'home' position. Is it OK if the two shafts (input and output) move at the same rate starting at whatever position they were at when the power came on?

The first step is to read the position of the potentiometer. How many pins does it have?

Hi alto777,
yes of course, I have tried several programs copied here and there, unfortunately my programming skills are too poor.
Posting what I've tried that doesn't work, that's a lot of stuff.
and I think it's not worth it.
Yes, I saw the video that does what I would like but unfortunately there is no code and I could not find it plus it is also in Chinese or Japanese ...
Many thanks

Wasn't there? At the very end? True you'd have to type it in again but it's only very short.

If you can't share your attempts, point link us to the here and there sketches that you thought be applicable.

Don't worry about being new to this, we all started somewhere. Knowing nothing.

a7

Hah,
Many many thanks again, I found the code, it's a basic example of the stepper library.
:+1:

1 Like

Hi johnwasser,
the motor has 5 pins and is geared down, 1:64, but I saw that there is an example of the Stepper library that maybe is right for me, now I have to find the system every time I turn it on to know in what position the potentiometer is so as to move or not to move the motor if it is already in that position.
Thank you

Thanks you have all been very kind and thoughtful, it's a great forum with special people.
Thanks again to everyone, if I have difficulty I will definitely post my problem here again

The question was "The first step is to read the position of the potentiometer. How many pins does it have?"

I can read only 2 pins of potentiometer no 3. If is this the question.

Hi,
I'm sorry but I don't know how to post a new question at all.
I connected the nano to the ULN2003 and I feed it with the 5V required by the motor.
If I use a potentiometer with 3 pins one to ground, the other to the A0 input and the other to 5V, it seems to work even if it only makes half a turn and not a full turn.
But this is another problem.
The problem is that I have a potentiometer from which I can only take two pins, the central and one on the side, but not the third pin, as shown in the diagram.
In addition I have noticed that the motor does not stay still once it has reached the position but continues to shake as if there were small variations in values.
UnipolarKnob_schms
Any suggestion about ?


This is the code

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 64

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 11, 9, 10, 8);

// the previous reading from the analog input
int previous = 0;
int d ;
void setup() {
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(500);
   Serial.begin(9600);
 Serial.flush(); // Clear Serial buffer 
}

void loop() {
  // get the sensor value
  int val = analogRead(0);
  Serial.println(val);
  d = map(val,0,1005,0,2048);
  // move a number of steps equal to the change in the
  // sensor reading
  stepper.step(val - previous);

  // remember the previous value of the sensor
  previous = val;
}

If you meant in a new topic, it is better that you didn't. Open a new topic or thread, that is.

I didn't mean to suggest you should do other than stay here while we get this sorted.

So… measure the maximum resistance that develops between the two pins you have, that is when it is turned to the extreme that makes that happen.

Then add a resistor of equal value. Where the red X :x: is in your schematic.

I mean to say from the wiper to 5 volts. I can't draw it from where I am right now. From A0.

This will form a voltage divider.

Your analogRead will range now from 0 to 512, code accordianly.

That resistor can be smaller to recover more range… what is the max resistance from the potentiometer?

a7

Hi,

Can you please post an image of your potentiometer?
What value is the potentiometer?

What is the application?
What is your project part of?

What turns the 500R pot?
I am sum what confused, we really need to know the full scope of your project.

Thanks.. Tom... :grinning: :+1: :coffee: :australia: