MeEncoderOnBoard help, what are the setPulse and setRatio methods?


#1

Hey guys,

I’m trying to figure out what is the purpose of the method setPulse in the MeEncoderOnBoard class.

My first thought was it was for the number of pulse per rotation, but it is clearly not the intent.

The same question goes to the setRatio. It thought it was about the wheel radius.

Whe the default values are 9 for the pulse and 39.267 for the ratio?

I looked at the following code :

void MeEncoderOnBoard::updateSpeed(void)
{
  if((millis() - _Measurement_speed_time) > 20)
  {
    uint16_t dt = millis() - _Measurement_speed_time;
    long cur_pos = getPulsePos();
    setCurrentSpeed(((cur_pos - encode_structure.previousPos) *(1000.0/dt)*60.0) /(encode_structure.pulseEncoder * encode_structure.ratio));
    encode_structure.previousPos = cur_pos;
    _Measurement_speed_time = millis();
  }
}

But I still having trouble to wrap my head around the logic.

Let say the documentation is quite inexistant.

Thank you


#2

I had a brain freeze. I forgot that there is a gearbox attached to the motor.

So if this can help other people, the answer is :

  • setPulse is the number of pulses on the encoder attached to the motor shaft.
  • setRatio is the gearbox ratio. Basically, it takes 39.267 motor rotation for a single gearbox shaft revolution.

[https://www.youtube.com/watch?v=oy374XhbXVg](http://Disassembly video)


#3

Hmm… I’ll think about it. Mention @Crackel and @CommandeR.


#4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.