RoboClaw Duty Cycle Control

Hi, I just read the instruction of “Drive M1 With Signed Duty Cycle” in the packed serial mode. It says that the range of duty value is ±1500. If I’d like to directly send bytes to roboclaw using arduino due, then what is the corresponding value of duty cycle? The command is like this: Send: [Address, CMD, Duty(2 Bytes), Checksum]. Duty cycle is 2 Bytes.

Another problem is that if I’d like to make the load on my motor shaft to complete some complex motion, like the speed is sinusoidal function verse time, then can I use “Drive M1 With Signed Duty Cycle” and send control signal of different duty cycle to roboclaw in every time step to make it?

Yes, you can update the duty cycle as often as you want.

If you actually want to compensate for load, you will need to use encoders, and use drive-with-target-velocity commands instead.

The parameters in RoboClaw commands are sent most-significant-byte-first. This means that if the value is 1000, which is hex 0x3E8, the bytes would be 0x03, 0xE8. The value -1000, which is hex 0xFC, 0x18.

Thnak you for reply! Then how does the checksum be calculated? Just use the most significant byte?

You checksum all the bytes. I e, first generate the bytes for the entire command into a buffer, and then calculate the checksum across all the bytes you put in the buffer. Or checksum them as you send them, if you send one byte at a time.

For the checksum, I should add all the bytes, I.e, the address is 128, the command is 32 and the duty value is0x3E8, then the checksum would be (128+32+0x03+0xE8) & 0x7F. Is that right?

Another question is that if I’d like to use my DC motor to exert certan value of force on a plane, like a table, then how can I use roboclaw to make it. Now my plan is based on the fact that the armature current of DC motor is proportional to the output torque. Then I feedback the armature current to adjust the duty cycle of input signal to control the armature current to desired value, which represents the desired output torque. Is that an applicable solution?

Yes, that is the correct calculation of checksum.

Regarding applying a very specific amount of torque, if you know the torque of the motor at a few duty cycles, then doing a regression fit for the torque curve and controlling torque that way will get you in the ballpark, especially if you average over some time.
If you need highly accurate torque control, you will need a torque sensor and read that as input to a control algorithm.