CLSMB icon indicating copy to clipboard operation
CLSMB copied to clipboard

did not work with pro mini

Open rizpardazan opened this issue 5 years ago • 3 comments

hello dear with wireing like in readme file , with arduino pro mini , did not work it seems can not count quadruples encoder.

rizpardazan avatar Jan 11 '20 20:01 rizpardazan

Hi, Could you test your quadrature encoder with this simple test code?

  1. Flash Pro mini with test code
  2. Open tools->Serial Plotter
  3. Set baud rate to 115200
  4. Try to rotate quadrature encoder. You should now see A and B signals on plotter.
#define PIN_IN_A     5
#define PIN_IN_B     4

void setup() {
  Serial.begin(115200);
  pinMode(PIN_IN_A, INPUT_PULLUP);
  pinMode(PIN_IN_B, INPUT_PULLUP);
}

void loop() {
  Serial.print(digitalRead(PIN_IN_A)*3+5);
  Serial.print(" ");
  Serial.println(digitalRead(PIN_IN_B)*3);
}

arttupii avatar Jan 11 '20 22:01 arttupii

Hi, Could you test your quadrature encoder with this simple test code?

  1. Flash Pro mini with test code
  2. Open tools->Serial Plotter
  3. Set baud rate to 115200
  4. Try to rotate quadrature encoder. You should now see A and B signals on plotter.
#define PIN_IN_A     5
#define PIN_IN_B     4

void setup() {
  Serial.begin(115200);
  pinMode(PIN_IN_A, INPUT_PULLUP);
  pinMode(PIN_IN_B, INPUT_PULLUP);
}

void loop() {
  Serial.print(digitalRead(PIN_IN_A)*3+5);
  Serial.print(" ");
  Serial.println(digitalRead(PIN_IN_B)*3);
}

yes , this code work, in main code , encoder A and B will be connected to pin 4 and 5 or 2 and 3 in pro mini ?

rizpardazan avatar Jan 12 '20 06:01 rizpardazan

Sorry, I thought (read) you are using esp2866 chip and ESP2866 branch (I know you wrote arduino pro mini, but but I read it somehow wrongly).

You can try to remove line #define FLIP_ENCODER from config.h file. If it doesn't work you can try to enable debug prints. Set ENABLE_PRINTS to 60 from config.h (it prints values of internal_encoder_position and motor_position). If everything works ok, internal_encoder_position value should increase when motor_position value increases and internal_encoder_position value should decrease when motor_position decreases.

Please be aware about that there are known bug in master branch and you should swap D3 and D8 pins on 8-bit Arduino (this needs also some code changes. I have no time do this :(). StepIn needs RISING interrupt. CHANGE interrupt causes too many interrupts for 8-bit arduino and it starts losing pulses at high speed. This issue has been fixed in ESP2866 branch.

arttupii avatar Jan 12 '20 17:01 arttupii