Using USB-C for UART TX/RX and 5V VCC - Split keyboard TRRS alternative idea - Page 1
Forum section: electronics / projects

author: Zucca
author_rank: Unknown
timestamp: December 31, 2023, 09:40:18 am
content: I got stung by thecorne keyboardbug a while ago...To my biggest surprise, it is standard for split keyboards to use an audio TRRS connector for 5V power and RX/TX UART communication between the two keyboard halves.To me it is simply unacceptable... regardless what the entire split keyboard community is doing, my split keyboard can't have a TRRS connector for power delivery.Looks like I am not the only one!As my first choice I would like to use an USB-C connector, but I do not have enough experience in designing USB-C...According to my homework I would just connect:5V to VBUS A4, A9, B4, B9GND to A1, A12, B1, B12UART TX to A6, B6UART RX to A7, B7and done.I am open to discuss and flexible to accept new ideas...PS: Can I squeeze a I2C in the USB-C as well? If yes what would be the best pins?Many thanks in advance...

author: tszaboo
author_rank: Super Contributor
timestamp: December 31, 2023, 09:45:45 am
content: I wouldn't repurpose connectors to different ports. I had a few people do this, some in professional capacity, and it always leave me disgusted. Just place a USB HUB and treat it as two keyboards. Or those avionics 4 pin connectors are really trendy in the KB community.

author: NiHaoMike
author_rank: Super Contributor
timestamp: December 31, 2023, 06:03:31 pm
content: What about a PS/2 connector? Could even have the capability to program it to work as a PS/2 keyboard if some unusual use case comes up.

author: ataradov
author_rank: Super Contributor
timestamp: December 31, 2023, 06:33:40 pm
content: If this is just for a short dedicated connection between the halves, then I don't think it is a huge issue. Especially if this is for one-off keyboard you are doing for yourself.Normally, you would use SBU pins for dedicated communication like this, but the standard compliant way is for both halves to negotiate the use of those pins over the normal data channel, which is not ideal in this case. For bidirectional communication you would also need to handle the orientation correctly.

author: Zucca
author_rank: Unknown
timestamp: December 31, 2023, 09:58:27 pm
content: Quote from: tszaboo on December 31, 2023, 09:45:45 amI am trying to find the best compromise.TRRS for 5V power delivery can fry boards... that's more severe than "disgusted" level.Not 100% happy with the USB-C solution... but I still think it is the best for me.Quote from: tszaboo on December 31, 2023, 09:45:45 amTempting idea... but I don't know if I can trigger a layer change in one half keyboard and automagically the other half will execute the layer change over the USB HUB.Quote from: tszaboo on December 31, 2023, 09:45:45 amToo bulky and seemsthey are just used for esthetic/personal taste reason, which is unreasonable and reasonable at the same time.

author: Zucca
author_rank: Unknown
timestamp: December 31, 2023, 10:01:08 pm
content: Quote from: NiHaoMike on December 31, 2023, 06:03:31 pmInteresting idea but I don't thing I can find easily a two male PS/2 connectors cable.USB-C cables are polluting our poor planet.

author: Zucca
author_rank: Unknown
timestamp: December 31, 2023, 10:05:52 pm
content: Quote from: ataradov on December 31, 2023, 06:33:40 pmwhich brings me the $1000000 question, does all the USB-C cables have the SBU lines wired up?In other words, if we take the USB-C power only cables out of the equation, does a standard USB-C cable have all the other pins wired up?This is why I tend to use the D+ D- lines, since I imagine they will always be there, nothing critical just talking in the nice to have field...I mean just use the right USB-C cable.

author: fchk
author_rank: Frequent Contributor
timestamp: December 31, 2023, 11:41:10 pm
content: What about standard SATA data cables. Small connector, shielded, cheap.

author: ataradov
author_rank: Super Contributor
timestamp: December 31, 2023, 11:46:46 pm
content: Quote from: Zucca on December 31, 2023, 10:05:52 pmNo clue. There are so many junk cables that it is hard to tell. I would expect all decent cables to have it.Quote from: Zucca on December 31, 2023, 10:05:52 pmFor a personal project, I would not worry about that too much. I would place series resistors before the UART outputs to limit the current, and realistically, the worst that can happen when you plug that into a standard port is nothing will work.

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 01, 2024, 12:19:53 am
content: Repurposing standard connectors is always an issue except of course if it's just a personal project, or if your product is a niche one and it's acceptable to have your customers well aware of it and careful.Now I've also considered using USB-C connectors for non-USB interconnections. If you make sure it's clearly identified on your product that it's not USB *and* you make sure that connecting a USB device or host to this connector will not have any consequence (so use pins appropriately), then it can be acceptable I think.

author: ataradov
author_rank: Super Contributor
timestamp: January 01, 2024, 12:37:04 am
content: If it has to be UART, then the safest thing would be to only enable the receiver initially and enable the transmit part after a valid command is received from the other side.Bonus points if your MCU supports inverted UART levels. Then you can use pull-downs on the D+/D- to maintain the idle UART level. A valid USB host will not even notice your device in that case.

author: tooki
author_rank: Super Contributor
timestamp: January 01, 2024, 04:46:12 pm
content: TRRS for this application is dumb, but so is a USB connector that isn’t used for USB signaling.Some options to consider, in no particular order:- 4P4C (aka “RJ-9”) modular plug (the one used on phone handsets)- 6P4C (RJ-14 or “RJ-11”) modular plug (analog phone line)- 8P4C (“RJ-45”) modular plug (Ethernet/ISDN)- Binder 709 and 719 series- Binder 420 series- Mini-XLRAnd of course if money is no object, Lemo or Fischer connectors. (And if money istrulyno object, the Glenair series 860 MouseBud would be delightful for this application. But they’re in the “if you have to ask you can’t afford it” stratosphere.)

author: Zucca
author_rank: Unknown
timestamp: January 01, 2024, 09:59:38 pm
content: Quote from: fchk on December 31, 2023, 11:41:10 pmnice idea... definitely on my list now. I am worried about the cable flexibility between the two halves kbds.

author: Zucca
author_rank: Unknown
timestamp: January 01, 2024, 10:16:05 pm
content: Quote from: tooki on January 01, 2024, 04:46:12 pmI think this is the winner of my quest... what is a big plus is the cheap coil cable easy available...so it will nicely absorb any mechanical torture and do not stress the PCB connector...the only concern I have is how much mA@5V can I feed on that cable...Let's see RJ-9 cable is normally 30AWG so 350 Ohm/Km...so let's say in a 1m RJ-9 coiled cable I get 350/1000*2=700mOhm...I think it should be fine to power thisKB2040board.... which has a 3.3V reg on the board....Do you think somebody will try to attach a phone to a keyboard... or should I print on the PCB "not a phone cable"??Ah even if not shielded, the UART TX/RX should be robust enough to function on that cable... I assume...

author: magic
author_rank: Super Contributor
timestamp: January 02, 2024, 09:29:26 am
content: This is a decent idea.I was about to suggest USB A - nonstandard A-A cables are readily available.

author: Someone
author_rank: Super Contributor
timestamp: January 02, 2024, 11:14:13 am
content: Everything old is new again:https://deskthority.net/wiki/Apple_M0120

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 06, 2024, 10:06:42 pm
content: I've considered repurposing USB-C for a custom link as well recently, so I had another look at this.Turns out that the USB-C spec defines a "Debug Accessory Mode", which allows you to repurpose most pins of the connector except the VBUS, GND and CCx pins.This mode is identified by connecting both CCx pins along the cable, something that is not normally done with standard cables which only wire 1 CC signal (which allows sources and sinks to sense the orientation if needed.)For the DAM mode to work, you need a cable with both CCx signals wired, so a custom cable. And of course you need to detect the level on both CCx signals on both sides, but that's something you can easily do if you have a MCU with a couple spare ADC inputs on each side. And you need of course to be able to put all of your signals in Hi-Z until you have properly detected that it is safe to use them. It's not a huge deal.The deal is to have this custom cable made. I couldn't find anything like this off-the-shelf so far, but if someone has, please chime in.And also of course, you need to handle the direction (if there is bidirectional communication), something that will be harder to detect here since both CCx signals will be wired. That's something that you can handle with some custom protocol though.Note that all USB specs are free to download without even any registration, so feel free to do so. This particular one is "USB Type-C® Cable and Connector Specification".

author: Zucca
author_rank: Unknown
timestamp: January 09, 2024, 04:12:09 am
content: Thanks Silicon, BTW I should have looked at the QMK docs... there are good info there.https://github.com/qmk/qmk_firmware/blob/master/docs/feature_split_keyboard.md