Ben Krasnow of Applied Science reverse engineered an electron microscope to add image capture using a Teensy-LC.
The image capture system allows Ben to connect a computer to the electron microscope and capture images directly.
He started with analog video signal that the SEM (scanning electron microscope) is outputting and digitized it using a Teensy-LC to send the digital values over USB to the computer. On the computer a Processing.org script displays the image in real time and optionally saves the frames.
The microscope doesn’t have a port to capture an analog video signal, so by probing around on the circuit board along with the schematic, Ben was able to find a signal that would work.
He used opamps to translate the -12V to 12V signal to a zero to 3.3V signal, and also extract the video sync pulse. After searching around around he found that using the programmable delay block (PDB) is recommended for projects like this. This seemed like the way to go until it was discovered that he had a Teensy-LC on the shelf which doesn’t have a PDB. When he started coding he had a challenge on his hands to made the signal processing code work without the PDB. He ended up using interrupts, which proved to be challenging. Interrupts can’t be trusted for accurate timing because there could be an undetermined delay when the interrupt fires leading to variable timing. Playing with interrupt priorities and writing the code as efficiently as he could he was able to get consistent timing for 142 kHz sampling.
It’s well worth the time to watch the full YouTube video. Ben does a great job explaining how he accomplished this project. Ben has a link to his source code in the video’s description.