Author Topic: Arduino + i2c expander instead of Teensy  (Read 4318 times)

0 Members and 1 Guest are viewing this topic.

Offline 680000

  • Thread Starter
  • Posts: 6
Arduino + i2c expander instead of Teensy
« on: Sun, 10 July 2016, 01:39:18 »
From where I live (not in America) the Teensy is unavailable, however Atmega32u4 Arduino clones are. The keyboard being modified is full-size with numpad and LEDs. Besides that, there are some laptop keyboards (i really dig scissor switches), but those are lower priority. I will use an i2c I/O expander to make up for the lack of pins on the Arduino. Is this possible, and if so, will the polling of the keys (rate, synchronisation etc) be affected when both the Arduino pins and those of the i2c expander are connecd to the pins of the keyboard matrix? Also are there better options, such as other ways to inctease pin count or other microcontrollers?

EDIT: https://www.sparkfun.com/products/retired/8130
This is similar to what I might be using
« Last Edit: Sun, 10 July 2016, 01:55:47 by 680000 »

Offline Melvang

  • Exquisite Lord of Bumfluff
  • * Maker
  • Posts: 4398
  • Location: Waterloo, IA
  • Melvang's Desktop Customs
Re: Arduino + i2c expander instead of Teensy
« Reply #1 on: Sun, 10 July 2016, 01:48:52 »
I can concur that the I2C expander works with Teensy, but can't comment about with the Arduino.  Sorry I can't help further, but they both use the same Atmel chip, so I don't see it being that much different.
OG Kishsaver, Razer Orbweaver clears and reds with blue LEDs, and Razer Naga Epic.   "Great minds crawl in the same sewer"  Uncle Rich

Offline QuincyJones

  • Posts: 270
  • Location: The Greatest Of Them All, England
Re: Arduino + i2c expander instead of Teensy
« Reply #2 on: Sun, 10 July 2016, 06:01:21 »
be very careful when buying clones - to save money, the chinese manufacturers use a different chip - the p, not the 32u4. the u4 has HID capabilities, whereas the P does not.
SENT FROM MY TRKA-100-ULTRA-PRO-1R WITH FLASHY MULTI-COLOURED LEDS FOR MEGA ULTRA COOLNESS
(please like me)

       

Offline 680000

  • Thread Starter
  • Posts: 6
Re: Arduino + i2c expander instead of Teensy
« Reply #3 on: Sun, 10 July 2016, 07:29:18 »
be very careful when buying clones - to save money, the chinese manufacturers use a different chip - the p, not the 32u4. the u4 has HID capabilities, whereas the P does not.
Yeah, you're right. There are clones with both chips, with the 32u4 chip costing slightly more. I already ordered two clones which are presumably 328P (since they have a serial to USB chip) before realising my mistake. But I can always order again, and I have other uses for them. You mean the Atmega328P, right?

Offline 680000

  • Thread Starter
  • Posts: 6
Re: Arduino + i2c expander instead of Teensy
« Reply #4 on: Sun, 10 July 2016, 07:36:13 »
I can concur that the I2C expander works with Teensy, but can't comment about with the Arduino.  Sorry I can't help further, but they both use the same Atmel chip, so I don't see it being that much different.

Do people use the Arduino IDE or Arduino code with the Teensy when they make keyboards, or is there some custom firmware that everyone uses?

Offline QuincyJones

  • Posts: 270
  • Location: The Greatest Of Them All, England
Re: Arduino + i2c expander instead of Teensy
« Reply #5 on: Sun, 10 July 2016, 07:49:33 »
be very careful when buying clones - to save money, the chinese manufacturers use a different chip - the p, not the 32u4. the u4 has HID capabilities, whereas the P does not.
Yeah, you're right. There are clones with both chips, with the 32u4 chip costing slightly more. I already ordered two clones which are presumably 328P (since they have a serial to USB chip) before realising my mistake. But I can always order again, and I have other uses for them. You mean the Atmega328P, right?

heh, i made the same mistake but cancelled before i submitted payment after realising the mistake! yep the 328P - "P" meaning it has a bootloader programmed onto it allowing you to code it via the onboard usb.

for sure, no doubt you will find something to do with them - consider it two potential projects!

i'm not sure what you're getting but whilst developing you may want to see if you can get the larger developer board version as it would save messing about with a breadboard, and smaller areas for wires, e.g. the leonardo and the leonardo micro. same stuff, just different factor forms.

if you hop over to the 'making stuff together' forum, you'll meet hasu and soarer etc (both developers of firmware / controller code for keyboards), and hasu is fairly confident that his code isn't compatible with arduino. adafruit made a small port / fork of it for arduinos, but PS/2 only (search for their bluetooth into model m article).

This was a while ago though, I think before Arduino released the HID-capable boards like the Leonardo so maybe things have changed. It may just be as simple as a few pin differences or it may not. I would be able to answer more here, but I'm waiting on China myself to get (quite a bit of) stuff to me!

Hop to the making stuff together forum and have a gawk down some of those threads
SENT FROM MY TRKA-100-ULTRA-PRO-1R WITH FLASHY MULTI-COLOURED LEDS FOR MEGA ULTRA COOLNESS
(please like me)

       

Offline QuincyJones

  • Posts: 270
  • Location: The Greatest Of Them All, England
Re: Arduino + i2c expander instead of Teensy
« Reply #6 on: Sun, 10 July 2016, 17:23:07 »
I can concur that the I2C expander works with Teensy, but can't comment about with the Arduino.  Sorry I can't help further, but they both use the same Atmel chip, so I don't see it being that much different.

Do people use the Arduino IDE or Arduino code with the Teensy when they make keyboards, or is there some custom firmware that everyone uses?

I believe Teensy have made an addon which you can use with the Arduino IDE.
SENT FROM MY TRKA-100-ULTRA-PRO-1R WITH FLASHY MULTI-COLOURED LEDS FOR MEGA ULTRA COOLNESS
(please like me)

       

Offline 680000

  • Thread Starter
  • Posts: 6
Re: Arduino + i2c expander instead of Teensy
« Reply #7 on: Mon, 11 July 2016, 10:07:34 »
I can concur that the I2C expander works with Teensy, but can't comment about with the Arduino.  Sorry I can't help further, but they both use the same Atmel chip, so I don't see it being that much different.
Did you have to hook some of the pins directly, and others to the expander? If so, did you have to control those rows/columns differently?

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Arduino + i2c expander instead of Teensy
« Reply #8 on: Wed, 13 July 2016, 13:02:47 »
Yes the expander will behave differently to built in pins - the only firmware I know of with support is TMK (and derivatives) and you can look in the Ergodox for example code.  If you get the same expander and use the same pins you can pretend your board is an Ergodox.  Not much use to you if it doesn't run on an Arduino though.

I believe someone was working on adding an expander to EasyAVR too but haven't seen anything lately.  EasyAVR does work on Arduinos if they have a 32u4.

Also I've moved this to MST as I think you'll get more answers :)
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline QuincyJones

  • Posts: 270
  • Location: The Greatest Of Them All, England
Re: Arduino + i2c expander instead of Teensy
« Reply #9 on: Wed, 13 July 2016, 13:13:55 »
There is code that Adafruit have done on converting TMK to use on an Arduino. SGould i think was / is the repo's owner however it's been abandoned and not touched for a few years (2012 ish). Soo... how many pins do you need? There are different arduino's with more pins that should be enough?

I'm going to be in a sort of similar boat soon once the goods arrive from Pluto (aka China) as I'll be using TMK as a codebase to mod some old keyboards and maybe retrofit a nice little QuietKey but as I only need a few pins I still had to buy a Leonardo Micro clone with more than enough pins.
SENT FROM MY TRKA-100-ULTRA-PRO-1R WITH FLASHY MULTI-COLOURED LEDS FOR MEGA ULTRA COOLNESS
(please like me)

       

Offline bpiphany

  • Posts: 1033
  • Location: Stockholm, Sweden
  • bpiph is a special type of crazy. //mkawa
Re: Arduino + i2c expander instead of Teensy
« Reply #10 on: Mon, 18 July 2016, 01:21:02 »
Look at decoders. A much more straight forward way of increasing pin count. They won't be general purpose, but you don't need that anyway.

https://en.wikipedia.org/wiki/Binary_decoder

With a n-bit binary number you reach 2^n possible values. Decoders do pretty much the same, although you may need a few extra for practical circuits.

3-8  decoders (74hc138) are the most common. With one you get 8 outputs from 3 controller pins, and two gives you 16 outputs from 4 controller pins. After that it's not quite as trivial. With three decoders you can easily get 24 outputs from 5 controller pins. (2^5 should theoretically produce 32, but that requires extra components.)

I use two 4-10 decoders (74hc42) and get 20 outputs from 6 controller pins on my custom controllers. I really only needed 18 outputs, so 5 pins and three 74hc138 would have done that. But I rather spent the extra pin in exchange for fewer components.

Offline vextanys

  • Posts: 40
Re: Arduino + i2c expander instead of Teensy
« Reply #11 on: Mon, 18 July 2016, 04:40:26 »
If you have 2 Arduinos (even if one is a 328P) you should be able to program one as a slave, and one as a master, on the i2c bus - this would allow all-but-2 pins on both to be used (SDA/SCL pins for the i2c bus). It should be possible to use as many slave devices as you can address, and the Arduino IDE has pretty good support for i2c buses.