Closed nesiax closed 9 years ago
I have no experience with i2c things at all. But I'm almost sure that it works with my firmware. And you will be able to borrow i2c code from ic07's Ergodox firmware for quick start of project.
You won't lose any features of my firmware offers as long as i2c code is used only inside your matrix.c. If i2c code is reusable for other projects you can put it in protocol/ directory, if not you should put it under you project.
Hi neslax Where do you want to use I2C in keyboard ? connect two halves in KEY64 ? If so, using I2C is somewhat troublesome works. I2C is very slow and there are many things to do in communicating devices. According to specification I2C, slow mode speed 400KHz and fast mode speed would be under 2MHz. (In fact, it could be more fast in connecting special two devices.) I don't know the ergodox keyboard and why you want to use I2C. (Ergodox assembly instruction PDF is so big, I couldn't opened it up to now. )
I have experience in using I2C with some boards and in addition to this, I have made I2C slave/host in ASIC. Of course I wrote firmware code for my I2C part in chip. If you make I2C function with FPGA, there would be fewer restrictions but general purpose I2C chip has fewer registers and restrictions in speed.
If your objective is connecting two halves, I suggest connect them by wires (if possible). It is most simple and intuitive method and there is no need to modify matrix.c.
When I misunderstood your objective, let me know. I could help you. : )
Just for reference, the code I'm using for I2C on the ErgoDox right now is here, and it really is pretty trivial. Take a look at the links in this section of my references.md for examples of more feature-complete TWI implementations, if you like. This shows how I'm using it, and this contains most of the relevant chip-specific documentation.
It is slow - back when I was profiling stuff, just for fun, I think I calculated that my firmware takes something like 4ms per scan cycle communicating over I2C. But that still leaves the scan rate at a total of ~5ms, which is more than fast enough for a keyboard.
I'm almost certain it would work in Hasu's firmware as well, probably without all that much trouble. The only reason I didn't set out to do that instead of writing my own is because, when I started, I didn't know enough to be able to figure out what was going on in Hasu's firmware in the first place :) .
Hi all, thanks for your comments, the main reason i would like to use the i2c device is simplicity, from what i have read it seems speed is not the problem, in fact the teensy is so fast that i have to modify the matrix code to wait 5 ms on every scan or i will get bounces, even with that sometimes i get some but they are minimal, probably i will have to increase the delay a little more. Right now the two halves communicate using a 8x2 connector on every halve via ribbon cable which is cheap, however 16 wires make a cable a little fat if you want to separate the halves, so i was thinking in another possibilities, the simplest was to use a slim hdmi cable which provides 19 pins, more than i need like this one, the ziotek slim hdmi cable : I haven't tested it but i suppose they will work fine too, a little more expensive than a 3.5mm cable but seems to do the job. Some people say, i shouldn't use a cable which is not designed for a keyboard, anyway a 3.5mm audio cable isn't too but is cheaper. For now the hdmi cable seems to be the easy path but still expensive.
I don't know much about signal electronics, but there was someone who tried using an HDMI cable to connect the halves of a hand-wired ErgoDox a while back. He said it didn't work for him. http://blog.fsck.com/2012/12/building-a-keyboard-part-2.html (the reference is somewhere around the middle of the page)
mmmm... thanks for pointing me about that journey, one of the drawbacks of the hdmi cable is the soldering problem, the author didn't use a pcb and instead he soldered everything by hand which i think is very difficult and not error prone, the majority of the hdmi female receptables are smt but there are some with pinhole like this one http://www.toby.co.uk/content/catalogue/products.aspx?series=51L-019S-036xN-A1 and the distance between the holes are 1.5mm a little difficult to solder but not impossible, another options i was consider is to use a 15 pin serial cable which are exactly what i need like this one: but they are so big, and so for the options, when it comes to hardware the i2c seems to be the best one but i have to modify the firmware, in case i am going with the i2c option and with your experience and according to this: http://www.pjrc.com/teensy/td_libs_Wire.html then the only thing i have to do in hardware is to wire pins 5 and 6 from the teensy to the i2c chip ? those are the only pins that work for i2c connection ? do you have the kicad schematic for this ? also the footprint of the i2c chip ? thanks.
There's a circuit diagram of how we have things set up (you'll have to download the file before viewing since github doesn't display '.svg's). You can find the kicad files for the PCB here. The I2C pins we're using (PD0 = SCL, PD1 = SDA) are the only pins you can use if you want I2C supported by the hardware (as opposed to doing it yourself in software, which would be a relative pain).
Note that the I/O expander also needs power and ground - so 4 wires total.
Also note that if you use Arduino libraries (like the one you linked to) you'll probably pull in a bunch of dependencies that aren't currently used in either of our firmwares (or any keyboard firmware I know of for the Teensy, actually). I'd recommend using a different one.
Thanks for all the information i will investigate about that further, that seems to be the right direction.
Shift registers may be an interesting alternative to i2c port multiplexers. However there's only one keyboard using them at the moment. And ErgoDox seems to be the only project with multiplexer. HDMI/DIN15 cables are nothing compared to standard USB cable, harder to bend and much thicker, and even costier. Usage of shift register (need one for input and one for output) requires 5 wires between controller and another half of keyboard (GND, VCC, CLK, DATA IN, DATA OUT), so standard USB 2.0 cable (4 wire+shield) should work. Programming a shift register is straightforward, and pretty sure, but it takes more time, since clock leg should be triggered and then the value for a pin is set, repeated 8 (or 16) times, so this is 16 (32) times slower than connecting switches directly to controller.
Hi Hasu, i would like to hear your comments about the idea of connecting an i2c device to the teensy board in order to transmit keyboard data, honestly i don't know how they work, i am still in the research stage, but thinking in an improved version of the key64 keyboard and since an i2c is so cheap, another way to connect the two halves of the key64 could be using an i2c chip borrowing the same idea from the ergodox keyboard, off course i would like to be sure everything will stay working as for now, as the teensy feature a twi interface http://www.avrbeginners.net/architecture/twi/twi.html it seems just a matter of adding and i2c chipset like the MCP23018-E/SP, so do you have experience with them ? what do you think about that approach ?