More fiddling with switches

Following up on using optocouplers to press buttons, I have created a new device that switches off an USB power cable on demand. This is required to perform automated testing.

I have used a Digispark as a microcontroller, because of its very small form factor. All it has to do is emulate serial over USB (which is done by software) and toggle two GPIOs with enough output power to drive two optocouplers. Those will control an Adafruit on/off switch, which is essentially a power transistor controlled by some latching components. This is rated for up to 3A current, which should be enough for most applications.

There are some annoying bugs in the Digispark's USB serial software stack, which have given me a few hours of headaches, but overall the setup works reliably. In the process of looking for the root cause I moved some developments from Python with PySerial to native C code with Posix calls. This has been an interesting move and I look forward to doing more posix developments in the future.

The most challenging part in the process remains the mechanical assembly, because soldering all the parts together and stuffing them into a box risks breaking the parts. For one sample it is hard to justify the cost and learning curve of designing custom PCBs which can be ordered online, but I might trying one day. I also have some components ordered to try low power relays in the same type of application.