Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

did not work with pro mini #2

Open
rizpardazan opened this issue Jan 11, 2020 · 3 comments
Open

did not work with pro mini #2

rizpardazan opened this issue Jan 11, 2020 · 3 comments

Comments

@rizpardazan
Copy link

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

@arttupii
Copy link
Owner

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);
}

@rizpardazan
Copy link
Author

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 ?

@arttupii
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants