2

I'm programming the in- and outputs of a 4x4 matrix keypad for the RPi in order to print the pushed key's value (a letter).

In order to (first) read which row was pushed, the tutorial tells me to convert the row pins to input with a pull up resistance and the column pins to output low. When a key/button is pressed on the pad, a row pin will read a low value.

In order to then read the columns, the "found" row is converted to output high, and the column pins to input with a pull down resistance. When a key/button is pressed on the pad, a column pin will read a high value.

I then asked myself why a pull up was preferred for reading the pushed row, but couldn't make sense out of it. I re-programmed the rows to read for a high value (column pins set to output high) and it worked just as well and made more sense to me (in both reading of row and column: read for a high value).

Why not convert rows to input pull down (instead of pull up) and columns to output high (instead of low)? Wouldn't that make more sense?

tlfong01
  • 4,847
  • 3
  • 12
  • 24

1 Answers1

4

In general the reason electronic engineers prefer pull-ups to pull-downs is that in silicon N type (NPN bipolar or N-channel FET) transistors are better than P type transistors (PNP bipolar or P channel FET).

This meant that when ICs were built out of 1 type of transistor they were built out of N transistors and as a result they were much better at pulling lines low than they were at pulling them high.

With modern CMOS it doesn't matter much, P devices are still intrinsically worse than N ones, but IC manufacturers now use both types of device and compensate by using different geometries for the P devices than the N ones but the habit of using pull-ups rather than pull-downs remains and "open drain" outpus still nearly always drive low.

P.S. your post describes a rather unusual method of reading a matrix.

Peter Green
  • 6,595
  • 1
  • 21
  • 26