Page 1 of 1

SpeedAccelDeccelPositionM1 goes crazy with accel decel values

Posted: Mon Oct 31, 2016 7:33 am
by tiffo
Hi, I have been using the roboclaw 2x30 (4.1.19) with the python library for an year. I have been noticing a weird and unpredictable behavior when I set the motor position with the function SpeedAccelDeccelPositionM1 or SpeedAccelDeccelPositionM2 whenever the accel and decel values are not zero. Most of the times it behaves normally, but sometimes motors run at full speed to the very end and then, after a while, they go back to the commanded position. The motor board does not loose the encoders' zero.

I wrote down a little test an I noticed that is happening every time I change the accel, decel, velocity from all set to zero (full speed) to some value (any value).

In the attached picture, in red the reference, blue are the X and Y motors of my robot. In the first half I command position with accel = 0, decel = 0, vel = 0, while in the second half I set both the positions to zero with accel = decel = 8000, velocity = 300. As you see, X and Y go to their limit, then X goes back to zero. Y does not react for a while and then goes to zero.

I found out that setting accel and decel to zero fixes the issue, but... it is not what I'd like, as I wanted a smooth movement.

Re: SpeedAccelDeccelPositionM1 goes crazy with accel decel values

Posted: Tue Nov 01, 2016 8:56 am
by Basicmicro Support
One cause of this is mixing non-encoder commands or velocity commands with position commands. The position commands keep track of the previous position to calculate when to start/stop accel/decel when executing position commands. If other commands are using in some situations, the next position command will have an invalid position stored in its previous position variable. This can cause the described behavior.