DC motor control with DueTimer library and RoboClaw driver on Arduino DUE

Hi everybody,

I am trying to control one 24-V DC motor by means of RoboClaw 2x7A driver. I am currently using the RoboClaw.h library and the DueTimer.h library for the implementation of a timer in Arduino DUE.

I would like to control the motor in PWM mode (roboclaw.ForwardM2(address,speed_m2); ) and to read data from the encoder (actual_encoder_position = roboclaw.ReadEncM2(address, &status2, &valid2); ) inside the function handled by my timer but it doesn’t work.
You can find the code in the attached file.

How can I manage it?

I would appreciate if you could look into this matter as soon as possible.
Thank you very much in advance,

RoboClaw_DueTimer_ArduinoDUE.ino (1.06 KB)

Please explain exactly what you mean by "it doesn't work".

Hi Pert,

Thank you for your reply.

If I insert the lines related to the control of the motor and the reading of the encoder in the void loop() I am able to control the motor and correctly read data from encoder. Whether if I insert those lines in the function handled by the timer the motor does not move, I can not read the encoder and the code is blocking.

Why the timer does not work?
How does the roboclaw command lines block the timer?

Thank you again.