NearZero1
NearZero1 copied to clipboard
Resetting phase index in velocity mode
In the functions Roll1_vel()
and Roll2_vel()
the following code is supposed to keep the phase index in the interval 0 to 2*pi:
//RESET PHASE INDEX AFTER 2PI
if (phaseindex1 >= 2*pi) { //Reset phaseindex_U1 once it completes 2*180o in phase.
phaseindex1 = 0;
}
else if (phaseindex1 <= 0){
phaseindex1 = 2*pi - phaseindex1;
}
For the case of phaseindex1 <= 0
, I believe is should really be phaseindex1 = 2*pi + phaseindex1;
rather than phaseindex1 = 2*pi - phaseindex1;
. For the case of phaseindex1 >= 2*pi
, it's not really wrong, but setting it to 0 could cause a small speed inconsistency. It would be better to use phaseindex1 = phaseindex1 - 2*pi;
.
All together, I would propose the following code:
//RESET PHASE INDEX AFTER 2PI
if (phaseindex1 >= 2*pi) { //Reset phaseindex_U1 once it completes 2*180o in phase.
phaseindex1 -= 2*pi;
}
else if (phaseindex1 < 0){
phaseindex1 += 2*pi;
}
The reason I found this was that I experienced that the motor got stuck after rotating just a little bit at certain speeds. I believe this is due to the controller getting stuck in an infinite loop jumping between the edge cases. It only seems to happen at certain negative speeds, which I think is due to floating point imprecision.
@JohnJohanssonChalmers I have a similar issue where the motors run for a while and starts cogging. It happened to me in both i2c and PWM mode. Did you find a solution to this?
@sriharshakunda What do you mean by cogging? The issue I had manifested itself by the motor stopping completely coupled with faint buzzing noise. I only experienced it in velocity mode and only in one direction. I could get out of it by sending a velocity command in the opposite direction. The issue only occurred for certain speeds also. So one way to get around it was to find a speed for which the issue didn't occur.
Does this sound similar to your experience? Are you operating in velocity mode?
I have now modified the firmware of the NearZero to avoid the issues that I found and also to operate in a quite different mode. Hence I can't really reproduce the old issues without changing back to the original firmware.
@JohnJohanssonChalmers after digging down a little deeper, the issue is with controller over heating and causing the motors to create ticking noise and cogging.