new calibration

184 views
Skip to first unread message

Kai Wolter

unread,
May 13, 2018, 12:08:28 PM5/13/18
to Mechaduino

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

Trampas Stern

unread,
May 13, 2018, 3:33:20 PM5/13/18
to Mechaduino
Kai,

On the smart steppers I calibrate with one coil on. That is a full step can defined as both coils on (which is what Mechaduino did) or as one coil on, most people define it as one coil powered and the other off.  So if you calibrate with phase A on, phase B off, then phase B on, phase A off, etc then you will not have position errors based on the mismatch in coil currents.  

The definition of a full step being one coil on and one off is the more common definition, and then half step is when both coils are powered. Hence I think it was an oversight in Mechadiuno to use both phases on for a full step.  

However based on your description you should get the same results. That is you are interpolating between the two steps where one phase is on to determine the half step (your full step) between.  Hence your results should be the same as calibrating with one phase on full stepping, as I do in the smart steppers.  

You will also find that doing the one phase on full stepping will give you best calibration. That is if the magnetic flux for a pole is not the same for a step it will not matter as that with one phase on it will still move to the best location.  More specifically if the two phase currents are matched the magnetic field strength for poles for the motor might not be, hence you can still get a position error trying to calibrate with both coils on.  

Trampas


Kai Wolter

unread,
May 13, 2018, 4:26:32 PM5/13/18
to Mechaduino
Hey trampas,

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

Trampas Stern

unread,
May 13, 2018, 9:25:35 PM5/13/18
to Mechaduino
Since the PID will adapt based on the encoder it will correct for the coil imbalance, but it might take a bit more time.
It would be interesting to see if the coil current error is consistent over a full rotation.

Kai Wolter

unread,
May 14, 2018, 3:04:48 AM5/14/18
to Mechaduino
The above algorithm has produced a similar error for my servos over one revolution. When I have the time I will upload an Image.

As you have already written, the PID controller will compensate for such an error, but it can cause instability due to the resulting variations in the magnetic field and the resulting torque.

István Tuba

unread,
May 18, 2018, 10:39:31 AM5/18/18
to Mechaduino
Hello Kai,

I tried the new calibration routine, but it doesn't work.
After calibration, there is a "hole" where there is no torque.
The previous version works flawlessly.

Kai Wolter

unread,
May 18, 2018, 2:06:18 PM5/18/18
to Mechaduino
Hey could you please try it again with the debug activated? Just add a " -debug" at the command. And upload the output from the terminal in this forum (maybe a txt file because it's pretty long).

Thanks Kai

István Tuba

unread,
May 19, 2018, 6:48:43 AM5/19/18
to Mechaduino
Ok, here is the result.
calibrate_coil_smooth_debug.zip

Kai Wolter

unread,
May 19, 2018, 11:56:06 AM5/19/18
to Mechaduino
After Looking at the output it seems that your motor stalls at the calibration for higher rotation speeds. You could increase the maximal current to counter this problem.
Could you you try it agian with a higher current setting?

If this dosn't help i need to change some lines in teh firmware.

- Kai

István Tuba

unread,
May 19, 2018, 12:46:49 PM5/19/18
to Mechaduino
To this stepper 1500 mA the maximum.

István Tuba

unread,
May 19, 2018, 12:52:37 PM5/19/18
to Mechaduino
The previous firmware I try to run at a constant speed. But every  ~ 30 turns makes a shake. 

Trampas Stern

unread,
May 20, 2018, 7:08:30 AM5/20/18
to Mechaduino
The current rating for a stepper motor is the continuous current rating (ie long term average current), with a mecahduino or smart stepper the current should only be at max current for a brief period. Hence you should be able to increase the maximum current beyond the motor rating without issue.  

I have been debating on putting this feature in the firmware. That is measure the average current over a time period and using this for the maximum current limit.  What would happen is that when you have an error the motor will move at maximum torque (exceeding motor rating briefly) if the error still exists after a few milliseconds it will drop the current to keep from burning up motor. 

István Tuba

unread,
May 20, 2018, 7:59:35 AM5/20/18
to Mechaduino
I know that in short term can cross the max. current.
Any way I made another test with the max current.
The result also faulty.
calibrate_coil_smooth_debug_max.zip
Reply all
Reply to author
Forward
0 new messages