Unexpected readings from 74LS165 register

This is a very basic circuit and a basic question, but I can't get my head around it.
I'm using an SN74LS165AN to read from a row of buttons with an Arduino Pro Micro.

This is the circuit sketched in Wokwi (Arduino 74LS165 - Wokwi ESP32, STM32, Arduino Simulator) with only two buttons connected to pins D6 and D7. Notice that here I have used an Arduino Nano, since the Pro Micro is not available.

And this is a picture of my breadboard, where the connections are:

  • D18 -> CP (clock)
  • D19 -> PL (latch)
  • D12 -> Q7 (data)

The simulation on Wokwi gives the expected results, but when run on the breadboard D6, D7 are HIGH even if they're grounded through the two pull-down resistors.

Measuring the voltage at the two pins I read 1V (1.2V if I remove the resistors), instead of the expected 0V.

What's wrong with my connections?

If that is indeed an LS165, the current requirements for a low input are 0.4mA. If you're trying to pull down the inputs with a 10K resistor, the best you're possibly going to get is 0.5mA. Dangerously close to the margins. And if you're reading 1V at the input, you're only getting 0.1mA, which is nowhere near close enough.

You'd be better off to pull the inputs up with those 10K resistors (high level input current is only 20uA, or 0.02mA) and ground them with your switches.

Edit: I originally read the 74165 part of the datasheet, not the 74LS165. Sorry about that! But my advice still stands: with TTL, passively pull up, actively ground.

2 Likes

I didn't consider the input current requirement,thanks.
Indeed HC has a higher requirement of 1.6mA, maybe that's why I see a lot of similar circuits with the 74HC165

I'm using pull-down because the buttons are a matrix with diodes on a pre-existing board. I don't think I can drive them low on the other side of the switch.

I guess I'll go buy a 74HC165 :slight_smile: .

A 1K resistor would pull it low enough

Then 74XX165 is not what you need. With a matrix, you need outputs to drive the rows and inputs to read the columns of the matrix (or vice-versa). 74XX165 has only inputs.

I would suggest PCF8574 (or PCF8575 depending on size of your matrix).

PS. whenever you use any bare chip in a circuit, you need to put a ceramic 0.1uF decoupling capacitor close to its Vcc & GND pins. Chips can misbehave if the decoupling capacitor is omitted. Simulators probably won't replicate that.

I'm driving the matrix from 2 Arduino outputs
The matrix is a 2x8, so my plan is to drive the outputs from Arduino and read through the 165 (to reduce the number of input pins required on Arduino) with a matrix scan.

Anyway, my doubt was more general. I assumed I could drive the inputs of the 74LS165 low with a 10k pull-down, like I see in many examples that emply the 74HC165.
Apparently this is not the case.

With PCF8575 you could scan the matrix with no Arduino pins (well, ok, it would use 2 pins, but those same 2 pins would still be available to use with other i2c devices like OLED displays, sensors, etc). And you would have an additional 6 digital inputs/outputs to use.

Thanks for the suggestion.
By the way my question remains: is it ok to use a pulldown with a ttl input? And if I read 1V with a 10k resistor I guess I should use a lower its value, at the expense of more power consumption.

@giohappy

guess I should use a lower its value, at the expense of more power consumption.

See post #4

TTL input only defines the input thresholds 0.8 and 2.0 not the input currents.

Oh, I missed your previous answer. Ok then. From my calculations for a 1.6mA I should use even lower values, but I will try with 1k first.

Of course this means I will have way more power consumed when the buttons are pressed...

Yes, so it's still a good idea to go with an HC or HCT device.

I confirm that with 1k pull-downs I read 0.2V, and so a LOW.

Anyway I will consider the other proposed alternatives, to reduce power dissipation.

Thanks everyone.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.