# Position Sensor

During my design of a simple robotic arm, where I 3D printed most of the parts, then used these HS-422 servos, it turned out that for a better control precision and to be able to apply Inverse Kinematic Modeling on my arm, I need feedback positions from these servo, which HS-422 do not provide.

I want to keep using these Servos because the parts are designed to fit them, what options do I have to include feedback position sensors without changing the servos and re-designing the arm's parts? Or is there any servo with feedback position and close dimensions to HS-422 that I can replace with?

• Apparently some guy did some modifications to get some position from voltage readings forums.trossenrobotics.com/tutorials/how-to-diy-128/… I never tested it myself, I would personally recommend to put encoder on the shaft , you should be able to make space for them in the 3d printed part with a good hobby knife. – N. Staub Nov 30 '17 at 11:07
• @N.Staub, that was worth the try, which I already performed and could get position data, nice hack, but the issue now lies in the fact that Pi3 does not have any analog in, which leads me to hook up an external ADC or directly read them from Arduino itself. – Iron Fist Nov 30 '17 at 19:33
• I would suggest to use arduino for the low-level control, aka the position control loops. 1. you might get better results as there are no OS and you only control 5/6 motors. 2. you can run the Pi slower as high level, with inverse kinematics, user interface and all other high level funtionnalities – N. Staub Dec 1 '17 at 11:01
• Are u suggesting to use Arduino instead of ADC I2C boards? If Arduino option, that means I need it to communicate with Pi3 through serial?, Whereas with the ADC I2C boards, it seems to me a lot simpler but requires more boards (in my case 4 of the 4-Ch 16bit ADC I2C)? – Iron Fist Dec 1 '17 at 17:17
• You should also be able to use I2C with the arduinos. I am surprised you need so many ADC. How many motors do you have? You only need 1 channel per motor as I understood. The suggestions for the arduinos was more based on the fact that you already seem to have one and that from a system engineering point of view it was nicer to have the low-level control in one place close to the feedback inputs. – N. Staub Dec 4 '17 at 7:56

The suggestion posted by N. Staub worked well for me, I was able to perform the hack onto the HS-422 where the min and max readings of the servo potentiometer were [0.34-2.04 Vdc] and by using Arduino MEGA 2560, which has the option to provide an interval voltage reference of 2.56V, as fellows:

analogReference(INTERNAL2V56) #Arduino MEGA Only


With this setup I could get a good resolution of 0-2.56V/0-1023 counts.

For other boards, you can provide an External Aref, using a voltage divider rule, keeping in mind that the max External Aref cannot be more than 5V otherwise you will damage the chip.

A slightly difficult but interesting way to solve this would be to stick markers on your joints, and then you can use a camera to find the relative position of the marker wrt to the base point.

• Using Camera for every joint does not seem to be interesting to me, plus I need position values, so how accurate the camera solution will be compared to a rotary encoder or something similar? – Iron Fist Nov 30 '17 at 8:36
• You don't need to use one camera for each joint, you just need one that covers the work space. It wont be as accurate as an encoder, but it will be non-invasive to your existing design. And should be able to do the job well, given the camera has a good enough resolution. – Ln_r1 Nov 30 '17 at 18:09
• They use cameras to identify positions of swarm drones and help in trajectory planning to make sure they don't hit each other when carrying out complex motions – Ln_r1 Nov 30 '17 at 18:13
• But this will require you to learn and use image processing which is a sub set of machine learning. Plenty of programming involved, and relatively very little physical changes. – Ln_r1 Nov 30 '17 at 18:25