Author Topic: Wiring a Matrix to a Teensy Safely  (Read 2871 times)

0 Members and 1 Guest are viewing this topic.

Offline possumgumbo

  • Thread Starter
  • Posts: 30
Wiring a Matrix to a Teensy Safely
« on: Wed, 11 February 2015, 10:38:19 »
I am 3D printing my own unique ergonomic keyboard, and have had great success with Swill's tool.

My keyswitches and Teensy 3.1 have arrived, and I am now faced with the following conundrum:

When wiring to a button on a digital input, I have always had a leg of the button shorted either to ground.
The BrownFox tutorial on wiring shorts one input to another.
http://deskthority.net/workshop-f7/brownfox-step-by-step-t6050.html

I used to work with microcontrollers quite often, and I am still at a loss for how this does not damage the chip.
After all, here is an article (see method #2) that shows how to avoid destroying an Arduino:
http://www.ruggedcircuits.com/10-ways-to-destroy-an-arduino/

How are the pins configured to allow the BrownFox configuration to work?

This is the layout I am trying to use:
http://www.keyboard-layout-editor.com/#/layouts/b90aac02cbfd2217364f2ad8b55a600d

I was hoping to use a very simple Arduino code block to control the keyboard, but the more I read into it, the more difficult this seems. I have looked at both Soarer and Hasu's firmware, but I am not sure how to use them with the Teensy.

This thread http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html explains how to use Hasu's code, but I feel that the code is unnecessarily over-complicated.

Why can I not just use usb_keyboard_send() or something similar, with an array detailing each layer?

Is there an Arduino code in existence that I can easily reconfigure to work with my layout?



Offline hasu

  • Posts: 3472
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Wiring a Matrix to a Teensy Safely
« Reply #1 on: Wed, 11 February 2015, 20:41:47 »
You can start with small keyboard using simple example codes to learn enough to make full fledge keyboard yourself. If you have time...

PJRC and Arduino have great libraries and example codes and  for hardware 3x3 key matrix will be good enough.
https://www.pjrc.com/teensy/usb_keyboard.html
http://arduino.cc/en/Reference/MouseKeyboard

Offline Findecanor

  • Posts: 5036
  • Location: Koriko
Re: Wiring a Matrix to a Teensy Safely
« Reply #2 on: Thu, 12 February 2015, 01:05:48 »
I have looked at both Soarer and Hasu's firmware, but I am not sure how to use them with the Teensy.
Soarer's and Hasu's firmwares were made for the Teensy 2.0, which has an 8-bit AVR microcontroller. The Teensy 3.1 has a 32-bit ARM Cortex microcontroller.

You could start with HaaTa's Kiibohd controller which supports the Teensy 3.0/3.1.
It supports several keyboards already, with the specific files for each keyboard neatly ordered. It shouldn't be too difficult to start with one of those as an example.
« Last Edit: Thu, 12 February 2015, 01:09:03 by Findecanor »

Offline possumgumbo

  • Thread Starter
  • Posts: 30
Re: Wiring a Matrix to a Teensy Safely
« Reply #3 on: Thu, 12 February 2015, 11:03:07 »
I have looked at both Soarer and Hasu's firmware, but I am not sure how to use them with the Teensy.
Soarer's and Hasu's firmwares were made for the Teensy 2.0, which has an 8-bit AVR microcontroller. The Teensy 3.1 has a 32-bit ARM Cortex microcontroller.

You could start with HaaTa's Kiibohd controller which supports the Teensy 3.0/3.1.
It supports several keyboards already, with the specific files for each keyboard neatly ordered. It shouldn't be too difficult to start with one of those as an example.

I did not realize that the old code wouldn't port! Thanks for the lead. I will get started on researching this Kiibohd code right away.



Offline possumgumbo

  • Thread Starter
  • Posts: 30
Re: Wiring a Matrix to a Teensy Safely
« Reply #4 on: Sat, 21 February 2015, 17:16:39 »
I really would prefer to use Arduino code over any of the stuff posted in this thread. Has anyone actually used the basic Keyboard.Send() commands to make something like this?

Also, does anyone have any input on the question I initially asked about inputs and outputs? I really need to know how to wire safely in a matrix form, and what to tell each pin to do.



Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Wiring a Matrix to a Teensy Safely
« Reply #5 on: Sun, 22 February 2015, 13:37:20 »
The matrix goes between the [letter][number] pins (e.g. C3), you choose either columns or rows to be connected as inputs and the other as outputs.  Then you set each output high in turn and read back which input was made high to know which key was pressed.

Following that article on damaging your Teensy the only ones to worry about in a keyboard (where there is no other voltage to do something bad with) are the first two and the last one.  You haven't mentioned LEDs so that just leaves two, which are easy to avoid.

1) Don't connect anything to the GND pin.

2) Don't connect two outputs together.

Is that less scary? :)
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline possumgumbo

  • Thread Starter
  • Posts: 30
Re: Wiring a Matrix to a Teensy Safely
« Reply #6 on: Sun, 22 February 2015, 17:17:45 »
The matrix goes between the [letter][number] pins (e.g. C3), you choose either columns or rows to be connected as inputs and the other as outputs.  Then you set each output high in turn and read back which input was made high to know which key was pressed.

Following that article on damaging your Teensy the only ones to worry about in a keyboard (where there is no other voltage to do something bad with) are the first two and the last one.  You haven't mentioned LEDs so that just leaves two, which are easy to avoid.

1) Don't connect anything to the GND pin.

2) Don't connect two outputs together.

Is that less scary? :)

Yes. Thank you. I read the spec last night and saw that the inputs are rated for 3.3V or so, which is the output voltage, so that makes it safe. I really did not want to make a $25 mistake.