Pages: [1]   Go Down
Author Topic: pcb that connects cherrymx switches and shift registers to make a keyboard  (Read 2114 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello and thank you for any help you may provide! I am making a custom keyboard using cherry mx switches(specifically brown, www.cherrycorp.com/english/switches/key/mx.htm). I am currently in the PCB design stage. The board should connect multiple (23ish) cherry mx brown switches to 3ish daisy-chained piso shift registers. The daisy chained shift registers will connect via jumper wire to an Arduino uno that is off the pcb. Now back to the meat of the problem. What traces should I make from each switch to the sift registers? I emailed the cherry people and they said that the mx line is a standard open switch with 2 leads. When the switch is depressed, a connection is made. Since the problem isn't directly due to their product, they didn't help much.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27425
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

NO switches? One side back to Arduino Gnd, one side to shift register input with pullup resistor to 5V. Shift register reads in a High until switch is pressed, then it reads in a Low.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes I'm pretty sure normal open is what they meant, though I don't know for sure. 2 questions and sorry because I'm new and feel like at least 1 of them may be dumb.
  • Does it matter which lead is connected to the Arduino and shift register?
  • Does this approach negate the advantages of a shift register? Before I was only using 3 pins, now if I understand right I will use 1 additional pin per key. Am I supposed to somehow daisy-chain all traces going to ground together? Just to be clear, I am not using a keyboard matrix approach.
Thanks so much for at least pointing me in the right direction. The amount of rabbit holes to go down in hardware makes me think I should change my name to Alice.
« Last Edit: November 22, 2013, 11:33:06 pm by fozbstudios » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27425
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does it matter which lead is connected to the Arduino and shift register?
Select one that is not connected to Gnd.
Quote
Does this approach negate the advantages of a shift register?
You will use 3 pins - latch to capture the state of the input signals, MISO for data out of the shift registers, and SCK to clock them in:
Code:
digitalWrite(latch, LOW);
digitalWrite (latch, HIGH); // assumes data is stored on this rising edge
byte0 = SPI.transfer(0);
byte1 = SPI.transfer(0);
byte2 = SPI.transfer(0)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

NSW Australia
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3716
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You will use one pin of the shift register per key, but only three pins on the Arduino - and with suitable programming, two of those can be shared with another function.

As CrossRoads points out, each switch connects between ground and an input of the shift register with a pull-up resistor (4.7k or so) from that input to Vcc.  Three connections, two outputs from the Arduino and one input go from the shift register(s) to the Arduino, "latch" (latch enable) which copies the key data into the register, "clock" which steps data along the register and "serial out" which conveys the shifted data from the last bit of the register to the Arduino to be read.  The last register takes its "serial in" from the "serial out" of the previous and so on.

The precise layout of the ground connections is not very important; whatever achieves the shortest paths in total.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How I am supposed to connect all switches to ground when there is only one ground "pin" on the Arduino  I would imagine I make them all run together like the tributaries of a river. (If there is a term for that please tell me).

Sorry for asking so many questions. Thanks for your patience!
Logged

NSW Australia
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3716
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah!  There's the question.

And - it's worse than that ... Jim!

You quite likely have to connect other "peripherals" to the Arduino as well, each (every) one of which requires a ground connection.  (Common trouble brought to these discussions is where external devices such as power supplies have been connected to peripherals but not to the common ground.)

Clearly, you will have to have some arrangement for connecting so many things, which is why there are I/O "shields" offered for the Arduino with banks of pins, or for a temporary experimental arrangement, there are "breadboards" with ground (and Vcc) rails in order to make multiple connections.  In a fully permanent design, you would generally solder connections together and/ or lay tracks on a PCB.

In general, you wish to approximate as much to a "tree" (that's the term for which you were looking  smiley-wink) or "star" structure rather than a "daisy chain" in order to minimise the length (and thus resistance and inductance) of each path to the main board itself; in practice it usually involves a composite pattern where the connections "daisy chain" along rows of buttons, but the row connections come together at the end of each row.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

NO switches? One side back to Arduino Gnd, one side to shift register input with pullup resistor to 5V. Shift register reads in a High until switch is pressed, then it reads in a Low.
Ok everything is coming together! Though I probably will never know WHAT that video was. Once final question. It seems as though I have to "tree" all shift register all inputs from each shift register which doesn't seem possible. Don't most shift registers have one spot for connection to vcc that suffices for all? If this the case do I need to make that connect with all 3 shift registers or only the one with all other connections? (Shift registers can be daisy chained to minimize pin use.)
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27425
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Will leave it to you to work out getting +5, Gnd to each device.


* cascaded74HC165.png (8.02 KB, 961x445 - viewed 41 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for this jewel and all your help! I should be good now.
Logged

Pages: [1]   Go Up
Jump to: