Author Topic: Newbie questions about split wiring  (Read 4816 times)

0 Members and 1 Guest are viewing this topic.

Offline replicaJunction

  • Thread Starter
  • Posts: 7
Newbie questions about split wiring
« on: Tue, 11 October 2016, 10:38:43 »
Hi all, first post here. I've built a couple of keyboards from kits already, and now I'm ready to design my own. I'm pretty new to electronics design, so please go easy on me. :)

I'm hoping to build a split keyboard with a controller in each half (I learned through building my Ergodox that testing and debugging a half without a controller is a pain). I'm also working my way through designing a PCB in KiCad, so I'd like to built something reversible that can be used on either side. I'm not sure how to wire up the controller to allow it to act as either the master or the slave, though.

I'm referencing the Teensy 2 pinout (below for convenience). Based on the Teensy docs here https://www.pjrc.com/teensy/td_libs_Wire.html, it looks like it uses pins 5 and 6 for I2C.



I've also been referencing the Let's Split design files from climbalima https://github.com/climbalima/split-pcb-throughole, and they've been a huge help for the main part of the design...but I'm having trouble understanding the connection from one keyboard to the next. It also looks like he's attaching an ATmega32U4 chip directly to the PCB instead of using a Teensy or Arduino board - but I don't trust my soldering skills enough to attach stuff with that much detail. :D

If I connect ground, +5V, and pins 5 and 6 in the image above to a connector cable (TRRS or similar), where do I connect them on the other Teensy? Do I connect each pin to the same pin on the other device (ground to ground, 5 to 5, etc.)?

Would I need to connect both ground and +5V pins on the slave Teensy (on the bottom and in the upper corners), or just one set or the other?

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Newbie questions about split wiring
« Reply #1 on: Fri, 14 October 2016, 03:11:52 »
Yes, the pins go to the same pin on the second Teensy.  By setting one as slave it takes the clock signal from SCL instead of generating one on that pin, and data (SDA) goes both ways anyway.  The 5V and grounds are connected in the chip so one of each is enough :)

Also just for reference most of the pins on the Teensy are directly connected to the chip so there is no technical advantage to soldering directly to the PCB.  It's cheaper and you get a shorter PCB so people do, but functionally it's the same.
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline replicaJunction

  • Thread Starter
  • Posts: 7
Re: Newbie questions about split wiring
« Reply #2 on: Mon, 17 October 2016, 09:33:26 »
Awesome. Thank you very much for the help!

I'm glad to hear that soldering directly to the board isn't very different from a technical perspective. That might be something I'd look into down the road once I start getting more comfortable with this sort of design, but for the time being, using a Teensy or Pro Micro will make things a lot easier.

If I could bug you with one more silly newbie question...is it possible to get the Teensy to "auto-detect" whether it's acting as a master or a slave? I know I could just flash different programs to each board, but is there a hardware solution that would let me use the same program for both sides?

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Newbie questions about split wiring
« Reply #3 on: Mon, 17 October 2016, 13:06:17 »
That's a good question, takes you well beyond newbie.  Most two part builds use an IO expander in the second half rather than a second Teensy, actually I can't think of anyone using two...

As for forcing slave mode I don't think there's a way of doing it purely in software, but if you set a pin as an input with internal pullup when your program initialises and on the slave board have that pin connected to ground with a smaller resistor it would read low, while on the master it would read high. 

You might even be able to use the pin later with it set to pulldown but that would depend on the resistor value being high enough and a quick search only revealed that the internal resistors are 'weak' - not very helpful :))

One problem you might have using the same program on both sides is the amount of space on a Teensy, but that's one for later.
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline replicaJunction

  • Thread Starter
  • Posts: 7
Re: Newbie questions about split wiring
« Reply #4 on: Mon, 17 October 2016, 16:15:37 »
Well, ideally I want to be able to use the same PCB for both sides. If I connected an input pin to a resistor, then to ground on the TRRS jack (or USB, or whatever I end up using to connect the two pieces), then wouldn't I end up with both sides wired the same way, with that pin reading low?

I suppose I could only solder the resistor on the slave boards, so on the master it's not connected to anything. That would mean there's a physical difference in the construction of the two, though, so they wouldn't be "plug and play" in the sense that I could unplug the two from each other, then connect the other one to a computer and have two standalone masters with no flashing or config necessary.

The reason I'm looking into this is that I'm trying to design something modular. My end goal is to have at least two TRRS jacks on each piece so I can connect (for example) two halves of a keyboard, a numpad, and a "control" module with an LCD in any order I want. If I feel like putting the numpad on the left, I can unplug it from one piece of the keyboard and plug it into the other piece. Maybe that's too ambitious for my first self-designed project...

Thanks again for the help!

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Newbie questions about split wiring
« Reply #5 on: Mon, 17 October 2016, 16:54:20 »
I see - that is ambitious!

You could use one of the keys as a "master" trigger?  That would mean having to hold it whenever you booted/woke the computer or plugged the board in, but would allow them to be the same physically.

Also note you can't plug/unplug TRRS sockets while the board is powered on as the pins short when the connector is partially inserted - consider using USB sockets or RJ?? (square connectors like in phones and network cables) instead :thumb:
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline vextanys

  • Posts: 40
Re: Newbie questions about split wiring
« Reply #6 on: Tue, 18 October 2016, 03:54:29 »
You could delay the I2C initialization until USB enumeration (or timeout), so that the Teensy connected to the USB host is the master, and the one that times out is the slave. That way, the same program could be run on both Teensy's, and either could be connected to the USB host. Its similar to the ErgoDox Infinity.

Offline replicaJunction

  • Thread Starter
  • Posts: 7
Re: Newbie questions about split wiring
« Reply #7 on: Tue, 18 October 2016, 11:38:48 »

Also note you can't plug/unplug TRRS sockets while the board is powered on as the pins short when the connector is partially inserted - consider using USB sockets or RJ?? (square connectors like in phones and network cables) instead :thumb:


Awesome. Thanks for letting me know; that finalizes my decision not to use TRRS. I was thinking of using USB type-C as described in another thread (https://geekhack.org/index.php?topic=71614.msg1797077#msg1797077). That will make the wiring a little more complex since I need to connect things to two different points, and it might make cables more expensive as well...but on the other hand, it's hard to pass up a reversible connector. ;D

Barring that, I might just use USB micro B. It seems significantly easier to work with than mini B, and more common. I've got plenty of RJ45 cables, but that connector is pretty big and I'm hoping the board doesn't end up being that tall.


You could delay the I2C initialization until USB enumeration (or timeout), so that the Teensy connected to the USB host is the master, and the one that times out is the slave. That way, the same program could be run on both Teensy's, and either could be connected to the USB host. Its similar to the ErgoDox Infinity.

I like this idea. That's basically exactly what I want - if it detects USB, it should be the master device; otherwise, it should act as a slave. I'll take a look at the Infinity firmware to see how they do this. Thanks!

I don't know if I'll be able to implement the full scope of this project right away or not, but I'm looking forward to giving it a shot. I appreciate both of your help!

One other silly question: am I going to need a capacitor on devices I expect to be connected via I2C, or will the power from the USB device be steady enough not to worry about it?

Offline suicidal_orange

  • * Global Moderator
  • Posts: 4771
  • Location: England
Re: Newbie questions about split wiring
« Reply #8 on: Tue, 18 October 2016, 12:32:01 »
You could delay the I2C initialization until USB enumeration (or timeout), so that the Teensy connected to the USB host is the master, and the one that times out is the slave. That way, the same program could be run on both Teensy's, and either could be connected to the USB host. Its similar to the ErgoDox Infinity.

That's clever!  Filed away for future reference...
120/100g linear Zealio R1  
GMK Hyperfuse
'Split everything' perfection  
MX Clear
SA Hack'd by Geeks     
EasyAVR mod

Offline spindle

  • Posts: 28
Re: Newbie questions about split wiring
« Reply #9 on: Tue, 25 October 2016, 15:56:46 »
I've made a split keyboard with two promicros per a half. see here. I use the VBUS pad on the atmega32u4 to detect if is plugged in via USB and become master or slave based off that.