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

Help with open collector encoder. #78

Open
kotopuz opened this issue Nov 29, 2020 · 3 comments
Open

Help with open collector encoder. #78

kotopuz opened this issue Nov 29, 2020 · 3 comments

Comments

@kotopuz
Copy link

kotopuz commented Nov 29, 2020

Dear all.
I got things with small motor. Now i moved to 500w. Accidently I've dropped encoder. After that I position readings are unpredictable. Looks like encoders are very gentle devices. Now I found another with open collector. I cant make it work. Please advise. Tried to connect it to 5 volts. Looks like I can measure voltage across power plus and output. Nothing from gnd to A or B. Should I add some resistor? Type is omron e6b2-Cwz6C

@misan
Copy link
Owner

misan commented Nov 29, 2020

The more info you provide, the higher the chances you can get help.

We do not know:

  • what processor are you using?
  • what is the code you are running? (are pull-ups enabled in encoder inputs?)
  • how are you connecting the encoder to the circuit?
  • when describing your problem, more info is better ("I can't make it work" is not very specific).

That said, a couple of 4K7 resistors from A and B to +5 (assuming that is the voltage of your microcontroller) won't hurt.

@kotopuz
Copy link
Author

kotopuz commented Dec 2, 2020

Finally I found how to fix it. I was very very lucky that encoder can run at 5 volts which simplifies a lot solution. I've connected 0 and 5 volts to ESP32 Vin and GND. A and B as per sketch. Trick was to use build in pullup resistors. It means pinMode(encoder0PinA, INPUT_PULLUP );
pinMode(encoder0PinB, INPUT_PULLUP );

Reason is because open collector only connect output to ground, when it's not connected it's floating and pull up to 5V changes floating to TTL level of 5 volts.
If I use 24 VDC as power I need to make voltage divider.
Now everything works and I have working ESP32 with Blynk interface to jog from mobile phone!
Thanks!

@misan
Copy link
Owner

misan commented Dec 2, 2020

You're welcome. If using external pull-ups with ESP, please remember to connect them to 3V3, not to 5V.

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