Keypad project voltage drop issues

Hey everyone!

I have a keypad project that I'm working on which is currently having some voltage drop issues I need to resolve. The Tinkercad project that mirrors the actual project can be found here.

Fair warning, electrical engineering is not my strong suit. Feel free to point out any glaring mistakes in this project :sweat_smile:

It uses a couple of decade counters to reduce the number Arduino pins needed to scan the keypad. The tinkerpad project works fine, however in the actual project I'm seeing a voltage drop on the output of the AND logic gate that checks for when the counters are at the start of a scan cycle. This voltage drop only occurs when pressing '2' or '3' on the keypad. When pressing '1' on the keypad I see some noise, but no voltage drop. See the scope images below to see what I mean...

No buttons pressed

'2' or '3' key pressed

'1' key pressed

For the '2' and '3' keys it drops below the voltage where I can reliably check that the counters are in the starting position, which in turn prevents these keys from being detected a lot of the time. I'm sure I'm just missing something obvious, but it's alluding me at the moment.

Thanks in advance for any guidance on this!

-Rich

Here's the schematic from tinkercad. It wouldn't let me attach more than three images in the original post.



I recommend using an I2C-chip to get the keyboard connected
The SX1509

It has even a keypad-matrix scanning engine implemented

best regards Stefan

Are you really expecting somebody will take the effort of analysing such a clumsy schematic?
Sure all lines are vertical / horizontal but that's it.

I tried to analyse it. At this stage I stopped it:

This might be an intriguing escape-room-riddle for electronic geeks
but it is very unconvenient to analyse.

Can you tell me which pin of the transistor is what? I can't read it.


Though in general connecting two transistors in this way seems very odd

If you want to go on with the DIY-circuit post an easy to analyse schematic.

best regards Stefan

why second counter is clocked by first one?

Connecting two transistors like that is a basic AND gate.

The first counter is incrementing the rows. When it gets to output 5 it triggers it's own reset and increments the second counter to move to the next column.

only if the emitter resistor is small compared to R.

yes, R on T2 base must be big enough to prevent unwanted HIGH on Q

ok, i see, first counter set one pin to HIGH and three other to LOW and if you press two buttons on same line, level will be not identical - you cause a short circuit, right ?




for this inverted signal the code is:

#include <LiquidCrystal_I2C.h>

class LCDScroller {
  private:
    short m_cols = 0;
    short m_rows = 0;
    short m_printRate = 20;
    LiquidCrystal_I2C* m_lcd;
       
  public:
    LCDScroller(LiquidCrystal_I2C* lcd, short cols, short rows) {
    m_lcd = lcd;
      m_cols = cols;
      m_rows = rows;
    }

    void update() {
    }
};
// Set LCD address to 32 for a 16 chars 2 line display
LiquidCrystal_I2C lcd_1(0x20, 16, 2);



// C++ code
//
short clockOut = 7;
short stateIn = 13;
short cycleStartIn = 12;
short pinState = 0;
char keys[4][4] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
char lastKey = 0x00;


void setup()
{
  pinMode(clockOut, OUTPUT);
  pinMode(stateIn, INPUT);
  pinMode(cycleStartIn, INPUT);
  Serial.begin(9600);
  lcd_1.init();
  lcd_1.clear();         
  lcd_1.backlight();
  LCDScroller scroller(&lcd_1, 16, 2);
}

void loop(){
    while(digitalRead(cycleStartIn)) {
      digitalWrite(clockOut, HIGH);
      delay(1);
      digitalWrite(clockOut, LOW);
      delay(1);
    }  
  
  for(short col = 0; col < 4; col++) {
    for(short row = 0; row < 4; row++) {
      
      pinState = digitalRead(stateIn);
      
      if (pinState == 1) {
        // Debounce button press
        if (lastKey != keys[row][col]) {
          Serial.println(keys[row][col]);
          lcd_1.print(keys[row][col]);
        lastKey = keys[row][col];
        }
      }
      else if (lastKey == keys[row][col])
        lastKey = 0x00;
      
      digitalWrite(clockOut, HIGH);
      delay(5);
      digitalWrite(clockOut, LOW);
      //delay(1000);
    }
  }
  
  delay(2);
}

There's a much easier way to do it with zero pins!

PCF8574.

requires two pins
even easier because the keyboard scanning logic is intergrated into the chip
SX1509

he means "zero additional pins", I2C is already in use by display.

1 Like

It requires zero more pins than @sickgrin is currently using :wink:

I agree sx1509 is also a good option. I don't know if it is easier for a beginner to use pcf8574 or sx1509, that may depend on availability of a keypad library which uses either chip.

Solved it by going a slightly different route.

Dug through the parts bin and found some quad AND gate ICs. Switched to a 3 x 4 keypad configuration instead of 4 x 4 (since that's the actual application) Used the 74LS08 in place of the transistors and everything is working as expected now.

If anyone is interested here's the tinkercad project with the changes:

now that's ironically. Using completely different components described as "slightly" changed.

@StefanL38 How do you figure? It's using the exact same logic in exactly the same way. Instead of individual transistors it's using logic gates.

@PaulRB Nice! I like that PCF8574. I'll have to pick some of those up to have on hand.

For the moment I was just trying to get this up and running with stuff I had lying around.

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