Servomotors are very useful components when we have to make movements with precise angles.
In this article I will mainly refer to arduino controlled servo motors, in particular the servo motor models are: Sg90, ds3115, ds3220, ds3225, ds3235, etc ..
The goal is to be able to stop the servo motor when desired by the application. In particular we would like to stop the servo when it cannot reach the desired position or when the desired position varies according to the application.
There are two methods mainly to stop the servo: sensor on off, current control.
On off sensor or commonly known as endstop sensor for 3d printers and cnc is a sensor that opens or closes a circuit allowing the arduino to recognize the obstacle. The sensor is useful when the servo touches a component and activates the sensor. In the event that the object changes position it could move away from the sensor and therefore change its state, vice versa if the object approaches the sensor the sensor will not detect further changes. It may be useful to position three of these sensors at different distances and when one of the two external sensors is triggered make the servo move to position itself again. Personally it is not a method that I particularly like and a pressure sensing system could be useful, do you know anyone? leave it in the comments.
Control of the servo motor with the current: this is certainly the method that intrigues me the most and it could be for you. When a motor is overloaded there is an increase in absorbed current, by measuring this variation we will be able to understand when to stop our servo. How to do? To measure this absorption we will have to put a small resistance on the gnd of the servo, the gnd of the servo will then go to a resistance that will then go to the gnd of the arduino or the power supply, upstream of the resistance we put a cable that goes to an analog pin (example A0) by arduino.
How to size the resistance? Let’s do two calculations: servo ds3225 the stall current is 2A at 5V and we use a 1ohm resistor we use the equation P = R * I ^ 2 = 4A * 1 ohm = 4 W. By connecting to the arduino analog pin we can read values from the serial and set a value limit beyond which to block the servo.
In the hope of having been helpful if you have any questions or corrections do not wait to email me.