Command 54 - M1/M2 Duty & Acceleration

General discussion of using Roboclaw motor controllers
Posts: 33
Joined: Sun May 06, 2018 5:06 am

Command 54 - M1/M2 Duty & Acceleration

Postby ecorrales » Tue Aug 07, 2018 8:15 am


I am using a Roboclaw + motors without encoders. Over USB. Raspberry Pi. C++. I treat both motors together (it's a tracked robot, for turning I just want to pivot, so duty cycle is always the same amplitude just different sign (?)).

Been using someone else' code. I believe it's currently command 34. For ramping, it seems to be just keeping track of previously sent duty cycle, and slicing/dividing up the range between previous and currently desired duty cycle, and just sending new duty-cycle commands for each slice until the desired duty is reached.

I was thinking to replace all that with command 54.
Q: is that the command I should use? If so,

Q: I think I understand the duty-cycle part of the command. Wanted to clarify the acceleration values. Trying to relate the 0 to 655359 to the -100% to 100% ( I actually dont plan to use 0-100% values in my program - dont mind directly manipulating the real values)

I do best with concrete examples.

say the motors were at -32767 and I wanted to ramp to zero as quickly as possible. Would the acceleration be 655359? Does that mean it goes from -32767 to 0 in 100ms?

or this one: (I might always stop in between, but maybe not): what if motors were at -32767 and I wanted them to go to 32767 as quickly as possible. First, is that possible? and if so what would be the acceleration value.


User avatar
Basicmicro Support
Posts: 965
Joined: Thu Feb 26, 2015 9:45 pm

Re: Command 54 - M1/M2 Duty & Acceleration

Postby Basicmicro Support » Tue Aug 07, 2018 9:02 am

Yes you can use the MixedDutyAccel command to control both motors with one command.

The Duty range is +-32767. The accel range is 0 to 655350. The accel rate is just the amount of change in duty per second when chaning from one duty to another duty. Its maximum value is determined by the maximum acceleration rate allowed(-100 to =100% duty in 100ms which is 10 times the range between -32767 and +32767, Technically its a little more since we just round to 10* the maximum 16bit value, 65536(eg (10*65536)-1)

In your first example it would go to 0 in approximately 50ms.. Your second example is what I described above(100ms).

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests