You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Large motors work great - medium motor won't move? #663
I've been happily driving my tank around using 2 large EV3 motors.
But when I tried to add in a medium motor, it locks up when it tries to rotateTo. I tested the motor using the standard EV3 OS, in case it was a bad motor or bad cable, and it works just fine.
Anything I can do to debug why it stops running when I issue the rotateTo command?
val motorSweep =EV3MediumRegulatedMotor(MotorPort.D)
logger.info { "Created motor. ${motorSweep.maxSpeed}${motorSweep.position}${motorSweep.tachoCount}" }
motorSweep.resetTachoCount()
motorSweep.rotateTo(45) // Locks up here
logger.info { "Finished 45: ${motorSweep.position}" }
speed and speed_sp attributes are both zero. Setting speed_sp seems to have no effect. Therefore when the library waits for the move to end, it probably gets stuck waiting for the running state to disappear.
I see the problem: after reset, the speed request is set to zero. With zero speed, the kernel controller indeed sees the motor as stalled. Setting the motor speed fixes the problem:
packageissues;
importev3dev.actuators.lego.motors.EV3MediumRegulatedMotor;
importlejos.hardware.port.MotorPort;
publicclassIssue663 {
publicstaticvoidmain(String[] args) throwsException {
EV3MediumRegulatedMotorm = newEV3MediumRegulatedMotor(MotorPort.D);
m.resetTachoCount();
/* here */m.setSpeed(360); /* here */intdstAngle = 90;
for (inti = 0; i < 10; i++) {
m.rotateTo(dstAngle);
dstAngle = -dstAngle;
Thread.sleep(1000);
}
}
}
On the other hand, it does not directly explain the difference between the medium and large regulated motors. @salamanders Does setting the speed solve the issue?
It seems that it is a bug in this library in the functions rotate() and rotateTo(). In functions forward() and backward(), the speed_sp attribute is configured before issuing the command. This is not done in the problematic two.
the way I remember it is the following: it is necessary to set the ev3dev speed_sp attribute (and maybe others) before sending the movement command (like run to rel pos) to the kernel driver, because sometimes the speed_sp attribute gets reset to zero (probably when resetting the tacho count, because our code sends reset command to the kernel). Without resending the speed, speed_sp will stay at zero and after the movement command is sent, the kernel regulator will show the motor as busy forever. This is because there is no movement towards the target point - it is literally moving at zero speed.
Tomorrow, I will check this example to raise the error:
import ev3dev.actuators.lego.motors.EV3MediumRegulatedMotor;
import lejos.hardware.port.MotorPort;
public class Issue663 {
public static void main(String[] args) throws Exception {
EV3MediumRegulatedMotor m = new EV3MediumRegulatedMotor(MotorPort.D);
m.resetTachoCount();
int dstAngle = 90;
for (int i = 0; i < 10; i++) {
m.rotateTo(dstAngle);
dstAngle = -dstAngle;
Thread.sleep(1000);
}
}
}
Activity
JakubVanek commentedon May 21, 2019
I can reproduce the issue with this kernel (not tested on previous ones.
Reproducer:
Log:
In the background, the connected motor in
/sys/class/tacho-motorchanges frommotor1tomotor2.JakubVanek commentedon May 21, 2019
When the motor is manually configured from command line, this happens:
speedandspeed_spattributes are both zero. Settingspeed_spseems to have no effect. Therefore when the library waits for the move to end, it probably gets stuck waiting for therunningstate to disappear.JakubVanek commentedon May 21, 2019
I see the problem: after reset, the speed request is set to zero. With zero speed, the kernel controller indeed sees the motor as stalled. Setting the motor speed fixes the problem:
JakubVanek commentedon May 21, 2019
On the other hand, it does not directly explain the difference between the medium and large regulated motors.
@salamanders Does setting the speed solve the issue?
JakubVanek commentedon May 21, 2019
It seems that it is a bug in this library in the functions
rotate()androtateTo(). In functionsforward()andbackward(), the speed_sp attribute is configured before issuing the command. This is not done in the problematic two.Configure speed_sp before executing rotate() and rotateTo()
JakubVanek commentedon May 21, 2019
If the workaround with
m.setSpeed(360)works, the #666 PR should be a working solution for this.salamanders commentedon Jun 16, 2019
I think it is something intertwined with motor states between app runs. Possibly.
I tried a simple:
And got odd results:
Almost like it thought the speed was 0, but it was leftover set to 360 from the previous run.
jabrena commentedon Sep 1, 2019
Reading the whole discussion, I don´t understand the issue.
I need a summary to get an idea.
JakubVanek commentedon Sep 2, 2019
Hi,
the way I remember it is the following: it is necessary to set the ev3dev speed_sp attribute (and maybe others) before sending the movement command (like
run to rel pos) to the kernel driver, because sometimes the speed_sp attribute gets reset to zero (probably when resetting the tacho count, because our code sendsresetcommand to the kernel). Without resending the speed, speed_sp will stay at zero and after the movement command is sent, the kernel regulator will show the motor as busy forever. This is because there is no movement towards the target point - it is literally moving at zero speed.Regards,
Jakub
jabrena commentedon Sep 2, 2019
Tomorrow, I will check this example to raise the error:
And I will review the possible solution:
https://github.com/ev3dev-lang-java/ev3dev-lang-java/pull/666/files