1 Introduction

Many industrial manufacturing and measurement fields require autofocusing systems to control a light beam focus to be matched onto a target surface for precise machining or non-contact optical and vision inspections due to their high accuracy, rapid response, and relatively low cost [13]. As a result, in recent years, many autofocusing microscopes have been developed and these autofocusing microscopes can be broadly classified as image-based or optics-based methods [418]. But autofocusing microscopes of the image-based method are rather time-consuming during autofocusing procedure, and the depth of focus constraints limits the maximum focusing accuracy which can be obtained [19]. In other words, this kind of microscope may not achieve a satisfactory response and focusing accuracy for the requirement of manufacturing and inspection processes. In order to resolve this issue, many sophisticated optics-based autofocusing microscopes have been proposed in recent decades [2034]. However, to the best of the authors’ knowledge, existing optics-based autofocusing microscopes generally achieve a satisfactory focusing performance over only a limited range [35]. Accordingly, in a previous study, the present group proposed a novel optics-based autofocusing microscope with two optical paths capable of providing both a large linear autofocusing range and a rapid response without any loss in the focusing accuracy [36]. Moreover, for on-line or off-line automated optical inspection and machining applications, rapid focusing response is important to fulfill a real-time requirement throughout industry. It is necessary to improve the focusing response time of autofocusing microscopes yet further with the continuing trend toward high performance [37].

Accordingly, in the present study, the focusing response of the developed autofocusing microscope presented in [36] is further improved by replacing the two optical paths with one tunable optical zoom system. The zoom out optical path is used to achieve a less-precise focusing accuracy over a longer linear autofocusing range, while the zoom in optical path is used to achieve a highly precise focusing accuracy over a short linear autofocusing range. The two zoom out and zoom in optical paths and a self-written autofocus-processing algorithm are combined to achieve a more rapid response without any loss in the autofocusing range and focusing accuracy. The performance of the proposed autofocusing microscope is characterized numerically using commercial ZEMAX software and is then verified experimentally using a laboratory-built prototype.

The remainder of this study is organized as follows. Section 2 reviews the structure of the conventional and developed autofocusing microscopes presented in [36]. Section 3 describes the autofocusing microscope proposed in the present study with one tunable optical zoom system. Section 4 describes the numerical evaluation of the proposed autofocusing microscope. Section 5 discusses the experimental characterization of the proposed autofocusing microscope using a laboratory-built prototype and compares its performance with that of the developed autofocusing microscope presented in [36]. Finally, Sect. 6 presents some brief concluding remarks.

2 Review of conventional and developed optics-based autofocusing microscopes

This section reviews the basic structure, mathematical background, and optical architecture of the conventional and developed optics-based autofocusing microscopes proposed by the present group in [36].

2.1 Conventional optics-based autofocusing microscope

Figure 1 shows a schematic illustration of the optical path within a conventional optics-based autofocusing microscope with only one optical path [36]. As shown, when the collimated laser beam is incident at point A on the target surface which is located at the focal plane of the objective lens, it is reflected from the target surface and then is incident on the CCD sensor at point A′. When the target is moved a displacement +δ, the laser beam strikes point A1 on the target surface. Then, it is reflected and incident on the CCD sensor at point A1′. According to the geometrical relation, the following equation can be obtained [35, 36]:

$$\Delta = \delta \frac{2dK}{{f_{1} }} = \delta \frac{{2df_{2} }}{{f_{1}^{2} }},$$
(1)

where Δ is the distance between point A′ and point A1′, d is the radius of the collimated laser beam, f 1 the focal length of the objective lens, f 2 is the focal length of the achromatic lens, and K (=f 2/f 1) is the total magnification of the objective lens and the achromatic lens. Equation (1) infers that the defocus distance δ and the laser spot’s displacement Δ are linearly related.

Fig. 1
figure 1

Schematic illustration of optical path in conventional optics-based autofocusing microscope [36]

Figure 2 shows the image of the laser spot on the CCD sensor surface given different values of the defocus distance. As shown, the geometrical image centroid coordinates (x centroid, y centroid) can be expressed as

$$x_{{\text{centroid}}} = \frac{{\sum {\sum {xP_{ij} } } }}{{\sum {\sum {P_{ij} } } }} ,$$
(2)
$$y_{{\text{centroid}}} = \frac{{\sum {\sum {yP_{ij} } } }}{{\sum {\sum {P_{ij} } } }} ,$$
(3)

where P ij is the intensity of the pixel located at the intersection of row i and column j, and i and j are the row number and column number of the CCD sensor, respectively. According to Eqs. (1), (2), and (3), it can be observed that assuming the image intensity P ij is uniform for the overall image of the laser spot, there is a linear relationship between the defocus distance δ and the centroid of the image on the CCD sensor. Utilizing this linear relationship and closed-loop control based on the image centroid coordinates, an autofocusing function can be achieved [35, 36, 38].

Fig. 2
figure 2

Schematic representation of laser spot on CCD sensor surface given different values of defocus distance [36]

2.2 Developed optics-based autofocusing microscope with two optical paths

Figure 3 illustrates the basic structure of the developed optics-based autofocusing microscope presented by the present group in [36]. From this figure, the light beam is expanded and collimated by means of an expander lens and is then bisected by a knife edge. The light beam is then passed through a beam splitter BS1, a filter, and an objective lens and is incident on the target surface. The laser light reflected from the target surface passes back through the objective lens, filter, BS1 and is then incident on a beam splitter BS2, where it is split into two separate optical paths (referred to hereafter as Optical Paths I and II). Finally, in two separate optical paths, the light beams are passed through two lenses (Lens2 and Lens3) and are then incident on a CCD sensor (CCD1) and another CCD sensor (CCD2), respectively. In designing the developed autofocusing microscope, the focal length of Lens3 is greater than that of Lens2. Form Eq. (1), the following equations for Optical Paths I and II can be obtained, respectively:

$$\Delta = \delta_{\text{I}} \frac{{2df_{{2{\text{I}}}} }}{{f_{1}^{2} }} ,$$
(4I)
$$\Delta = \delta_{{\text{II}}} \frac{{2df_{{2{\text{II}}}} }}{{f_{1}^{2} }} ,$$
(4II)
$$f_{{2{\text{II}}}} > f_{{2{\text{I}}}} ,$$
(5)
$$K_{\text{I}} = {{f_{{2{\text{I}}}} } \mathord{\left/ {\vphantom {{f_{{2{\text{I}}}} } {f_{1} }}} \right. \kern-0pt} {f_{1} }} ,$$
(6I)
$$K_{{\text{II}}} = {{f_{{2{\text{II}}}} } \mathord{\left/ {\vphantom {{f_{{2{\text{II}}}} } {f_{1} }}} \right. \kern-0pt} {f_{1} }} .$$
(6II)

From Eqs. (5) and (6), Optical Path I results in a smaller total magnification \(K_{\text{I}}\). As a result, Optical Path I can be used to implement autofocusing with a large range of distance and low focusing accuracy. By contrast, Optical Path II can be used to implement autofocusing with a shorter range of distance and higher focus accuracy.

Fig. 3
figure 3

Structure of developed autofocusing microscope with two optical paths

The output motion characteristic curves of the image centroid position with the defocus distance in both the conventional autofocusing microscope and developed autofocusing microscope with two optical paths are shown in Fig. 4a, b, respectively. It is observed that there is a linear autofocusing segment for each output motion characteristic curve. The slopes of these linear segments dominate the corresponding focusing accuracy of each autofocusing microscope. It means the steeper the slope, the higher the focusing accuracy. As shown, there is only one slope of linear segment for the conventional autofocusing microscope, while there are two different slopes of linear segments for the developed autofocusing microscope. It has been proven that the developed autofocusing microscope with two optical paths can achieve a large linear autofocusing range and a rapid response without any loss in the focusing accuracy. (Note that for a more comprehensive description of the proposed system, the reader is referred to [36].)

Fig. 4
figure 4

Output motion characteristics of a conventional autofocusing microscope and b developed autofocusing microscope

3 Proposed optics-based autofocusing microscope with tunable optical zoom system

Figure 5 shows the basic structure of the proposed optics-based autofocusing microscope, in which the two optical paths in the developed autofocusing microscope are replaced by one tunable optical zoom system (Navitar, 12X Ultra Zoom). As shown, the laser light beam is collimated by means of a lens and is then reshaped by a knife edge into a semicircle form. The light beam is passed through a beam splitter (BS), a 45° red dichroic filter and an objective lens, and is then projected on the target surface. The light is reflected from the target surface and passes back through the objective lens, filter, BS, and a tunable optical zoom system. After being passed through the tunable optical zoom system, the light beam is incident on a CCD sensor (CCD1).

Fig. 5
figure 5

Structure of proposed autofocusing microscope with tunable optical zoom system

Importantly, the tunable optical zoom system comprises two lens assemblies and it can adjust its equivalent focal length flexibly. It means the tunable optical zoom system can adjust its total magnification K to achieve a large linear autofocusing range (a smaller total magnification K, i.e., the zoom out optical path) and keep a high focusing accuracy (a greater total magnification K, i.e., the zoom in optical path). In the proposed autofocusing microscope, the two zoom out and zoom in optical paths and a self-written autofocus-processing algorithm are combined to achieve a more rapid response without any loss in the autofocusing range and focusing accuracy.

Figure 6 represents a flowchart showing the basic steps in the proposed autofocusing procedure. By our self-written autofocus-processing algorithm, the objective lens can be moved directly via a linear motor featuring a closed-loop control scheme based on the image centroid coordinates. Following the autofocusing procedure in Fig. 6, the output motion characteristic curves of the proposed autofocusing microscope are illustrated in Fig. 7. As shown, there are three different slopes of linear segments for the proposed autofocusing microscope. The slope of the blue linear segment is greater than that of the green linear segment and is smaller than that of the red linear segment. Moreover, the red curve has the maximum total magnification \(K_{\rm max}\) which can achieve high accuracy but small focusing range, and the green curve has the minimum total magnification \(K_{\rm min}\) which can achieve large focusing range but low accuracy.

Fig. 6
figure 6

Flowchart of autofocus-processing algorithm in proposed autofocusing microscope

Fig. 7
figure 7

Output and motion characteristics of proposed autofocusing microscope

For comparison purposes with the same standard between these three figures (Figs. 4a, b, 7), we design identical maximum and minimum total magnifications \(K_{\rm max}\) and \(K_{\rm min}\) in each figure to easily find out which structure has more rapid response. As shown, Fig. 4a shows the conventional autofocusing microscope should take ten movement times to move the objective lens on focus from the same beginning position of the δ 1 in the same accuracy (in \(K_{\rm max}\)), and Fig. 4b shows the developed autofocusing microscope should take four movement times to move the objective lens on focus. It is worth noting that it takes less movement times to move the objective lens on focus (see Fig. 4b) in minimum total magnification because of its low accuracy and slope. On the other hand, Fig. 7 shows the proposed autofocusing microscope can adjust the appropriate total magnification by zoom system to reduce the number of objective lens movement times to achieve more rapid response.

If the initial defocus distance δ 1 is located outside of the green linear range, the autofocusing procedure should commence by shifting the objective lens through a distance L I. If the resulting defocus distance δ 2 is located outside of the red linear range, but within the green linear range, the tunable optical zoom system will automatically adjust its total magnification K appropriate to achieve an appropriate blue linear autofocusing range, where the defocus distance δ 2 is located inside of the blue linear range. In other words, K min K appropriate K max. Then, the objective lens is shifted through a distance equal to the defocus distance via a linear motor in accordance with the calculated centroid coordinates (x centroid , y centroid ) of the image detected by CCD1 in K appropriate (see blue curve). However, compared to red curve, blue curve has a lower focus accuracy. Therefore, the position of the objective lens is moved to δ 3, outside of the depth of focus of this system. However, if δ 3 is located within the red linear range, the objective lens is moved directly to the point of maximum focus. From Fig. 7, it can be seen that irrespective of the initial defocus distance δ, the objective lens need be shifted no more than three times in arriving at the point of maximum focus. Comparing Figs. 4 and 7, in the same measurement range, the number of objective lens movement times in the proposed autofocusing microscope is less than that in both the conventional and developed autofocusing microscopes. In other words, the proposed autofocusing microscope has a more rapid response, but maintains the same autofocusing range and focusing accuracy. Also it can be seen that the proposed autofocusing microscope reduces to the developed autofocusing microscope with two optical paths if the appropriate blue linear autofocusing range is not activated.

4 Numerical simulation and analysis

4.1 Simulation of proposed optics-based autofocusing microscope with tunable optical zoom system

To prove the focusing performance of the proposed autofocusing microscope and determine suitable values of the main design parameters, a series of ZEMAX ray-tracing simulations were performed according to the zoom in/out functions of the tunable optical zoom system. Due to the lack of the detailed design parameters of the tunable optical zoom system, two equivalent lens assemblies (Lens3 and Lens4) were used in the optical modeling and simulation in this study. Although we cannot know the detailed design parameters of the lenses in the tunable optical zoom system (Navitar, 12X Ultra Zoom), we can get its maximum and minimum total magnifications \(K_{\rm max}\) and \(K_{\rm min}\) from its specification. Therefore, we just design the same maximum and minimum total magnifications \(K_{\rm max}\) and \(K_{\rm min}\) to simulate its function by adjusting the distance between \({\text{Lens}}_{3}\) and \({\text{Lens}}_{4}\). Figures 8 and 9 illustrate the two optical models of the proposed microscope in \(K_{\rm min} = 7.1\) and \(K_{\rm max} = 33.3,\) respectively. The selected design parameters of the proposed autofocusing microscope are listed in Table 1.

Fig. 8
figure 8

ZEMAX optical model of proposed autofocusing microscope in \(K_{\rm min} = 7.1\)

Fig. 9
figure 9

ZEMAX optical model of proposed autofocusing microscope in \(K_{\rm max} = 33.3\)

Table 1 Design parameters of proposed autofocusing microscope

4.2 Simulation results and analysis

Figure 10 presents the simulation results obtained for the laser spot shapes in \(K_{\rm min} = 7.1\) and \(K_{\rm max} = 33.3\), respectively, given different values of the defocus position. As shown, in \(K_{\rm max} = 33.3\), it is noted that a non-semicircle shape of the laser spot exists at the defocus distance ∑ of ±200 μm. This can be explained as: When the defocus distance ∑ is located outside of this linear range, a certain part of the reflected laser beam is incident on the region outside the CCD1. Therefore, the image captured by CCD1 has a nonlinear situation. A flowchart showing the basic steps in the proposed autofocusing procedure and image processing was shown in Fig. 12 of [35]. From the captured images of the laser spots, the variation of the image centroid position with the defocus distance can be obtained. Figure 11 presents the simulation results obtained for the variation of the image centroid position with the defocus distance in the proposed autofocusing microscope in \(K_{\rm min} = 7.1\) and \(K_{\rm max} = 33.3\), respectively. For the result of the magnification \(K_{\rm min} = 7.1\), the centroid movement deviates from a linear behavior for a defocus larger than −400 µm, but that is not shown for the positive values. This phenomenon is related to the inaccuracy of the simulation model. We believe that if we can build the real design parameters of the zoom system in simulation, this asymmetry for the \(K_{\rm min} = 7.1\) will not be existed.

Fig. 10
figure 10

Simulation results for laser spot on CCD sensor surface given different values of defocus distance in proposed autofocusing microscope

Fig. 11
figure 11

Simulation results for variation of image centroid position with defocus distance in proposed autofocusing microscope

It is observed that the slope of the green linear segment for \(K_{\rm min} = 7.1\) is smaller than that of the red linear segment for \(K_{\rm max} = 33.3\). It indicates that the numerical results are consistent with the theoretical analysis presented in Sect. 3.

5 Experimental characterization of prototype model

As shown in Fig. 12, a laboratory-built prototype model was used to verify the validity of the proposed autofocusing microscope. The prototype model was equipped with a human–machine interface (HMI) written in LabVIEW. Figure 13 shows experimental results for the laser spot shapes in \(K_{\rm min} = 7.1\) and \(K_{\rm max} = 33.3\), respectively, given different values of the defocus distance. Figure 14 shows the comparison of the experimental and simulation results for the variation of the image centroid position with the defocus distance in the maximum total magnification \(K_{\rm max} = 33.3\). From Figs. 13 and 14, it is observed that these experimental results are in good agreement with the simulation results.

Fig. 12
figure 12

Photograph of laboratory-built prototype

Fig. 13
figure 13

Experimental results for the images of laser spot on CCD sensor surface given different values of defocus distance

Fig. 14
figure 14

Comparison of experimental and simulation results for variation of image centroid position with defocus distance

To confirm the practical feasibility of the proposed autofocusing microscope, a series of autofocusing experiments were conducted by moving a mirror target given initial defocus distances δ ranging from ±1500 μm. For comparison purposes with the same standard, the experiments were also performed in both the conventional and developed autofocusing microscopes presented by the present group in [36]. The experiments were repeated five times for every initial defocus distance. The experimental results for the variations of the measured autofocusing position and the number of objective lens movement times with the initial defocus distance for the developed autofocusing microscope are shown in Figs. 15 and 16, respectively. From the two figures, it shows that the objective lens is moved from the initial defocus distance to the final focusing position (yielding a focusing accuracy of ≤1 μm, repeatability of ±1 μm) with the number of movement times of ≤5. By contrast, the experimental results for the variations of the measured autofocusing position and the number of objective lens movement times with the initial defocus distance for the proposed autofocusing microscope are shown in Figs. 17 and 18, respectively. From the two figures, it shows that the objective lens is moved from the initial defocus distance to the final focusing position (yielding a focusing accuracy of ≤1 μm, repeatability of ±1 μm) with the number of movement times of ≤4. Comparing the developed and proposed autofocusing microscopes, it is evident that the number of objective lens movement times in the proposed autofocusing microscope is decreased. In addition, Fig. 19 shows the comparison of the experimental results for the variation of the focusing response with the defocus distance in conventional, developed, and proposed autofocusing microscopes, respectively. The results confirm that the focusing response of the proposed autofocusing microscope is faster than that of the conventional and developed autofocusing microscopes. As a consequence, the proposed autofocusing microscope results in a more rapid focusing response (less than 3.5 s) under the same autofocusing range (±1500 μm) and focusing accuracy (focusing accuracy of ≤1 μm, repeatability of ±1 μm). As a result, the proposed autofocusing microscope provides a potential solution for automated vision inspection and optical applications.

Fig. 15
figure 15

Experimental results for variation of autofocusing position with defocus distance in developed autofocusing microscope

Fig. 16
figure 16

Experimental results for variation of number of objective lens movement times with defocus distance in developed autofocusing microscope

Fig. 17
figure 17

Experimental results for variation of autofocusing position with defocus distance in proposed autofocusing microscope

Fig. 18
figure 18

Experimental results for variation of number of objective lens movement times with defocus distance in proposed autofocusing microscope

Fig. 19
figure 19

Comparison of experimental results for variation of focusing response with defocus distance

6 Conclusions

This study has proposed a novel optics-based autofocusing microscope with one tunable optical zoom system to achieve a more rapid focusing response without any loss in the autofocusing range and focusing accuracy. The performance of the proposed microscope has been evaluated by means of numerical simulations, and its practical feasibility has been demonstrated using a laboratory-built prototype model. The simulation and experimental results have shown that compared to both the conventional and developed autofocusing microscopes, the proposed autofocusing microscope achieves a rapid focusing response (less than 3.5 s) under the same autofocusing range (±1500 μm) and focusing accuracy (focusing accuracy of ≤1 μm, repeatability of ±1 μm).