Stop Motion Command

Questions about using encoders with the Roboclaw product line
Post Reply
rantangan
Posts: 10
Joined: Sun Aug 30, 2020 6:11 pm
Stop Motion Command

Post by rantangan »

Is it possible to add a decelerate to stop command. I follow Basicmicro suggestion issuing read encoder and move to the read position. It works ok at really slow speed but at higher speed the motor exhibit visually an overshoot. I think it's not really an overshoot. Roboclaw is executing the 2 commands correctly. It's just while executing read encoder and the move to position, the motor has passed the read position.

Thanks
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Stop Motion Command

Post by Basicmicro Support »

There is one. The Speed Accel commands work in both acceleration and deceleration. If the current speed is higher than the new target speed it will decel to that speed. If the new speed is 0 it will decel to 0 speed.

If you are using distance commands you have to do some fancy math to determine when to start decelerating so you stop at the point your distance runs out. There is a post in the forums specifically detailing this.

viewtopic.php?f=2&t=46&p=158&hilit=Calc ... tance#p158
rantangan
Posts: 10
Joined: Sun Aug 30, 2020 6:11 pm
Re: Stop Motion Command

Post by rantangan »

Thanks.

The only command I can use is position command since I have to have the motor holding the axis at its position after it stops.

When used to detect an object and stop the motor when object is detected, the result is pretty good since motion is very very slow. The sequence is position cmd to max travel, poll sensor, read encoder and position cmd to the position just read.

But, a touchscreen joystick, motion is a much faster (but still very slow), using read encoder and position cmd combo causes the overshoot looking motion. Keep in mind, I can only use position command for continuous holding of the axis.

An internal "read encoder and move to the position" command will be much faster and perhaps solve my problem.
rantangan
Posts: 10
Joined: Sun Aug 30, 2020 6:11 pm
Re: Stop Motion Command

Post by rantangan »

I've using "Speed, Accel, Deccel and Position" command after read encoder to stop motor. Today, I tried "Drive with Position" instead of "Speed, Accel, Deccel and Position". It seems to work stopping motor without the overshoot.

How to change speed, accel, and DECEL, with Drive with Position (119, 120, 121) commands. I use Studio to do it but I'd like to programmatically set those parameters. I tried command 68-71 but not sure it's the same as the one on Studio since it doesn't have Set Default Decel.

Thanks in advance
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Stop Motion Command

Post by Basicmicro Support »

I am not sure what you are talking about when you say "Drive with Postion". We have Distance commands and we have 3 Position commands(speed, accel,decel,Position, for M1, M2 and Both).

Please describe exactly what you did in Motion studio and I can tell you how to replicate it in packet serial.
rantangan
Posts: 10
Joined: Sun Aug 30, 2020 6:11 pm
Re: Stop Motion Command

Post by rantangan »

From manual's TOC:

119 - Drive M1 with Position ......................................................................... 99
120 - Drive M2 with Position ......................................................................... 99
121 - Drive M1/M2 with Position ................................................................... 99
rantangan
Posts: 10
Joined: Sun Aug 30, 2020 6:11 pm
Re: Stop Motion Command

Post by rantangan »

Default Speed, Accel, Decel on "Motors" section on General Settings of Motion Studio. What's the equivalent command from RS232.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Stop Motion Command

Post by Basicmicro Support »

That is clearer. Thank you.

The default accel commands are documented in the manual.
The default speed commands were just added and havent been updated in the manual yet.

The command numbers are:
SETM1DEFAULTSPEED 70
SETM2DEFAULTSPEED 71

Send: addr, cmd, speed (2bytes), CRC16(2 bytes).
Receive: 0xFF

Post Reply