A while back I obtained a desktop CNC lathe. It was stripped from its electronics, so this was a good opportunity for me to learn how to retrofit a CNC lathe. In this post I will cover this DIY project at a high level. The details for all of the components used and how they are connected can be found in the embedded videos. Also I have included a PDF file in this article, which contains the electrical diagrams, BOM and settings for the CNC controller and VFD. I hope that by sharing this journey it will help people to get an estimate of what takes to do a retrofit on an older CNC machine. This is not an ultimate guide on this type of work, it is just to share what I have learned so far. Let me know if you have any questions in the comments section below or under one of the YouTube videos.
Safety notice: working with mains voltage is dangerous. It can kill you. If you copy anything from this build, it is at your own risk. Have your work verified by a licensed electrician before turning the equipment on.
Update 10-12-2022: updated Fusion 360 post processor in CAM section.
Update 07-11-2022: added alarm connection for stepper drivers to the PDF file.
Update 05-10-2022: added lathe tools to BOM in the PDF file.
Update 29-08-2022: added CAM section with Fusion360 post processor.
The PDF file below contains the wiring diagram, Bill Of Materials and software parameters. It is free to download.
1 – Introduction, SZGH Controller Dry run, Motor Wiring and VFD Settings
The EMCO lathe that I bought on a local online market place seemed to have all of the mechanical components, but the electrical components were removed and came separately in a box. Since I do not have full user manuals of the mostly proprietary EMCO components, I decided to start fresh and replace all of the components, except the spindle motor and turret board.
CNC Controller
To control the lathe I opted for the SZGH 990TDb-2. The reason for choosing this model was the relatively low price and the large feature set. It has all of the Inputs and Outputs that I need, a programmable PLC and good manuals in English. I also considered the Masso G3, which looks like a great option (especially the touch model), but it was quite a bit more expensive.

The SZGH controller looks a bit like a classic Fanuc controller, but in my opinion the SZGH interface is much more intuitive. Although the unit itself was 350 euros when I bought it last year, the total came to around 800 euros with taxes and shipping included. All cables except the one for linear scale feedback are included in the package, which makes connecting it quite easy. I also bought an IO board and spindle encoder separately.
Stepper motors
To drive the X and Z axes I purchased 2 closed loop stepper motors. They came as a set and included the stepper driver, which eliminates the need to find a compatible driver yourself. The stepper motors have a closed loop between the motor and the driver, allowing it to correct for any position errors detected by the encoder on the back of the motor. The closed loop does not reach the SZGH controller, but for my application I have no need for that feature. The SZGH controller does have the option to read the position of the axes, but besides the aforementioned missing cable this would also require scales on both axes.
The stepper motors are 3 phase models, which is not intentional, I was just looking for motors that would fit in the enclosure and also have limited power, to prevent the risk of damaging the mechanics with overpowered stepper motors.

Spindle Motor Wiring
The lathe still had the original Spindle Motor mounted in place. It is a 3-phase motor with a rated power of 0,37 kW.

It was already wired in a delta configuration and I am sticking to that setup. The name “Delta” refers to the shape the wiring diagram has when you draw it out on paper. In reality it looks different, due to the way the wire terminals are positioned. See picture below. L1, L2 and L3 are the lines going from the VFD to the AC motor.

The lathe itself runs on 230V / 50 Hz. To convert the single phase input power to a 3-phase connection for the motor a VFD is used. Also, the VFD allows for an infinitely adjustable RPM of the spindle.

Because I was not able to reuse the proprietary spindle drive unit that came with the lathe, I bought a new VFD. To limit my losses in case something went wrong I opted for a cheap model I found on Amazon: the SAKO SKI780-0D75G-1. It is a 0.75kW model and has a maximum outout of 4.0 Amps. It can roughly deliver twice the power needed to drive the motor. From online resources I understood that oversizing the VFD to twice the required power is a common factor to be on the safe side.
In order to reduce electrical noise in the mains line I have placed a 2 stage power line EMI filter between the mains plug and the VFD. This is rated at 20A, which is plenty for this application.
To reduce EMI emitted from the outgoing lines of the VFD, I placed a Ferrite ring between the VFD and the spindle motor. The more formal name used for this specific model is a “Zero Phase Converter”. This noise filter is designed specifically for use with VFDs. It should be placed over the lines as close as possible to the VFD. Each of the 3 wires should be individually looped through the ring 4 times to achieve the maximum filtering effect.

VFD settings
- Motor Control mode
For now, I have made a couple of key changes to the parameters to get started. The motor control is set to default as V/f control, which is the most simple control mode. This works, but makes the motor emit a high pitch noise. I changed this to Sensorless Flux Vector Control, which made a big difference. It sounds much better now. This mode is an efficient method to control a motor and adapts to the motor dynamics without the need for encoder feedback. - Switching Frequency
This is the switching frequency of the VFD. A higher frequency generates a cleaner waveform, reduces high pitch noise from the motor and increases efficiency. There are however also downsides: It reduces the life of the VFD, generates more heat and increases the EMI, which may affect the functioning of other components in the system. So there is a tradeoff. I am setting this as high as possible to reduce noise, but might have to lower it if I run into issues with EMI. - Refer to the PDF linked at the start of this article for more changes I made to the VFD settings, including a short explanation. For now these settings work but I will update the document if I make any changes later on.
More details on the Controller, stepper motor connections, VFD and motor wiring is included in Part 1 of the video series on this project. Also make sure to have a look at the wiring diagram in the PDF file.
2 – Panels for the lathe cabinet, Stepper motor replacement and tool modifications
The lathe was missing a back panel and a bottom panel. I ordered aluminum panel to size and mounted them onto the lathe. Rubber feet ware added to the bottom panel.

For both the X and Z axes I designed custom motor mounts. Nuts were pressed into the mount, for mounting the stepper motors. Using nuts is a very easy solution, but care needs to be taken not to overtighten the screws holding the motor. Otherwise the plastic may be permanently deformed.

For the lathe I bought both a set of HSS tools and a set of tool holders with carbide inserts. Since all tools were too long to fit in the turret I shortened then using an angle grinder. The same method was applied to shorten the round tool holders for the boring bars.

More details of the items discussed above are provided in Youtube video part 2:
3 – Tool Turret wiring and programming
In the original configuration of the lathe, the turret was driven by a custom EMCO turret board, containing a relay and power resistors. I have reused this board in the new setup. The relay is used to switch between forwards and backwards rotation. When rotating forwards the turret motor receives 24V. When rotating backwards part of the energy is dissipated by the resistors on the board, which basically act as a voltage divider. Only 10V is across the motor leads when rotating backwards.

A pawl and ratchet mechanism it used to lock the turret in place at each position. Even when the turret has reached a position, the motor is still activated, holding the turret in place.

The turret has an encoder wheel at the back and 2 optical sensors. The first sensor is only triggered at tool position 1, while the second sensor is triggered at each tool position.

Linked below is the “ProgramTool” file, which is the macro for the SZGH controller to drive the turret. A demonstration of how the turret operates with this macro is given in video part 3. In the ProgramTool file itself, I have placed comments behind important lines of code to explain how the macro works. If you have any questions on the macro, please leave a comment below. Note: the file now has a .txt extension. The file extension needs to be removed before copying it to the controller.
More details of the items discussed above are provided in Youtube video part 3:
4 – Polishing the safety door, connecting the E-stop and ladder programming
The lathe has a polycarbonate safety door which was heavily scratched. I applied wet sanding, starting at 1000 grit to remove the deeper scratches and working my way down to 5000 grit to get an almost scratch-free transparent surface.

The cover was finished up with a coarse and fine polishing paste consecutively, to obtain a very smooth transparent surface.

The original external E-stop was faulty and therefore needed to be replaced. It was connected to one of the inputs on the IO board (M14).

In order for the controller to respond to the E-stop on M14, the ladder needed to be modified. This can be done directly on the controller. Alternatively, you can also edit the ladder on the PC with a special editor and then upload the ladder file back into the controller.

Details on the ladder modifications for the E-stop and other items discussed above are discussed in detail in video part 4:
5 – Replacing the spindle bearings, a safety switch and adding a spindle encoder
The bearings on the spindle were worn and were making strange crackling noises, so I decided to replace them. The bearings were replaced with the same type as the original: 6006-2Z deep groove ball bearings. These cannot withstand as much axial force as tapered roller bearings or angular contact bearings, but for light use I hope they will suffice.

I fitted brackets in the back of the lathe onto which I mounted 2 DIN rails, allowing for 2 rows of components to be placed in the back of the lathe.

The safety switch for the door was replaced, as the original switch was behaving unreliably. I used a similar type, in a normally closed configuration. The safety switch for the door will stop a program and the spindle in automatic mode, but it will still allow you to jog the lathe in manual mode for tool setting. The safety switch fitted behind the side door, where the drive belt is housed, will simply trigger an E-stop, as you are not allowed to run the spindle and open the side door in any mode.

To be able to cut threads a spindle encoder is needed. This allows the controller to track the spindle angle and move the slides in a correct manner, such that the thread will have the correct pitch and start at the same angle for each consecutive pass.

All items discussed in above are covered in much more detail in video part 5:
CAM
I am using Fusion360 for CAD /CAM. The included ” Fanuc turning” post processor is used to generate the G-code. Some canned cycles generated by this post do not function on the SZGH-990TDb. For several drilling, boring and reaming cycles I have changed the post processor to generate standard G01 moves instead of a canned cycle for that specific operation. This will generate more lines of code, but at least the generated program now runs on the SZGH controller.
Make sure to rename the “.TXT” file extension to “.CPS” and place it in your post directory (C:\Users\<your name>\AppData\Roaming\Autodesk\Fusion 360 CAM\Posts). To find the changes I made to the post, search for “Robin” in the text file.
The post processor is provided “as is” and not guaranteed to be free of errors. You are responsible if you use it on your machine. (check the generated code, verify with simulation mode and run the first time at low feed rate)
Questions or other feedback is welcome in the comments section below.
Cheers,
Robin
Useful links:
CAD files for all custom parts used in this build:
https://grabcad.com/robin.z-1/models
VFD settings and programming: Video by James from Clough42 for more detailed information on VFD programming: https://www.youtube.com/watch?v=RQKPtf7stiw&list=PLDlWKv7KIIr_Znhfg8obxwcduFee5Ub5z&index=2
Article on the most useful VFD settings including background information: https://www.controleng.com/articles/top-5-vfd-parameter-changes-explained/
Information on Sensorless Vector Control: https://resources.system-analysis.cadence.com/blog/msa2021-sensorless-vector-control-of-ac-drives
hi,
how much is it the complete mini lathe ?
Hi I paid 1500 for the lathe second hand. The price of the components is in the PDF, best, Robin
You have done a great job. I am converting a Compact 5 CNC to SZGH control over like the last 3 years. Little by little. I am getting close to the end and I will try my tool turret as your coding. I do need some help with my spindle encoder. I used a US Digital optical encoder mounted directly on the spindle end. Mine is 500CPR but I can change this from a large selection. Its quad type with A, B and Index. I have it connected to C9 but I don’t understand how to make the settings so it reads the right RPM and angle. Can you advise?
Hi Gary, since I directly started with the SZGH encoder I do not have any experience with different types of encoders in combination with the SZGH (or other controller) and how to connect them. If I understand correctly, your encoder does work, but it does not display the correct RPM? This should be straight forward with P10 set to 500, P412 and P413 both to 1. But From what you have achieved so far I assume you already tried this?
If you have more details I can try to help. If all options fail you can also try to reach out to SZGH support. They also helped me with my turret questions, so it is worth a try.
Best, Robin
Dear sir, your work is wonderful, I have few questions, how can I configer tools for linear table, what encoder will you recommend for index for threading, if the rpm is upto 8000
Hi, if you are not using a turret but just ave your tools in a gang-tooling style setup on the X axis, you can just deactivate the automatic tool changer option (Tool Parameter P1). Also, set P2 to the actual number of tools you have (instead of #tools +1 when using a turret). For the spindle encoder I am not sure what the maximum pulse frequency is for the controller, also I don’t know what the maximum RPM of the encoder is. Both are not listed in the manual. I know from experience it goes up to at least 3000RPM because this is the maximum RPM of my lathe. It might go higher, but I am not able to test this. If you want to make sure the controller and encoder go up to 8000RPM, please contact SZGH support. If the maximum RPM is exceeded of course, you can use a smaller pulley on the spindle than on the encoder to “gear” it down (if this fits in your lathe).
Terima kasih sudah memberi inspirasi untuk meretrofit mesin cnc emco
Wow, I had to google-translate this:
——
Thank you for inspiring me to retrofit the emco cnc machine
——-
Thank you for letting me know this post was useful for you!
Cheers,
Robin