Firmware – Update

You may have been wondering what is firmware; it is the part of the AFM that sits between the software interface and the electronics that control the microscope. This means that we need to take care of two tasks: first, to listen to the interface and translate that into a signal that controls the scanning stage. Secondly, we need to measure the signal from the AFM and send it back to the interface. These tasks are accomplished using an Arduino and a microcontroller that we can program to read & write voltages. To do all these things at the right time and in the right order, we control the behaviour of the Arduino using C++ code, we wrote this over the past two weeks.

There are four distinct classes that handle all the problems that our microcontroller might encounter:
– The RTx class: that handles the reception and transmission of data between the Arduino and the Interface.
– The DAC controller class: that controls the motion of the scanning stage.
– The signal sampler class: that is in charge of measuring the signal the electronics team has prepared for us.
– The scanner class: that controls the three other classes for complete scans.

To control the stage, we need to smoothly control the voltage output over a range of voltages.
The problem is that our Ardunios can only send bits (only ‘high’ or ‘low’ voltages and nothing in between). To overcome this problem we need to use a ‘Digital to Analog Converter’ (DAC) (More info and detail here). Microcontrollers can talk to DACs using the so called ‘Serial Peripheral Interface’, this defines which bits we need to send for the DAC to understand what we want. The DAC we use takes one byte as an input, which means we can define our output voltage to be one of 256 discrete levels. Our DAC controller takes care of all this and makes control of the position of the scanning stage a breeze.

image

The signal sampler can jump into action and acquire data once the DAC controller has moved the stage by a certain amount. The two analog outputs provided by the electronics team is sampled several times (default value is 5). Each pair of values is added together to find the total focus error of the DVD head. Under the right conditions, this corresponds to the distance between sample and DVD head. Lastly, the median of the samples is taken as the true measurement, to reduce sensitivity to noise.

The scanner class coordinates the interplay between the other classes, to acquire an entire image.
This is done by having the DAC increase the output by one step, sampling that point and repeating that process to scan an entire line. Afterwards, the scanner will decrease the voltage again, scanning the same line in reverse direction. After one line-scan we need to send the data to the interface (due to low memory on the Arduino).

To send data, the RTx class starts listening for the ‘ready’ command from the interface. This way, we ensure that the interface is ready to receive more data and we are not scanning faster than they can receive and plot the data. After the data is sent, the scanner will do another line scan and iterate until the entire image is sampled.

With all the separate components of our device nearing completion last night we performed our first fully integrated operation! Combining the interface, firmware, electronics and mechanical components we were able to use our newly developed desktop app to initiate a scan, driving the piezo stage and receive data from the dvd head via the arduino to plot an image! Although there are clear issues with the images received (the upper left quadrant seems to be projected into the other parts of the image, suggesting the stage is halting halfway through the scan) we are now are a stage where we have an ‘operational laser scanning microscope’ just a fair bit of troubleshooting to go!

image