Balanduino Forum

Off Topic => Electronics development => Topic started by: reinier on September 23, 2014, 11:45:55 PM

Title: different encoders and motors
Post by: reinier on September 23, 2014, 11:45:55 PM
Hi,

I don't understand the code with defined the encoder resolutions

// Encoder values
#if defined(PIN_CHANGE_INTERRUPT_VECTOR_LEFT) && defined(PIN_CHANGE_INTERRUPT_VECTOR_RIGHT)
const uint16_t zoneA = 8000 * 2;
const uint16_t zoneB = 4000 * 2;
const uint16_t zoneC = 1000 * 2;
const double positionScaleA = 600 * 2; // One resolution is 1856 pulses per encoder
const double positionScaleB = 800 * 2;
const double positionScaleC = 1000 * 2;
const double positionScaleD = 500 * 2;
const double velocityScaleMove = 70 * 2;
const double velocityScaleStop = 60 * 2;
const double velocityScaleTurning = 70 * 2;
#else
const uint16_t zoneA = 8000;
const uint16_t zoneB = 4000;
const uint16_t zoneC = 1000;
const double positionScaleA = 600; // One resolution is 928 pulses per encoder
const double positionScaleB = 800;
const double positionScaleC = 1000;
const double positionScaleD = 500;
const double velocityScaleMove = 70;
const double velocityScaleStop = 60;
const double velocityScaleTurning = 70;
#endif


I use encoder HKT22 Optical Encoder (quadrature).
It has 300 resolutions (counts) per rotation.
The motor is ZY1020 500W max 2500 rpm gearmotor with ratio of 6.7 : 1.

When I do the calibrateMotor()  the testMotorSpeed() is executed.

Within this program this code will control the velocity and speed.

    if (abs(leftVelocity) < 200)
      (*leftSpeed) += 0.1;
    else if (abs(leftVelocity) > 203)
      (*leftSpeed) -= 0.1;

    if (abs(rightVelocity) < 200)
      (*rightSpeed) += 0.1;
    else if (abs(rightVelocity) > 203)
      (*rightSpeed) -= 0.1;

I don;t know how to change the 200 and 203 and encoder values above with my new encoders.
Please can someone advice my.

Regards, Reinier
Title: Re: different encoders and motors
Post by: Lauszus on September 23, 2014, 11:56:39 PM
Hi Reinier,

Those lines are needed because I effectively doubles the encoder resolution at some point by using pin change interrupt as well.

Those numbers are simply needed, as these are about the maximum speed the motors can travel, but to be honest the motor calibration routine is really not that important, as there has only been case in internal testing where it was needed, so I would recommend focusing on getting the rest of the stuff to work first.

Regards
Lauszus