SpeedAccelDeccelPositionM1 goes crazy with accel decel values

Questions about using encoders with the Roboclaw product line
Post Reply
tiffo
Posts: 5
Joined: Mon Aug 01, 2016 11:55 am
SpeedAccelDeccelPositionM1 goes crazy with accel decel values

Post 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.
Attachments
motor X and Y behaviour
motor X and Y behaviour
XY_CRAZY_20161027.PNG (71.69 KiB) Viewed 4475 times
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: SpeedAccelDeccelPositionM1 goes crazy with accel decel values

Post 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.

Post Reply