Synchronise two dc motors with Roboclaw 2x30A

Hi,

I want to synchronise 2 of DC brushed motors with roboclaw 2x30A, thus I have two quadrature encoders and my microprocessor is Arduino Mega2560. I can read to speeds of the motors and encoder values on arduino terminal. But i don’t know exactly that how to calculate the difference and then speed up/down to motor ? I’m looking at the roboclaw user manual for a while but there are many methods which are about accel, speed, distance… I confused because of that. I’m adding my code here which is incomplete.

#include "Arduino.h"
#include <RoboClaw.h>
#include <BMSerial.h>

RoboClaw roboclaw(10, 11, 10000);
#define RoboClawAddress 0x80

#define Kp 0x00010000
#define Ki 0x00008000
#define Kd 0x00004000
#define qpps 44000


void setup() {
roboclaw.begin(38400);
Serial.begin(38400);

roboclaw.SetM1VelocityPID(RoboClawAddress, Kp, Ki, Kd, qpps);
roboclaw.SetM2VelocityPID(RoboClawAddress, Kp, Ki, Kd, qpps);
}

void loop() {

}
void displayspeed(void){
	uint8_t status1, status2, status3, status4;
	bool valid1, valid2, valid3, valid4;
	uint32_t enc1= roboclaw.ReadEncM1(RoboClawAddress, &status1, &valid1);
	uint32_t enc2 = roboclaw.ReadEncM2(RoboClawAddress, &status2, &valid2);
	uint32_t speed1 = roboclaw.ReadSpeedM1(RoboClawAddress, &status3, &valid3);
	uint32_t speed2 = roboclaw.ReadSpeedM2(RoboClawAddress, &status4, &valid4);
	if(valid1){
		Serial.print("Encoder1:");
		Serial.print(enc1);
		Serial.print(" ");
		Serial.print(status1, HEX);
		Serial.print(" "); 
	}
	if(valid2){
		Serial.print("  Encoder2:");
		Serial.print(enc2);
		Serial.print(" ");
		Serial.print(status2, HEX);
		Serial.print(" "); 
	}
	if(valid3){
		Serial.print("  Speed1:");
		Serial.print(speed1, DEC);
		Serial.print(" ");
	}
	if(valid4){
		Serial.print("  Speed2:");
		Serial.print(speed2, DEC);
		Serial.print(" ");
	}
	Serial.println();
}

Can anybody help me, what should i do next ?

Thanks in advance

Hello.

“Synchronizing” two motors can mean different things (like synchronizing their speed or synchronizing their position) and the RoboClaw has some specific functions to perform different types of synchronization. We do not have much more information about the RoboClaw than the details we provide on our website. I suggest posting some more details about the two motors, the loads you have attached them to, and the type of synchronization you want to achieve to Ion Motion Control’s support forum. They should be able to offer you some more information on how the various drive modes of the RoboClaw might work in your application.

-Nathan

Thank you nathan, it was helpful to me and when I move the wheels, I can read encoders and adjust with speed.
But I have one more problem.When I rotate encoder, the motor which is connect the encoder, running immediately fast and when I stop the rotate, it’s immediately stop. After that the roboclaw is giving an error (red led is on). Is it relevant to the qpps value ? I calculated with this way : ((motor rpm on max speed(4250rpm) ) / 60 ) * (encoder p/r value (1024 ppr) * 4 )

I’m using 1024 ppr quadrature encoder which is : roboweb.net/media/catalog/pr … 102-01.jpg

And my PID values are Kp : 1.0, Ki : 0.5, Kd : 0.25 qpps : 290133

Thanks in advance
-Omer

Hello, Omer.

We are not very familiar with the way the qpps parameter functions in the RoboClaw firmware. I recommend contacting Ion Motion Control with your question.

-Nathan

Ok, I contacted with ionmotion. Thank you for your guidance.

Omer