Showing posts with label electronics. Show all posts
Showing posts with label electronics. 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
             






Saturday, July 20, 2013

Router lathe – upgrades and wood sign



Router lathe – upgrades and wood sign.

Here's a wood sign I made for a friend's woodworking shop, Artsubstrates. This is the first time I've wrapped a 3D shape around the rotary axis. It worked better than expected.

 

(note: from here on is going to be pretty dull for anyone not building a cnc machine. ...and maybe for those who do, as well.)
I generated the text using "FEngrave" a great piece of software for generating gcode for signs. It does one thing and does it very well. Highly recommended. Then I used another piece of software to take the output from FEngrave and wrap it around the rotary axis.

Recent upgrades:

Some upgrades were required to convert from arduino 2 axis control to 3 axis CNC. Added was new z  axis assembly with stepper motor and controller, new belts and pulleys on the rotary axis to increase the gear ratio, and limit switches on the linear axes.


New Z axis assembly with motor.
The new Z axis assembly has 3/8" aluminum plate for the base and the carriage platform, 5/8" O1 tool steel rods for rails and UHMW bearings to slide on. I made another UHMW nut and used the acme threaded rod left over from the X axis. I'll have to re-think the UHMW bearing though -- they slide really smoothly by themselves but take a lot of adjustment to get the carriage to slide without binding with all 4 attached.

Limit switches on Z axis
Motor and switch wiring

Showing the limit switches and motor wiring on the Z axis. I used ethernet cable and jacks for the limit switches, and heavier 22g wire for the motor.



New rotary axis belts
 The big automobile timing belt and diy pulley were replaced two XL timing belts and pulleys. increases the motor/ axis ratio from the previous 4:1 to 16:1. This provides a lot more holding power against the router and gives smoother rotary axis travel and much finer resolution. With the old belt, there was more backlash that I liked and at larger diameters, one step on the motor translated into as much as .003" of travel. With the new belts and gear reduction, resolution at large diameters is still very fine and I see less chatter during heavy cuts.

The current belts are neoprene with polyester fibers, which do stretch a little and is more noticeable with the double gear reduction. I purchased new belts with kevlar fibers that have very little stretch, but haven't installed them yet.

All this is because these 285 oz/in motors are OK for the two linear axis, but a bit puny for the rotary axis. A motor upgrade on the rotary axis may be in order, but would require a bigger power supply and new controller as well -- not in the current budget.
 




Wiring to the electronics enclosure. 5 pin XLR connectors with 22g stranded cable for the motors and ethernet cable and jacks for the limit switches and e-stop button. There's a vented cover for this enclosure, but after an overheating incident where the cooling fan lost power and the controllers started making real funny noises and smelling bad, I don't have the courage to close it up yet. I'm thinking of putting in a temperature monitor, but that may be overkill.



Sunday, June 10, 2012

Router Lathe: Internal threads




Internal bore cutting spindle
I always knew that the big challenge would be cutting internal threads. What cutter? How much extension? Speed? How to manage chatter and deflection? The criteria was that I wanted to cut threads a half inch deep, at least 3 inches into a bore. For this I needed a 60 degree side cutting bit that I could extend 3 inches past the end of the router. Good luck finding that router bit…

My solution was to create an offset spindle with a half-inch shaft that holds a fly cutter. The spindle is made up of a couple of bearings and a .515" ground stainless steel shaft, turned down to a half inch on the ends to fit the bearings. The spindle frame and router clamp is made of birch ply. The spindle is hinged so it can be swung free to check the fit of the bore. The spindle is driven by a vacuum cleaner belt off the router with a 4:1 speed reduction. I bought a cheap Harbor Fright trim router to run it, just in case this is hard on router bearings. (better to trash a $30 tool than a $130 tool). I also got one of their router speed controls to slow it down. (I seem to be buying a lot of cra stuff from those guys lately)

speed control


spindle
.


 In order to keep the rotating weight down, I used 1/4" drill rod for the fly cutter, inserted at an angle through the mandrel, and ground so that each end only cuts one side of the thread groove.

cutter layout
 Grinding the tool bit on my other wood lathe. It was actually much easier than expected to get the angles and correct extension on the cutter. The only problem was the drill rod I was using turned out to be stainless, not heat-treatable tool steel. It holds an edge - kinda. 

Grinding the cutter.
To grind the cutter, I slowly spun the lathe spindle by hand while cranking the cross-feed vise back and forth. The cross-feed vise is set at 30 degrees to the cutter. It took a different setup for each end of the cutter. This fixture only ground the angle. All back relief and rake on the cutter were ground by hand & eyeball.


You can hear the harmonic vibration from the stretchy belt, right before the cutter exits the end of the bore. This is a problem I'll have to confront before I can increase depth of cut and cutting speed.

Here's a better video made after the outside of the nut was formed.




Lessons learned:
  1. Needs mass. There's a fair amount of vibration that would probably be dampened by more mass in the router carriage and spindle. I was planning to rebuild anyway after this initial test, I'll just beef things up a bit more.
  2. Stretchy belt -- not so good. I'm getting a significant harmonic vibration, especially when cutting across end-grain that I think comes from belt stretch. (you can hear it in the video, right before the cutter exits the end of the bore) I can dampen it somewhat by putting my finger on the belt. I'll look into a better drive belt to replace the $2.99 Hoover belt I used. More mass in the router carriage may help this as well.
  3. Cutter needs rake. I just ground a flat cutting face on these cutters, so there's zero rake on the cutting edge. I think if they had a little rake ground in they would cut better -- slice the wood rather than scrape.

Monday, May 21, 2012

Router lathe: Full size test

Newly acquired shop space in the basement

After spending most of the weekend building a bench for the lathe, a table for the computer and a stand for the air filter,  I moved the lathe to its new home. Then I was finally ready to make a big cut as a road test, to test accuracy and speed. I found a 30" long oak 4x4 to use as a test. The lathe can actually handle up to 11" diameter, and about 36" in length, but I figured this was big enough to expose most major problems or weaknesses.

rounding the stock





Everything worked pretty much as expected -- at least the arduino/stepper motor part. No dropped steps -- the cutter followed the exact same path each cut. In my previous test, the pitch was off, but I'm pretty sure it was a loose coupler on the spindle.  I did find out that the tailstock is not aligned so the lathe cuts a pretty significant taper, and after 3+ hours of continual operation, my shop vac sounds like squirrels hid nuts in the motor. Once I deal with those issues, I'll start testing how fast and deep it can cut in a single pass.

3.5" x 2.5 threads per inch

Here's the arduino code:





Friday, May 11, 2012

Router lathe: first threads


First threads. They came out looking great, but the pitch is a little off. I found a loose coupler on the spindle motor that I hope is the reason. Otherwise the stepper motor is losing steps or my math is wrong.


Threads look chipped, but that's just the wood grain showing,
the cut itself is very clean.

Wednesday, May 9, 2012

Router lathe: electronics


For electronics, I went with 280 oz, NEMA 23 8 wire hybrid motors, and drivers based on the Sanken SLA7078MPR chip. The power supply puts out 40V and the drivers are configurable up to 3A current. The drivers have step and direction inputs that run great off the Arduino -- just toggle a pin HIGH and immediately back to LOW, followed by a few hundred microseconds delay to control speed. The driver boards also have dip switches to select among full, half, quarter, eighth and sixteenth steps. Mine came set to eighth-step which gives a nice balance between power and smooth motion. Given the low gearing of the lead screw and the 4:1 reduction on the spindle, I'm still experimenting with the best step setting to use on each axis. I may go with quarter or even half step.

There's a 12v/5v switching power supply from a defunct external hard drive zip-tied behind the big transformer, and it breaks out to power the Arduino, the cooling fan and the logic circuit on the stepper drivers. That leaves the big power supply to run only the motors.

12v goes to the Arduino and fan, 5v to the driver boards. I put a diode on the 12v to the Arduino -- when USB was plugged in, but main power off, the computer's USB port was spinning the fan. The diode fixed that and drops the Arduino voltage a bit as well.

I've been pretty happy with the hardware so far, and the initial support was good, however the purchase experience was not fun -- sadly, I just can't recommend the company I bought them from.

More recycled parts...in this temporary build, the aluminum the electronics are mounted to is a shelf from the telecom rack that supplied the base and rails for the lathe.

Sunday, May 6, 2012

Router lathe: motor mounts and drive mechanism

Here's the feed motor mount and feed screw. The stepper motors are the yellow blocks. The screw is stock 1/2"-13 threaded rod. I picked up a flex coupler at a local surplus store, and put adapters on each end to convert from 1/4" at the motor to 1/2" at the feed screw. the black bearing material the rod runs through is UHMW. It was tough finding a piece of rod that was straight enough. Measuring over 42", the pitch is at least a half thread off (I didn't count, so it could be more than that). My intention is to replace it with 2-start 1/2" acme threaded rod, once the mechanics are all figured out.
 Tailstock end of the feed screw using same UHMW bearing.


Spindle drive. My auto mechanic gave me a selection of discarded timing belts. This one's from a Honda, I think. They are huge, but work great. I figured out what the gear circle would be for a 60t gear and drilled holes in a piece of particle board using a rotary table. Then cut & sanded the corners off till it fit. The particle board was just a test, but it works so well, I'll keep using it for now. The black adapter attaching the gear is acetyl turned to fit the spindle.


Spindle motor mount. The small gear is UHMW. This was cut the same as the particle board gear -- close guess on diameter, drilled holes and cut the diameter -- x-acto knife to round the corners. Not terribly pretty, but it runs well with very little backlash or slop. I plan to replace all these "Land of the Giants" parts with much smaller .2" pitch XL belts and pulleys, but this gave me a way to test whether a 4:1 ratio was good without buying a bunch of parts. There's a 5/16" shaft through the small gear and skateboard bearings pressed into the pulley housing, and one end is turned down to 1/4" so a simple coupler could be used to connect it to the motor shaft. This allows the belt to be tight without putting lateral stress on the motor.

(the 5/16" coupler was loose, causing inaccuracies in the first part cut. I thought there was a problem with electronics or code, but so far, all my major mistakes have been mechanical)

Router-lathe: Prototype


First off, I had to see if it would even work. I built a prototype out of acrylic with a rail from an old printer, a couple of little steppers and an Adafruit motor shield. Using a couple of nested loops, I was able to draw all kinds of spiral and geometric patterns on a pvc tube. Here's the code:

I learned a lot. First of which was that none of it could be used on the big machine. The Adafruit motor shield is a great little device and a wonderful learning tool, but it will only handle little motors (600mA). It also has its own Arduino libraries with step, speed and direction commands, that don't translate to bigger drivers that have step and direction inputs. That being said, for small projects, it's a very cool device -- if you're working with motors with Arduino, absolutely get one.

The next thing I learned was what odd devices stepper motors are, and how inconsistent the available data seems until you understand how they work. I'd salvaged steppers out of several old printers, but was never able to make them work. They would miss steps, rattle back and forth, get hot and smell bad. And I was mystified why, when if lucky enough to find a motor with an actual datasheet, it would say something like "2.6 v, 3.4Ohms", but the power supply in the printer it came out of  would be putting out 36v, 42v or some other crazy voltage. Huh? (anyone that actually knows something about this may be rolling your eyes right now, but this was all new to me.) I wish I'd found this simple explanation -- it would have saved me lots of time: Stepper motor specs typically give resistance and current values. Voltage, if given, is to calculate current. As long as the current is kept at or below that value, the voltage can increase. A lot. (eye-rollers: please correct me if I got that all wrong, I'm still working on it...) In fact it's assumed that steppers will run at many times the spec'ed voltage. For instance, the steppers I ended up using are rated at 3A, .92Ohms. That comes out to 2.76v. Seems low, right? It is, my power supply puts out 40v, but the driver restricts current to the rated 3A.

The Adafruit motor shield doesn't have current limiting, so you need to use motors that pull less than 600mA. The little NEMA 17 motors at Sparkfun and Adafruit are great for this.




Router Lathe: Rails and carriage


Here's the Sketchup model I used to work out the mechanics. The lathe bed is the angled piece with the t-slot on the right. The two rails on the left are 1.5" x 3" aluminum rails from a discarded telecom equipment rack. The big angle pieces on the bottom are the base of the same rack.

The assembly in the upper left is the feed carriage. The whole unit runs on skateboard bearings by a 1/2"-13 feed screw (not shown in the model, but visible below). On top of that is a z-axis-like router carriage that slides on 1/2" rails, driven by a 1/4"-20 screw to move the router in and out. Stepper motors will rotate the lathe spindle (not shown), and the 1/2"-13 feed screws. The router's depth of cut will be manual, for now at least.

After I got it all assembled, I discovered the angle I used for the base wasn't square, so I have to shim everything that attaches. Re-using the aluminum network rack seemed like such a good idea, but I've made a series of compromises in strength, wear and accuracy, in order to use it. Once I get everything figured out, I may rebuild the rails using something better suited.




Router lathe: arduino controlled

Delta Homecraft lathe circa 1940's (?)

I found an old lathe at a garage sale and decided to turn it into a router lathe for cutting spirals, flutes and threads. Initially, I considered using a strictly mechanical mechanism to synchronize spindle rotation and lateral travel, but after playing with an Arduino and some stepper motors, I realized that could be a better solution, possibly even converted to a full CNC system sometime in the future. Now that I know it's going to work, (I made the first cut today) I'm sharing some notes on the build. I'll be posting over the next few days to get this blog up to where the project is currently.