October 7, 2014

Laser-cut boxes

I frequently build new physics equipment ---as I say, 2nd-best job in the world--- and if the new equipment is something that's going to be used frequently I try to build a semi-permanent version. This frequently requires some sort of electronics box.

Last week we got our new Laser Cutter working here in the College of Natural Sciences, and wow! This changes everything. Previously the process would be "order a metal box of about the right size, then cut holes in about the right places, then print labels with a labelmaker and call it good." With this laser cutter, though, the results can be pretty spectacular.

I took about three hours last weekend designing the box. Most of that time was spent learning how to use the drafting program I installed on my Mac. (DraftSight, if you're curious. Seems good, and free for education use!) I could probably do the same design in about 20 minutes or less now that I know how to use the program. Here's the design:


It's designed to be cut from 1/8" acrylic sheet, and all the tabs interlock so it holds together nicely. The laser cutter software detects different colors and interprets them to mean different laser power/speed. For this one I set the red to high speed and low power, so it just marked the plastic. The black was set to high power, medium speed, so as to cut the pieces.

Here's the resulting box:


That doesn't have the circuitboard in it yet (a student is making it for a project) but it has the mount points for that circuitboard already. It's pretty slick! The acrylic sheet comes in different colors also, so clear is not an absolute necessity. The lettering shows up well: at high speed/low power the laser just makes a fingernail-deep "scratch" on the plastic, which is reasonably visible. To increase the visibility, I rubbed the lettering with a dry-erase marker and then rubbed the surface clean. The marker ink stayed in the lettering groves and shows up quite nicely. I held the pieces together by solvent-welding with Methyl Chloride (use a fume hood!) but superglue or model cement would also work.

I need to re-think how I do this, though. For my entire career, any time I've needed to make holes for banana jacks I just drill a round 5/16" hole; so for this case, I cut a round 5/16" hole. But the banana jacks aren't round! They have flats on two sides so they don't twist in the hole. It's never been an option to use those flats before, since with a drill press all holes are round... But with this laser cutter I can just as easily make holes with those flats on them. Same with the BNC connectors on the front: there's a flat on the threads to keep them aligned. Now I can use that! I can even cut square holes for meters or NASA-style mil-spec switches.

June 3, 2014

Programmable Servo Controller

This is an update on my earlier Remote key-switch operation post. These things have become rather useful around the lab! In addition to the original key-switch operation, they've been put to use running optical shutters for pump lasers, turning deposition shields inside vacuum chambers, etc. Basically, any time we have a mechanical device we want to be in one of two positions, we use a servo and this board.

The only problem is the inconvenience of programming the limits on the servo. Each application has different desired positions for 'on' and 'off' logic level, and we were having to break out the AVR Programmer each time... So here's the fix. This version has user-programmable limits!
After first turning the device on, apply one logic level (low, say) then press the 'Learn' button. While holding the Learn button, adjust the servo position with the 'Adjust' potentiometer. When the servo is in the desired 'low' position, release the 'Learn' button and the ATtiny45 will store that position in EEPROM. Then apply high logic level, and use the 'Learn' button to teach the microcontroller where the servo should go for high input. Releasing the 'Learn' button stores the high position in EEPROM. From then on, even after power cycling, the device will remember where it needs to go for high and for low input. You can re-program it any time, as often as you like. (Well, up to the limit of EEPROM write cycles for the ATtiny45, which is about 10,000 or so.)

The LEDs indicate power, logic state, and whether the servo is currently 'active'. That last one deserves some more explanation... Servos twitch. They jitter. They are not mechanically (or electrically) quiet. This is an annoyance sometimes, and a serious disadvantage if you need to mount the servo on an optics table. So the other feature to this device is that it turns the servo power off when it's not moving the servo. This may be a disadvantage if you have an application for which the holding force is not negligible, but it's acceptable for our applications. There's a switch in the code so that you can leave the servo power on continuously if you wish.

Another improvement to the previous circuit is that the PWM signal on this version drives a transistor buffer which drives the servo, rather than driving the servo directly with PWM. This allows the circuit to control much larger servos reliably.

It's still limited to 5V supply. The obvious next version would be to add a voltage regulator for the microcontroller, and drive the servo with whatever supply voltage you wanted... but we haven't needed that increase in servo power yet, so haven't bothered.

Here are the EAGLE files and the ATtiny45 code.