video_autofocus
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| video_autofocus [2016/09/07 18:26] – ↷ Page moved from documentation:video_autofocus to video_autofocus asiadmin | video_autofocus [2023/01/25 13:57] (current) – [MANUAL CALIBRATION] Added serial focus score instructions chrisd | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Video AUTO-FOCUS ====== | ||
| + | The ASI auto-focus system uses an electronic circuit to detect the high spatial frequency information present in a video signal coming from an analog camera, and converts it to a focus value for each frame – the better the focus, the larger the focus value. | ||
| + | |||
| + | [{{ autofocus_connectors.png? | ||
| + | |||
| + | [{{ autofocus_video.png? | ||
| + | |||
| + | When the controller is given an auto-focus command, it moves from a starting position to a stop position, constantly checking the focus signal. | ||
| + | |||
| + | [{{ autofocus_scan.png? | ||
| + | |||
| + | There is also a //" | ||
| + | |||
| + | |||
| + | ===== AUTO-FOCUS ALGORITHM ===== | ||
| + | |||
| + | |||
| + | An actual auto-focus is initiated with the '' | ||
| + | |||
| + | The '' | ||
| + | |||
| + | <wrap cmd> AF X= [% of speed] Y= [travel distance in mm] Z= [Hill Detect enable] F= [Hill Offset] </ | ||
| + | |||
| + | **% of speed: | ||
| + | |||
| + | The hardware auto-focus circuit generates a new focus value for every video frame (every 16 milliseconds for an NTSC/RS170 camera). | ||
| + | |||
| + | \begin{equation} 0.1 \frac{mm}{second} × 0.016 \frac{seconds}{frame} = 1.6 \frac{µm}{frame} \end{equation} | ||
| + | |||
| + | This //speed// would give roughly a 1.6 µm focus resolution. | ||
| + | |||
| + | \begin{equation} 5\% × 0.6 \frac{mm}{second} × 0.016 \frac{seconds}{frame} = 0.48 \frac{µm}{frame} \end{equation} | ||
| + | |||
| + | The trade-off when scanning at a slower //speed// for better resolution is the extra time it takes to complete the scan. For the fastest operation, pick the maximum //speed// that gives you the resolution you require and choose a small //travel distance//. | ||
| + | |||
| + | **Travel Distance: | ||
| + | |||
| + | **Type of Search: | ||
| + | |||
| + | **Normal: | ||
| + | |||
| + | {{ autofocus_normal_scan.png? | ||
| + | |||
| + | **Hill Detection: | ||
| + | |||
| + | {{ autofocus_hill.png? | ||
| + | |||
| + | The **Hill Offset** value is the percentage that the //focus value// must decrease from its recent maximum before the scan is satisfied that a hill has been detected. | ||
| + | |||
| + | ===== AUTO-FOCUS CONFIGURATION ===== | ||
| + | |||
| + | |||
| + | To ensure safe and proper operation during auto-focus moves, perform the following procedure: | ||
| + | |||
| + | 1.Focus the sample manually and then press the ZERO button on the controller. | ||
| + | |||
| + | [{{ autofocus_microscope_limits.png? | ||
| + | |||
| + | 2.Insure that **DIP Switch 2** on the back of your controller to UP position (Fig. 4). Your LCD will now display the //focus value// marked as '' | ||
| + | |||
| + | [{{ autofocus_display.png? | ||
| + | |||
| + | 3.By focusing through your sample, you can watch the focus value change on the LCD screen. | ||
| + | |||
| + | 4. '' | ||
| + | |||
| + | 5.Next, using the '' | ||
| + | |||
| + | <wrap cmd> AF X=5 Y=0.05 </ | ||
| + | |||
| + | 6.Next, issue an AFCALIB (or AFC) command without parameters. | ||
| + | |||
| + | 7.Finally, perform a regular auto-focus run using the '' | ||
| + | |||
| + | 8.If the focusing is inconsistent, | ||
| + | |||
| + | ===== MANUAL CALIBRATION ===== | ||
| + | |||
| + | The '' | ||
| + | |||
| + | 1.Manually focus the sample and insure that **DIP Switch 2** on the back of your controller is in the UP position. | ||
| + | |||
| + | 2.Next, set'' | ||
| + | |||
| + | The **Y** value sets an internal digital potentiometer that controls the video signal amplitude. | ||
| + | |||
| + | With **Y** set at '' | ||
| + | |||
| + | If this step is not performed, over time, the internal noises and offsets will accumulate, and the //focus value// will ramp up and saturate. | ||
| + | |||
| + | The **Z** value sets the gain of an Analog-to-Digital converter (ADC) which is connected to an internal integrator that converts spatial frequencies into the //focus value// | ||
| + | |||
| + | 3.Now, to tune other parameters, insure that your camera is connected and feeding video into the auto-focus card. Allow some video signal into the system by increasing the **Y** value of the '' | ||
| + | |||
| + | 4.The '' | ||
| + | |||
| + | By default, the highlighted area is centered in the video frame. | ||
| + | |||
| + | 5.Next, set the '' | ||
| + | |||
| + | ^AFADJ ^Focus Value Multiplier ^ | ||
| + | |Z=0 |1x| | ||
| + | |Z=1 |2x| | ||
| + | |Z=2 |4x| | ||
| + | |Z=3 |8x| | ||
| + | |||
| + | 6.Now re-adjust '' | ||
| + | |||
| + | 7.The auto-focus system works well when the difference between the in-focus focus value and the out-of-focus focus value is large. | ||
| + | |||
| + | 8.If the system consistently settles at a spot that is a bit off the focus or the image is not sharp enough, try adjusting the '' | ||
| + | |||
| + | 9.Another parameter that can help with better scanning is the scan speed as set with the '' | ||
| + | |||
| + | ===== TROUBLESHOOTING AND OPTIMIZATION ===== | ||
| + | |||
| + | |||
| + | == Focus value on the LCD ramps up and saturates when the sample is motionless and the focus controller is quiescent == | ||
| + | |||
| + | This problem occurs when the //Zero Potentiometer// | ||
| + | |||
| + | == Hill Detect does not work well. == | ||
| + | |||
| + | Two parameters that greatly influence Hill Detect performance are //Hill Offset// (set by the **F** argument of '' | ||
| + | |||
| + | If the Hill Detect continues to scan the sample for considerable time after passing the best focus, it could be caused by large '' | ||
| + | |||
| + | If the Hill Detect returns a false focus, try increasing the '' | ||
| + | |||
| + | == Stage returns to a position just off the best focus spot. == | ||
| + | |||
| + | There are two things you can do to improve this: try rescanning with lower //speed// setting (set by the **X** argument of '' | ||
| + | |||
| + | To determine which option is best for you, try the following: | ||
| + | |||
| + | //Frame offset// is a constant that depends on your camera’s frame rate and your focus drive’s speed. | ||
| + | |||
| + | == Unfocused spot has a higher focus value than a focused spot. == | ||
| + | |||
| + | |||
| + | Here are a few things you can try when the focus value reads a higher value at a defocused spot than at a focused spot: | ||
| + | *Turn off any Automatic Gain Control (AGC) settings on your video system and use a Manual or Fixed Gain setting instead. | ||
| + | *The illumination might be insufficient; | ||
| + | *Limiting the background might help; decrease the highlighted screen area with '' | ||
| + | |||
| + | |||
| + | To simply read the focus value over serial, use the command [[commands: | ||
| + | ===== AUTO-FOCUS High Level COMMANDS ===== | ||
| + | Apart from the core MS2000 commands like [[commands: | ||
| + | |||
| + | {{topic> | ||
| + | |||
| + | |||
| + | ===== Auto-Focus Low Level Command (version 8.8+) ===== | ||
| + | |||
| + | Low level command set is ideal Ms2000 interface for scripts/non humans. Since the commands are so rigid and streamlined, | ||
| + | |||
| + | ==== Command: Perform Autofocus ==== | ||
| + | |||
| + | ^Byte# | ||
| + | |1 |Axis Identifier |0x18/ | ||
| + | |2 |Command |0x5A| | ||
| + | |3 |Termination |0x3A| | ||
| + | |||
| + | **1st Byte:** is the Axis Identifier, this can be any of the valid axis identifier ('' | ||
| + | **2nd Byte:** is the command. Its 0x5A, same as the Autofocus scan edit command, when this is followed by the termination byte, Ms2000 knows to perform autofocus command. | ||
| + | **3rd Byte:** is the termination character “:” in ASCII or '' | ||
| + | |||
| + | **Response: | ||
| + | |||
| + | Example < | ||
| + | Reply < | ||
| + | |||
| + | ==== Command: Read Autofocus Settings ==== | ||
| + | |||
| + | ^Byte# | ||
| + | |1 |Axis Identifier |0x18/ | ||
| + | |2 |Command |0x5B| | ||
| + | |3 |Termination |0x3A| | ||
| + | |||
| + | **1st Byte:** is the Axis Identifier, this can be any of the valid axis identifier ('' | ||
| + | **2nd Byte:** is the command. Its '' | ||
| + | **3rd Byte:** is the termination character “:” in ASCII or 0x3A in hex. If not received, MS2000 ignore the command. | ||
| + | |||
| + | == Response: == | ||
| + | |||
| + | |||
| + | ^Byte# | ||
| + | |1 |LSB of autofocus scan range in 10th of a micron|0xD0 |0xE8 | | ||
| + | |2 |MSB of autofocus scan range in 10th of a micron|0x07< | ||
| + | |3 |Autofocus Scan speed percent|0x0A (scan speed is 10%) |0x05 (scan speed is 5%) | | ||
| + | |4 |Current Autofocus mode |0x00 <wrap lo> | ||
| + | |5 |Hill Offset percent |0x46 <wrap lo>(Is 70% hill offset) </ | ||
| + | |6 |AFMOVE enable <wrap lo>(when enable performs an autofocus automatically after each move)</ | ||
| + | |7 |LSB of Contrast Value |0x0A |0xC8| | ||
| + | |8 |MSB of Contrast Value |0x00 <wrap lo> | ||
| + | |||
| + | **Example** <wrap cmd> 0x18 0x5B 0x3A </ | ||
| + | **Reply** < | ||
| + | |||
| + | === Command: Edit Autofocus Settings === | ||
| + | |||
| + | This command lets you edit the autofocus scan range, hill offset percent, autofocus mode and autofocus scan speed. \\ | ||
| + | **1st Byte:** is the Axis Identifier, this can be any of the valid axis identifier ('' | ||
| + | **2nd Byte:** is the command. Its 0x5A, same as the Autofocus scan command, when this is followed by other bytes and not the termination byte, Ms2000 knows that it’s the edit version of the command \\ | ||
| + | **3rd Byte:** Number of bytes following, notifies the controller of the number of bytes following this byte. \\ | ||
| + | **4th Byte:** When set to '' | ||
| + | **5th and 6th Byte:** Are the Least Significant byte and Most Significant Byte of the autofocus scan range entered in units of 10th of a micron. Maximum possible value is '' | ||
| + | **7th Byte:** is Autofocus scan speed percent. Only accepts values between 1 to 100 ('' | ||
| + | **8th Byte:** is Autofocus scanning mode. When set to 0x00 performs the normal/ | ||
| + | **9th Byte:** is the Hill Offset percent \\ | ||
| + | **10th Byte:** '' | ||
| + | **11th and 12th Byte:** LSB and MSB of the Contrast Value. If the controller finds the difference between the maximum and minimum focus value to be less than the contrast value, it declares the run a failure and returns to the starting position. Maximum value allowed is '' | ||
| + | **13th Byte:** is the termination character “:” in ASCII or '' | ||
| + | |||
| + | == Response: == | ||
| + | |||
| + | |||
| + | '' | ||
| + | ^Byte# | ||
| + | |1 |Axis Identifier |0x18 |0x18 |0x18 | ||
| + | |2 |Command |0x5A |0x5A |0x5A | ||
| + | |3 |No of bytes following |0x03 |0x04 |0x09 | ||
| + | |4 |Perform an Autofocus scan after edit. |0x01 |0x02 |0x02 | | ||
| + | |5 |LSB of scan range |0xE8 |0xD0 |0xE8 | | ||
| + | |6 |MSB of scan range |0x03 |0x07 |0x03 | | ||
| + | |7 |Scan speed percent |- |0x8C |0x0A| | ||
| + | |8 |Autofocus Mode |- |- |0x00| | ||
| + | |9 |Hill Detect Offset percent |- |- |0x3C| | ||
| + | |10 |AFMOVE enable |- |- |0x01| | ||
| + | |11 |LSB of Contrast Value |- |- |0x0A| | ||
| + | |12 |MSB of Contrast Value |- |- |0x00| | ||
| + | |13 |Termination |0x3A |0x3A |0x3A| | ||
| + | |Command string | |0x18 \\ 0x5A \\ 0x03 \\ 0x01 \\ 0xE8 \\ 0x03 \\ 0x3A |0x18 \\ 0x5A \\ 0x04 \\ 0x02 \\ 0xD0 \\ 0x07 \\ 0x8C \\ 0x3A |0x18 \\ 0x5A \\ 0x09 \\ 0x02 \\ 0xE8 \\ 0x03 \\ 0x0A \\ 0x00 \\ 0x3C \\ 0x01 \\ 0x0A \\ 0x00 \\ 0x3A| | ||
| + | |Result| | ||
| + | |||
| + | If you just wanted to edit the scan range, then you can only update the 2 scan range bytes. But if you want to just edit the Hill Offset percent and leave all other settings unchanged, you still have to enter proper values for the bytes before it. | ||
| + | |||
| + | **Example** <wrap cmd> 0x18 0x5A 0x03 0x01 0xE8 0x03 0x3A </ | ||
| + | **Reply** <wrap reply> none </ | ||
| + | **Example** < | ||
| + | **Reply** <wrap reply> 0x01 </ | ||
| + | |||
| + | ===== AUTO-FOCUS CONTROLLER’S VIDEO PROCESSING SEQUENCE ===== | ||
| + | {{ autofocus_processing_sketch.png? | ||
| + | |||
| + | {{tag> | ||
| + | |||
Address: 29391 W Enid Rd. Eugene, OR 97402, USA | Phone: +1 (541) 461-8181
