SpeedAccelDeccelPosition

Questions about using encoders with the Roboclaw product line
Post Reply
qdn
Posts: 2
Joined: Fri Sep 06, 2019 2:55 am
SpeedAccelDeccelPosition

Post by qdn »

Hi everyone,

I'm working on control in position on a motor and i had some hardwork on it.
The setup is :
24VDC motor 3000rpm -> gearmotor 1/12 -> worm screw 1tr/5mm and the encoder is fix on the worm screw.
The final max speed is 240rpm.

Control side : tennsy 3.2 -> RC 2x15A

the encoder is a quadrature type with 2000pulse/r.

The problem is, when i push a "roboclaw.SpeedAccelDeccelPositionM1" command to the RC, it's seems that the motor reach the accel/decel value for the speed and not the speed i set.

the part of the code concerned is below :

Code: Select all

#include "RoboClaw.h"
#define address 0x80
RoboClaw roboclaw = RoboClaw(&Serial3,10000);

// Data control input
int PositionMax = 50; // mm
int time_opening = 20; // s
int time_closing = 30; // s
int timeAcc_opening = 8; // s
int timeDec_opening = 16; // s
int timeAcc_closing = 8; // s
int timeDec_closing = 16; // s
int speedMax = 10; // mm/s  (max = 20)


//---------------------------------
// Convert input forroboclaw 
long EncDist_Max = PositionMax / 5 * 2000; // Distance in encoder tic
int acc_openingRC = 32768 / timeAcc_opening; // Raw value defining by the time of acceleration
int dec_openingRC = 32768 / timeDec_opening;
int acc_closingRC = 32768 / timeAcc_closing;
int dec_closingRC = 32768 / timeDec_closing;
int speedRC = speedMax / 5 * 2000; // mm/s  / 5(pas de vis) * nb tic/tr => max QPPS
void setup()
{
  Serial.println("Roboclaw setup");
  roboclaw.begin(38400);
}

void loop(){
      roboclaw.SpeedAccelDeccelPositionM1(address, speedRC, acc_openingRC, dec_openingRC, EncDist_Max,0);
}


When the command reach the RC, i see the speed on the graph reaching the accel value instead of the speed i set.

ex : If i set the speed at 4000QPPS, the accel at 8000. The motor reach 8000qpps.

Maybe i misundertood how this command work or i miss something...

I hope i'm enough clear ^^
If necessary i can link the github.

Thanks for your help!
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: SpeedAccelDeccelPosition

Post by Basicmicro Support »

You need to look at the function definition: bool SpeedAccelDeccelPositionM2(uint8_t address,uint32_t accel,uint32_t speed,uint32_t deccel,uint32_t position,uint8_t flag);

It takes accel, speed, decel and position. Not speed, accel, decel and position.
qdn
Posts: 2
Joined: Fri Sep 06, 2019 2:55 am
Re: SpeedAccelDeccelPosition

Post by qdn »

oh allright! thanks!

All is working well ^^

Thanks again :D

Post Reply