How to use a Spindle Camera and SpindleView
CNC Spindle Cameras Part IV
Here I discuss how to most effectively use SpindleView, the underlying physics, and various tricks.
How to get Accurate Readings
There are a lot of places where errors propagate in an application like this. So, it’s easy to be disappointed with the app accuracy unless you do a few things.
- Lens Linearity — Inexpensive lenses have distortions and mounting issues.
- Resolution off — You can spend forever re-measuring resolution or just leave it really close and never touch it. I know where I fall in that.
- Machine Position drift — based on limit switch and other physical things that change a tiny bit
- Nonlinear motor systems — motor systems have imperfections in gearing and belt stretching and …
So, start off assuming these errors and then… use the center of the image as the only measuring spot.
In other words, if you want to know the coordinates of a visible spot move the camera to be right overhead — so the center is at the spot. At this spot resolution, focus height, and lens linearity have zero effect and your accuracy is exemplary. The only terribly important variable is Spindle Offset here.
How to Check Vise Placement with a Camera
I move my vise a lot for different sized stock. Each time the question comes up as to whether it’s lined up perfectly. The fixture plate is pretty tight but overtightening it causes the bed to warp so it’s possible it can shift.
Anyway, in just a few seconds it’s easy to see the (fairly small) vise placement error. Because the camera doesn’t move here (at all) the overall accuracy is near 2400dpi (or .0004").
Installation and Setup
Tighten the Camera
Make absolutely sure the camera won’t slip or slide during production. Specific Z axis movement isn’t a huge deal but rotating or displacing the camera is real bad. While the machine moves no one cares what’s on the video but at rest it’s important the camera be at a known X,Y offset from the spindle and Z offset from the stock.
Try hard to ensure the camera is pointing straight down before you tighten it. Look at a crosshatch sheet of paper and ensure the grid looks as parallel as the lens allows. Perhaps elongate one screw hole to allow a small amount of rotation of the mount at install.
You will be sad if you don’t first define how the camera works in the Settings. That’s the button at the top-left of the window.
Settings are stored in the web cache so they may disappear when you clear the cache. Please read the Save As discussion below. It’s odd.
Set the Camera URL first, so there is an image to use for the rest of the steps. Then,…
Set the Camera Center to the image size/2 as a starting point. Then:
- Set the Focus Height
- Determine the Camera Center (optional)
- Set the Resolution
- Find the Spindle Distance
- Save the options
More important than getting focus height correct (where focus is best) is using the exact same height consistently. So, always click the Set Focus button and set material height as close as possible to actual for best results.
To set focus height:
- Move the spindle to where you can see the bed (or fixture plate) with the camera.
- Raise/lower the height until the bed/plate is in perfect focus.
- Look at the machine Z position and that’s what should be the Focus Height value.
This is defined in pixels offset from the top-left corner. Using display size/2 is a fine compromise. The reticles will all show this center and the given distance to spindle is based on this value.
To set this exactly move the head up and down from the focus point. One dot will not move XY on-screen as you do this. That’s the display center. If you are very wrong (like 1/5th the display) then it is important to get the focus height correct or you may introduce inaccuracy.
The distance from the defined camera center to the spindle center. This is critical.
To measure this
- Move to a convenient drill point and drill a tiny hole, perhaps just the tip of a drill rotated by hand, or… place a rectangular stock in the vise and probe one corner of it.
- Set X,Y workspace zero (0,0) here for reference.
- Set the program Spindle Distance to (0,0) in Settings, as a help.
- Move the CNC so that the center of the camera is over the center of the drilled hole or the corner of the stock.
- The value shown in the Center’s position display (in Workspace coordinate mode) is the negative Spindle Distance.
- Change the Spindle Distance and watch the Center display — it should change to (0,0) Workspace.
This is the resolution of the camera (in the center) when it is focus height above the measured stock.
To measure the resolution:
- Place a ruler horizontally on the stock. You can check horizontal by moving X back and forth while watching the camera.
- Use the “Move to Click” button or the CNC controller move buttons to get the camera exactly on an Inch marker (or something easy). When resolution is wrong the moves will not be accurate.
- Set the location display mode to distance.
- Move the mouse to either side and see if when the mouse is 1/2" away the distance is shown as 1/2".
- Change the resolution (use (reading/actual reading) * old-resolution) until the distance shown is accurate. The farther away you go from the center the more error a lens will introduce so don’t overdo the range.
- To test, use the “Move to Click” button. If the resolution is correct the move will be right. If the resolution is too low then it will move too far.
Typically, with mjpeg-streamer this would be camera-url/?action=stream which is an mjpg stream of images. For me that’s http://zerocam1.local/?action=stream.
It needs to be an acceptable source for an http img object.
In case the camera is mounted upside down or sideways, use the option here to make it right-side-up.
This is the address where gcode is pumped. Currently only Duet3d Reprap is supported (supply the controller site URL) but other machines are easily also supported if they have any communications.
This is very strange because it’s a web site. It can only really download so you must pick an existing file (ignore the button saying Open, it won’t open the file) and it will write file-name(1) like typical download of a same name.