Site hosted by Angelfire.com: Build your free website today!


SOFTWARE Screenshot from early software version




C language was the language of choice for the software developed. The main console program hosts a number of subroutines that drive the various STM functions. The default display is an oscilloscope trace, showing the actual value of the Z-signal. During approach it depicts the inward and outward motion of the tip as it hunts for the sample surface. Once the tunnel current is obtained, it depicts the vertical height of the sample at that position. A single line scan (X-scan) can then be repeated for a few times to check if tunneling conditions are stable. If they are, scanning at constant Y should give the same height profile over and over again. A full raster can than be scanned which is stored in memory and is then saved on disk.

During a raster scan, the image displayed is a "contour map" of the sample surface, the height at each point being represented by 256 shades of grey. The completed image can than be processed using filters that do noise removal and auto-scaling. The image can also be rotated in steps of 90 degrees. Finally a three-dimensional view of the surface can be generated using the surface rendering routine. This employs a technique, similar to raytracer routines, whereby the intensity of reflected light is calculated for each location on the surface.

To this end, the surface is subdivided into tiny triangles and the reflected light intensity at each point is calculated using the SCALAR PRODUCT of the NORMAL to the absolute VERTICAL. The NORMAL to each triangle is derived by calculating the VECTOR PRODUCT of two of its sides and then scaling the resultant vector to unit magnitude.

In order to even out certain inconsistencies, such as piezo creep, sampling times must occur at regular intervals. This task is complicated by the fact that the processor has to attend to other tasks in between samples, so a loop that increments a counter cannot be used for setting sampling delays.

Ideally the timer on the PC should be programmed to give interrupts at the required sampling intervals. However tentative steps in this direction failed, probably due to the fact that this interrupt was already in use by the operating system. The operating system may tolerate chaining to the same interrupt, but it would not allow a different periodic length. An external interrupt may be handled more easily, but would require additional hardware. In the end, timing was achieved by polling the speaker clock.

Each of the main loops in the program ANALOG60.C include a call to the function Gap_control( ). Gap_control( ) waits for the correct sampling time, samples the Z voltage, and makes the required adjustments to Iref, depending on the stage of operation. During coarse approach it also sends commands to the stepper motor driver routine, Stepper( ). These loops are kept short to enable as high a sampling rate as possible. It was felt necessary to include a watchdog function in the timer routines to guard against late sampling. An error is signalled by the timer routines if a sampling window was missed due to an excessive delay in the loop.

TIMING6.H is the include file for the timer routines. Start_timer( ) sets the "decrement and repeat" mode, with the counter being reloaded with 0xFFFF after counting down to zero. The timing intervals are defined by the increments that bring about a change in the higher order bits of the counter. The number of highest-order-bits monitored is variable, from 2 to 8, with the lower numbers corresponding to longer delays. This selection corresponds to the parameter passed to Wate( ). Wate( ) also watches out for a skipped count, which would be signaled with an error flag, on returning. Wate( ) stores the latest count in the static variable klokref, for comparison with the next poll.

The basic I/O routines for the analogue card are to be found in IOBOARD3.H. Get_sample( ) reads a 16-bit word from the one ADC on the board. Write_word( ) sends a 16-bit value to the DAC specified. The iocard routines get machine-specific parameters from IOHOST.H. This tiny file contains the Centronics port addresses, a flag indicating whether the analogue card is present, and may also include a flag indicating whether the "hemisphere" test simulation is to be used. This file promotes portability for the program while it is still being developed.

The sequence of signals from the routine Stepper( ) make up the travelling wave that nudges the stepper forward. It monitors the variable stepcount in daemon mode and then proceeds to move the number of steps requested. Each half-step is calculated to be at least 3.5ms long, which conforms to the stepper-motor/stepper-driver specification.

Another feature for the user interface is Set_doubling( ), that provides an exponential scaling function for the scan magnification. With the original equipment, the size of the scan area was altered through ganged potentiometers. But the scan frequency changes that this would require could only be affected by changing the value of two capacitors. The new setup is not only more convenient, but also needs no adjustment. This is because, the step size on the piezo is kept constant, regardless of the scan width.

PLEASE NOTE: The graphics driver included, EGAVGA.BGI , is not actually the original one from the Borland C++ package. It is instead a 256 colour version that has been renamed. Note also that the software may run at half speed on other system as my motherboard, which was purchased second hand, may be overclocked.



Source Files