Page 3 of 5

Posted: 12 May 2013, 02:59
by Soarer
The first one looks neater... you could even put the DIPs inside the 11x8 matrix, on say C2,C3 and R3,R5,R6. Or maybe on all the blanks in C14.

Posted: 12 May 2013, 03:35
by alfa147x
Soarer wrote:The first one looks neater... you could even put the DIPs inside the 11x8 matrix, on say C2,C3 and R3,R5,R6. Or maybe on all the blanks in C14.
I might go the 1st route. It would be easier to wire all from a single column and it would leave me 3 free I/O ports. Which would allow me to wire up some extra LEDs for layers.

Any disadvantage to being lazy and making a new column?

Just measured the stock PCB. Trying figure out the protoboard layout.

Edit:
Which pins on the Teensy are used for something like this? B, D, C, or F?

Posted: 12 May 2013, 04:04
by Soarer
Using a new column is just... inelegant :) The two ways I suggested give a choice between using only 5 connections to the DIP switches (2 columns + 3 rows), or 7 connections with 6 rows used on C14. If you're building it on stripboard the C14 way might be easiest, or clearest, even if it is more connections.

Port B is a good one for the inputs (rows) - it's the only complete 8 bit port that's clear. Also, if the firmware supports a low power sleep mode (perhaps not now but in future) then port B works well to wake up the Teensy. It really doesn't matter much which pins you use for the strobes or LEDs, unless the firmware is easier to adapt to certain arrangements.

Posted: 12 May 2013, 04:22
by alfa147x
Soarer wrote:Using a new column is just... inelegant :) The two ways I suggested give a choice between using only 5 connections to the DIP switches (2 columns + 3 rows), or 7 connections with 6 rows used on C14. If you're building it on stripboard the C14 way might be easiest, or clearest, even if it is more connections.

Port B is a good one for the inputs (rows) - it's the only complete 8 bit port that's clear. Also, if the firmware supports a low power sleep mode (perhaps not now but in future) then port B works well to wake up the Teensy. It really doesn't matter much which pins you use for the strobes or LEDs, unless the firmware is easier to adapt to certain arrangements.
Ah I see. Working on the layout now. Looks like using the stock DIP switch location + pin header location will not be possible. Looking into a ribbon cable option. Too bad no one makes cables that are 14x2

Edit: New plan: Dual PCB design. One for the dip switch and one for the rest. Hopefully that won't be too thick. Can't find a suitable ribbon cable :\ Or bend the pins on the dip switch so it sits off set on the bottom of the PCB

Even newer plan. The DIP switch and the pin header will be on separate boards since I can't seem to route all the lines from the header without taking up too much space.

Posted: 12 May 2013, 04:58
by Soarer
Forgot to mention, in case you didn't realise, you could put the rows onto port B in any order if it helps with the layout.

Posted: 12 May 2013, 05:01
by alfa147x
Soarer wrote:Forgot to mention, in case you didn't realise, you could put the rows onto port B in any order if it helps with the layout.
Yeah. I just measure the clearance under the board past the stock controller. That solves a few problems.

Posted: 12 May 2013, 06:02
by alfa147x
Image

Okay that is now combined. It shouldn't be as difficult as I first thought to combine those rows and add in the dip switches.

Posted: 12 May 2013, 06:10
by alfa147x
Thoughts on getting something like this to connect the keyboard PCB to the controller's protoboard?

http://i.imgur.com/npP6dki.png

Posted: 12 May 2013, 20:29
by alfa147x
Gf's parents are visiting tomorrow. Got to get this place clean. I realized I made some errors on the layout so I'll have to redo that. The Teensy should arrive tomorrow so I should have this up and running soon. Just need to get cracking on the code. Might be next next weekend before I move the project over from a breeadboard state.

Posted: 12 May 2013, 20:39
by webwit
alfa147x wrote:Gf's parents are visiting tomorrow.
Get your weirdest keyboards out.

Posted: 12 May 2013, 20:42
by alfa147x
webwit wrote:
alfa147x wrote:Gf's parents are visiting tomorrow.
Get your weirdest keyboards out.
Unfortunately I am a keyboard amateur.
My boards:
  • Apple Bluetooth wireless bluetooth keyboard
  • Logitech K120
  • Random $3 MicroCenters keyboard
  • Das Keyboard Pro Model S
  • MiniLa

Posted: 13 May 2013, 17:44
by alfa147x
I wonder how hard it would be to embed a USB hub. Might be easier to just buy a tiny hub and rip the board out of it vs making one. I brought my board into work today and I am enjoying being able to plug my mouse into it.

Posted: 13 May 2013, 19:11
by Muirium
Yes, I've always wondered why any USB keyboards don't have hubs. It's the perfect place to plug in a memory reader etc. at random, let alone a mouse.

I got one of these little solar powered hubs recently. (For use with iPad and camera connector kit.) A powered hub may be overkill, but keyboards aren't the worst place to put solar cells, either.

Posted: 13 May 2013, 20:34
by alfa147x
Muirium wrote:Yes, I've always wondered why any USB keyboards don't have hubs. It's the perfect place to plug in a memory reader etc. at random, let alone a mouse.

I got one of these little solar powered hubs recently. (For use with iPad and camera connector kit.) A powered hub may be overkill, but keyboards aren't the worst place to put solar cells, either.
Yeah.Idk about power cells though

I do have one of these that I will rip open this week:
Image

Posted: 14 May 2013, 03:32
by alfa147x
My Teensy just came in. It's tiny! Wow. Not what I was expecting. Won't be able to breadboard till later this week.

Posted: 14 May 2013, 11:53
by Muirium
The name is well earned. It'd better be, the nooks and crannies we go sticking them. Often in the gap under the spacebar.

Posted: 17 May 2013, 20:37
by alfa147x
Got the bread board out. Getting ready to test this thing out today. After getting the Teensy time seemed to move slower BUT I have finally found time to get this thing on the road!

Posted: 18 May 2013, 00:35
by alfa147x
How does this look?

Old layout

Image
See any problems?

Posted: 18 May 2013, 01:53
by alfa147x
Okay. I have no idea what I'm doing with the code.

Question 1: How do I tell the code which pin which column and row is hooked to?

Posted: 18 May 2013, 01:55
by Muirium
Got a link to the code you're looking at?

Posted: 18 May 2013, 02:03
by Soarer
Column 14 -> D2 ... but D2 is already used for another highlighted column, 10!

Yeah, it's worth checking in the code whether a certain selection of pins will make life easier.

Posted: 18 May 2013, 02:07
by alfa147x
Muirium wrote:Got a link to the code you're looking at?
tmk_keyboard

Just the different keyboard packages that ship with the code.

I was thinking I would map the pins to the code. Then map the keys to rows and columns. Is that right? Am I thinking of the logic wrong?

I think I found it. It's set matrix.c

Should I modify an existing boards code or should I start from scratch?

Thanks again for all the help!

Posted: 18 May 2013, 02:11
by alfa147x
ignore

Posted: 18 May 2013, 02:11
by alfa147x
alfa147x wrote:
alfa147x wrote:How does this look?

Old layout

Older layout

Image
See any problems?

Fixed. Thanks!

Posted: 18 May 2013, 02:11
by alfa147x
ignore

Posted: 18 May 2013, 03:05
by alfa147x

Code: Select all

static void init_rows(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRB  &= ~0b00111111;
    PORTB |= 0b00111111;
}
Any idea how I am suppose interpret this?

Posted: 18 May 2013, 03:21
by Soarer
Each port on the AVR consist of (up to) 8 pins and is controlled by three registers...

DDRx - Direction - each bit sets whether the corresponding pin is input (=0) or output (=1).
PORTx - For an output pin, the output state. For an input pin, setting a bit to 1 activates the pullup resistor for that pin.
PINx - Input. (Also can be used to toggle output states, but not relevant here).

So, the first line clears the direction bits for pins PB0..5, and the second activates the pullup for those pins.

Posted: 18 May 2013, 03:53
by alfa147x
Soarer wrote:Each port on the AVR consist of (up to) 8 pins and is controlled by three registers...

DDRx - Direction - each bit sets whether the corresponding pin is input (=0) or output (=1).
PORTx - For an output pin, the output state. For an input pin, setting a bit to 1 activates the pullup resistor for that pin.
PINx - Input. (Also can be used to toggle output states, but not relevant here).

So, the first line clears the direction bits for pins PB0..5, and the second activates the pullup for those pins.
Thanks. That helps a lot. I hate to be a pain in the ass but could you explain the 2nd chunk of this code

Code: Select all

/* Row pin configuration
 * row: 0   1   2   3   4   5
 * pin: B0  B1  B2  B3  B4  B5
 */
static void init_rows(void)
{
    // Input with pull-up(DDR:0, PORT:1)
    DDRB  &= ~0b00111111;
    PORTB |= 0b00111111;
}

static uint8_t read_rows(void)
{
    return (PINB&(1<<0) ? 0 : (1<<0)) |
           (PINB&(1<<1) ? 0 : (1<<1)) |
           (PINB&(1<<2) ? 0 : (1<<2)) |
           (PINB&(1<<3) ? 0 : (1<<3)) |
           (PINB&(1<<4) ? 0 : (1<<4)) |
           (PINB&(1<<5) ? 0 : (1<<5));
}
by the name it looks like it's what reads the row but I still don't understand where the pins are assigned to the physical pins on the board

I think I get it.

Code: Select all

/* Column pin configuration
 * col: 0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16
 * pin: D5  C7  C6  D4  D0  E6  F0  F1  F4  F5  F6  F7  D7  D6  D1  D2  D3
 */
static void unselect_cols(void)
{
    // Hi-Z(DDR:0, PORT:0) to unselect
    DDRC  |= 0b11000000; // PC: 7 6
    PORTC |= 0b11000000;
    DDRD  |= 0b11111111; // PD: 7 6 5 4 3 2 1 0
    PORTD |= 0b11111111;
    DDRE  |= 0b01000000; // PE: 6
    PORTE |= 0b01000000;
    DDRF  |= 0b11110011; // PF: 7 6 5 4 1 0
    PORTF |= 0b11110011;
}
If it says

Code: Select all

PORTF |= 0b00000010
it's referring to F1 on the physical board

Code: Select all

PORTC |= 0b10000000
it's referring to C7 on the physical board




Wow. Roughing it. Going to sleep on it and pick it back up in the morning

Posted: 18 May 2013, 13:30
by Soarer
Hmm, how much do you know about C's bitwise operators? &, |, ~, << etc.

Looks like you got the relationship between logical bits and physical pins OK.

Posted: 18 May 2013, 20:48
by alfa147x
Soarer wrote:Hmm, how much do you know about C's bitwise operators? &, |, ~, << etc.

Looks like you got the relationship between logical bits and physical pins OK.
I know how to read a wiki page:
http://en.wikipedia.org/wiki/Bitwise_operations_in_C

That code was right from the TMK_Keybaord examples. I'm working on setting up for the Minila