Author Topic: Help needed for optical encoder connection  (Read 2763 times)

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Help needed for optical encoder connection
« on: December 15, 2020, 12:55:31 PM »
Hello all some simple help would be appreciated!

I have a 600 line optical encoder that I want to connect to an Arduino R3 Uno. The description of the encoder that I stumble over is:

Quote
Operating voltage: DC5-24V

Output: AB two-phase quadrature output rectangular pulse, the circuit output is NPN open collector output type, the output of this type can with internal pull-up resistor is directly connected to the microcontroller or PLC, such as 51 single or Mitsubishi PLC (the PLC input should switch to the 0V work), Note: If the encoder is not connected to the device can not be directly oscilloscope oscilloscope (open collector output when there is no pull-up resistor, there is no voltage output) for oscilloscope please plus two pull-up resistor AB two-phase output;

Note: A phase and B-phase output line must not be directly connected to VCC, otherwise, they will burn the output triode.

Wiring: Green = A phase, phase = B white, red = Vcc Positive power to black = V0, please wiring as described above. Another metal shielding layer interference. 

My needs:

Let's say I'm running the Arduino and encoder at 12v vcc.

Let's say I want to connect encoder's green and white to Arduino pins 2 & 3 (configured as inputs).

I'm not understanding the "internal pull-up resistor" mentioned.  Does the above actually all just mean to add external pull-up resistors to vcc at Arduino pins 2 & 3?  If so any suggestion for what size?



I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline awemawson

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8966
  • Country: gb
  • East Sussex, UK
Re: Help needed for optical encoder connection
« Reply #1 on: December 15, 2020, 01:33:32 PM »
"the output of this type can with internal pull-up resistor is directly connected to the microcontroller or PLC"

If the output IS 'open collector' then the encoder doesn't have an internal pull up resistor (unless there is an option link that can be made to connect it on the encoder ?).


Chinglish translation perhaps?
Andrew Mawson
East Sussex

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Help needed for optical encoder connection
« Reply #2 on: December 15, 2020, 01:42:20 PM »
Okay, I didn't think so, and there's nothing to change on the encoder. I did find a reference to the Arduino Uno registers that explains that I can configure internal pull up resistors located on the Arduino board itself by using the "PORT" register instruction. That must be what the Ebay encoder description means.

However further reading says that the PORT register instruction only puts a pin high if it is configured as an output pin. (Arduino pins can be configured as either input or output with the DDR instruction). The encoder connected pins on the Arduino would be configured as input pins. So I guess you couldn't pull them high internally.

So this is pretty much looking like I should add external pull-up resistors..........?
I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg

Offline vtsteam

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6466
  • Country: us
  • Republic of Vermont
Re: Help needed for optical encoder connection
« Reply #3 on: December 15, 2020, 02:26:21 PM »
Wrong! Further reading......... You can only put pins configured as output to HIGH, true.

BUT, you can configure those same pins with pull-up resistors if they are configured as inputs. To add to the confusion, the same "PORT" command is used to do either. And if you change a HIGH cofigured outport port into an input port, the PORT register flag will be retained and it will end up with a pull-up resistor.

My confusion was the term "HIGH". They (Arduino documentation folks) mean that strictly as an output term. An input with a pull-up resistor is still technically high, but not the "HIGH" that they mean. Seems Chinese translation is not the only source of ambiguities!  :doh:

Anyway, it looks like no, I don't need external pull-up resistors if I program the Arduino to have the two input ports (2 & 3) with internal pull-up resistors, using the PORT register command.

simple.   :bang:
I love it when a Plan B comes together!
Steve
https://www.youtube.com/watch?v=4sDubB0-REg