CNC Lathe Retrofit: Part 2

Disclaimer

When working with tools, always make sure to take appropriate safety precautions. Always wear safety glasses and any other appropriate PPE. Make sure you have a comprehensive understanding of how to use your tools safely.

This video/article just documents how I approached a problem. This is not necessarily the proper, or safest way to do something. If you see something that looks unsafe, let me know! I'm always happy to learn a safer or better way to do something

All links to Amazon are affiliate links. As an Amazon Associate I earn from qualifying purchases. This helps fund these projects!

Introduction

Now that the CNC controller is assembled (check out part 1 for details) I can get into the meat of the project, mechanical assembly. Luckily for me since this lathe was already a CNC machine, there really wasn't much to do other than reassemble things and add the few extraneous custom bits, like my spindle encoder.

I will take a moment to gripe about the different sizes of hardware that Spectralight used here... All of the hardware is in the same ballpark in terms of size, but there are about 3 different machine screws used, all requiring different hex keys. My personal design philosophy for this type of thing, is to take the biggest size screw that you need and use that for everything. This keeps things nice and simple for assembly, since the only difference between the hardware is the length! This kind of hardware ubiquity is especially nice when you're designing things that you're going to build for yourself. If you have very specific hardware that you use (I personally like M4x0.7 and M8X1.25) then it's easy to keep an assortment of lengths 'in stock' which makes it easy to get to work right away when you cook up a fresh design.

Partslist

As a bit of a reminder for the main CNC controller build I'm using:

The main CNC controller will be complemented by a separate spindle controller board which will take care of monitoring the spindle speed, and position.

The spindle controller will consist of:

All of this will be put together with a mix of various cables, wires, 3D-printed parts and M4 stainless machine screws.

Stepper Motor Assembly

Assembly here is pretty straight forward, just four socket head cap screws to hole each motor in place.

What is kind of interesting is the type of coupler that was used to couple the stepper motor to the leadscrew. This style of coupler certainly isn't the norm these days, with lovejoy style couplings being much more popular, even for small machines like 3D printers. That said, there really isn't any reason that I can see to change it, other than the face that the tiny setscrews holding the coupler to the shaft may want to slip...


Next up is quite possibly the easiest part of the assembly, connecting the plug in connectors to the back of the controller box! I took a little time to add labels to each of the ports to help keep things organized.


Now that I've got things together let's try it out! I'm using Universal Gcode Sender to handle the communication between my laptop and the CNC controller. I really thought that getting the software setup was going to take a whole bunch of mucking about, but all I had to do was go through the new machine wizard in UGS. You will need a dial indicator to calibrate the stepper motor output so that the axes move the correct amount, but the wizard is incredibly easy to follow. Huge props to the people coding UGS, it's really a treat to use.

Spindle Motor Troubleshooting

And now I hit a problem, and coincidently this is where things start to deviate from the video, so if you've made it this far, props to you!

So for some reason the spindle just wouldn't turn on. And that reason is that I built a custom homebrew spindle controller. One-off electronics like this pretty much always end up requiring a little bit of troubleshooting... I'm not sure I can think of anything more boring than reading a description of someone doing electrical troubleshooting, but I do think it's important to talk through the process because if you're taking on a project like this knowing how to systematically troubleshoot strange problems is super important!

When I started everything was working as expected except the spindle motor. Since I know that the problem is isolated to the spindle controller, I can start by identifying all of the inputs and outputs to the spindle controller board. Then I can start checking things out with a meter.


For inputs I've got +12V power and ground which run the isolated, or machine side of things. On the microcontroller side I have a separate ground, +5V, and Speed input. The first step is just to check continuity to make sure that all of the wiring is actually connected. This sounds silly, but it's not all that hard to break a soldered connection while you're bending wires around to fit them into the enclosure. Checking for continuity (with all power disconnected) is an easy way to make sure that broken or shorted connections aren't the problem.

Power is the next easiest to check. Using a multimeter set to measure DC voltage I can check that I'm getting power at all the points where I expect to. With power checked out then you can move on to signals. In the GRBL control I can vary the spindle speed output between 0, 50, and 100 percent output, and because the Arduino analog output varies from 0 to 5V I know that this should cause the output voltage to shift from 0 to 2.5 to 5 volts. This signal feeds into a logic level converter to shift this to a 0-3.3V range, and so I should get a corresponding output on the other side that ranges from 0 to 1.65 to 3.3 volts.

Now some of you may be rolling your eyes and saying 'but logIc level converters are for converting digital signals, not analog, this won't work.' or maybe 'Why aren't you just using a voltage divider?' Both of which are good points, but technically the pwm analog output from the Arduino is a digital signal, as it's a series of 5V pulses with varying duty cycle. And therein lies the rub...

I had planned on using an analogRead() on the Teensy to read this input signal, but due to the pulsed nature of the input the Teensy just sees it as a series of logic level high or low pulses. Meaning that it's trying to turn the spindle on to 100% duty cycle and then off again at like 200Hz, and that simply will not do! If I want to use an analogRead() statement then I'll need to filter the pwm signal to smooth it out. Easy! I can just stick a cap in and that ripple will smooth right out, right? Well, uh... No. To get strictly the DC component we'll need a more complicated filter... Something like the two stage Sallen Key filter shown here, which is not my preferred solution... Shoutout to the Analog Devices Analog Filter Wizard. It's a really great tool for, you guessed it, analog filter design.

So what to do... Fixing things in software is usually a nice, easy, hacky way to cover for your lack of foresight in hardware design, so let's do that! And if that doesn't work I can always build the filter...

There are two approaches that you could take here. The most obvious being to just implement the filter that you need in software, but that would involve some buffering and array programming, and also keeping pretty good track of the timing on the Teensy, all of which may not exactly play nice with the interrupts that I'm using to read the spindle encoder. So instead I'm once again going to leverage the fact that the Teensy is much faster than the Arduino and just directly read the duty cycle of each pulse with the pulseIn() function. The downside here is that any variability in the Arduino's timing will get directly injected into the spindle, but I figure that the actual inertia of the rotating assembly should filter that out mechanically, but eh we'll see...

Time for Testcuts

I wanted to start with something that's fairly easy to machine, so I'm going to use some 3/8" 6061 aluminum round bar and turn a little pawn that I modeled up in Fusion360. This is my first crack at running a CNC lathe and also my first dime really digging into the CAM tab within Fusion360. All things considered, it wasn't nearly as daunting as I thought it would be to get this lathe up and running, and for a first run, my pawn turned out pretty great!

Let's make a chuck key

So now that I've run a useless demo part, I think I should make something of use. This lathe didn't come with a chuck key, and I've been using a crusty old bolt with some flats filed on it instead... I really think that I can do better, so I'm going to try my hand at making a chuck key.

This is probably a bit of an ambitious project for this lathe, as it really gets right near to the edge of what this lathe is capable of turning. I'm starting with a chunk of 5/8" mystery steel that I had kicking around the shop. I took a quick skim cut to clean the rust and scale off of it, and ended up with a 63mm x 15.5mm slug. I used these dimensions to define the stock within the CAM page in Fusion.

Running this part was certainly a little more nerve-wracking than the aluminum pawn... I was using small stepovers (0.1mm) and things seemed to run okay. The chips broke nicely, and were nice straw coloured 6's and 9's which seemed like a good sign. The only downside here was surface finish, which was really just okay. Now I do think that I'm asking quite a lot of the machine, but I think a little bit of dialing in will certainly be in order.

The only major error happened during a rapid move where the machine lost some steps. This resulted in it attempting to turn the small diameter for the tip of the chuck key into the middle of the shaft. But I turned the rapids down a little and reran the operation and everything went smoothly from that point on.

With the lathe up and running I'm really excited to make some more parts! I think it's going to be really fun to get my CAM recipes dialed in, because this lathe should be capable of producing some nice parts with reasonable tight tolerances (at least by benchtop machine standards.)

So check back soon, and subscribe on YouTube to get notified when the next project comes out!