Roboclaw Solo 30A, Motor Controller

General discussion of using Roboclaw motor controllers
Post Reply
ilijavk
Posts: 5
Joined: Sat Apr 18, 2020 10:53 am
Roboclaw Solo 30A, Motor Controller

Post by ilijavk »

Hi,
I read manual but I need help with settings:-(
General settings:
Max current 2.7A (is this In2.7A, Istart 18A, or Idemag24A)
Default speed: 45 (is this 90rpm or 45 QPPS encoder speed)
Default Accel: have no idea where to look for this data (manual says full forward to rewerse speed 6555.360=100ms but where to find this data)
Default Ecel: no idea where to look this data
Velocity settings:
QPPS: 45? (can it be calculated by input data (90rpm/60s)*15=45 is this correct)

Motor data:
24 VDC; 3300 rpm; In 2.7A; Ifm 24 A
starting current 18A, demagnetisation current 24A, max torque 1.08Nm, stall torque 1.08Nm,
otput RPM after gearbox output speed is 90 RPM

Ecoder, 16 impuls/revolution

Sorry for long post.
Thank You.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw Solo 30A, Motor Controller

Post by Basicmicro Support »

With that motor set your maximum current between 18a and 24a. It appears to be pretty touchy(eg very little range between starting amps and demag amps so I set it between 18 and 20 amps.

Default speed is what we call a binary percentage. +-32767 = +-100%. Range of speed is set by QPPS(eg motor actual maximum speed).
Default accel is also a binary percentage, +-655360 = +-2000%. Range is accel is also set by QPPS(eg up to 20 times QPPS for encoder counts per second per second).
Default decel is same as Default accel range.
QPPS is maximum encoder counts per second(eg when the motor is at 100% power). You can estimate this at lower speeds(eg 10 times 10% power encoder counts per second).
ilijavk
Posts: 5
Joined: Sat Apr 18, 2020 10:53 am
Re: Roboclaw Solo 30A, Motor Controller

Post by ilijavk »

Thank You for help.
It was very useful for my project.

Still have problems with command:
roboclaw.SpeedDistanceM1(address,distance,Vin,1);
Motor always run with max speed, PID values does not affect speed, QPPS does not affect speed and distance.
I think that my encoder does not work as intended.

Followed instructions for determining QPPS and PID values, no luck.
I'm waiting for new motor and encoder.


Commands ForwardM1 and BackwardM1 works.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw Solo 30A, Motor Controller

Post by Basicmicro Support »

You need to check speed control is working properly using Motion Studio before you can debug the problem. If the motor runs properly using motion studio at different speeds and holds a set speed under changing load then your PID is set correctly. Remember you write the settings to the contoller after setup and testing in Motion Studio.

Then double check your SpeedDistanceM1 command arguments. What is Vin? I assume it is a variable with the speed set in it. Make sure it is providing a valid range of speed values from -QPPS to +QPPS).
ilijavk
Posts: 5
Joined: Sat Apr 18, 2020 10:53 am
Re: Roboclaw Solo 30A, Motor Controller

Post by ilijavk »

Speed control is working properly using Motion Studio, motor runs properly using motion studio at different speeds and holds a set speed under changing load.

Just arrived AndMark PG188 Gearmotor with encoder with 7 pulses per revolution.
MotionStudio auto tune options gives PID values as follows:
P: 6.38650
I: 1.28910
D: 0.000
QPPS: 1125

Motor change direction, but speed is always the same.
Can You please share some example code that is working, thank You.

Example 1, speed set in range of +-QPPS (+-1500) where 10% speed is set as 150

Code: Select all

//See BareMinimum example for a list of library functions

//Includes required to use Roboclaw library
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <RoboClaw.h>

/*--------------------------------( Declare objects )------------------------------*/
// open hardware serial port on arduino //Setup communications with roboclaw with 1ms timeout
RoboClaw roboclaw(&Serial,10000);


#define address 0x80

//Velocity PID coefficients
#define Kp 6.38
#define Ki 1.28
#define Kd 0.00
#define qpps 1500

void setup() {
  //Open Serial and roboclaw serial ports
  Serial.begin(57600);
  roboclaw.begin(38400);
  
  //Set PID Coefficients
  roboclaw.SetM1VelocityPID(address,Kd,Kp,Ki,qpps);
  roboclaw.SetM2VelocityPID(address,Kd,Kp,Ki,qpps);  
}

void displayspeed(void)
{
  uint8_t status1,status2,status3,status4;
  bool valid1,valid2,valid3,valid4;
  
  int32_t enc1 = roboclaw.ReadEncM1(address, &status1, &valid1);
  int32_t speed1 = roboclaw.ReadSpeedM1(address, &status3, &valid3);

  Serial.print("Encoder1:");
  if(valid1){
    Serial.print(enc1,DEC);
    Serial.print(" ");
    Serial.print(status1,HEX);
    Serial.print(" ");
  }
  else{
	Serial.print("failed ");
  }
 
  Serial.print("Speed1:");
  if(valid3){
    Serial.print(speed1,DEC);
    Serial.print(" ");
  }
  else{
	Serial.print("failed ");
  }

  Serial.println();
}

void loop() {
  uint8_t depth1,depth2;
  
  roboclaw.SpeedDistanceM1(address,500,1500,1);  // ------  (adress // + - speed in QPPS // dist in quadrature counts // flag )

  do{
    displayspeed();
    roboclaw.ReadBuffers(address,depth1,depth2);
  }while(depth1!=0x80);	//Loop until distance command has completed
  
  delay(1000);

  roboclaw.SpeedDistanceM1(address,-1000,1500,1);
  do{
    displayspeed();
    roboclaw.ReadBuffers(address,depth1,depth2);
  }while(depth1!=0x80);	//Loop until distance command has completed
  
  delay(1000);  //When no second command is given the motors will automatically slow down to 0 which takes 1 second

  roboclaw.SpeedDistanceM1(address,1500,1500,1);  
  roboclaw.SpeedDistanceM1(address,-200,1500,0);
  roboclaw.SpeedDistanceM1(address,0,1500,0);
  do{
    displayspeed();
    roboclaw.ReadBuffers(address,depth1,depth2);
  }while(depth1!=0x80);	//Loop until distance command has completed
  
  delay(1000);
}
Example 2, with same result:
Speed is in binary range +-32767, where 10% speed is given as 3276

Code: Select all

//See BareMinimum example for a list of library functions

//Includes required to use Roboclaw library
#include <LiquidCrystal.h>
#include <EEPROM.h>
#include <RoboClaw.h>

/*--------------------------------( Declare objects )------------------------------*/
// open hardware serial port on arduino //Setup communcaitions with roboclaw with0 m1s timeout
RoboClaw roboclaw(&Serial,10000);


#define address 0x80

//Velocity PID coefficients
#define Kp 6.38
#define Ki 1.28
#define Kd 0.00
#define qpps 1500

void setup() {
  //Open Serial and roboclaw serial ports
  Serial.begin(57600);
  roboclaw.begin(38400);
  
  //Set PID Coefficients
  roboclaw.SetM1VelocityPID(address,Kd,Kp,Ki,qpps);
  roboclaw.SetM2VelocityPID(address,Kd,Kp,Ki,qpps);  
}

void displayspeed(void)
{
  uint8_t status1,status2,status3,status4;
  bool valid1,valid2,valid3,valid4;
  
  int32_t enc1 = roboclaw.ReadEncM1(address, &status1, &valid1);
  int32_t speed1 = roboclaw.ReadSpeedM1(address, &status3, &valid3);

  Serial.print("Encoder1:");
  if(valid1){
    Serial.print(enc1,DEC);
    Serial.print(" ");
    Serial.print(status1,HEX);
    Serial.print(" ");
  }
  else{
	Serial.print("failed ");
  }
 
  Serial.print("Speed1:");
  if(valid3){
    Serial.print(speed1,DEC);
    Serial.print(" ");
  }
  else{
	Serial.print("failed ");
  }

  Serial.println();
}

void loop() {
  uint8_t depth1,depth2;
  
  roboclaw.SpeedDistanceM1(address,32767,3000,1);  // ------  (adress // + - speed in percent of QPPS +-32767 // dist in quadrature counts // flag )
  delay(5000);

  roboclaw.SpeedDistanceM1(address,-3276,3000,1);
  delay(5000);  //When no second command is given the motors will automatically slow down to 0 which takes 1 second

  roboclaw.SpeedDistanceM1(address,0,1500,0);  
  delay(6000);
}
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw Solo 30A, Motor Controller

Post by Basicmicro Support »

If you tuned the motors using Motion Studio and wrote the settings to the Roboclaw, remove the SetVelocityPID commands from your examples. Those are overriding the settings in the controller which is probably most of your problem.
ilijavk
Posts: 5
Joined: Sat Apr 18, 2020 10:53 am
Re: Roboclaw Solo 30A, Motor Controller

Post by ilijavk »

Yes, that worked :-)
Thank you!
Hours and days of agony :-D

Just commented out set PID commands

Code: Select all

 
// Set PID Coefficients
// roboclaw.SetM1VelocityPID(address,Kd,Kp,Ki,qpps);
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw Solo 30A, Motor Controller

Post by Basicmicro Support »

I recommend always checking with us if you get stock on something for more than a couple hours. Phone for fastest response of course but don't bang you head against a wall for days. 99 times out of 100 we have already seen the problem you are having and can give you a quick fix.
ilijavk
Posts: 5
Joined: Sat Apr 18, 2020 10:53 am
Re: Roboclaw Solo 30A, Motor Controller

Post by ilijavk »

Thank You!
Great support!

Post Reply