The auto-focusing realization of a new-style visual sensor for measurement is studied.The sum of gray-change function is used to evaluate the image of the object for its long range coarse focus position.The Roberts gradient function is applied to realize the fine adjustment beside the peak.Control command will be sent by computer serial port to drive motor to rotate lens to a location where the focus is clear.The system has the advantages of simple
useful
reliable.The experiment results show that the auto-focusing results can meet the requirement and have good veracity.