Pull-Up Resistors for Inputs from Encoder

I have a pretty simple question but can't seem to find the answer:

I've been reading about pull-up/pull-down resistors and I understand the concept reasonably well. I get that the resistor forces an input pin to have a particular state even when it is not asserted, rather than being in the ambiguous "high Z" state. I have a push button in my circuit with an external pull-down resistor (I wanted an active HIGH signal, so used pull-down rather than pull-up) with software debouncing and it is working great.

My question is, what kind of inputs need pull-up/pull-down resistors? For a button it makes sense considering when the button is not pressed you basically have an open circuit susceptible to electrical noise. However, my project involves inputting high-speed digital pulses from an encoder to the Arduino to calculate the speed of a motor via interrupts triggered by each pulse. Would it make sense to activate the internal pull-up resistors for the pins I send the encoder signals into?

From what I've read, I think I will not need the resistors because the output from the encoder will always have a definitive LOW or HIGH voltage, but I am unsure.

If I do need the pull-up resistor, how will this affect my pulses? Using a pull-up will basically make the signal active LOW (right?) so that would mean my pulses would be inverted, right? I suppose the frequency of the pulses is what really matters, so maybe inverting the signals wouldn't matter anyway.

Also, what about digital outputs? Is there any reason to activate the internal pull-up resistor for a pin set as an output?

Thanks for any info you can give me. I am just looking for some general info but if it would help to see some code I can post what I am working on.

P.S. The encoder model is 15T--2048C5RHV-F-T2, it has the output type "line driver". Here is the datasheet:

http://encoder.com/literature/datasheet-15th.pdf

You always need either a voltage source, or a pullup or pulldown resistor of some sort with an Arduino input. A resistor can be internal to the Arduino, external, or part of the sensor you are connecting it to.

The pullup/pulldown merely defines the input state when no other voltage source is present. The resistor does not make a particular state "active" -- your code defines that.

The encoder link does not work for me.

Open Collector and Open Drain outputs need a pull-up resistor. These act like an NPN transistor or N-Channel MOSFET between the pin and Ground. When the transistor/MOSFET is conducting it drags the pin to Ground. When the transistor/MOSFET is NOT conducting the pin is left floating and a pull-up resistor is needed to give the pin a defined state.

The device datasheet will say if an output is Open Collector/Drain or not.

One advantage of Open Collector/Drain outputs is that you can connect more than one of them to a single input pin. If any of them are active the pin goes LOW. This can allow several devices to use the same bus as long as only one is active at a time.

As you have seen from your experience, switches also need a pull-up or pull-down. Since it is not unusual for the processor to have to deal with Open Collector/Drain outputs, the processor has built-in pull-up resistors that can be activated on input pins. You can save on your component count by using them and having your switches/button connect between the pin and Ground. Yes, this means that LOW is for PUSHED and HIGH is for NOT-PUSHED but you can get used to that fairly easily.

@johnwasser:

Thanks for the info!

The datasheet indicates that this encoder has output of the type "Line Driver." I just did some research and found this tidbit:

"A line driver is a sourcing output. When in the on state, a line driver will supply Vcc. In the off state, a line driver will float. Because of this, a sinking input is required for proper operation." I also attached a diagram of this setup.

This indicates to me that there will be a need for a resistor because the "LOW" state of the line driver output will not be Grounded but will instead be ambiguously floating. But that would mean I need a pull-down resistor, right? Also, it's my understanding the Arduino's digital pins can sink current when set as in input, is that right?

LineDriver.gif

Yes, you need a pulldown.

No, Arduino input pins do not sink current.

@jremington:

Thanks for the reply.

If the Arduino cannot sink as an input, how would I read the output from a Line Driver encoder? would something like the schematic I have attached work and be safe for the board?

Edit: I just checked the datasheet and it says the line driver output has a maximum of 20mA per channel, and the voltage Vcc is 5V.

r.mcgrady:
The datasheet indicates that this encoder has output of the type "Line Driver." I just did some research and found this tidbit:

"A line driver is a sourcing output. When in the on state, a line driver will supply Vcc. In the off state, a line driver will float. Because of this, a sinking input is required for proper operation." I also attached a diagram of this setup.

Looks like the opposite of an Open Collector output (Open Emitter?). You will need a pull-down resistor. I'd try a 1k or 10k resistor but anything between 250 Ohms (20 mA @ 5V) and about 10,000 Ohms should work.

Looks like the opposite of an Open Collector output (Open Emitter?)

Most likely, it is a PNP open collector output, as shown below. Very common.PNP.gif

PNP.gif

Hi,

I found this discussion when searching for the exact same question.
My application is the same too.I am using Arduino to read encoder inputs and my encoder datasheet mentions it to be line-driver type.

As far as the line drivers are concerned after some research and a silly experiement(below) I was convinced too that pull-downs would be needed.

To confirm this , I compared the current drawn using pull-ups and pull-downs, and found that pull ups were drawing approx 0.18A compared to 0.1A for ones with pull-outs. Without giving any external pull up/pull down I see that my encoder is drawing 0.77A. Which brought me to the idea that maybe not connecting any external resistors might be a good idea.

Here is the datasheet.

So my questions are -

  1. How do set my Arduino pins in the code? Or no setting required at all?
  2. Going by the current drawn am I drawing too much current ? However that seems to be at no load. I just have a motor shaft connected , the movement I am doing using my hand.

E5_datasheet.pdf (900 KB)

The data sheet covers many different versions of that basic encoder. You need to state the complete part designation for us to help.

If the encoder is really drawing 0.77 Amperes, something is very wrong with your connections. I would not expect it to survive that.

"A line driver is a sourcing output. When in the on state, a line driver will supply Vcc. In the off state, a line driver will float. Because of this, a sinking input is required for proper operation."

I don't understand what more you need to know. Use pinMode INPUT. Attach a pulldown resistor - 1k to10k has been suggested.

If the encoder is really drawing 0.77 Amperes, something is very wrong with your connections.

No sh*t. Are you sure you don't mean milliamps?

Thanks for the replies.

My mistake, I meant 0.077A, so that would mean 77mA.

So my exact encoder type would be E5-4096-315-IE-D-D-D-B, which means a CPR of 4096.
For this CPR, the expected current in the datasheet is typically " 88 mA ( for CPR>2000) on no load "

So rephrase my question again, with pull down resistor I am getting a current draw of 0.1 A compared to 0.077A for one with no connections made.
Wanted to know if going above the 88mA mark is acceptable in this case(I'm turning the shaft of the motor manually).Would this qualify has no load or load?

I understand external pull-down resistor and INPUT mode, I was wondering if I had to use internal Arduino pull up or pull down in the code.

You have the differential output version, which is intended to be used with twisted pair wiring and a differential line receiver chip (typically used in a noisy industrial environment), and not with a single ended input like an Arduino. You might be able to get it to work, though.

Yes, you are right.
Length to my Arduino is less than 1m from my encoder for my robotic application.
So I am just trying to make the system work for now and will integrate with an RS422 shield later.