A project log for DIY Spin Coater

A spin coater is used to spread a thin layer of liquid on a flat surface to a very precise thickness, like photoresist on a PCB.

jeroen-delcourJeroen Delcour 07/21/2023 at 12:370 Comments

Jeremy Clarkson Driving an Ariel Atom | Know Your Meme

I FINALLY got the motor PID control working!

Like I mentioned in the project description, there's a few different ways to do PID speed control on brushless motors, depending on the ESC hardware and firmware. I decided to use the Dshot protocol to send throttle commands to the ESC. I owe many thanks to Chris Landa who wrote an amazing guide on how the Dshot protocol works. Implementing the Dshot protocol using MicroPython was definitely a challenge, but thanks to Chris, I didn't have to reverse engineer the protocol first (which would have been a real pain, since I've never reverse engineered a digital protocol before).

I used the RMT module that's on the ESP32 to send the very short pulses necessary for the Dshot protocol. In theory, the same module could be used to implement bi-directional Dshot to receive telemetry (such as RPM) from the ESC. Sadly, eceiving pulses is currently not supported in MicroPython. I could write a separate module in C just for the receiving part and import as a MicroPython library, but I'd have to seriously brush up on my C skills. Instead, I decided to pick an older ESC that has an extra telemetry wire. The telemetry wire uses a separate protocol which seems to be poorly documented. Chris Landa thankfully posted a link to a PDF document from an rcGroups thread that has enough details to work with.

However, I just couldn't get it to work. I banged my head against the wall for days trying to find a bug in my code or an issue in the wiring. I bought a special connector to hook up the ESC to my PC so I could look at some settings in the BLHeli_32 firmware. At some point, a friend of mine was gracious enough to lend me his oscilloscope and teach me how to use it. I wanted to see what the signal coming over the telemetry wire looked like. So I hooked up the probe and started requesting telemetry data using Dshot, but nothing was coming over the telemetry wire. No signal at all. It was steady at a rock-solid +3.3V. I spent another day looking for a bug in my code, figuring I must not be requesting the telemetry data correctly.

After many sunken hours without progress, I went for a Hail Mary and ordered a different ESC that also had a telemetry wire. I had originally bought a SkyStars Slim40A Blheli_32 128K from AliExpress. I didn't have the patience left to wait another two weeks on shipping from China, so I bought a more expensive ESC (a T-Motor F35A) from a local shop with next-day delivery. To my surprise and great relief, it worked straight away. Turns out there was no flaw in my code, it was just a bad ESC. Such is the way of the hardware hacker doing it on the cheap. Oh well, at least I learned a thing or two about digital signal analysis along the way.

After some tuning of the PID values, the motor was humming away and staying at the specified RPM beautifully. To simulate the increased load when the chuck and spin plate would later be attached, I pushed my finger against the motor as it spun to increase friction. It's fun to feel the motor ramp up and down to maintain the target RPM.

Here's a picture of the electronics inside the plywood enclosure. There's a lot of empty space and nothing is properly secured, but I figured it's fine for a prototype. Better to have things come undone sometimes than glue everything down only to find out you have to replace the ESC.