# Potentiometer on motor for position control

I am using a wiper motor as a rotor. I am trying to get it to at least point in different azimuths (compass azimuths eg. 180 degrees) In order to do this, I am thinking about attaching a potentiometer on the axle inside the motor housing to see where the motor is pointing.

So lets say the pot gives me a range of 0-1023. If I divide 1023 by 360 i get 2.84. So lets say the pot gives the Arduino a 1, I can relate that to 2.84 degrees?

Also, what if the motor is pointing at 350 degrees, and I want it to point at 2 degrees. Instead of it turning around 348 degrees, it just cross pass 360 and go to 2 degrees. How would a pot handle going over a single step? If the motor passed a single step would it consistently give me a 1023 reading?

I am trying to get a wiper motor to have a known position 360 degrees around.

• Most pots have a interrupted circle, made of something like carbon, with a wiper moving along it. Moving from one side of the circle to the other side of the interrupted circle, means the wiper will be disconnected for a few degrees, giving you some random analog value (unless you have a pull-down). You won't be able to measure the angle around this point. You could use two pots with there "0-point" opposite of each other. Or go with a rotary encoder, combined with a home-position sensor. Jul 1, 2016 at 12:39

## 2 Answers

I am trying to get a wiper motor to have a known position 360 degrees around.

There might be a few possibilities.

First there are continuous rotation potentiometers on the market. They seem expensive though and I can't comment on how accurate they are.

Second, if your device is only ever going to turn through say ten revolutions then go back, you could just get a multiturn pot that will handle that range of turns. (Depends what you're building of course - for example I've heard of servo winches for model sailboats that use this method.)

Thirdly, and I accept this may not be a good answer to your question, but have you thought about using incremental encoders instead? In theory they could be more accurate too. The hardware is quite easy but a bit more programming is required to make these work...

• The device in theory should only rotate once. No more than 5 times if need be. So I guess a mulit turn pot would be in order! Jul 1, 2016 at 20:18

So lets say the pot gives the Ardunio a 1, I can relate that to 2.84 degrees?

Yes, if the pot goes from 0 to 1023 in 360 degrees of rotation, and it can rotate continuously. That sounds unlikely - f/ex, thinking about how a pot is made, how will it get from its maximum resistance to its minimum resistance in 2.8 degrees?

Instead of it turning around 348 degrees, it just cross pass 360

Smart software. :) You would need to read the pot, decide which direction of rotation will get from the current position to the new position, and select that direction in the motor drive circuit.

Update: A pot doesn't really "output" anything; it is a variable-resistor, whose resistance can be measured by placing it in a known electric circuit and using an Arduino A2D input to measure a voltage in that circuit which depends on the resistance of the pot. The reading you get is a 10-bit integer. If you divided that by 1024, you'd have a pure fraction representing the measured voltage as a fraction of the A2D's full-scale voltage, which you select as INTERNAL (1.1v internal reference voltage), or EXTERNAL and apply a reference voltage to the chip's Aref pin. Usually that is the power-supply voltage, and in any case must not exceed the power-supply voltage.

So, back to reality, if you use the EXTERNAL reference with Aref connected to +5v, then the A2D readings would mean:

``` A2D  Volts  Mag.Azimuth
0   0       0
256   1.25   90
512   2.5   180
768   3.57  270
1023   4.99+ 359.6
```

In this case you probably don't care about the measured voltage, only it's relationship to 5v, which the A2D already gives you. That relationship equals the pot's relationship to 1 full rotation. So the azimuth, Az, you're seeking:

Az/360 = A2D / 1024, and

Az = (A2D * 360)/1024

• I am thinking more along the lines of, if the pots reading at 511.5, then the motor is facing 180 degrees (half of the 360 magnetic degrees) I am referencing the position of the pot, to magnetic azimuth.also, how would i say the pot is reading at 511.5. What unit does the pot output? Ohms? Jul 1, 2016 at 20:22