UCamCopy logo

CamCopyM3

UCamCopy for Mach3 — User Manual — Version 2.400

A video-camera based reverse-engineering and tracing program for Mach3
Manual revision: October 18, 2026
www.craftycnc.com

1. Introduction

CamCopyM3 is the Mach3 edition of UCamCopy, a vision-based probing and line-following program for CNC machines. It needs a webcam, preferably a “microscope” camera with fairly high magnification and adjustable focus. The camera image is processed with the EMGU/OpenCV libraries to find edges, lines, circles and enclosed shapes. Once an edge or target is found, CamCopyM3 drives the machine along it and records the path to a DXF file (and optionally a CSV file), so that you can reconstruct or copy existing geometry.

It runs as a separate program next to Mach3 and attaches to the running Mach3 through its COM interface. A small Mach3 plugin, CamCopyM3Plugin.dll, runs inside Mach3 and gives the program smooth, independent velocity control of the axes (section 5.4). The windows, the image processing, the PID velocity control, the recorder and the 3D viewer are the same as in UCamCopy for UCCNC, so everything from section 6 on works the same way. Sections 1 to 5, and the notes marked Mach3, are specific to this edition.

Camera orientation is essential Your camera must be oriented so that +X is at the right of the image and +Y is at the top of the image. Use the cross-hair lines as a reference against a horizontal or vertical mark, and adjust the camera as close to perfect as you can.

There is no scaling or dimensional calibration between the camera image and the machine. The image is used in a unit-less way to calculate position errors, and those errors drive the machine’s velocity through a closed-loop PID (proportional / integral / differential) controller using gains that you enter. The PID only generates velocity commands. Every dimension recorded in the DXF comes from Mach3’s actual axis position in the active work coordinate system, so the recorded data is as accurate as your machine’s steps-per-unit calibration.

1.1 How this edition differs from UCamCopy for UCCNC

TopicUCamCopy for UCCNCCamCopyM3 (Mach3)
What it isA plugin loaded by UCCNCA separate program (CamCopyM3.exe)
Starting itPlugin button code, hotkey or screen buttonStart Mach3 first, then start CamCopyM3 (section 5)
MotionAlways allowedOn by default, confirmed in a dialog at start; the switch /read-only turns it off
License IDFrom the motion controller’s serial numberFrom this PC, the Mach3 license file and the name in Mach3’s title bar (section 4)
E-Stop buttonAsserts E-StopAsserts E-Stop, and clears it again after you confirm (section 5.5)

About the picturesThe screenshots in this manual were taken from the UCCNC edition. The windows are the same in CamCopyM3; only the title bar, the About tab’s License ID and a few messages differ.

2. Important: limitations and safety

2.1 Motion is on, with a read-only mode for set-up

Started normally, CamCopyM3 can jog and move the machine. A dialog at start says so, and asks you to confirm that the machine is clear and you can reach the E-Stop. Answer No and the program closes without touching the machine.

To work without any risk of motion, start it with the switch /read-only (the installer adds a read-only shortcut). It then only reads Mach3: positions, state and limits. It never jogs, moves, changes an offset or sends G-code; anything that would is refused with a message on Mach3’s status line, so you can set up the camera, the image detection and the viewer, and check the DROs, safely. Stopping is always allowed. The title bar shows [MOTION ENABLED] when motion is on.

2.2 What happens when something goes wrong

EventWhat happens
CamCopyM3 crashes or is killedThe plugin notices that the program’s heartbeat has stopped and ends every jog it started. Measured on a real machine at 3 units/min: the axis stopped within 0.27 to 0.47 s, having coasted about 0.02 in. The coast grows with speed: at 23 units/min expect roughly 0.13 to 0.18 in.
Stop button, or the jog releasedThe plugin is disarmed at once (22 to 177 ms measured) and a zero speed is sent.
Hardware E-Stop during a jogMach3 stops the axis (59 ms measured).
Mach3 in E-StopNothing is sent to Mach3 at all: sending G-code to Mach3 while it is in E-Stop can hang Mach3 for good.

2.3 Warning and disclaimer

CamCopyM3 tries to be as reliable as possible, but it operates your machine through Mach3 and its settings. Setting up Mach3, your machine and the camera is your responsibility. You are responsible for checking and testing all signals, for the setup of your machine, and for becoming familiar with the software and its routines.

Machining is dangerous. Even though CamCopyM3 is only a video-probing utility and is not used while cutting, operate the machine as carefully as if you were machining. Keep your hand near the E-Stop whenever motion is enabled. Never place your hands in the machine’s working envelope while video probing. Always turn off or disconnect the spindle motor power when a camera is mounted. Do not video probe at excessive feed rates, and use common sense. By using CamCopyM3 you accept all liability for damage or harm that could be caused by its use, to you and to your equipment. If you do not agree, do not use this software.

CamCopyM3 is still in development. It has been tested to make it as bug-free as possible, but it is not guaranteed to work with every setup. CraftyCNC is not liable for any damage or lost time resulting from its use. UCamCopy, CamCopyM3, CamCopyM4 and CraftyCNC are in no way affiliated with Newfangled Solutions (Mach3, Mach4) or CNCDrive (UCCNC).

3. Requirements and installation

3.1 Mach3

CamCopyM3 is written for Mach3 version 3.043.x (the one the speed tuning was checked against). The program is a 32-bit (x86) program, as Mach3 is; it runs on 32-bit and 64-bit Windows. You need the .NET Framework 4.0 or later, which every current Windows has. Mach3 must be running, with your profile loaded, before you start CamCopyM3.

It was developed and checked on a router with a UC100 motion controller (profile RouterTesting, inches), and on a second profile with the controller switched off (inches and millimeters). Other controllers should work the same, because the program moves Mach3’s own jog engine, but they have not been tried.

3.2 Equipment

You need a video camera connected and configured on the PC that runs CamCopyM3. Notes on the camera:

See the appendix for the camera I use and what I do not recommend.

3.3 Installing

  1. Close Mach3. The installer will not continue while Mach3 is running, because Mach3 keeps its plugin files locked.
  2. Run CamCopyM3-2.400-Setup.exe (it needs administrator rights). It asks for the folder for the program (default C:\CamCopyM3; use a folder you can write to, because your settings and recordings are kept below it) and for your Mach3 folder (the one with Mach3.exe, normally C:\Mach3). It copies CamCopyM3Plugin.dll into the Mach3 PlugIns folder and adds Start Menu shortcuts: CamCopyM3, CamCopyM3 (read-only) and the manual.
  3. Start Mach3, open Config → Config Plugins, tick CamCopyM3Plugin, click OK, and restart Mach3 once. Mach3 starts a newly enabled plugin only after a restart.

Silent install: CamCopyM3-2.400-Setup.exe /S /MACH3=C:\Mach3 /D=C:\CamCopyM3 (/D must be last, without quotes). The installer never touches your settings and recordings, and the uninstaller keeps them too.

To check the plugin, look at C:\Mach3\CamCopyM3Plugin.log after Mach3 has started: it should contain shared memory channel ready, the profile path and a line starting tuning from the planner. When you start CamCopyM3, its confirmation dialog says how it will jog: smooth: through the CamCopyM3 Mach3 plugin, or stream of short G1 moves (audibly choppy) with the reason (for example the plugin is loaded but not enabled).

Without the pluginIf the plugin is missing, CamCopyM3 still works: it jogs by sending a continuous stream of short G1 moves. That works, but the motion is audibly choppy and less smooth for the PID. Install and enable the plugin for good results.

4. Trial and licensing

CamCopyM3 installs in a demonstration mode. In Demo Mode all features are fully functional for a trial period, so that you can try it before buying. The window title bar and the About tab show the current status.

To get a license, send an email asking to purchase one, and include the License ID shown on the About tab. It looks like 1a2b3c4d5e6f7a8b9c0d_YOUR NAME: a 20-character code followed by the licensee name. The code is made from three things on this PC: the Windows machine identity, your Mach3 license file (Mach1Lic.dat) and the licensee name that Mach3 shows in its title bar (Mach3 CNC  Licensed To: NAME). After payment, a passkey for that ID is emailed to you. Enter it in the Passkey box on the About tab and click Validate License Key. The status then shows Licensed.

The About tab
Figure 1. The About tab, with the License ID and the license status.

The Check Online for New Version button on the About tab compares your version with the latest one on the CraftyCNC website.

5. Starting CamCopyM3 and the machine controls

5.1 Starting

  1. Start Mach3 and load your profile. Leave the plugin enabled (section 3.3).
  2. Start CamCopyM3 (or its read-only shortcut for set-up and viewing, section 2.1).
  3. A dialog tells you how it will jog (smooth through the plugin, or the choppy G1 fallback). Make sure the machine is clear and you can reach the E-Stop, then answer Yes.
  4. The main window and the 3D viewer open. If Mach3 is not running, CamCopyM3 cannot find it and says so.

5.2 What the buttons do in Mach3

ControlHow it reaches Mach3
Jog buttons, Move ToPlugin (smooth) or short G1 moves (fallback)
Step movesA fixed-distance G1 move through Mach3’s COM interface
Work coordinate G54 to G59Reads Mach3’s active system; clicking another one selects it
Zero / Set DROWrites Mach3’s work DRO for that axis
Go to safe ZMoves to Mach3’s Safe Z height, in machine coordinates (G53 G0 Z…)
G68 / G69 rotationSent as G-code. Mach3 only reports the rotation angle, not its center, so the center is not shown

5.3 The jog panel: Step and Continuous

The jog panel on the right of the main window has two modes. Continuous is the hold-to-jog mode: the axis moves while you hold the button, and it goes through the plugin. Step sends a fixed-distance move; it runs to its target and does not stop when you release the button. If a jog button starts but does not stop on release, the panel is in Step mode.

5.4 Speed limits

The top speed the program can use per axis comes from Mach3’s own motor tuning, scaled by a figure the plugin measures and remembers for each profile and unit system (in C:\Mach3\CamCopyM3Plugin.ini). On a profile it has not seen, the first runs are held to 10% of the top speed until it has measured the scale. A feed rate above the top speed is limited, and Mach3’s status line says so. Both axes use the lower of the X and Y top speeds, and the program warns if they differ. The switch /plugincap=F sets what fraction of Mach3’s master velocity the plugin may use (default 1.0).

G20 and G21Mach3’s tuning is in the profile’s setup units. Switching the display between inch and millimeter with G20/G21 does not change the setup units; the plugin takes this into account and learns the scale again when the unit system changes.

5.5 The E-Stop button

The E-Stop button in the main window is a toggle. Not in E-Stop, it asserts Mach3’s E-Stop (it presses Mach3’s Reset button, which Mach3 uses as the E-Stop toggle). In E-Stop, it asks you to confirm and then clears it (Reset again) and waits up to 1.5 seconds for Mach3 to leave E-Stop. If a hardware input keeps Mach3 in E-Stop, it says so. The button flashes while Mach3 is in E-Stop. The program never presses Reset while Mach3 is already in E-Stop except when you ask it to clear.

5.6 Closing

Close CamCopyM3 with its window close button. Any jog is stopped first. Settings are saved if Auto Save is on (section 18).

6. The windows

CamCopyM3 is made of two main windows, plus a few settings windows:

Windows snap to one another when you drag them close together. When the viewer is stuck to the main window the pair moves as a group if you drag the main window; grab the viewer and pull to unstick it. CamCopyM3 works best at a screen resolution of 1280 × 1024 or higher.

The main window with the 3D viewer beside it
Figure 2. The main window and the 3D viewer.

6.1 Settings windows

The settings are not in tabs under the video any more. They are in separate windows that you open from the Settings menu, the first item of the menu strip above the camera view:

Menu entryContents
Image DetectionAuto Tune, the HSV option, blur, Canny, circle and line-detection values (section 10)
Offset & VelocityCamera/spindle offset moves and calibration (section 17), PID mode, gains and axis enables (section 13)
General SettingsInterface, safety and jogging, startup and updates, video overlay, detection colors, defaults and backup, DXF recording, live info (section 18)

The windows have a blue frame, can be dragged anywhere (also onto a second monitor), and remember where you left them. They snap to the other CamCopyM3 windows too. Closing a window only hides it. The viewer has its own settings window, opened from its toolbar.

The Settings menu with Image Detection, Offset and Velocity, and General Settings
Figure 3. The Settings menu.

6.2 Hiding panels

The side panels can be tucked away to give the video more room. The small arrow buttons on their edges (labelled Hide / Show) slide a panel away and bring it back. The viewer has the same strips for its two right-hand panels (Hide DRO / Info and Hide Layers / File Info). Which panels are shown, and how wide they are, is remembered.

The E-Stop button flashes while Mach3 is in E-Stop, so it is hard to miss (section 5.5).

7. The main window

The main window gives access to all of CamCopyM3’s features, laid out like a CNC control screen:

The main window
Figure 4. The main window.

7.1 Special Operations and Configuration Help

The Special Operations menu holds the arc/circle collection dialog (section 12.3) and the G68 rotation setup. The Configuration Help menu opens two guides that walk you through the first setup: camera alignment, and calibrating axis velocity (section 13).

8. Quick start

This is the shortest path from an unconfigured install to a traced part. Each step is described in detail in the later sections.

  1. Start Mach3, then start CamCopyM3 (section 5).
  2. Select your camera in the left panel and start it. Check focus and lighting in the Camera Capture view.
  3. Align the camera so that image-up is Y+ and image-right is X+, using the Configuration Help → camera alignment guide (section 13).
  4. Set the PID gains with a dot on a piece of paper (section 13.3). Do this once per machine and camera zoom.
  5. Put the part under the camera so the edge to trace is in view, open Settings → Image Detection and click Auto Tune (section 10).
  6. Select Lines / Edges, check that the mask shows a single clean line with a target dot at each end (section 11).
  7. Click the DXF button on the top panel so it shows DXF ON (section 15).
  8. Press Run (or the space bar) to start tracing, and press it again to stop.
  9. Click Save DXF.

9. The camera and the image views

The left panel controls the camera and selects which stage of the image processing is displayed.

The left panel
Figure 5. The left panel.

The Use HSV color for edges and detections checkbox (in the Image Detection window, next to Auto Tune) makes CamCopyM3 use color information instead of grayscale to find edges. This helps when your part looks similar to its background in grayscale. It is always better to create a color or shade difference yourself, for example by placing the part on light or dark paper.

9.1 Zoom and field of view

I usually zoom in so that about 1 cm (0.5 inch) spans the width of the camera view. Even with 640 × 480 pixels that gives less than 0.001 inch (0.015 mm) per pixel, which makes CamCopyM3 accurate without any calibration.

Camera view of a scale in millimetres
Millimetres
Camera view of a scale in inches
Inches

9.2 How the image is processed

EMGU/OpenCV captures the video and runs several steps to find lines, edges and circles:

Grayscale flow (HSV off): Capture → Grayscale → Blur → Mask (narrow region of the image) → Canny filter (edge detection) → Detections → output to drive the machine.

HSV color flow (HSV on): Capture → HSV conversion → Blur → Mask → Canny filter → Detections → output to drive the machine.

The Select View options let you look at each stage, so you can set thresholds more easily. During normal operation you will leave Composite Output selected.

9.3 The image views

The pictures below all use the same example part so you can compare the stages.

Camera Capture

The original, unmodified camera image. Use it to check lighting and focus.

Camera Capture view
Figure 6. Camera Capture.

Mask Only

A black and white picture of the mask. Image processing is limited to what falls in the white area.

Mask Only view
Figure 7. Mask Only.

Edges (Canny)

The most important view. It shows the edges the program finds after processing the image inside the masked region (yellow outline). Use the Edge (Canny) Threshold values and Thicken Edge (Canny) Lines to filter the edges until you get a strong, clean result like this one.

Edges (Canny) view
Figure 8. Edges (Canny).

Gray / Blurred

The grayscale image with blur applied. Available only when HSV is not checked. Adjust the Blur Amount in the Image Detection window to remove noise: too much blur makes edge detection difficult, too little leaves a lot of noise.

Gray/Blurred view
Figure 9. Gray / Blurred.

HSV Original

The original image converted to HSV color space and blurred. This can separate the image much better than grayscale, but needs extra thresholds to isolate the area of interest.

HSV Original view
Figure 10. HSV Original.

HSV Threshold

The HSV image needs the Color Detection Thresholding sliders adjusted. On the left below there are no thresholds and the areas are not separated well enough to detect an edge; on the right the thresholds give a clear edge.

HSV threshold with no thresholds set
No thresholds set
HSV threshold after adjustment
After adjusting the sliders
TipHold Shift and click a region of the image to set a first threshold range from that spot, then fine-tune with the sliders. Auto Tune (section 10.2) does this for you from the center of the image.

Composite

The final image, with overlays of the DROs and cross-hairs (if turned on) and the detections that drive the machine. The dark blue arrow is the direction the machine moves when Run is on. Red points and light-blue lines are the detected edges and the endpoints used to calculate the movement.

Composite output view
Figure 11. Composite output.

Multiple View

Shows the four most useful views at once, so you can adjust thresholds without switching back and forth. With HSV on you see the HSV image, HSV threshold, masked Canny edges and composite output; with HSV off you see the gray image, gray threshold, masked Canny edges and composite output.

Multiple view with HSV on
HSV on
Multiple view with HSV off
HSV off (grayscale)

10. Image detection and Auto Tune

Open Settings → Image Detection. The window opens in a Simple view that shows only what most people need: Auto Tune and its Undo button, the Use HSV color checkbox, the blur value, the Canny low/high thresholds and, when HSV is on, the HSV color range sliders. Tick Advanced settings to show every detection setting.

The Image Detection window, Simple view
Figure 12a. The Image Detection window, Simple view (Advanced settings off).
The Image Detection window with Advanced settings on
Figure 12b. The Image Detection window with Advanced settings on.

10.1 Settings

SettingWhat it does
Blur AmountRemoves noise before edges are found.
Edge (Canny) Threshold Low / HighLimits which edges are kept. Raise them to ignore weak edges.
Thicken Edge (Canny) LinesMakes detected edges thicker. Advanced.
Circle ThresholdHow strong a circle must be to be detected by the circle detector. Advanced.
HSV color rangeWith HSV on, the range of hue, saturation and value that counts as the target.
Use custom line detection settingsWhen ticked, the Hough and merge values below are used. When unticked, built-in defaults are used. Auto Tune turns it on. Advanced.

The line-detection values (Advanced view) control the line detectors and the line-merging algorithm:

10.2 Auto Tune

Finding good blur, Canny and line-detection values by hand can take a while. Auto Tune sets them for you with one click.

  1. Start the camera and put the part under it so that the edge you want is in view. If you use HSV color detection, put the target color at the center of the image first.
  2. Click Auto Tune. It samples a few live frames and tries different blur sizes (and, in HSV mode, different color-range widths). It scores each one by how continuous the resulting edge is and how strong the real image contrast under it is, then fills in the blur, Canny low/high, HSV range and line-detection values with the best result.
  3. A message reports the edge score before and after, and asks whether to keep the new values. Choose Yes to keep them or No to leave your settings as they were.
  4. The Undo button beside Auto Tune puts the previous settings back after you have kept a tune. It is greyed out until a tune has been kept.

Auto Tune needs the camera running (it asks you to start it first). You can still adjust any value by hand afterwards.

Auto Tune keep the new values message
Figure 13. Auto Tune asks whether to keep the new values.

11. Masking

The mask limits the part of the image that is used for detection. It has two shapes (round and rectangular) and an adjustable size. When you edge-trace, the size and shape of the mask are important: they reject noise and keep the tracing on course. The mask follows the angle of the edge it finds, which helps with steering. Items inside the white area of the mask are “seen”; items in the black area are rejected.

Mask Adjustments with the rectangle mask
Rectangular mask settings
Mask Adjustments with the round mask
Round mask settings
Rectangular mask in Mask Only view
Rectangular mask
Round mask in Mask Only view
Round mask

When edge tracing, your goal is to adjust the image and the mask until you have essentially a single line with a target dot at each end inside the mask. That is the line that will be followed.

When to use the maskMasking should be off for intersection, circle and contour detection, and on only for edge following.

12. The detectors

The detector buttons in the bottom panel choose what CamCopyM3 looks for:

Select Image Detector for Targeting group
Figure 14. Selecting the detector.

12.1 Lines / Edges

The detector you will use most, for auto-tracing the outside edges of objects. It needs a clear edge in the image and a mask that limits detection to the area of interest.

Edge detected and ready to trace
Figure 15. Good edge detection, ready to go.

You choose the direction the machine travels around the perimeter by double-clicking the image to re-orient the mask in the opposite direction:

Mask re-oriented to run the other way
Figure 16. Ready to go the opposite way.

You may have to help by positioning the part so the edge is initially centered, and by orienting the mask. In the next picture the edge is in the right place but is not detected, because the mask is not oriented over the edge:

Edge not detected because the mask is not over the edge
Figure 17. The mask is not over the edge, so nothing is detected.

Edge tracing

When you are calibrated and ready to trace: switch to line mode, jog until the cross-hair is over an edge, and adjust the image and the mask until you have a clean line with target dots at both ends. The mask aligns itself with the edge and can go either way around the part (clockwise or counter-clockwise makes no difference). Double-clicking near the center of the image re-orients the mask direction.

You can start and stop the velocity and move around as needed to cover all the edges. If the line is lost or the machine gets off track, stop the velocity, jog back into place, adjust the video and mask, and enable velocity control again.

DXF Data (edge trace) group
Figure 18. Edge-trace recording options.

12.2 Intersections

When enabled, the detector looks for the two most prominent lines in the image and uses their intersection as the target. Turn the mask off.

Intersection detection of two lines
Figure 19. Intersection detection.
Under developmentThis detection is somewhat erratic at the moment and is still being improved.

12.3 Circles and arcs

There are two ways to deal with holes and circles.

Circle detector

If the hole is small and fits completely in the camera view, select the circle detector and the machine drives to its center point. It only finds a location; the size of the circle cannot be determined from the camera image alone. Adjust the Circle Threshold until you get a reasonable detection (it may bounce around quite a bit). In the picture, the red dot is the center target and the dark blue arrow is where the machine will drive.

Circle detector
Figure 20. The circle detector.

Arc or Circle From Points dialog

For geometry that is too big for the camera view, open Special Operations → Arc or Circle From Points. The dialog helps you collect circles and arcs into the DXF or find sizes and center points.

Fit Data Points to Arc/Circle dialog
Figure 21. The arc/circle dialog.

Follow the prompts: jog to at least three locations on the arc or circle and click Sample Point at each. With three points the center and the diameter/radius are calculated and shown. You can collect more points for a least-squares fit, and then use the result to:

For an arc you can only use three points: sample one end, a point along the arc, and then the opposite end.

12.4 Contours (enclosed shapes)

Similar to the circle detector, but it finds shapes that are not perfect circles more easily. It is the detector I recommend when calibrating, because it is more reliable and stable than the circle detector and has no threshold to adjust.

Contour detector
Figure 22. The contour detector.

13. Velocity control and PID tuning

Before going far with CamCopyM3, set up the PID controllers (proportional / integral / differential) that drive the axes together with the velocity you choose. They are on the Offset & Velocity settings window (Settings → Offset & Velocity).

The Offset and Velocity window
Figure 23. The Offset & Velocity window, PID section.

13.1 Setup helpers

Under the Configuration Help menu, camera alignment and Calibrate Axis Velocity open guides that walk you through the initial setup.

The Align Camera Image entry of the Configuration Help menu and the first page of the alignment guide
Figure 24. The camera alignment guide, opened with Configuration Help → Align Camera Image. Click Next to move through the steps.
Calibration Setup dialog
Figure 25. The Calibrate Axis Velocity guide.

Key points:

13.2 Velocity control mode

ModeHow it worksUse it when
PID OnlyOne PID per axis, aimed at a target held a fixed distance from the current position. The X and Y PIDs calculate separate velocity commands from the difference between target and current position.The part has sharp corners or lots of twists and turns.
PID w/ Centering PIDAs above, plus two “Center PID” loops that reduce the following error between the closest point of the edge and the current position. Recommended. Can be unstable if the center PID is poorly tuned or aggressive; set its max output to 5 or 10% (the limit is 50%).Most work.
Angle/VelocityUses the Center PID loops to put the closest point of the edge at the target, and takes velocity out of PID control: speed and direction come only from the slope of the detected edge. A simplified algorithm that may work better on some machines.The part has long straight sides and few twists.

13.3 PID values

PID is a classic negative-feedback control (servos, thermostats and so on). In CamCopyM3 it looks at the error in the camera image — how far the center of the picture is from a defined target — and sends velocity commands to Mach3 to drive that error to zero. kP, kI and kD are gain coefficients. They must be set before you let CamCopyM3 control your machine.

The total gain fed to the machine is the combination of the maximum velocity you enter and the PID gains for the normal and center PIDs. If gains are too high the machine oscillates; if too low, it is slow and the following error grows, which turns into measurement error.

Tuning procedure

Place a small dot on a piece of paper as a target, then:

  1. Turn off Lines / Edges and turn on Contours. When the dot is detected, a target dot appears at the center of the outlined dot. Make sure the mask is off.
  2. Enable only the X PID first (leave the Y PID off with its enable checkbox). The kP, kI and kD values apply to both axes equally, but it is easier to watch one axis at a time.
  3. Jog to one side of the contour (left or right).
  4. Enter a starting value for kP, and leave kI and kD at zero.
  5. Click the Run button. The machine should move the center of the dot to the center of the screen and stop. Turn Run off.
  6. If the machine goes in the wrong direction, stop and check the camera orientation and your axis definitions.
  7. If it goes to the center and stops without oscillating, try a larger kP. If it overshoots and swings back and forth, reduce kP and try again.
  8. When kP is just starting to cause a small overshoot, cut it in half.
  9. Enable the Y PID as well and check that it settles similarly. Reduce the gain if Y oscillates.
  10. Run X and Y together and check that the machine centers on the dot while both axes move.
  11. Leave kP alone and repeat the process for kD only.
  12. Until you are tracing real profiles and watching the line-following behavior, leave kI at zero. It is used to eliminate overall following-error offsets.

When it works, the target dot is brought to the center of the view and stops without oscillating. You can then change the values, jog off center and run again to test them. You want the machine to snap quickly to the dot without oscillating or overshooting.

Units and zoomMy testing was in inch units. Good PID values for your machine depend on your units, steps per unit, camera resolution and zoom. Camera zoom also affects the gains, so try to set things up consistently if your camera has an adjustable zoom.

13.4 Update rate

The PID Update Rate (in ms) is how often the PID loops are calculated and velocity commands are sent to Mach3. I suggest about 100 ms (10 times per second). It should be slower than the camera’s frame rate by about 50%. For example, a camera running at 15 fps delivers a frame every 67 ms (1/15 = 0.067), so set the update time larger than that; 100 ms gives 10 updates per second. If your camera has a consistently high frame rate you can decrease the value: 50 ms (20 Hz) works with a 30 fps camera.

You can see the real frame rate in the status messages at the bottom of the window:

Video info status: Act FPS and Process FPS
Figure 26. The video info.

14. Running: Run/Stop and recording

CamCopyM3 does not run routines step by step like a touch probe. Instead you use the Run/Stop button to give CamCopyM3 control of the axes or to take it away.

Run/Stop button, stopped (red) Run/Stop button, running (green)
Figure 27. The velocity box and Run/Stop button: stopped (left) and running (right).
Move vector in dark blue and target points in red
Figure 28. The move vector (dark blue) and the target points (red).

If there are no targets, jog the machine by hand to bring one into view. If the target is in view but not detected, adjust the image and the detections until it is.

Machine moves can be aborted, and fail safe: if Mach3 is in E-Stop or refuses a move, CamCopyM3 stops rather than guessing.

14.1 Working on one file

Once you have opened a file to record to, you can start and stop recording as often as you like. For example, you can record some perimeter feature (click Abort to stop), record a bore or edge feature elsewhere, set a new Z location, go back and record another perimeter, all to the same file. When you are done, save it all with Save DXF.

15. DXF and CSV recording

The top panel controls recording of DXF or CSV data, opening, saving and closing files, choosing the DXF layer to record on, and so on.

The DXF and CSV control bar
Figure 29. The DXF controls at the top of the main window.

You can also record points manually and choose whether each point is joined to the previous one by a line (line join / break).

The Point Sample Distance is used during auto edge tracing and sets how far apart the recorded points are, which controls the resolution of the edge: a smaller number means finer resolution. Edges are recorded as points joined by straight lines. You can fit this data to polyline curves in your CAD or CAM software afterwards.

CamCopyM3 records to a CSV (comma-separated values) file that Excel can import, to a DXF file, or to both at once. Files are stored in the output folder inside the program folder, next to CamCopyM3.exe (section 18.4).

UnitsRecorded files are unit-independent. Positions and sizes are written as plain numbers in your native units. If you probe a one-inch (25.4 mm) bore, the circle is recorded with a diameter of 1.000 if Mach3 is in inch mode, or 25.4 in metric mode. Scale the file if you use it directly in CAM or CAD.

15.1 Starting a recording

Turn on the CSV checkbox, the DXF checkbox, or both. You are prompted for a file name; if you select both, the name is used for both formats. Once the DXF or CSV button shows ON and a name has been entered, you only have to trace the part: all data is recorded until you close the file. Starting a DXF recording creates (or selects) the DXF layer for you; use the Active Layer selector to record to a different layer.

DXF ON?DXF points are only added while the DXF button at the top left of the main window shows DXF ON. If traced points are not showing up in the DXF, check that button first.

15.2 Open

If no DXF data has been recorded, Open opens an existing DXF file. You can open several files, which are appended together; new data you collect is merged into them. When you save, you can overwrite or save under a new name. As soon as a file is opened or data is recorded, the button works for saving until you clear the DXF buffer or save the file.

15.3 Empty and Close

While a recording option is on, data keeps being collected and appended internally. After you finish probing a part, click Close DXF to close the file (you are asked to save if you have not). To throw away data you do not want, click Empty DXF, which clears it without saving.

15.4 Save DXF

You can click Save DXF at any time to make sure the results are on disk. If there is no file name yet you are prompted for one; if CSV and perimeter files are selected, they are saved with the same name as the DXF. Once the file has a name it is displayed, so you can confirm where the data is going.

15.5 Save As

To save the DXF data under a different name, use Save As on the viewer toolbar (or Save As… in the viewer’s right-click menu). Unlike Save DXF it writes the file whether or not the DXF button shows ON, and the new file becomes the current file, so a later Save DXF goes there (section 16.9).

16. The 3D viewer and DXF editing

The viewer shows the point cloud and DXF data measured and recorded while you probe, and the camera position in real time. It also shows information about the DXF, lets you control the layers and colors and choose the active layer to record on, and is a basic DXF editor: you can pick, delete, move to another layer and draw lines. Colors and visibility are set by you.

The 3D viewer
Figure 30. The 3D viewer.

16.1 Window layout and panels

Each of the two right-hand panels has a vertical Hide / Show strip beside it. Click it and the panel slides away to give the 3D view more room; click again to bring it back. Drag the left edge of a panel to make it wider or narrower. Which panels are shown, and how wide, is remembered the next time the viewer opens.

File Info panel text
Figure 31. The File Info panel.

16.2 Moving around the view

A short right-click that does not drag opens the right-click menu instead of rotating.

Yellow pivot dot while rotating
Figure 32. The pivot dot (yellow) shown while rotating. Its size and color can be changed in the viewer settings.

16.3 Selecting entities

Click a line, circle, arc or polyline to select it. It is drawn in the Selection Color (cyan by default) and its layer and coordinates are shown in the status bar. Before you click, the entity under the pointer is drawn in the Hover Color (orange by default). Open shapes (lines, arcs, open polylines) show a green Start dot and a red End dot, and an arc also shows a blue Center dot. Closed shapes such as circles have none of these.

An entity highlighted under the pointer
Hover
A selected entity with start and end dots
Selected, with Start and End dots

While Select or Zoom Box is on, dragging draws the box instead of panning the view.

The Select tool with a selection box being dragged
Figure 32a. The Select tool on (the button stays highlighted) with a box being dragged. Everything the box touches is selected.

16.4 Delete, Undo and Redo

With entities selected, click Delete (or press Delete) to remove them from the DXF data. Undo (Ctrl+Z) takes back the last change and Redo (Ctrl+Y or Ctrl+Shift+Z) puts back what you just undid. The history covers deleting entities, drawing lines and moving entities to another layer, one change at a time. A new change clears the Redo history, and opening or clearing a DXF clears both.

Any edit marks the DXF as having unsaved changes, so the Save button on the main window becomes available.

The viewer after deleting 89 entities, with the status bar message
Figure 32b. After a delete, the status bar says how many entities were removed and reminds you that Ctrl+Z undoes it. The Cnt column of the layer list drops to match.

16.5 Draw Line

Draw Line adds new lines to the DXF by clicking in the view. Click Draw Line on the toolbar (the button stays highlighted while the tool is on), then:

The viewer toolbar with the Draw Line button highlighted
Figure 32c. The toolbar with Draw Line turned on.
  1. Click the start point. A green dot marks it.
  2. Click the end point. A line is added, and its end point becomes the start of the next line, so you can keep clicking to draw a connected series. A rubber-band line follows the pointer from the start dot.
  3. Press Esc once to end the series (then click a new start point), and Esc again to leave the tool. Clicking the Draw Line button again also turns it off.
Green start dot and an orange rubber-band line following the pointer
Figure 32d. The green start dot, and the orange rubber-band line that follows the pointer. The status bar tells you what to do next.
A connected series of drawn lines, with the rubber-band line from the last point
Figure 32e. A connected series of lines (red). The rubber-band line runs from the last point, ready for the next click.

Snapping: when the pointer is within about 12 pixels of the start or end of an existing line, an orange dot appears on that endpoint and the status bar names it. The point you click is then exactly that endpoint, so lines join cleanly. Away from an endpoint the point is where you click, at Z = 0. Only the endpoints of lines are snap targets; arcs, circles and polylines are not.

Orange snap dot on a line endpoint
Figure 33. Snapping to a line end: the orange dot sits on the endpoint, and the status bar names the line and its layer.

New lines go on the active layer (shown in the Layers panel; one is created if there is none). Each line is one Undo step. Pan, rotate and zoom still work while the tool is on. Use the Top view for drawing: in an edge-on view such as Front or Right a click cannot be placed on the Z = 0 plane.

Lines drawn on the new active layer TestDraw, shown in pink, with the snap dot on an existing line
Figure 33a. Drawing on the active layer. Here a new layer, TestDraw (pink), is the Active Layer, so the new lines are pink and its Cnt goes up as lines are added. The orange dot is snapping to the start of an existing line.

16.6 Layers and Move to Layer

The layer list has these columns: Vis (click to show or hide the layer), Col (double-click to change its color), Del (delete the layer and its entities, after a confirmation), Layer Name (edit it to rename the layer) and Cnt (the number of entities on it). Add Layer creates a new layer and Refresh Layer List rebuilds the list. The Active Layer is the one that newly recorded data and newly drawn lines are put on. Layer names must be unique (upper and lower case count as the same): a name that is already in use is refused, both for a new layer and when renaming.

To move entities to another layer, select them, right-click one of them, choose Move to layer and pick the destination layer. The entities keep their positions; only their layer changes. They stay selected so you can see the result, and Undo moves them back. If the layer you want does not exist yet, create it first with Add Layer or New Layer… in the right-click menu.

The viewer with the Layers panel showing two layers
Figure 34. The layer list in the viewer's DXF/Layers panel, with two layers.

To make a new layer, click Add Layer (or choose New Layer… in the right-click menu). CamCopyM3 asks for a name, then for a color. If you cancel the color dialog the layer is still created.

The Add new Layer name prompt
Figure 34d. Enter the layer name.
The color chooser for the new layer
Figure 34e. Pick the layer’s color.

Moving entities, step by step: first select them (here part of the red Tri layer is selected, shown in cyan), then right-click one of them and open Move to layer, which lists every layer. Pick the destination.

Entities selected in the Tri layer
Figure 34a. The entities to move are selected.
The Move to layer submenu listing Slot and Tri
Figure 34b. Move to layer lists the layers.
The entities now drawn in the Slot layer color, with the status bar message
Figure 34c. After choosing Slot: the entities are drawn in that layer’s color, the Cnt values change, and the status bar says how many were moved (Undo puts them back).

16.7 Right-click menu

Right-click (without dragging) in the 3D view to open a menu. If you right-click an entity that is not selected, it becomes the selection; if it is already part of the selection the whole selection is kept, so you can act on a group. The menu has:

Entries that do not apply, such as Delete with nothing selected, are greyed out.

The viewer right-click menu with one entity selected
Figure 35. The right-click menu with an entity selected. The keyboard shortcut for each entry is shown beside it.
The viewer right-click menu with nothing selected, Delete and Move to layer greyed out
Figure 35a. With nothing selected, Delete, Move to layer and Clear selection are greyed out.

16.8 Viewer settings

The Display Options menu turns the Axis / WCS indicator, the grid and the current-position marker (Show Cur. Position) on and off. The colors and sizes are in the viewer’s settings window, opened from the toolbar. Its groups are collapsible; Viewer Colors and Sizes are open by default.

Click a color swatch to change that color. The settings are saved with the viewer settings when you click Save Settings on the main window.

The viewer settings window
Figure 36. The viewer settings window.

16.9 Saving a copy of the DXF (Save As)

Click Save As on the viewer toolbar, or Save As… in the right-click menu, to save the DXF data to a new file. The save dialog opens in the folder of the current file with its name filled in, ready to change. The data is written whether or not the DXF button on the main window shows ON, and the new file becomes the current file: the name shown on the main window changes to it, and a later Save DXF goes there. The original file is not changed. Save As writes only the DXF; the CSV and perimeter files are written by Save DXF.

17. Camera / spindle offset

You will most likely have the camera side-mounted to your spindle. The offset controls (in Settings → Offset & Velocity) let you set the offset between the spindle and the camera and then toggle the machine from one position to the other.

This is a good setup tool: use the camera and cross-hairs (or the detectors, or the arc/circle routines) to locate the origin you want, then move the spindle to that location and zero the DROs.

The Offset and Velocity window
Figure 37. The camera/spindle offset controls.

Each session, the first time you zero an axis or use a button to move between the spindle and the camera, you are asked which position you are currently using (camera or spindle). From then on the buttons only toggle between the two.

18. General settings, settings files and backups

18.1 General Settings window

Settings → General Settings holds the options that are not about image detection. They are in collapsible groups in two columns; whether each group is open is saved with your other settings.

GroupWhat is in it
InterfaceEnable Tool Tips?, Enable Error Message/hints?, Group Minimize/Restore All Windows?, and the Config ‘Open’ Button Code button, which is a UCCNC feature and has no use in CamCopyM3.
Safety & JoggingDisable Jogging in UCCNC interface? is a UCCNC feature and has no effect here: Mach3’s own jog keys stay active, so do not touch them or a pendant while Run is on. Check for softlimits, abort if hit stops and reports if a soft limit is hit during a move.
Startup & UpdatesAuto Save ‘settings’ on close? saves your settings when CamCopyM3 is closed. Auto Check for New Version Enabled? checks the website for a newer version when CamCopyM3 starts (if you have a network connection). The Check Online for New Version button on the About tab works whether or not this is ticked.
Video OverlayDROs on the image overlay, DRO color, cross-hair overlay, cross-hair color, line width, circle radius and number of cross-hair circles.
Detection ColorsThe colors of the detected line, the target point and the move vector.
Defaults & BackupSet Defaults – INCH, Set Defaults – MM, Save current as defaults… and Restore from backup….
DXF RecordingRecord Z on zero plane, the Z value to record as, circle size to draw on “record pt”, and cross-hairs on circle.
Live InfoThe live detection information that is also shown at the bottom left of the main window: video info (image size, actual and processing frame rate), mask info (the mask angle) and line info (lines found, and lines left after merging similar ones).
The General Settings window
Figure 38. The General Settings window, with all groups open. Click a group header to open or close it.

18.2 Saving settings

Click Save Settings on the main window to save your settings (the controls of the main window and the settings windows, and the viewer settings). Settings are only saved when you click the button, plus an automatic save when CamCopyM3 closes if Auto Save is on and the settings loaded properly. If the settings could not be read when CamCopyM3 started, nothing is auto-saved over them.

18.3 Defaults

The first time CamCopyM3 runs with no saved settings, it asks whether you work in inch or metric and loads matching starting values. You can also choose a settings file instead. The starting values are sensible first-pass settings for both the main window and the viewer; the metric set has the feedrates and lengths converted (for example the probing velocity is 102 mm/min instead of 4 in/min, and the viewer’s grid is 127 mm across instead of 5 in). Please check the values against your machine, camera and zoom, especially the PID gains (section 13).

18.4 Where the files are, and backups

Everything is in Settings\, a folder that CamCopyM3 creates next to CamCopyM3.exe:

File / folderWhat it is
UCamCopy.xml, UCamCopyViewer.xmlThe main window and viewer settings: every checkbox, number, text, combo, color and group state.
UCamCopy.settings.xmlWindow positions, sizes and panel state. On the first run, values from an older install are imported once.
Backups\Rotating backups (the newest 10 of each file), made whenever a settings file is about to change.
SettingsLoad.logOne line for every save, load and restore, plus anything that could not be applied and why. Look here first when “a setting didn’t stick”.
WindowPositions.xmlWhere each settings window was left.
Defaults\The defaults you saved.

Settings are written safely (a new file is written and checked before it replaces the old one), and a settings file that cannot be read is never overwritten by the defaults.

Restore from backup… (General Settings, Defaults & Backup) lists the backups and puts the one you choose back.

19. Troubleshooting

SymptomCheck
The camera is not in the listPlug it in, then click the refresh button next to the camera list. Make sure no other program has the camera open.
Run is on but the machine does not moveMoves only happen when a target is detected. Check that the overlay shows target points and a blue move vector; if not, adjust the image, thresholds and mask, or run Auto Tune. Check that Mach3 is not in E-Stop, that it was not started with /read-only (the title bar shows [MOTION ENABLED] when motion is on).
The machine goes the wrong wayCheck the camera orientation (+X to the right, +Y up) and the axis definitions in Mach3. See section 13.
The machine oscillatesThe gains are too high. Reduce kP (and kD); see the tuning procedure in section 13.3.
Edge is found but not tracedThe mask is probably not oriented over the edge. Double-click the image to re-orient it. Check the mask size and Max Angle Delta.
Traced points are not in the DXFMake sure the DXF button shows DXF ON and a file name has been entered (section 15.1).
Low frame rateCheck lighting: many cameras drop to about 10 fps in poor light. Compare Act FPS with Process FPS (section 13.4).
A setting was not rememberedClick Save Settings. Then check Settings\SettingsLoad.log, and use Restore from backup… if needed.
The program is not licensed after I entered the passkeyThe passkey must match the License ID shown on the About tab, which is created from this PC, your Mach3 license file and the licensee name in Mach3’s title bar. If any of those changed, a new passkey is needed.
Everything is refused with a message on Mach3’s status lineCamCopyM3 was started with /read-only, or Mach3 is in E-Stop, or a program is running in Mach3.
The jog is choppyThe plugin is not being used. Check that CamCopyM3Plugin is ticked in Mach3’s Config → Config Plugins, that Mach3 was restarted after enabling it, and that C:\Mach3\PlugIns\CamCopyM3Plugin.dll exists. The dialog shown at start says why the fallback is used.
Mach3 crashes when the plugin is enabledReport it with C:\Mach3\CamCopyM3Plugin.log. Make sure the plugin file is the one that came with this version.
Jog buttons start the axis but it does not stop when releasedThe jog panel is in Step mode; switch it to Continuous (section 5.3).
The speed is lower than the feed rate I enteredThe feed rate is above the top speed the plugin allows; Mach3’s status line says so. Raise /plugincap= (up to 1.0) or lower the feed rate.
The plugin refuses to jogThe plugin log (C:\Mach3\CamCopyM3Plugin.log) gives the reason: E-Stop, a program running, command stale (no heartbeat from CamCopyM3), no usable tuning, or trajectory ring busy.
The plugin file cannot be replaced when copyingMach3 still has it loaded. Close Mach3 first.
The License ID shows “not found”Mach3 is not running, or its title bar shows no licensee name (a demo Mach3).

Appendix: reference, switches, versions and cameras

A. Viewer shortcuts

ActionHow
PanLeft mouse button + drag
RotateRight mouse button + drag
ZoomMouse wheel
Reset viewR (pointer over the 3D view)
Select an entityClick; Ctrl/Shift-click to add or remove
Box select / zoom boxSelect or Zoom Box tool, then drag; Alt removes
Clear selection / leave Draw LineEsc
DeleteDelete
Undo / RedoCtrl+Z / Ctrl+Y (or Ctrl+Shift+Z)
Run / Stop (main window)Space bar
Re-orient the mask direction (main window)Double-click the image
Set a first HSV range (main window)Shift-click the image

B. Files and folders

Next to CamCopyM3.exe (the folder you installed it in):

PathPurpose
CamCopyM3.exe, CamCopy.Core.dllThe program and the shared UCamCopy code
Settings\Settings, backups, defaults and log (section 18.4); created by the program
output\Recorded DXF and CSV files; created by the program
input\Input files; created by the program
images\Interface icons
Manual\This manual (opened by the Help button), with its pictures
README.txt, UCAM_EULA.rtfThe install notes and the license agreement
Emgu.CV.UI.dll, Emgu.CV.World.dll, ZedGraph.dll, DirectShowLib-2005.dll, MagnetWindows.dll, x64\, x86\Video and graphics support files
C:\Mach3\PlugIns\CamCopyM3Plugin.dllThe Mach3 plugin
C:\Mach3\CamCopyM3Plugin.log, .iniThe plugin’s log, and the speed scale it remembers per profile and unit system
C:\Mach3\CamCopyM3Plugin.nodriveOptional flag file: if it exists the plugin never drives an axis
Windows registry HKCU\Software\CraftyCNC\CamCopyM3The trial and license information (separate from the other CamCopy products)

C. Command-line switches

SwitchMeaning
/read-only (or /no-motion)Read positions and state only; nothing is ever moved or changed. Without it, motion is on and a confirmation dialog is shown at start (default No). /enable-motion is still accepted and does nothing extra.
/log=PATHWrite a CSV of every jog command sent, for tuning.
/nopluginDo not use the Mach3 plugin; use the choppy G1 fallback.
/plugincap=FFraction of Mach3’s master velocity the plugin may use, 0 < F ≤ 1 (default 1.0).
/pluginminspeed=VSpeeds below V units/min are sent as zero (default 0.01).
/minspeed=V, /maxvel=V, /segment=S, /lead=S, /jogprefix="G64"Fallback mode only: speed floor, stand-in axis maximum, G1 segment length and queue lead (seconds), and a line sent before each jog.
/dev-unlockDebug builds only; ignored in the release build.

D. Version history

V2.400 — CamCopyM3 first release

The Mach3 edition of UCamCopy, built on the same code as UCamCopy for UCCNC: the main window, image detection and Auto Tune, the PID velocity control, DXF and CSV recording, the 3D viewer and DXF editor, and the safer settings files. The Mach3 plugin gives smooth, independent per-axis velocity control; without it the program falls back to a stream of short G1 moves. Motion is on by default, with a /read-only switch for set-up. The E-Stop button asserts and clears.

The history of the shared program before this release is in the manual for UCamCopy for UCCNC.

E. Cameras and FAQ

Cameras. I cannot make a direct recommendation on brand or model since I have only tried a few. In general, look for one that advertises 30 fps and has adjustable focus done with a knob at the back end.

What camera do I use? The one below, bought on Amazon. It is also sold by Oasis Scientific as model V1-PS.

USB digital microscope with a stand
The camera I use.

Things I like:

Things I do not like: some background noise in the image, but I think that is common with all cameras of this type (CMOS sensors).

Any camera I absolutely do not recommend? Yes: the type with a focus wheel near the lens instead of at the back. The lens has play, so the image moves around and the focus does not stay adjusted. It is fine as a real microscope but does not work well mounted on a CNC. This type also had a lower frame rate and a noisier image, and a maximum resolution of only 1920 × 1080.

A camera with a focus wheel near the lens
The kind of camera not to buy for CNC mounting.

CamCopyM3! Copyright 2023–2026 by Crafty CNC / Eric Brust. www.craftycnc.com