I'm having trouble coming up with a solution for a project. Currently, there is a servo-motor actuating a robotic finger. The position of the servo determines the curl in the finger (straight finger -> servo 0 degrees, curved inwards -> servo 100 degrees). On the finger-tip there is a pressure sensor.
Let's say I tell the servo to move to 100 degrees. The finger will curl until the finger-tips comes into contact with an object. When the pressure sensor senses the finger is squeezing above X amount of pressure on the object, the servo will stop at its current position, say 50 degrees.
The problem is I don't know how to make the servo stop at its current position. The servo always goes to the final position I initially set it at. How can this be implemented?
I have thought of 2 solutions, none of which are ideal:
- When the pressure sensor reaches a threshold, turn off PWM to the servo completely. This should stop the servo from moving further but I don't think it'll hold the position. Also this creates challenges for the next movement command.
- Have another sensor that measures the current position (degrees) of the servo. When the pressure sensor crosses threshold, take down the current position and update the duty cycle to the current position. Problem with this is that I need to find a way to measure current position.
Can anyone advise on a better way of implementing this?