Make Yourself More Precise

I’ve invented a new and exciting way to probe circuits more precisely. An old idea used in a new context. After using it, I can say it is a must for any electronics bench. What is it?

I have been building electronic circuits for a long time, but only in the last few years have I gone all-in with itty-bitty surface-mount parts. I built a reflow oven. I got a stereo microscope so I could see what I was doing, and I practiced soldering and reworking under the scope. I was surprised to discover that for many operations using surface-mount components was faster and easier than using through-hole packages. Why hadn’t I switched earlier?!

The one part that was getting harder was troubleshooting the boards.

 I had a board with a chip in a little QFN 28 package, and each pad was only 0.25 mm wide. The board wasn’t working. I really needed to figure out what was going wrong, but some of the important traces didn’t go though any exposed areas except at those tiny pads. How the heck was I going to probe this thing?

If I just went in with a scope probe, I was certain to short something out. I just don’t have a steady enough hand to poke around with sub 0.25 mm precision. That’s when it hit me. Engravers use something called a Pantographic Engraver to put the tiny lettering on wedding rings. Could I make some sort of Pantographic Probe to let me probe around the circuit willy-nilly with crazy precision? Yes. Yes, I could. That’s how the Pantoprobe was born.

You can build a Pantoprobe for < $20 if you have access to a 3D printer and a few hand tools.  The project has even been featured on Hack-a-Day and Makezine!
I hastily modeled a basic pantographic mechanism to 3D print. The one tricky part about a pantographic mechanism is that the joints have to have very little slop or stiction. I decided to use telescoping brass tubing at the hinge of each joint, with a pair of washers reducing vertical slope. I used a camera ball joint (that I had sitting around) as the base. This ball joint also lets you tilt the probe at different angles, providing an extra degree of freedom that most pantographs don’t have.

I printed a few test joints. The joint design seemed to work very smoothly, and I was ready to give the full assembly a try. What to use as the actual probe? I had some spring steel piano wire around, so I crimped a bit into another piece of tubing, ground a tapered pad on the end, and stuck the whole thing through the center of the pantograph’s output joint. That plus an alligator clip and it was time to take the probe for a test drive. Would it work?

I was amazed to discover that not only could I reliably place the probe on the center of the solder pigtail of those .25mm pads, but I could feel the probe pressing into the solder. Crazy! That tactile feedback really makes it nice to use. The contact is more than stable enough for me to look away long enough to read the oscilloscope/multi meter. Trouble shooting tiny boards will never be the same!

I did some more designs to make the probe fold up more tightly so it could fit in my pack of trouble-shooting widgets. I also ordered some cheap ball joints from China since it seemed like I’d be making more of these things. The probe was a HUGE win: Cheap, not that hard to build, makes the impossible possible. What else could I do with this idea?

I could already do Pick and Place with tweezers, and it wasn’t a big problem. I had some parts sitting around for building a suction pick and place tool, but I’d never gotten around to building it because, hell, I could just do it with tweezers. What if I gave the Pantoprobe an extra-precise rotational axis and plumbed a suction tip into it? Would that be awesome? So I built this Pantographic Pick and Place device.

Now THAT looks like a actual mad science invention. I used two o-rings to act as drive belts for an index-finger controlled rotational axis. The suction comes in via a pivot that then passes though the pantographs output axis and comes out to a syringe with swappable tips. Here you can see a small green tip holding an 0603 resistor. This was a bit more complicated to design.

My 3D printer really got a workout. I printed 7 different versions of just the hose clip! I went crazy and even designed a box to hold all the tips. In the end, it works, it’s nice, but it doesn’t have quite the super high return on investment that the Pantoprobe has. It’s only two 0-rings and a syringe kit more expensive to build than the Pantoprobe. As long as you already have some system to provide suction.

If you do a lot of pick and place and would like a steadier hand, you should build one. But it doesn’t make the impossible possible like the Pantoprobe. That’s the real killer app.

What else?

I realized that for measuring high frequency stuff the Kurt’s-random-piece-of-piano-wire sure left a lot to be desired. Maybe I could make a scope probe holder for the Pantoprobe?

The scope probe was going to have to stick out at an angle so I could still see the end under the microscope. Because it would stick out a long way from the axis, I had to worry about rotational slop. So I designed this rod that slides from the output joint though the opposite joint to lock rotation. At first I thought of this as just an insert that pops into a stock Pantoprobe, but as I struggled to keep the probe from twisting/flexing, I realized I was going to need to do something that attached both at the top and bottom of the joint. I printed it in two pieces and glued them together, and I also glued them to the shaft that goes though the joint. There’s no removing that thing. I added two zip tie ports so the probe could be fully locked in if need be.

Did it work? Sort of. Through my microscope I can’t see the actual tip, so you have to kind of think “the tip is right below the arc that is the side of the probe,” which kind of sucks. It wouldn’t be a problem if you’re just using an Opto-Visor instead of a scope. I also eventually figured out that my “clever” bar and tilted probe arrangement was reducing the precision multiplier of the pantograph, to something like 2x.

That plus the greater flex from the long probe extension makes the system less ridgid. It works, but the confidence factor/feel are not as good. Sometimes things slip. Another round of design on this one could make it stiffer and also increase the precision multiplier. I’ll have to see. This one is still very much a work in progress.

Maybe it would be smarter to make the piano wire probe into a more real probe in some way? Using 10:1 resistor divider and some coax cable, etc.

What else?

I thought maybe I could lock down the base so it’s easier to probe one handed. The great thing about using a 1/4-20 mounting nut is that I can use any sort of cheap camera mount. Luckily I’d ordered a suction cup mount when I’d gotten the ball mounts, so I was ready to give it a try.

The bad news is it’s hard to get your board in close enough with all those suction cups taking up space. The good news is that one-handed operation is reasonable with this setup. Two-handed usage makes it easier to hop large distances, and feels a bit more fluid but one-handed works.

I tried using my Third Hand to hold the probe locked on some test point, but it was infuriating. It really just didn’t work at all. Trying to position it was a mystery of over shooting and undershooting. A true fail. I was beginning to think maybe a fully locked test point wasn’t going to be a thing I’d be able to do. Then I realized I was over thinking the problem. I discovered that with a bit of technique you could lock the ball joint with the probe just a bit above where you wanted it, and then you could position it and the weight of the probe would hold it in place. Woot! Now you don’t exactly want to dribble a basket ball next to the “locked” probe, but it’s better than “you can’t do that,” and for bigger/safer test targets like a via I’d say it is safe enough. Still the rig is kind of huge. Maybe a smaller suction cup base would make it a lot better.

What’s next? Maybe an Exact-O blade tip for cutting traces? A higher precision multiplier one for people with shaky hands? A Dremel tool holding one? A soldering iron one? I think there are a lot of other good ideas hovering around this one. Build yourself a Pantoprobe. Give it a try. You won’t regret it!

Where do you go from here?

I feel like this is an important invention. Looking around, I didn’t see anyone making a product like this which is kind of crazy.   So I’ve done a lot of work to get the word out. I have the basic PantoProbe models on github. I made a video explaining the probe and another showing you how to  assemble one.  I set up pantoprobe.com to have a central place to point people, and where people can share ideas.

After building quite a few of these probes I also realized that there should be a simpler version of the probe that doesn’t have the complicated joints.  A very simple flexure based model.  So I developed the PantoFlex.  It doesn’t have the same range of motion as a full on probe, but it is almost trivial to print and use.  I also make it come apart so it could be printed on some of the smaller 3D Printers.

PantoFlexParts

Get out there and try one!

 

Cat Door Project Comes -a- Knocking

bobertLookingExpectantOur cat likes to go out at night and his comings and goings cause us to lose a little sleep opening the door for him.   He has never put up with a collar, so I got an automated cat door that can read his imbedded ID chip so only he can get in.  I read in the Amazon reviews that the chip reader worked well, but that raccoons could learn to open it from the outside.  We live in the boonies with lots of raccoons and other critters, so I knew that was going to be an issue.

catFlapWithMotorizedCatchThe problem seemed to be that the chip reader could dynamically keep the door from being pushed “in”, but cats were free to push the door “out” from the inside.  Only a magnet keeps the door from going out.  The door is shaped to make it hard to pull it out from the outside, but apparently raccoons can manage it.  So I thought “I’ll add a beam break sensor and some extra locking so the door can’t push out unless my cat’s head is breaking the beam.”

A system like that would require an Infrared emitter detector pair and some electronics. I started designing it, and the design consisted of two timer chips, a bunch of resistors/capacitors some transistors, diodes, etc. I wanted it to fit into a pretty small space since I would have to integrate it into the existing cat door enclosure.   For a long time  I’ve wanted an excuse to try out some of those super tiny programmable CPU’s.   They come with internal clocks so you can get away with very few external components, and you can tune the behavior in software.   This cat door seemed like the perfect opportunity to give them a try.  Time to lose some sleep in the short term to try to gain some sleep in the long run.

railOfChips I decided on the ATTiny85 because it has 8k of program space, features a wide selection of internal timers/interrupts/analog to digital converters, and cost only about $.85 each.  They’re the kid brothers of the chips used for Arduinos. They use the C programming language and have GCC as the compiler. This sounded like very familiar turf.  I ordered 25 of the little guys to get the lower price point, make sure I had plenty of extras, and avoid the embarrassing situation of paying more for shipping than for the parts themselves.

USBTinyISPInPiecesSmallerUSBTinyISPAssembledI also ordered a USBTinyISP In Circuit Programmer that you get in kit form.   This past weekend the parts came, and I soldered up the programmer.   It’s all through-hole components and was pretty easy to put together.  They have a detailed step by step build of it documented on-line, although I personally prefer just a parts list and a population diagram.   There’s less scrolling around, and if you don’t happen to have a computer near your soldering area, having a giant scrolling assembly document is unwieldy.

ZIFprotoboardI also soldered up a board that has a Zero Insertion Force(ZIF) socket that wires the programmer to the program pins on the ATTiny85s.

I then downloaded the USB device driver for the USBTinyISP and the WinAvr tools, which include the compiler and a tool called avrdude that can use the ISP to program the chips.   By the end of that day, I managed to get avrdude to talk one of my tiny chips.  So far so good.

schematicForProgrammingHere’s a schematic of what I wired up to be able to program the chip.  The 6 pins of the programmer header are shown from above.

It wasn’t until the next weekend that I got a chance to try to run some code on the chip.   For the cat door project I need a 38khz signal to drive the Infrared LED.   That is because the IR receiver filters out all non 38khz signals so it can reject ambient light level changes and all kinds of other noise in the signal.   This is how pretty much all IR remote controls work and that’s why you can get a fancy receiver that does all the filtering for  cheap. Be careful when choosing a receiver module. Since they are used for IR data transfer, many of them can’t handle continuous 38khz signals.   If you just go get the receiver at Radio Shack, you’ll have to use bursts of 38khz to keep the receiver paying attention. That’s code complexity I’d like to avoid.

The ATTiny85 has timers/counters that can be set up to drive an output pin directly so I can setup the LED and forget about it.   That’s much nicer than trying to toggle the pin myself with a bunch of interrupts or code loops.   I found a nice overview of ATTiny timer programming and read though that.  I then read the ATTiny85’s datasheet to figure out exactly how to set it up on my chip.  With a full understanding of the chip, I should be able to avoid an unintended Rise of the Machines.  I did, however, only skim some parts of the datasheet ,so if you get word that I’ve been mauled by raccoons, head for the hills.

timerRegisters

Sorry this is so small

To set up the timer, there’s really only 3 bytes you have to fiddle with: two Timer/Counter Control Registers and the Output Compare Register ,which is the 8-bit number the counter compares against.  To have the counter run in a retriggering loop and have it toggle the output pin A each time it matches, I only really need to set these bits, and only two of those are non zero.

COM0A1 COM0A0   
  0      1        Toggle output pin A on Compare Match
WGM02 WGM01 WGM00
  0     1     0   Clear Timer on Compare Match

My first attempt at programming the timers worked, but there were a number of problems:

  1. outputting on the wrong pin
  2. totally at the wrong frequency

The funny part was that my programmer was upstairs in the house, and the protoboard/power supply/test equipment was in the garage.  I had to program the chip, pull it out and hoof it out to the garage.  I went back and forth about 10 times.  Who says hacking doesn’t provide exercise?

attiny85With38kI managed to get the output going to the correct pin. Then I got the clock prescaler turned off so the counter was getting the proper 1 Mhz clock.  Finally I tuned the output frequency in to as close to 38khz as I could get.  The counter counts up to a given number and then resets and toggles the output pin.   I’d originally calculated the count should be 26 since 1Mhz/38Khz is about 26.  Then I realized that the output pin toggles each time the counter is reset, which means the output frequency is actually half of what I was expecting.   So 13 was what I was looking for.   In the end I used 12, since the 1Mhz clock is only approximate (the chips running without a crystal) and it ended up being a better frequency match.  Or it could be that you want n-1 since we’re counting from 0.

What do I think of the 8pin CPU’s VS a pile of timers and discrete parts?

I won’t really know until I finish this project.  At the very beginning, this way has me spending more time installing device drivers, downloading and installing software, and fiddling with makefiles,  etc.     The other way lets you get right to the protoboard but is less flexible in terms of fine tuning the results.   Now that I have the tool chain up and running, the rate of progress has really increased, and the the rest of this project should be less annoying.   Tuning the output frequency might not have been as fast as adjusting a trim pot, but so far the only component I have is the chip!  I really should move the programmer closer to my test bench.

I’m starting to get the sneaking suspicion that I should have just sprung for the AVR programmer that Atmel makes.  It works natively with AVRStudio, which is the free IDE that they produce for their chips.  You can get the USBTinyISP to work with it too, but it sounds like you have to go though some wacky contortions to do it. I think the only real advantage the USBTinyISP has over the native one is that it can also power the external board via USB.  It also has a 10-pin programming header, but since I’m not trying to work with some board that has a 10-pin header, it isn’t much of an advantage.

I think if I were doing complex development with actual debugging, I’d go with the Atmel programmer just because it works natively with AVR Studio.   As it is I’m just doing code dumps without any interactive debugging, so it’s basically:  use your favorite code editor, write the code, and type “make”.   There’s even a make target that downloads the code to the chip, so you end up typing “make program ” a bunch.  Firing up AVRStudio for that would be way overkill.  So for this kind of dev a USBTinyISP is nice since I don’t need an external power supply for my programming board. This WinAVR way is simple, pretty much worked right out of the box, and it’s much smaller and less bloated than an AVRStudio install.

Here’s the code so far.  It just defines what pins I think I’m going to use, sets direction of the various pins, and configures the timer to toggle out of pin 5 of the chip.   In my next installment, I’ll try hooking up the IR receiver    I’ll also start dissecting the cat door, come up with a plan for how I’m going to lock it, and figure out what sorts of feedback and control I’m going to need.  Hopefully I’ll get to play with using the external interrupts and maybe I can even try out some power-saving modes.   I’d really like to put these chips though their paces and get a feel for many of the chips features.   Clearly with 25 of these little guys, they’re going to be showing up in lots of projects.

#include <avr/io.h>
#include <avr/interrupt.h>

#define IR_LED_OUT_PIN    (1 << PB0)
#define MOTOR_OUT_PIN     (1 << PB1)
#define SWITCH_IN_PIN     (1 << PB2)
#define IR_RECIVER_IN_PIN (1 << PB3)
#define OUTER_DOOR_IN_PIN (1 << PB4)

int main (void) {
    // Make it so the input from the switch will use the internal
    // pull up resistor.  Other inputs will have no pullup, and the
    // outputs will all be low.
    PORTB = SWITCH_IN_PIN;

    // Configure the motor and IR leds as outputs, and all the
    // other pins as inputs.
    DDRB = RELAY_OUT_PIN | IR_LED_OUT_PIN;

    // Configure the timer 0 to output on 0C0A with no pre-scaler
    // and so it'll  CTC (count down and auto reset) toggle every time
    // it gets to the compare.
    TCCR0A = (1 << COM0A0) | (1 << WGM01);
    TCCR0B = (1 << CS00);

    OCR0A = 12;  // 1Mhz/38khx = 26.3  Then you have to divide by 2
                 // you have to toggle twice to make the full wave.
                 // so that's about 13.  With my clock 12 ended up
                 // being closer.  No prescaler needed for these high freq.

   for (;;) {
   }
}