I'm a software engineer, gamer, and technology nerd, so it's not surprising that I spent hours daily sitting in front of my computer. I enjoy having a pain-free body like everyone else, so I thought about ergonomics of my office setup and I decided to buy an electric desk and a comfy chair.
I researched what was available on the market at that time that met my requirements, looked what had the highest value for the buck, and in the end I bought Mark Adler Leader 9.3 (picture below from this site).
I got two heavy packages soon after, assembled the desk, and happily started using it. I was content with my choice, the desk seemed to be just fine - looks elegant, two column construction makes it extremely solid and stable, the controller works well and has USB-C port for charging, and the cut-outs and felt organizer make cable management easy.
So, the desk was fine and together with the chair they allow me to sit/stand comfortably in from of my computer and not cry because of back pain. I could say it's the end of the story, task accomplished, and job well done.
Welp.
I could say that, only if I had not realized that one of the features I cared about, the collision detection, was not working properly 😠It wasn't mentioned on the product page, but was in the manual, so I assumed it's supported (apparently incorrectly).
It's important for me as I have a cat that likes to wander around the desk; the desk is surrounded by other things closely, so if it gets moved by accident to either side it will collide; and I like my shit to work lol
I got annoyed and decided I should do something and that's how this whole thing began...
Disclaimer: The whole project came to me on a whim and everything described here was done without much forethought. I just saw a problem, wanted to fix it and and keep my neurospicy brain interested by keeping momentum. Be warned about numerous wrong decisions lol
Ideation
So I started thinking (sometimes I do that, to everyone's welcome surprise) and started to consider my options.
I checked the desk's manual and found that there is a collision detection setting, which can be toggled between OFF and Low/Normal/Heavy force detection. I switched from one to another few times, checked if it'd stop, and got sad when it didn't work.
So I thought some more and realized that:
a) I know how to write code...
b) I have a bunch of items and tools needed for tinkering with electronics...
c) I have an electronic board that I was itching to use for something for quite some time...
... and I miraculously came up with an idea to build a Microcontroller-In-The-Middle device that could supplement the desk controller and improve the collision detection.
Initial Reconnaissance
I started with the first thing that came to my mind which was to raise the desk and look at the controller, both motors, and power supply unit.
Power supply unit: takes 230V in, puts 30V out
Motors: 24V DC
Controller: takes power via 2-pin connector and communicates with each motor via 6-pin connector
I've seen that connector before, but for crying out loud, I could not remember what it was called. I went googling, but to no avail.
I went the easy route next, took two pictures of the connector, put them into the ✨ all-knowing machine ✨ called Claude, and asked the simple question of "What connectors are those?" only to be told the wrong thing and be sent on like 15-minute long adventure of figuring out that the JST connector is not the connector I was looking for.
Claude did mention though something about the pin pitch and I'd learned that it's the distance between the centers of two adjacent pins. I grabbed calipers from my toolbox, measured the pin pitch and got the result of ~4 mm. I let Claude know that and it suggested that it could be Molex KK series with 4.2 mm pitch. I measured again and it was it... until it wasn't.
The pitch matched, but after looking at the pictures of the KK series I realized it wasn't the one, the plastic connector was different. I went on another googling adventure and after some time I found out the right one, Molex Mini-Fit series.
I found some Molex FiT Family Brochure (screenshot below from this PDF) with pictures and sizes and confirmed it was it 🎉
Building a sniffer
With the knowledge of how everything is connected physically, I went on to the logical (at least to me) next step, which is to make a makeshift sniffer to see what the specific pins do (it did not occur to me to just google that at that point, but much much later ;-;).
The idea was simple: buy Molex connectors, crimp pins, and some wires, use universal board and gold pins I had laying around, and build a sniffer.
So, I went on a shopping spree and got everything I needed:
The execution? Well, you'll see.
Why would I measure things before buying?
I started working on it and the problems appeared as if by touch of a magic wand 🪄
Problem 1: The Molex connector pin pitch was different from my universal board holes pitch.
It surprised me a bit (well, it wouldn't if I had measured everything beforehand, but who does that?), but not a big problem to solve. I just bent the metal pins of the connector to match the board's pitch.
Problem 2: Not only the metal pins were too thick to go through the holes, due to bending, they would be too short to even go through.
That stopped me in the tracks for a moment, as there was no simple and good solution. Another hurdle was that the cheap universal board I had was one-sided, which limited my options a bit.
That’s when I came up with a shitty, but working solution of threading the wires through the board and soldering the connector directly to them. This way the wire was soldered to the board via copper board and connector was stable by being soldered to the wires.
Problem 3: The other end of the wires was on the bare side of the board, which complicates next move.
I wanted to use gold pins, so that when I would make a male connector, I could use it for future boards. But gold pins would have to be soldered on the copper side and wires were on the other side.
I came up with another terrible idea of threading the wires through and soldering them on the copper side to the wide pads. Then, I soldered the gold pins to the board as one should. And then, I used additional short wires to solder all of that together.
Simple, right? RIGHT???
Then, the only thing left was to make a male Molex connector and finish the wires on the other side with female gold pins.
Once that was done, my Frankenstein board was ready!
Rapid questions round
Q: Couldn't I just buy a universal board with matching raster?
Yes, but I didn’t want to spend more than absolutely needed and it wasn’t easy to even find such board (I tried!).
Q: Couldn't I just keep the connector on the bare side of the board, solder to the threaded wires and solder the wires to the copper side?
Yes, but I’m not sure if it would be really better.
Q: Couldn't I just solder the wires directly to the gold pins instead of to the wide pads and adding another wire?
In retrospection, yes.
Q: Couldn't I just take some wires, finish them from both sides with Molex connectors and just get rid of a bit of shielding from each to connect probes this way?
In retrospection, yes. It would be much easier and arguably as bad as what I did.
Q: Do you even know how to solder?
I do actually! At least I think I know the basics lol
It’s just I haven’t done that in months if not years, I’m not sure if my soldering iron is not broken a bit, the soldering iron's tip is not in its best condition, and the soldering wire I used wasn't of the best quality. But tbh, I think the biggest issue was that I was doing it tired in the evenings/at night and I wasn't patient 😅
What do those pins even do?
Before playing with the sniffer, it'd be wise to know what each pin actually represents, right? Welp, I'm wise like that now, but when I was actually working on this project, I checked those kinda before and kinda after connecting the sniffer lol
I picked up my multimeter, got some weird results, and got confused. With Claude's help, I'd learned that DC motors like the ones in my desk have 6 wires, instead of just 2 I expected, because of an embedded encoder for collision detection. The wires are used for 3 separate purposes:
2 wires for 24V DC motor power
2 wires for 5V encoder power
2 wires for encoder's A/B signals
(screenshot from the Progressive Automations product's picture)
Again, with Claude's help, I was able to take measurements and identify each pin (until I messed up something, but shh)! Here are the results:
1. GND
2. 5V
3. A/B (encoder signal)
4. 24V / GND
5. GND / 24V
6. B/A (encoder signal)
Worky or not worky?
With the sniffer ready and knowledge of pins purpose (actually I didn't know it the first time I connected it, otherwise I wouldn't connect the 24V probe to the analyzer 😅), I could finally put it between the motor and the controller, connect the logic analyzer via the probes, and try to see what's being sent over the wires!
I used PulseView to capture the electric signals from the logic analyzer, which gave me the following output.
Whiiiiich is incorrect (partially) due to the fact that I forgot I have to connect GND from the wires to GND in the logic analyzer, but it does confirm that the POC works!
What's next?
I see two possible paths forward:
1. Connect the probes properly to the logic analyzer, sniff the signal while the desk is operated via the controller, and analyze the results.
2. Make a proper sniffer using the electronic board I have, sniff the traffic digitally via the board, and analyze in this way.
I'm not sure which way I want to go, but also, these options are not exclusive, so I might end up doing both!
Nevertheless, that's all for this article, the next one will appear soonish! Thanks for reading!