Page 1 of 1

Asking for the Teensy PCB wiring help

Posted: 18 Apr 2016, 14:45
by solkoseryl
Hello friends,

I'm trying to create the DIY-keyboard PCB.

I've decided to drive my keyboard by Teensy 2.0++. Summary it will be 26 lines: 19 for the matrix (10 rows, 9 columns) and 7 for LEDs.

So, the question is: what to do with the power pins of the Teensy ("+5v", "GND")?

I've took a look at a plenty of different projects, and found out that some of them has power connected to that legs (and traced on the PCB as well), some not.

But, if I understand right, the matrix is a completely passive device, right? So, I think, there is no need to trace the power lines on the PCB, for Teensy will receive all the power it needs via USB?

Completely other case, if I'd decided to use the separate Atmel chip itself in my project. Thus, I'd need to create the power wiring between the USB and the chip (and other components).

Or, maybe, in my case I need the ground wiring only to power LEDs?

Thanks in advance for the answers!

Posted: 18 Apr 2016, 15:06
by Scarpia
First, to clear up any potential confusion about the pins themselves: The VCC pin puts out 5V pulled directly from the USB cable, and the GND pin is fixed to something close to 0V. You do not need to put power 'in' through these pins at all, since the power is supplied from the USB.

As you mention, the matrix itself is passive (probing a number of times per second to detect keypresses) but the LEDs aren't. When an LED is on, there is a constant flow of current through it, and the Teensy is responsible for switching this current on or off.

Obviously, each LED has two leads. You could imagine a scenario where you would connect each LED to two pins on the Teensy and have code on the Teensy push power into that circuit when the LED needs to be on. However, that would require two pins per LED, or 14 in your case.

Turns out we can do better, and quite easily. We can simply let the LEDs share one side of the circuit, by connecting them all to one fixed-voltage pin on the Teensy (either positive or ground depending on your code).

The other lead for each LED gets its own pin on the Teensy (let's call it the control pin for that LED), so instead of 7*2 pins you can make do with 1 fixed pin + 7 control pins on the Teensy.

Then, all we need to light an LED is to pull its control pin high (if the fixed pin is GND) or low (if the fixed pin is VCC).

TL;DR: You don't need to use the VCC or GND pins for anything, but they can be useful in reducing the number of pins you need for things other than the matrix, like LEDs.

Posted: 18 Apr 2016, 15:10
by solkoseryl
Scarpia, thanks for your detailed answer!

So, if I've got it right, I'm only need to wire GND pins for LEDs, and leave the '+5V' pins floating (or vice versa)?

Posted: 18 Apr 2016, 15:20
by Scarpia
Depends what the code looks like. I have used hasu's TMK firmware code for my Zenith board, but I haven't wired up the LEDs yet, so I'm not sure if the firmware prefers to control the positive or the negative side, or if both are supported. But if you wire the negative side of the LEDs to the GND pin, then you need to wire the positive side of the LEDs to separate Teensy pins and configure those in the firmware. In this case, the +5V pin on the Teensy will be connected to nothing.

Posted: 18 Apr 2016, 15:28
by solkoseryl
OK, I'm going to use the TMK firmware, and will take further investigation about the potential level need to drive LEDs.

But, looking at the Ergodox, which utilizes the TMK code too, the LEDs' cathodes have to be connected to the ground, and anodes — to the corresponding Teensy pins (through resistors, of course).

Scarpia, thanks again for you explanations!

Posted: 18 Apr 2016, 15:45
by Scarpia
Пожалуйста ;)