2

I have an Arduino Uno and a Micro Servo 9g A0090 servo.

Given that Servo.read() simply returns the last value written to the servo I guess there is no way to query a servo's actual position.

If I can't query the servo, how do I know that the servo rotated to the position of my last write() call?

Rotating from 0 to 180 will take longer than rotating from 0 to 10. How do people normally handle this scenario? Perhaps I just time how long it takes to go from 0 to 180 and then always call delay() afterward to give the servo time to complete its rotation?

7

Normal servos don't provide any feedback. Their speed depends on the servo's specs and the load.

You could measure the time it takes to rotate a certain angle and use that to calculate the time, then add some safety margin. But if the load isn't constant, the times will be off.
You could change the position slowly, but that still doesn't guarantee that the servo will do what you told it to.

If you want to know servos's position, you need a servo that outputs it. There are servos that expose the signal from their internal potentiometer.

analog feedback servo

Adafruit sells them and has a useful guide about them.

You can also modify a normal servo yourself, by attaching a feedback wire to the potentiometer's wiper pin.

2

I can imagine several ways how to do it:

  • You can wait some specific time. How long it takes to rotate from 0 to 180. But it'll wait for much longer for small angles than it's necessary.
  • Better aproach would be to compute delay based on angle (maybe even on servo power supply voltage)
  • Another way would be measuring servo's power supply current.
  • You can use some rotary encoder. But some extra gears might be needed to be able to detect position fine enough.
  • You can "hack" into the servo's electronic and get the position - it's usually voltage divider (potentiometer). But it might introduce some extra interferences and servo might be fuzzy or unstable...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.