Engineering Documents - Tormach CNC Scanner
Tormach CNC Scanner™
An affordable optical measuring and 2D reverse engineering system for CNC mills
Over the last few years, we became aware of several interesting marriages of low cost USB cameras (aka webcams) and CNC mills, mostly for use as optical centering devices. The CNC Scanner project began in earnest when our colleague John Prentice mentioned that he had just acquired a USB microscope for his own workshop and was pleasantly surprised at the capability. A quick investigation showed that affordable USB microscopes were already in common use in medicine, biology, and other fields.
Direct measurement from optical images is typically accomplished using a reticule - a dimensioned grid that can be placed in the field of view for estimating measurements. Depending on the grid size of the reticule and how much care is taken, an observer can make fairly accurate linear measurements. Of course, the size of the measurement is restricted to what is possible within the field of view. This isn't a problem when you want to measure the width of fly's wing; however, in manufacturing, we often need to measure much larger dimensions with the same, if not better precision. A typical manufacturing drawing for a machined part will commonly call for toleranced dimensions of ±.001" for key features.
The USB microscope by itself is handy for a CNC machinist: not only for making small measurements, but also for other uses. We've used it for observing the edges of small cutting tools for worn or chipped edges, or for qualitative metrology of finished surfaces – looking at tool marks, chatter, etc. But we also wondered if something else was possible. With a CNC machine, we already had a platform for precision positioning of a spindle mounted camera. It seemed possible that we could command the mill to take a series of pictures at regularly spaced intervals and build a much larger composite photo from the images - similar, in a way, to the stitched-together satellite images in popular internet mapping programs like MapQuest and Google Maps. This photomosaic would have both the size and resolution needed to make precision measurements of many commonly machined parts.
The goal for the CNC Scanner project was to combine affordable USB microscope technology with a simple 2D CAD system and a set of innovative plug-in applications for a Mach3 controlled CNC mill or router. With this system, we can produce scaled scans of 2D geometries, accurately measure dimensions, and recreate geometries for export into CAD/CAM systems. We also investigated the use of the system as an optical centering device. In this capacity, it is useful but also limited in application.
CNC Scanner was designed with several goals in mind:
Innovative Measurement Capability - While there is no shortage of measurement tools available, none are perfect solutions for measuring difficult shapes. Recreating these shapes can prove to be a tedious or impossible task if the original dimensioned prints are unavailable. Examples are numerous and include watch mechanisms, engravings, and complex curves. Even with the advancements in affordable 3D scanning, accuracy is often limited to ±0.005" . This simply isn't good enough for many toleranced mechanical fits.
Affordable - Industrial metrology systems use expensive optics with a price point that is out of reach for small shops that only require occasional use of the technology. The engineering challenge with CNC Scanner was to develop a tool that had both the accuracy needed to be useful for measuring CNC parts and still remain affordable.
Versatile – The control plugins for the CNC Scanner are generic and will support most USB cameras in addition the standard CNC Scanner software. It was important to adhere to Tormach's Open-Architecture philosophy , especially when taking into consideration the ever-changing landscape of consumer electronics.
Capable of 2D Reverse Engineering – Our goal was not to develop a standalone CAD program. There are many outstanding companies that already do this cheaper and better than anything we would have been able to provide. Our requirement was simply to create a CAD environment with simple measurement and drawing tools that could import a photomosaic and provide enough functionality to measure and recreate features. This can be exported in an industry standard .DXF format and then be further processed in CAD/CAM of the user's choice if necessary.
Easy-to-Use – CNC Scanner is designed with the occasional user in mind. This means that operation must be easy to learn and simple to use.
Basic Description of Operation
CNC Scanner assembles a dimensionally scaled photomosaic from a series of photographs that are stitched together build a larger image. It uses a spindle mounted adjustable focus USB microscope camera that features our Tormach Tooling System™ quick change mounting system.
Prior to taking each photograph, the camera is precisely positioned by CNC motion of the mill. This is done via a software plugin to the PC-based Mach3 motion control program. The exact position and number of photographs depends on the desired size and resolution of the photomosaic and is determined by the CNC Scanner software algorithm.
The scale of the picture is determined by one of two methods. The first, traditional method, uses a known dimension placed in the field of view to establish the scale- this is in essence, the reticule method that has already been discussed. The second method is unique to CNC Scanner. It uses the controlled motion of the mill itself to establish scale by calibrating the change of position in a particular point in the field of view to the actual distance that the mill traveled.
After the photomosaic is assembled, it can be opened in Tormach CNC Scan CAD, a simple 2D CAD program with basic functionality for measuring distances and tracing shapes. This information can be exported as an industry standard .DXF file to other CAD/CAM programs for further work.
Tool Making: EDM Electrodes for Jet Turbines
In this example, CNC Scanner was used to recreate the profile of a turbine vane, as shown in Figure 1. The exact profile of the vane is needed to make an EDM electrode that is used for reworking a stator for jet engine repair. Previously, this work was done by using an electronic touch probe to collect a 2D point cloud, which was time consuming and labor intensive.
Example Courtesy Joe Gore, Carbon Tools
Reverse Engineering: Mechanical Clock Movement
Mechanical Clock Movements often feature shapes that are difficult to measure. Using CNC Scanner, these shapes can be reverse engineered by tracing the outline as shown in Figure 2. This technique can also be applied to cam mechanisms and other complex mechanical shapes.
Recreating a Damaged Part: AR-15 Rifle Gas Block
On an AR-15 Rifle, the gas block is fitted around the outside diameter of the rifle barrel and supports a gas tube that diverts some of the gas that travels through the barrel after firing to reset the firing bolt mechanism. CNC Scanner was used to accurately recreate both the hole diameters and center-to-center spacing. The dimensioned drawing can then be exported in to CAD/CAM to design the remanufacturing sequences (Figure 3).
Example Courtesy Ryan Kennedy
Verifying Manufactured Tolerances: Small Run / Custom Production
A small run of parts were manufactured for a customer. Using CNC Scanner, each part can be measured to verify that it meets customer requirements for dimensional tolerance (Figure 4).
Example Courtesy Rick Zrostlik
Restoration: Norton Commando Rocker Arm
Hard-to-find vintage components, such as the motorcycle rocker arm shown in Figure 5, can be difficult to recreate. CNC Scanner can be used to capture information about key geometries, such as the length and angles between the center of the rocker shaft and the CAM and valve connections. This information can then be used to recreate a mold to reproduce the original part or machine a new replacement part that preserves function.
An understanding of the following discussion is not necessary for operation of CNC Scanner, although it is informative for understanding its performance characteristics and developing realistic expectations.
Digital Cameras and the Limits of Resolution
Anybody who has purchased a digital camera has experience issues with resolution. Digital camera resolution is expressed in megapixels – a camera that can produce an image 1280x1024 pixels in size has a resolution of about 1.3 megapixels. Ultimately, the resolution is a function of the image sensor. Our USB microscope uses a CMOS image sensor. The CMOS captures light which is then converted into a digital signal that is interpreted by the camera's CPU to form an image. The number of discrete points that the image sensor captures to produce an image fundamentally determines the camera resolution.
Figure 6. The quality of the image can vary throughout the field of view. This can affect both scan quality and ultimately the accuracy of the measurements made from the scan.
However, this definition of resolution says nothing about scale. The actual dimension that the width of a pixel in any image represents also depends on the working distance of the camera – the actual distance between the lens and the object.
In application, however, it takes more than a single pixel to determine a feature, such as where the location of an edge occurs. How many pixels does it take? The answer to this question has fundamental limits in the camera and lens, but it is also strongly affected by the accuracy of your focus and the flatness of the image. Lighting issues and surface finish also come into play. This is perhaps best understood looking at the example in Figure 6.
The subject under the camera is a grid, but unfortunately it's impossible to focus uniformly over the entire object because of lens imperfections. In the first example we look closely at crossed lines in the central area of the grid. The image to the right of the top photo shows the crossed lines close enough to see individual pixels. Looking at the close up, it seems that we can determine where the center of a line is by considering 2 or 3 pixels.
Now let's look over in the lower right hand corner, where the grid is more out of focus. In this case the lines are less distinct. Looking at the image, you can still make an estimation of where the center of a line is, but you would do so by considering many more of the individual pixels. You might want to consider 5 or 6 pixels as the correct amount for making a decision as to where the center of the line is.
Keep in mind, you cannot re-focus or adjust an image after a scan is complete. The scanning system will take this into account by guiding you to put the camera closer to the work so that it can achieve your desired resolution in the amount of pixels specified. In this case it will also take more individual pictures to create the composite mosaic image.
The camera provided with the Tormach system has a fundamental limit of about 2 or 3 pixels for finding an edge. This can only get worse if you do not take care in focusing the camera, if the subject is not flat, or if there are lighting problems. We suggest going with the default value for picture quality of 2.5, but then increasing the number if you want the scan to show more detail.
Emulating a Telecentric Lens System with a Low Cost USB Camera
Telecentric Lenses are the basis of many industrial metrology and measurement systems. A telecentric lens (more appropriately, a system of lens) has the unusual property that it can produce an image whose size and shape is independent of the distance of the object from the lens or its position in the field of view. This is because the special telecentric objective lens only focuses rays that are parallel to the optic axis.
In practice, telecentric lenses:
- Reduce image distortion
- Eliminate the effect of perspective
- Negate magnification changes due to change in object position
Telecentric lenses are both large and expensive, but we can approach a telecentric system with CNC Scanner. This is done by restricting the useful field of view to a small percentage around the center of each image when constructing the photomosaic scan. This area of the image is produced by rays that are nearly parallel to the optic axis, thus emulating a telecentric system as shown in Figure 7
Figure 7. CNC Scanner emulates a telecentric system by limiting the useable Field of View.
Backlash is inherent in machine tools. It results from stiction, friction, and elasticity as well as the space present in rotating mechanical connections, such as the ball screw. With CNC Scanner, we have compensated for backlash by incorporating a consistent approach direction in both X and Y axes (Figure 8). The capture algorithm for CNC Scanner assembles a mosaic by always approaching each photo with a positive X and/or Y axes motion, effectively isolating the effect of machine backlash from the photomosaic.
Figure 8. Backlash compensation algorithm
Figure 9. By reducing the Field of View, CNC Scanner emulates a telecentric lens system and the orthographic nature of the image photomosaic is improved. This can be seen from the improved stitching, especially with features slightly above or below the focal plane.
Calibrating the Image Scale with CNC Motion
Typically, an image is calibrated to by placing a scale of reference in the image field (Figure 10).
However, CNC Scanner is unique in that you can also scale an image by the motion of the CNC mill (Figure 11). This method is both simpler in execution and more accurate, as the measurement resolution is equal to resolution of the mill.
Scaling by motion is especially convenient when scanning objects where a reference scale cannot be conveniently placed. In fact, all that is needed is to identify a point feature. This could be a corner, the center of a hole, or even a speck of corrosion or scratch on the surface of the object.
Scaling by motion also detects angular error and automatically corrects for this effect in each image.
Figure 11. Calibrating Image Scale by precise machine motion. (Scale by Motion). A recognizable point is moved within the field of view of the microscope by a known distance ΔX and ΔY. CNC Scanner determines scale by calibrating the of position change observed in the images with the actual motion of the machine .
LIMITATIONS AS AN OPTICAL CENTERING DEVICE
One phenomenon that is frustrating to users of microscopes is the apparent "wandering" of the optical center as the focal plane is moved to a different level (Figure 13). Our experience identified 2 distinct causes:
The first is backlash inherent to the mechanical focusing mechanism of these scopes (Figure 14). The microscopes use an internal thread to move the lens. This thread is either molded or machined. While a machined thread somewhat reduced the severity of the wandering problem, our testing showed that some wandering was always present, and this makes it impossible to refocus to the same focal plane by returning the focusing dial to the same location. While this problem can be fixed with higher end camera technology, the thousands of dollars in added cost was just not realistic.
The second is a more subtle point, but equally interesting. Absolute alignment of the optic axis of the microscope to the mill axis is not necessary for accurate scanning, but it does have implications with optical centering. The alignment procedure does not imply that the optical axis is parallel to the spindle axis. After alignment, we only know that the optic axis and spindle axis are coincident at the focal plane. It just isn't practical to align the scope with the spindle axis – typical consumer electronics have CMOS sensors that are offset to the optical axis as well, introducing a third stack up of error that cannot easily be overcome. The costs involved to correct these problems and produce an aligned system are not realistic if the CNC Scanner system was to remain affordable.
Figure 12. These two images demonstrate the inability of a variable focus scope to maintain center at different focal planes. In this example, the scope was aligned to the center of the hole at 200x (Top Image). When the working distance is increased and the image is refocus at 60x (Bottom Image), the center has wandered. -- Courtesy Wilfried Bittner, WB Design
Figure 13. The Optic and Centering Axes are co-incident at the focal plane at 50x magnification, but a change in magnification to 20x will induce a centering error unless the camera is re-aligned to make them coincident again.
Figure 14. Measurement of a Gauge Block in Tormach CNC Scanner CAD.
Although we originally had ambitions for a robust optical centering device, over the course of the CNC Scanner project it became clear that while it is possible to use the system as an optical centering device, there are limitations with consumer grade optical components that reduce the practicality of the device for this application.
This is especially true when considering it in the context of other time-proven methods – for many situations we found that we could use a dial indicator to find center quicker and more accurately. Because of the setup time involved with the optical centering procedure, we believe most will find it simpler to use another centering method for the majority of everyday work. We are offering the optical centering function as a specialty tool, which may be useful in some situations.
Figure 15. In the first image, the Focal Plane is the same as the measurement plane. In the Second Image, the camera was refocused so that the Focal plane is below the measurement plane and on the surface that the part is resting on.
As with any measuring tool, the ultimate accuracy that can be achieved is a combination of both the resolution of the tool and the technique and skill in how it is used. With that said, validation data is presented to demonstrate the accuracy of CNC Scanner in a carefully controlled series of measurements.
A series of scans were taken of a precision ground 1" gauge block, shown in Figure 14. Image resolution was increased by decreasing the working distance of the CNC Scanner. The gauge block was then measured using the dimensioning tools in CNC Scanner CAD. Figure 16 shows the error in measurement as a function of image resolution (expressed as a pixel density).
Interpretation: Unsurprisingly, increasing pixel density improves accuracy, although at the expense of both larger data file sizes and longer scan times. In a carefully design experiment, CNC Scanner demonstrated the ability to accurately measure dimensions to better than ±0.001".
The Effect of Depth of Field
Using a 10% Field Of View for image collection, a series of scans where collected from a 2.5D geometry (Figure 15). The camera was refocused after each scan to a new focal plane. Then, in each resulting photomosaic, the same round feature was measured. Figure 17 shows the relationship between the observed diameter measurement and the distance of the focal plane from the measurement plane.
Interpretation: With a small field of view, CNC Scanner performs fairly robustly as a telecentric lens emulation, showing in this case less than 0.002" variation in observed measurement over a 0.300" change in focal plane depth.
Sources of Error
- There are several sources of error to acknowledge in these measurements, including Observational Error introduced during the selection of the distance that is to be measured in Scanner CAD. It is still the responsibility of the user to interpret the exact location of an edge based on the contrast of the pixels.
- Systemic Error introduced from the inherent limits of positioning repeatability of the PCNC. The PCNC 1100 has a minimum discrete positioning move of 0.0001"; however, when considering the effect of other factors in the axes drive systems (ballscrew precision, friction, wind up, etc.), positioning repeatability will be 0.001" or better, depending on the individual machine
- Systemic Error introduced from the optics in CNC Scanner. Like any microscope, the optics used in CNC Scanner will have some image distortion introduced by lens aberrations, and curvature of field effects.
We initiated beta testing of the first CNC Scanner systems in September 2009 at a group of external customer sites. Reception was overwhelmingly positive. While several small changes were made to the initial design, we have been very pleased with its performance and released the product for general sale in January 2010.
CNC Scanner was demonstrated to be a useful tool for direct optical measurement and 2D reverse engineering of 2D parts. With care in technique, it can exceed accuracy of ±.001".Last Updated Jun 3, 2010
- Download Tormach CNC Scanner Design Analysis