Showing posts with label Mach3. Show all posts
Showing posts with label Mach3. Show all posts

Monday, May 30, 2022

CNC Probe for Mach3

I'm putting the finishing touches on a 3-pin style probe for my little CNC mill and figured I'd share what worked. The 3-pin switch is amazingly sensitive - closer than I can measure in my shop. I've already used it on one project so far, and after years of manual edge finding and fighting with flipped parts, it's pretty awesome. This page does a much better job than I can do to explain how it works: https://www.silvercnc.com/touch-probe/  A bunch of folks have made these, and you can even buy a pretty decent looking version on Aliexpress for under $70US. (V5 Touch Probe)



The goal was to keep it as short as possible in the vertical axis and to be able to use it on both CNC and manual machines. In order to use it on the manual mill, I needed some visual feedback (also helpful on the CNC), so I added red and green LEDs to indicate the state of the switch.

 

Mechanical:

The switch mechanism consists 3 radially spaced horizontal pins resting on 6 steel balls. The balls are soldered to a copper circuit board that's been machined to isolate the balls in pairs. A stylus on the bottom of the mandrel is used for probing and when it touches a surface in any plane, one of the pins will lift off the ball, breaking a circuit. This creates a very sensitive electrical switch. 

Centering and calibration are managed by a steel hub with a press-fit 1/4" shank to mount in the machine spindle, a V-groove, and a top lip. That inserts into an outer aluminum ring with set screws that engage the V-groove and lock it in place. There is about .030" clearance on the ring/hub interface to allow for centering.

3 long bolts run from the bottom acetal plate into the top aluminum ring, capturing an outer aluminum housing.

The stylus is a turned steel part with a 3/16" ball bearing soldered to the bottom end with 3mm threads on the top to attach to the mandrel.

Since none of my machines are particularly accurate, the probe is calibrated for the CNC mill, which is where I'll use it most. In order to maintain rotational orientation, it's mounted in an R8 tool holder that always goes back in the spindle in the same orientation. That way, I can calibrate it to about +-.001" on the CNC mill. I care a lot less about accuracy on the CNC router, so any runout will be close enough. On the manual mill, I can rotate the probe to take multiple readings and get an average. (there's about .002" difference in runout between the two milling machines - I suspect it's mostly in the old worn-out manual mill.)




 






Electrical:

The electronics consist of an inverting circuit that lights the red LED when the switch is open and green when closed. A transistor acts as a switch for the probe circuit, driven by the 3-pin switch. 

 My two CNC controllers use different voltage for the probe signals. The router uses a Gekko G540 which outputs 12V at about 7ma. The mill uses an old Probotix breakout that outputs about 4.3V at 2.5ma. I was a little worried about getting them both to work on the same wiring, but they seem happy. On both machines, I pulled 5V power from the internal power supply so there's a single connector. I used DB9 connectors on the controller box with just 3 pins active.

The connector on the probe itself uses mini-USB with Vin, ground and Data+. (But, it's NOT USB protocol, just the wiring.)

For use on the manual mill, a 5V wall wart with a 10K resistor on the probe circuit (without it, the transistor gets hot, smells bad then stops working...), and just use the lights to tell when the switch is triggered.


Mach3 code - (be sure to test and use at your own risk)

Here's the code I use for probing the ID of a circle:


If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Probe plate is grounded, check connection and try again)"
Else
FeedCurrent = GetOemDRO(818) 'Get the current settings
XCurrent = GetDro(0)
YCurrent = GetDro(1)

Code "G4 P1" 'Pause 1 second to give time to position probe plate
Code "F4" 'slow feed rate to 4 ipm 100mm

Rem Probe Left

XNew = Xcurrent - 3 'probe 3 inches to left 75mm
Code "G31 X" &XNew
While IsMoving() 'wait for the move to finish
Wend
XPos1 = GetVar(2000) 'get the probe touch location

Code "G0 X" &XCurrent 'rapid move back to start point

Rem Probe Right

XNew = XCurrent + 3 'probe 3 inches to right 75mm
Code "G31 X" &XNew
While IsMoving()
Wend
XPos2 = GetVar(2000)

XCenter = (XPos1 + XPos2) / 2 'center is midway between XPos1 and XPos2
Code "G0 X" &XCenter 'rapid move to the x center location

Rem Probe up

YNew = YCurrent + 3
Code "G31 Y" &YNew
While IsMoving()
Wend
YPos1 = GetVar(2001)

Code "G0 Y" &YCurrent

Rem Probe down

YNew = YCurrent - 3
Code "G31 Y" &YNew
While IsMoving()
Wend
YPos2 = GetVar(2001)

YCenter = (YPos1 + YPos2) / 2


Rem move To the center

Code "G0 Y" &YCenter
While IsMoving ()
Wend

Code "F" &FeedCurrent 'restore starting feed rate

DoOEMButton ( 1008 )
DoOEMButton ( 1009 )

End If

 

And this probes the upper left-hand corner of a rectangle. 

If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
Code "(Probe plate is grounded, check connection and try again)"
Else
FeedCurrent = GetOemDRO(818) 'Get the current settings
XCurrent = GetDro(0)
YCurrent = GetDro(1)
ZCurrent = GetDro(2)

probedia = .1875
ProbeOffset = .375

fff = machmsg("Is the probe diameter " &Str(probedia) & "?", "Probe Diameter", 4)
If fff = 7 Then
    probedia = question("Enter Current Probe Diameter")
    machmsg("Updated probe diameter is: " &Str(probedia), "Probe Diameter", 0)
End If

BackOff = .05


Code "G4 P1" 'Pause 1 second to give time to position probe plate
Code "F4" 'slow feed rate to 4 ipm 100mm


YNew = YCurrent - 2
Code "G31 Y" &YNew
While IsMoving()
Wend
YPos2 = GetVar(2001)

Code "G0 Y" &YPos2 + BackOff
While IsMoving()
Wend

Code "G0 Z" &Zcurrent + ProbeOffset
While IsMoving()
Wend

Code "G0 X" &Xcurrent - .6
While IsMoving()
Wend

Code "G0 Y" &YPos2 - ProbeOffset
While IsMoving()
Wend


Code "G0 Z" &ZCurrent
While IsMoving()
Wend

XNew = XCurrent + 2 'probe 2 inches to right
Code "G31 X" &XNew
While IsMoving()
Wend
XPos2 = GetVar(2000)

Code "G0 Z" &ZCurrent + ProbeOffset
While IsMoving()
Wend
Code "G0 X" &XPos2 - probedia/2
While IsMoving()
Wend
Code "G0 Y" &YPos2 + probedia/2
While IsMoving()
Wend

Code "F" &FeedCurrent 'restore starting feed rate

DoOEMButton ( 1008 )

DoOEMButton ( 1009 )

End If
             






Sunday, June 21, 2015

New CNC

A new CNC has been taking shape in my shop over the last several months. It's a major rebuild of my previous router-lathe that adds another axis of movement and a lot more capability. I kept quiet about it until it was actually running because the design is a little unusual and I wasn't entirely sure if it was going to work -- I wanted to avoid having to say "that new machine I'm building? umm, never mind...".

It's still under construction, but far enough along that I can use it to make parts for itself.

Configured for flat work

Configured for 4th axis (lathe)
It's basically a standard 3-axis router built around an old 11" x 36" wood lathe. It has two configurations: a 3 axis router, or remove the table to access the lathe for 4th axis work. As with previous projects, most of the design work was done in Sketchup before and during construction.

Configured for rotary work on the lathe
With the table installed for flat work.


Here are the first cuts:

 




Rotary axis test.


The rotary axis (lathe) drive. 16:1 ratio -- kevlar belts.


Detail of the bearings on the gantry sides

Fabricated lathe bed and side rails


Sunday, May 5, 2013

Router lathe -- converted to CNC


A lot has happened on the router lathe and this posting is way overdue. It's gained a nice new 3rd axis carriage driven by a stepper motor, adding programmable z-axis (depth of cut) control,  and has been converted from arduino control to full CNC, controlled by a PC running Mach3. Here's a video of the first major part cut on the machine since the rebuild.


The conversion to a CNC controller opens up huge potential. The arduino was great for spirals, but it took a lot of code to generate them. I found I could do in 3 0r 4 lines of g code what took 100+ lines of arduino code.  I could have installed Grbl and continued using the arduino as the CNC controller, but I like the feedback graphical programs like Mach3 and EMC2 provide. Although I do have an idea for a little internal thread-cutting machine that Grbl might be perfect for.

Cutting the square profile proved to be a bit of a challenge. Unfortunately, on this machine there's no way to move the cutter relative to the center line of the part (bad planning!), so cutting a flat is a little more complicated. After a calling up some forgotten math and doing some sloppy Excel scripting, I was able to make a spreadsheet to generate code to control depth of cut / rotation ratio that generates a flat surface as the part rotates. Then, rotating the part by increments between each cut to produce the spiral was a matter of learning how to use parameters and subroutines in g code to create loops

Here's the Excel function to make the square:  
=((Offset/COS(angle))+(tool_radius/COS(angle)))-tool_radius
...where offset is the distance from the center of the part to the flat surface you want to generate, angle is the angle relative to the axis of the cutter and tool_radius is... well tool radius. I have a spreadsheet that does all the math and generates g code for different angles and offsets. I'd be happy to share if anyone's interested, but I don't want to post it in its current unfinished state.