All posts by ron

AutoScope : Part 5 : Displays

Dr.  Dan Kott is a task master. At this point I’ve got steppers working, IR and Joystick Control, and have figured out our 3D printed part issues (at least when it comes to gears). In about a week. But, what does he have, more!

Take this with a grain of salt, because I consider Dan a friend. This is an inspiring person. A Renaissance Man in the truest sense. Tell me how many 85+ year olds are have more Raspberry Pis and Arduinos than most people have TVs. I’ve joked with him that his living room has enough computing power to send mankind to the moon. But, the moon would not be good enough for him — Mars, at least.

So, Dan wanted a display. I wanted to go with a large scale LCD display, but — I don’t have enough free pins on the microcontroller. (Most basic LCDs require at least 6 pins, and I’m using a cheapie Nano — which is busy doing motor control and IR remotes.)

And so I hunted down a cheap I2C (serial) OLED display on Amazon. These are pretty amazing devices, since you just need two pins to drive them (clock and data), plus power. Horray! A display that uses fewer pins.


Oh, but so small! Here it is next to a larger sized LCD display:

AutoScope_DisplaysAnd can you guess what problem I had? Not enough I/O pins? No, I went with a serial display to avoid that. But, the library size!

LadyAda has created an excellent OLED library for this type of display. But, when I try to compile — not enough memory. At first I was going to “slim down” her library. But I gave up. Instead, as a good programmer does, s/he finds an optimized version of the code.

Now, don’t get me wrong, Limor’s library is excellent. But I didn’t need graphics. I just needed text. And found (on github, again) a basic library called SSD1306Ascii. The SSD part is the display driver chip. The Ascii tells us that it only displays ASCII text (letters/numbers/basic characters).

With this slimmed down library I was able to compile and load the code onto my Arduino Nano board and get things running. With the remote, I can even enter direct coordinates:


Next up: improving the motor mounts




AutoScope : Part 4 : Manual Controls

Based on the examples provided by Brainy Bits, we started with controlling the motors with an analog joystick. These are really cool devices that work nicely with any microcontrollers (PIC, Arduino, Propeller, Pi, whatever).


The added bonus? The Geek Mom automated Etch-A-Sketch project already included excellent code for “normalizing” the joystick input. If you are using one of these joysticks with Arduino, get her code. What it does is translates the X/Y into values from -1 to +1. And ignores random centered values. No more converting from 0-1023 (Arduino analog values). No more complicated code. She has figured that out already. Did I say I liked her code? Well, I love it.

For a while I had the scope moving around happily with the joystick. And, it’s pretty awesome to see the scope move around using this little thumbstick.

But — now I needed to add features. Like entering coordinates. Like starting and stopping. Like taking photos. Buttons. And guess what? With the “old school” stepper controllers I need 4 I/O pins per motor — so just X and Y take 8. Want to automate focus? That’s another four. And the joystick takes X/Y/Button just on it’s own.

And so it was time to say goodbye to the joystick.

Fortunately, I remembered that I had purchased a cheap IR remote and Receiver from Adafruit — about 5 years ago. I never got to that project, but look at the remote — it has exactly what I needed:

AutoScope_IR_ControlArrows! Start/Stop! Setup! Numbers! Everything I need.

And, the best part, I could get all those commands through just one data pin! So, goodbye lovely joystick, hello IR remote.

AutoScope_IRSetupSo, I got back into the code. And ripped out all the beautiful joystick logic (sorry!) and replaced it with IR logic. Which requires a library.

Of course, there are a ton of IR libraries out there. There are the ones written by Limor Fried (Lady Ada), there are super powerful one written by Ken Shirriff. But, guess what happened?

Memory happened. As I add libraries, the memory constraints on the Arduino Nano became tighter and tighter. Ken’s library did everything I needed — and more — but was pushing my memory limits (remember: I still need to support a display, and maybe internet connectivity).

An aside: This is one of the reasons why I love working with microcontrollers — they limit you. In current development tools, you just throw more servers at a problem. What used to be solved with a 2K program is now in a 2Gb deployment package. And that’s crazy. It allows you to be sloppy, instead of really thinking through a solution. We landed men on the moon with less computing power than your pocket calculator (which has been replaced with a super computer — i.e. your telephone).

And so I searched and found a slimmed down version of Ken’s IR library. In a nutshell, it removes all the transmit code (which I don’t need) and the remote-specific code (ex. Sony, Panasonic, Sanyo, etc). I didn’t need that code since I have a no-name remote and had to map everything manually anyway.

So more trial and error, cleaning up code, and  I was able to control our scope with an IR remote (one data pin!). And can now handle things like direct coordinate entry, automatic homing, and more. And if my IR remote doesn’t have enough buttons? I find one with more.

Next: Displays



AutoScope : Part 3 : Steppers

Our doubts are traitors
And make us lose the good we oft might win

Moving a microscope stage around is not an easy job. Made more difficult by trying to retrofit motion on a manual scope. (There is a very good reason why the commercial solutions are so expensive — it’s a complicated problem.)

Dr. Kott started the project using the setup designed by the pathologist in Australia. But had problems. And so we played with different steppers. Different controllers. Different methods — steppers and gear? Steppers and linear actuators? Move the slide, not the stage? Attach the motors differently? We’ve gone back and forth a hundred times.

Two primary issues: How to drive the knobs (hardware) and how to control the motors (software).

Writing up our thought processes would probably take a novel, so let me summarize some key “lessons learned” for those working with steppers and wishing to automate microscopes, telescopes, X/Y plotters, or whatnot.

If you are using bipolar steppers, or unipolar steppers which can act as bipolar, I recommend motor control boards such as the Easy Driver (available from Brainy Bits, and others). These are excellent motor controllers — but their limitation is bipolar steppers. (Dr. Kott found these, and I highly recommend the technique — if you are using bipolar steppers.)

Which comes to our problem: The steppers were are using are the extremely common 5 wire unipolar geared steppers. They are small, and geared, so are perfect for applications such as this. But, the nice stepper drivers out there (like the Easy Driver) won’t work with them. So you have to use their included “controllers”.

And their “controllers” are a misnomer. They are NOT stepper controllers. They are simply Darlington Transistor Arrays — a method which allows a low power device (like an Arduino) to control higher powered devices (like DC motors). They aren’t “smart” like the Easy Driver. It’s not a smart chip — it’s just a bunch of power transistors in a DIP.

On the software side, we’re using an Arduino. The long and short of it is that you should use the AccelStepper for most all of your stepper needs. It’s well written. It’s non-blocking. It has a lot of neat features. Don’t bother with the default Aruino stepper libraries — just start with AccelStepper.

But, we didn’t use that.

Why? Because I was lazy and didn’t want to recreate the wheel. While researching how folks were using the geared unipolar steppers, I was reminded of a Geek Mom post about a stepper controlled Etch-A-Sketch.

And guess what? She used exactly the same motors. And needed to move things in almost exactly the same way as I did (X/Y). And had already written the code.

So I took her library, stripped out things I didn’t need, and now use it as our primary method of working with the motors. It doesn’t use AccelStepper, but it does handle everything we needed. And works perfectly with the unipolar steppers and their “controller”.

Believe it or not, this is the super-short summary of our motor control process. In the end, we used these inexpensive geared unipolar steppers, their included boards, and a library created by someone automating an Etch-A-Sketch. That’s what Product Development is all about.

Next up: Controlling it.


AutoScope : New Ideas from the Austin Maker Faire

One of the things I like about the Maker Faires is the feedback you get. You meet all sorts of interesting people. Some are technical, many are not — but love to see the stuff. And I love getting feedback and ideas from others.

Some ideas from teachers:

  • The Wet Slide problem. One teacher mentioned that viewing “pond life” (a drop of water) and showing it to the kids is a problem. By the time you’ve focused on an organism, it’s moved. The AutoScope would allow the teacher to project the slide onto a screen and then follow the critters with the remote control. Almost turns the process into a video game!
  • A Pathologist can use it as a teaching/test tool. For example, s/he locates items they want the students to find and identify. Students then take the slide and must find and tell the teach the coordinates/region they found the item in.

After telling the story the 100th time (trust me, I didn’t mind!) I realized that the scope could be used for remote analysis of slides. Let’s say you’re in the middle of nowhere, but have a microscope and this setup — you could allow a pathologist, or other physician, from anywhere in the world to control your scope. No need to ship or digitize the slides.

The cost factor was also a great turn-on. The commercial products, which include controlled stages and scanning, are just so expensive. The AutoScope allows not only schools access at a low price point, but also under-served communities, around the world.

While many were happy enough to look at a slide (the kids loved it) I found a number of older adults were very pleased with the project. The idea of making an expensive endeavor affordable. The ability for serving communities that can’t afford local pathologists. Helping people throughout the world. The reaction was really wonderful. I had more than one group walk away talking about how they could use this in their school or hospital. And, the most satisfying for me, people walking away thinking that the world is a better place — because there are folks out there making things to help humanity.