While
working on the Mechaduino in the last days for preparations of the new
hardware, I also worked on the calibration of the servos. I remembered an
earlier post from this forum. The point was that the calibration trusts the
sensor "blindly".
After thinking about it, I noticed one mistake here. The servo jumps to each full step position and measures the angle. It is assumed that the two coils of the motor are of exactly the same strength and that a full step lies exactly in the middle between two poles. In reality, one coil will always be stronger than the other. Therefore, the approached position will not be exactly in the middle. But this is important for calibration! The controller of the Mechaduino has no influence on the calibration and can therefore hardly compensate such an error of the positions. This can cause vibrations and noise.
After some thinking I wrote an algorithm to fight this phenomenon and worked it into the calibration of my firmware. Below is a brief description of the procedure:
- - Jump to full step position and measure the angle (100 values)
- - Take a half step in positive direction and measure the angle (coil A is energized, coil B is de-energized)
- - Take a half step in the opposite direction and measure the angle (coil B is energized, coil A is de-energized)
- - Compare the angle between the two half-steps
o If the angles are equal, the full step is exactly in the middle and both coils are equally strong
o If not: Adjust the coil currents to reduce the error.
The procedure is repeated for each 4 full steps (Every position with a positive coil current for A and B) and the mean value of all results is then calculated.
These mean values are then used to reset the coil currents accordingly. The weaker coil is set to 100% and the current of the stronger coil is reduced to e.g. 97%.
With my servo the new calibration showed differences of approx. 2-4 % in the coils and the servos run much smoother with the new scaled coil currents. I even removed the digital low-pass filters of the coil currents, which leads to a faster reaction of the servos (despite quieter running).
I uploaded the firmware with the new calibration at GITHUB. Maybe someone wants to try the same with their servos. It is important that the servos must never be loaded during calibration. The command for calibration is:
calibrate -coil -smooth
If you want to see the results of each step you have to add a -debug:
calibrate -coil -smooth -debug
Sincerely
Kai
I think you are right and I will try your suggested change in the coil currents.
But I also think that a scaling of the coils to work with the same strength will help for a better behaviour. Since an motor with different strenght in the coils will change its behaviour depending on the position. Hence the strength of the magnetic field is changing with the position of the rotor. This kind of mechanical system is not optimal for a PID controller. So if we can compensate it the whole servo should work better.
Kai
Thanks Kai