STM software

software

I finally got around to finishing up the Teensy software for my STM! The Teensy controls scanning, PI control of the Z-axis piezo, sigma-delta modulation of the scanner DAC outputs, and serial communications with a PC. I also wrote a C# program (screenshot above) that receives the serial data sent by the Teensy and displays the images line by line, and can set the scan parameters.

Here are the files:

There are simple libraries for the DAC8814 and LTC2623-16 included with Teensy software. Put them in your \Arduino\libraries folder. The PC software contains a .exe file and .exe.config file. Just put them in the same folder somewhere.

I’ll do a more detailed writeup on this later, but here’s a brief summary of how it works: the Teensy uses a timer to call a function at a regular time interval. This function increments the scan, performs PI calculations to update the Z axis, and performs sigma-delta modulation of the scanner DACs. Since the scanning probe is a (sharp, fragile) solid object, it’s velocity needs to be controlled at all times. If it moves too fast, it will likely crash into something, so the tip scans in a zig-zag pattern rather than a traditional raster (as in a CRT or SEM for example). Since the STM is always incrementing the scan at the same time interval, doing a slower scan will acquire more data. All data acquired between pixels is averaged, so you’ll get less noise in a slower scan. Once a line of the image has been scanned in one direction and re-scanned in the other direction, the Teeny sends the Z data and error signal data over USB.

If you need to invert the Z-axis signal, find the “#define INVERT_Z true” at the top of the Teensy code and change it to false.

The PC software receives the data, does some basic processing, and adds it to the images on the screen. The left image is the topography (Z signal) and the right image is the error signal. The error signal looks like the gradient of the Z signal and has more high-frequency content. The topography data is displayed line by line in the graph at the bottom of the window. The red curve corresponds to the most recent scan line, and the blue curve is the same line scanned in the opposite direction. Ideally, these curves should be identical, but the agreement will never be perfect due to piezo hysteresis and things like that. If they don’t agree at all or show oscillations, try lowering the line rate, proportional and/or integral gains. For scans larger than ~500 nm or so, you’ll probably want to scan at ~0.5-2 Hz or so. For scans < 10 nm, you’ll want to go much faster to minimize thermal drift effect, ~10 Hz or more. You can also decrease the number of pixels to increase the speed.

Connect a LED to pin 0 on the Teensy. This is used to indicate serial communication is active. Connect another LED to pin 1. This one lights up when tunneling is achieved.

To use the software:

  1. Upload the code to the Teensy
  2. Turn the microscope on and start STM.exe
  3. Select the Teensy’s COM port from the list
  4. Do coarse approach until tunneling is achieved
  5. Press “Engage tip”. All this does at the moment is start the scan. You should see data coming in.

Images are saved as 16-bit, multi-page, uncompressed tiffs whenever a scan completes. You’ll want to use a program like Gwyddion to process the images, otherwise they’ll mostly just look gray. To view the error signal image (page 2 of the tiff), load the file into Gwyddion, click “Info” -> “Show Data Browser”, and check the box next to the error signal image.

There are still some issues in the PC software but it should work for the most part. It crashes on exiting, and I think I know what might be causing this but haven’t managed to fix it yet. I’ve also noticed that scan lines in the saved images are sometimes missing. CPU usage tends to be high when scanning at higher line rates. I’ll hopefully have a fix within a week or so and will update this post once I do.

If you find any other issues or have suggestions for improvements, please let me know in the comments!

Advertisements

25 thoughts on “STM software

    • This version of the software is for use with manual approach only. The feedback loop is always active. You have to manually bring the tip into tunneling and then click “Engage tip” in the software to start the scan. I had planned on adding motorized coarse approach to this software but ended up rewriting the whole thing, and haven’t published it here yet.

      Like

    • Very nice! The tunneling current images are not blurry at all, they look great! If you want sharper topography images, you can try reducing the scan speed and maybe also the resolution, and taking a smaller scan.

      Like

  1. Hi Dan,
    Great work on that project!
    We would like to know if there is any other option instead of using the DAC8734, just because it has been so hard to find for us.

    Like

    • Hi Genis,
      Thanks! Yes there are many other options that will work. I use the DAC8814 in my current design for example, it’s shown in the schematics on the electronics page.

      Like

      • We used the DAC8734 and the ADS8517 in our STM, we tried to give a try with your software but as expected it did not work at all. We believe that by changing the libraries and changing some sentences should be enough, is there something else we must change?

        Like

      • You’ll have to modify the DAC8814 and LTC2326-16 libraries that are included with the Teensy STM firmware (DAC8814.cpp, DAC8814.h, LTC2326_16.cpp, and LTC2326_16.h), to work with the DAC8734 and ADS8517 SPI protocols instead. These files are pretty simple so it shouldn’t be too much trouble. Let me know if you run into issues.

        Like

  2. Dan,
    Great work. I am wondering how your STM will work with biological specimens? I would love to get up close and personal with some nematodes. As usual buying my own STM is way out of the question. I think i can afford your design.
    Jon S. Waldport Oregon

    Like

    • Hi Jon,

      Sorry for the late reply! Unfortunately STM isn’t suitable for imaging something the size of a nematode. The scan range of an STM is typically only ~1-10 um or so. The sample also needs to be conductive (or a single molecular insulating layer on a conductive surface). Sounds like an optical microscope of SEM would be more useful.

      Best,
      Dan

      Like

  3. Hi Dan,
    I just wanted to take a moment to thank you for documenting your work on your STM. I’m happy to say that I just got mine up and running too. I made the scanner several years ago, and it’s just been sitting on my desk until this week. I’m imaging gold plated connector contacts. It’s amazing how well this fairly simple machine works.

    Like

      • I wanted to share some results and attach pictures to my post, but I don’t see that option. Any way to do that?
        Also, I was wondering if you could share typical scope captures of your Z and error signals during scanning. My setup is having some trouble keeping the error steady during scans — especially the faster scans.

        Like

      • Maybe upload them to an image/file sharing site and share a link?
        The image at the top of this post is an example of a good Z trace and retrace. You can see the red and blue lines match up very well. That’s what you want to see. Don’t worry too much if the error signal seems to be jumping around a lot.
        For faster scans you’re ultimately limited by the scanner rigidity, and I find that for a ~1 um scan I get good images around a 1 Hz line rate or lower. Keep in mind most of the images I’ve posted here are of very smooth samples, so you might find you need to slow it down a bit. Try 0.5 Hz, and set the P-gain to zero to start, then adjust the I-gain to maximize image detail. If you start seeing oscillations in the tunneling current signal, lower the I-gain. If the image is a complete mess, the I-gain might be way too low which can cause a crash, and you might need to change tips.

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s