Potentiometers - reading and recording values

Hello, and thanks for reading...
I would very much appreciate any in-depth knowledge regarding using a potentiometer to position a servo arm.

Currently I am using a Hi-TEC HS-65HB servo which has a very useful maximum 189.5' arm rotation, using 690ms and 2510ms for pretty much 0 to 180' min and max positioning.
I am in the process of developing a program, with different modes, one of which will allow the use of the pot to position the servo arm, and an additional button to then record its value.
An subsequent program mode will then allow an additional input signal to switch the servo between two recorded positions.
Pulsout is my favoured servo drive command for this, as it seems to avoid the problems of using Servopos.

I thought I'd check/ask for some helpful info regarding the potentiometer, and the reading of its value when sweeping the servo arm...

Will the chosen potentiometer resistance have any advantage for the servo setting? i.e. Use of a 5K, 10K, or 20K pot?
If there is an advantage, then I assume it's best to choose this before programming, rather than trying to fix it in software?

When using the command 'readadc' to read the pot value, would it be advantageous to use greater definition, i.e. readadc10? ...
giving a better resolution for more accurate servo positions? ... which can then be more accurately recorded, and then used for more precise position repeatability?

Thanks in advance for reading, and any help is much appreciated.


If using the SERVO and SERVOPOS commands a byte variable is used and thus only values 0 to 255 are possible and accepted by the command. In this case there is no advantage in using the READADC10 - you would need to shift the value right (divide by 4) to use the top 8 bits.

lit using your preferred PULSOUT command then that command accepts values to 65535 and thus using READADC10 is worthwhile.
As the analog input is only 10 bits you will want to scale that up to achieve maximum required servo travel/rotation.
To achieve the highest resolution, first determine your lower end offset for the min value you desire as a constant (for 690 ms) Then scale the 10 bits from the analog input for the working range (2510 - 690 =) 1820 ms.
Hello Westaus55
I really appreciate the response - thank you :)

It's good to know that pulsout works with higher values - and can I therefore assume I have higher resolution for better servo position recording?

So I've had a go at what I think is required for the mapping of the servo range over the 10 Bit analogue input/potentiometer read...
If you can confirm I'm on the right lines, that would be great.

The servo I'm using has a range of 690 to 2510ms, or 69 to 251
251 - 69 = 182
10 Bit range is 1023 (0 to 1023)
1023 / 182 = 5.6 rounded down
5.6 = 56 / 10
The lower end offset to be added, will be lowest value of servo range, = 69

So if the readADC10 value is named PotVal
then the value mapping should be:
working left to right through the maths...

((PotVal * 10) / 56) + 69)

which will give the value to use at the pulsout command.

Hopes this looks good.
A very simple test program appears to work.
Any additional confirmation, advice and further tweaks, from other Tech Gurus too, is much appreciated.
Many thanks.

#picaxe 08M2

'Simple program to test the mapping of 10 bit ADC reading of 10K potentiometer
'for positioning a servo with range a of 690 to 2510ms

sertxd ("Filename: ", ppp_filename, Cr, Lf )
sertxd ("Created on: ", Ppp_datetime, Cr, Lf )

symbol ServoPuls = C.2     'pulse pin out to servo
symbol PotIn = C.1            'input pin from pot
symbol PotVal = w2           'value of pot

    do                                             'continuous do loop
        readadc10 PotIn, PotVal       'read 10 bit value into potvalue
        gosub ScaleVal                     'move to subroutine to scale pot value
        pulsout ServoPuls, PotVal    'pulse out to servo new scaled value
        pause 19

ScaleVal:                                       'scale value in PotVal
    PotVal = PotVal * 10 / 56
    PotVal = PotVal + 69