### Z Depth of Field Calibration

I've had a challenge figuring out the actual values to use for the depth of field.

I tried an experiment.  With the 10x objective and the 2.5x camera adapter I believe that I want to turn the fine focus knob 10/200ths of a revolution per image - conveniently, this matches the 200 steps of the stepper motor.  So for the Z axis calibration I am going to set the GCode to 10 steps per mm, and assume my depth of field is '0.1mm'

When I recreated the experiment with different pieces of paper I got results up to 6 increments off - that is, I would require p to 6 more photos at these resolutions.  I think.

Here is one experiment.  I created a stack of twenty sheets of oragami paper and used a micrometer on them.

0.0525" or so.  Or about 1.3 mm or .065 mm per sheet.

For these images:
10x objective.  2.5x adapter, I think 400x?  This is the main objective I think I will use on this rig.

I have determined that one full turn of the fine focus knob is 0.2mm.  There are 100 hash  marks, with numbers 0-180, so a hash mark counts for '2' units.  So each hash mark is 2 microns of z control?

The numbers on the fine knob
are arbitrary.  When you move the coarse focus the fine focus stays in the same place, so you can
reset the fine focus by moving the coarse focus knob.

By moving 5 hash marks at a time I took a stack of 13 images with a 10 micron movement of the z axis between images.

(please correct my math if it is off?)

To my eye the left side is in focus in zwork_001, and the right side is best in focus in z_work_010, or about 90 microns, 0.090 mm for the optimal stack of a back up .065 mm?

images:
zwork_001 - fine focus knob at '60'
zwork_002 - 50
zwork_003 - 40
zwork_004 - 30
zwork_005 - 20
zwork_006 - 10
zwork_007 - 00
zwork_008 - 190
zwork_009 - 180
zwork_010 - 170
zwork_011 - 160
zwork_012 - 150
zwork_013 - 140

I think the yellow sheet is in best focus at '170'

The images are on flickr at:

## Debugging

I set the GCode to 200 steps per mm (and 200 steps per inch, just in case the units were not being set explicitly).  The stepper motor I _think_ has 200 steps per rotation.  So I think 200 mm should equal 1 revolution.  It doesn't.  So that is strange.

It seems that the focus is 'drifting' over the course of taking multiple images. This is my testing of the focus rig. Test Hardware/Software: -Is the software and hardware consistent/repeatable. Can I turn the Z stepper back and forth and have it repeat a sequence of steps?

The knob goes from 0-200
I want mm to map to the knob settings evenly, but it does not right now.

Test 1. Set the fine focus knob so 0 was at a hash mark. With Max went +10mm and -10mm five times. The knob goes from 0-200. The first time the knob went to 244, and returned to 2 (the first hash mark). The next four times it went to 244, and returned to 2. So my initial setting of 0 may have been a backlash issue.

Conclusion 1: There is potential backlash the first time, so maybe go to the top and bottom of Z and check before starting a stack.

Test 2. What about a serious of steps in the same direction, and then reverse them.

Flex in the tube.  The tube does flex under rotation, about 20 on the dial in either direction, but when released it springs
back pretty closely.

So now do a series of steps in one direction, then reverse them.