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.
If I contol the motor from the void loop() it works but I need to control the motor and read the encoders with a specific frequency.

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,
Lorenzo

RoboClaw_DueTimer_ArduinoDUE.ino (1.1 KB)

Hello.

We did not write either of the libraries you are using and are not familiar with the DueTimer.h library, so our support will be limited. Can you elaborate more on what is not working in your code (e.g. error messages)?

You might consider contacting Ion Motion Control or posting on their forum as they might be able to better answer any detailed questions you have. You might also consider posting on to the Arduino forum so that your question can reach a larger community.

- Amanda