Limiting the registry

#1
Morning all

I am trying to limit the registry to run a servo. The servo requires between 75 and 225, however I am controlling the servo through a Wireless unit which is sending the ADC of a potentiometer, this is giving 0-255. I want to limit the registry at the servo end so it doesn't go below 75 or above 225, is this possible?

Thanks in advance.
 

hippy

Technical Support
Staff member
#2
The range of the servo is 225-75=150, so you need to convert the 0 to 255 pot value to a 0 to 150 value, and then add the 75, giving the desired 75 to 225 result -

toServo = fromPot * 150 / 255 + 75
 
#3
In the past I have found that some servo’s operate over a range that may vary from the typical 75 - 225 control values.
Even two servos of the same make and model from a reputable local electronics store can vary by a few “points”.
Thus a low end value may be as low as 60 and the upper end may be as high as say 240.
If you wish to get the maximum operating range from your servos, it would warrant a few tests on the bench to check the operating range of control values before committing to final PICAXE program code.
 

hippy

Technical Support
Staff member
#4
In the past I have found that some servo’s operate over a range that may vary from the typical 75 - 225 control values.
That's a good point. The more general case function would be -
Code:
Symbol MIN_SERVO = 75
Symbol MAX_SERVO = 225

toServo = MAX_SERVO - MIN_SERVO * fromPot / 255 + MIN_SERVO Max MAX_SERVO
 
Top