Build Your Own CNC Controller


In this article I will go through the entire build process for an offline CNC controller that I have made for my 6040 CNC router. Although it is made specifically for my router, most items covered should be applicable for any CNC machine for personal use. I will cover the preparation of the enclosure, why I used certain electrical components and I will include any errors I made along the way to hopefully prevent other people from making the same mistakes. This build is also covered in 2 videos. In addition to the build instructions in these videos, this article also provides additional information such as software parameters and settings for the DDCS controller and VFD.

10-01-2021: This article is work in progress. I will update this article and add a second video soon. These will cover the rest of the build process up to the point where the controller is fully functional.

Around 5 years ago I bought a 6040 router from the Chinese company YooCNC, who now go by the name OmioCNC. The machine is controlled by MACH3 over a USB connection.

The existing setup: laptop with MACH3 and a controller with a USB interface

The internal interface board only takes care of the communication with the PC and passes the commands from MACH3 on to the steppers and other components. Although this works fine, I have a preference for using an offline CNC controller. It eliminates the need to have a PC connected to your CNC all the times. Also if the USB connection fails at any point you might be in trouble. I experienced lost steps on the X-axis from time to time, which I hope will also be mitigated with a new controller. Lastly, the wireless controller has some nice functionalities, but there is a significant delay between the input on the MPG and the movements of the axes.

After some searching on Aliexpress I decided to go for the DDCSV3.1 controller. I purchased the 4-axis version since I also wanted to upgrade my router with a rotary axis. Although there are plenty alternatives, I opted for this controller since it appeared simple to use, has all of the functions I need and perhaps most importantly, there is a good manual available for it in English.


The DDCS controller does not fit in the original control box, so I also had to purchase a new enclosure. At first I purchased a plastic one that was only slightly larger than the original controller. However, after trying to fit the components in the new box it quickly became apparent that it is better not to skimp on the size of the enclosure for a DYI controller. A larger enclosure makes your life a lot easier when assembling everything. So I bought yet another enclosure (Famatel) measuring 400 by 500 by 175mm for only €85,-

I prefer a plastic enclosure because it is cheaper and easier to work on than a sheet metal housing.

Salvaging parts from the old Controller

Working with mains voltage is dangerous. It can kill you.
Always unplug the device before opening the enclosure.

Since I would not be using the old controller any longer, I took it apart to salvage any parts I could use in the new setup. The original plan was to reuse the Power supply, stepper drivers and VFD and hook all of these up to the new DDCSV controller. This would be a big cost saver and would only require me to buy new buttons and parts for the safety circuit. In the end I also ended up replacing the stepper drivers, but more on that later.

Disassembling the old controller…

While taking the old controller apart I marked all of the wires and constructed a wiring diagram, to help me understand how everything was connected, so it would be easier to wire the new controller.

Linked below is a PDF file, containing additional information for this build including wiring instructions and software parameters.

The PDF includes:

  • Wiring diagram for old YooCNC controller
  • Wiring diagram for the new controller as described in this article
  • MPG wiring
  • Parameter settings for the VFD
  • Parameter settings for the DDCS Controller
  • GX16 connector wiring (stepper motors)

From the mains plug one of the leads is going to the main power switch. This is connected in series with the E-stop, so you can kill the power to the entire system in case of an emergency. Behind this is a separate power switch for the VFD, so you can choose to leave that off even when the controller is running. The mains power to the VFD goes through an EMI filter to reduce electromagnetic interference. In case you are not familiar with the term VFD: it stands for Variable Frequency Drive. It drives the spindle motor and allows you to control the RPM of the spindle. The Mach3 interface board sends signals to the VDF for both ON/OFF as well as the desired RPM. The Wires connected to U/V/W terminals are going out to the spindle motor. The Mach3 interface board is also providing signals to the stepper drivers. The drivers themselves turn these signals into high current signals that drive the actual stepper motors. The stepper drivers are powered by the 40V power supply. I will go into more detail on how to connect the VFD and stepper drivers further down.

I took out the VFD with the mains cable. Besides the EMI filter, this also includes a ferrite ring a for reducing electromagnetic interference. All of this will be transferred to the new controller. The VFD comes with its own control panel, which can be plugged into the VFD itself or mounted on the outside of the control box to have access while the machine is running.

The drivers are placed between the CNC controller and the stepper motors to drive the motors at the specified current and number of pulses per revolution. More details on the settings for these stepper drivers further down. The only thing left in the old control box is the MACH3 interface card which is no longer needed.

Wiring diagram for the new controller

Refer to the PDF file linked in the section above for the graphical layout. The wiring schematic for the new controller is slightly different compared to the old one. This is mostly due to the addition of a safety circuit. What I did not like on the old controller were the flimsy E-stop button and the switches for the mains power and VFD. These 2 switches were placed directly in line with mains power. This means that if the machine is on and you have a power failure you might end up in a dangerous situation if you forget to turn the machine off before the power comes back on. A more common solution on industrial machines is to use a contactor to switch the mains power. The contactor acts like a sticky relay.

Siemens 3RT2016-1BB41 Contactor

The contactor is engaged by pressing the ON button and disengaged by pressing the OFF button. Both buttons are momentary contacts. The clever bit in this circuit is that the contactor keeps the desired state even after releasing either of these buttons. This is achieved through the use of auxiliary contacts. When the ON button is pressed the contactor closes not only the main contacts for the high power circuit, but it also closes the auxiliary contact. When this happens the contactor is held in place by a current going through the auxiliary contact that it just connected itself. So even after releasing the ON button, the contactor stays engaged. The OFF button is a normally closed contact. When this button is pressed, the circuit is broken and the contactor disengages and also here, stays in that position even after the button is released.

An E-stop button could be wired in series with the OFF button and would act in the same way. If the E-stop is pressed, the contactor disengages and will stay off even if the E-stop is released. You then have to press the ON button as an additional action to turn the machine back on. This is a typical safety feature as releasing the E-stop alone should not be the only action required to turn a machine back on. For my new controller I have an E-stop integrated into the MPG that will make the controller stop all motors and the spindle and will go into E-stop mode, where you cannot do anything until you release the E-stop and then press the reset button. I will wire the separate E-stop in series with the OFF button for the contactor, so this E-stop will actually cut power to the stepper drivers and the VFD. The result is the same as with the software E-stop triggered by the MPG, but in this case the mains power is cut from the components, which is a bit more crude solution, but I believe this adds an additional level of safety. Since the CNC controller is not in the circuit switched by the contactor, the CNC controller will remain on when the E-stop is pressed.

If there is a power failure, the contactor disengages, so when the power comes back on, the machine stays off. If the machine would come back on when the power is restored, this would be a major safety hazard.

Components for new controller

Bill of materials:

  • Enclosure 500x400x175mm – Famatel 39145
  • DDCS4 V3.1 CNC Controller, including MPG
  • Nowforever VFD E100, 2.2kW
  • Stepper Driver – DM556 (Amazon)
  • Mains Connector K&B 42R321121 (Conrad 736916)
  • Fan grille LFG80-45 SEPA (Conrad 189516)
  • PTFIX Cable Distribution Block Blue, Phoenix Contact 3002761
  • PTFIX Cable Distribution Block Grey, Phoenix Contact 3002757
  • PTFIX Cable Distribution Block Yellow/Green, Phoenix Contact 1091668
  • PTFIX DIN Rail adaptor, Phoenix Contact 3274054
  • Cable Tie Mount Phoenix Contact WT-BASE LS HF 4 (Conrad 1832324)
  • Siemens Mains Switch – 3ld2203-1tl53
  • Siemens contactor – 3RT2016-1BB41
  • Mean Well 24V DIN Rail Power Supply – DR-15-24
  • Mean Well 24V Power Supply LRS-35
  • Mean Well 40V Power Supply S-400-40
  • EATON LED – m22 led 230 w
  • EATON assembly tool – m22 ms
  • EATON normally open contact block – m22 k10
  • EATON normally closed contact block – m22 k01
  • EATON E-Stop – M22-PV/KC02/IY
  • EATON selector switch – m22 wrlk w
  • EATON ON/OFF push button – M22-DDL-GR-X1-X0
  • 4th Axis K11 80mm 3-jaw chuck – Aliexpress, RATTM Motor

I used the power supply that was salvaged from the old controller. It has an output voltage of 40V at a maximum of 10A. This should be sufficient for the 3 NEMA 23 stepper motors which are rated at 3A each. Since I am now also adding a 4th axis to the system it is a bit tighter. But the motors will not all draw their maximum current at the same time. Also, as I understood there is a rule of thumb that states you can use a power supply that is rated to 2/3 of the steppers phase current. So for having 4 motors rated at 3Amps it would require an 8Amp power supply. Unless I run into any stability issues I will keep this power supply. 

The smaller power supply is new. This will be used only for the CNC controller and the case fan, both of which draw very little power. The CNC controller requires only 500mA and the power supply should be able to deliver 740mA at 24V should this should be fine.

The new E-stop to replace the flimsy E-stop from the original controller is shown below. It is a standalone unit, so it can be mounted close to the machine. The E-stop contains 2 normally-closed contacts wired in series for redundancy.

External E-Stop: EATON M22-PV/KC02/IY

The mains switch I bought specifically for this project is ridiculously oversized both in physical dimensions as well as for the specifications. It is rated at 32A, which far more than this little CNC router will ever draw from the grid. So it is a bit over the top, but since I already ordered it and being too heavy and oversized doesn’t matter I decided to use it anyway.

Switch Disconnector; Siemens 3LD2203-1TL53

The switches I selected for the new controller are part of the EATON M22 series. The reason I selected these is because they are not very expensive, they have a modular design and there are many different switches available in this series. I used a dual ON/OFF switch with integrated LED and an illuminated Selector switch to turn on the VFD separately. Under the buttons or switches you can place normally open contacts, normally closed contacts, an LED or any combination of these. A separate tool is used to mount the switches to the panel, but you could also tighten them by hand.

The VFD from the old controller is a Nowforever E100 unit. As mentioned earlier this will be reused. For the time being I will leave the panel in the VFD itself instead of placing it on the outside. There is always an option to do that later if needed. This VFD is an older model that is no longer sold.

The most important component for this build is the DDCS V3.1 offline CNC controller. It has a compact form factor and a relatively small 5 inch display, which I think is adequate for the application.

DDCS4 V3.1 CNC Controller

This controller is still available, but by the time I completed the build a newer model, the DDCS Expert, is now also available. This unit has some more advanced features, a larger screen and also a larger price tag. It depends whether or not you need the additional features to justify the increase in price. For now, I am happy with the DDCS V3.1.

A number of the buttons have multiple functions based on the menu you are in. On the back there is sort of a break out board that directly mounts to the large sub-D connector. This is where you provide power to the unit and have all of the inputs and outputs. On the bottom there is a separate connector for external start, pause and Estop buttons. These are optional. In the center we have a 15 pin sub-D connector for an MPG.

The final port on the CNC controller is a USB port. A wire is provided with a panel mount USB plug. You can place this in a convenient location and load programs into the controller with a regular USB stick.

This is the MPG for the controller:

In case you are unfamiliar with this term; an MPG is a manual pulse generator. These are used to manually move axes on the machine and typically contain a handwheel and selectors for the axis and step multiplier. This model is very basic, but has all of the necessary functionality for manual jogging of the machine. Since the pulses are directly sent to the CNC controller, the response of the machine to your input on the handwheel feels very direct. With the wireless MPG from the old system with the MACH3 controller and USB break out board, I always felt like there was quite some delay. If you buy this type of controller from Aliexpress you typically have to solder it to a connector yourself.

Stepper drivers

The stepper drivers I salvaged from the old controller have a YOOCNC brand name on them, but there are similar to stepper drivers from many other brands with the same specifications and form factor, so these are likely OEM parts and could be similar to stepper drivers that are just branded differently.

The great thing about these type of drivers is that the settings are printed on the side of the unit, so you don’t have to look for the manual to see how they are configured. The stepper drivers are rated for 5.6Amps, but they are actually set to 2.7Amps, which suits the 3Amp stepper drivers used in my CNC router.

Micro stepping is set to 2000 pulses per revolution. A typical stepper motor has 200 steps per revolution. If we divide 2000 by 200, we get 10 microsteps per full step. Microstepping is used to make steppers motors run smoother.

The connections on the driver from left to right:

  • 4-pin connector which provides the steps at high current to drive the motor.
  • Power input connector: provides power to the stepper driver. The unit can run on anything between 24V and 50V. In this case it is powered by a 40V power supply, which is nicely in between these upper and lower limits.
  • Dip switch for configuring the various settings as mentioned earlier.
  • Connector to enable or disable the stepper driver. This can be used for example to shut down the unit in case of a failure or an alarm. I will not use this feature. If the pins of the connector are left open, the unit is enabled.
  • 4-pin connector. Provides a signal to the stepper driver, which tells the stepper driver how many steps to move the motor and in which direction. This is connected to an output port on the CNC controller, which generates the step signal.

I bought stepper drivers online from Amazon, but you can get them from many online stores including the well-known Chinese sources. Make sure that the drivers you get have screw terminals to avoid having to crimp connectors. I had many issues with the connectors on the other units, so I decided to replace all of them for new ones with the screw terminals.


Now it was time to figure out a layout for the new controller cabinet, which was harder than I thought. There are many different ways to arrange  the components inside the cabinet, each with their own pros and cons. I finally settled on this layout:

It has the stepper drivers at the top of the cabinet, close to the plugs to connect the motors. I placed the VFD on the opposite end of the cabinet since this is the largest source of electromagnetic interference and therefore I would have the lowest chance of it messing up signals to and from the stepper drivers. On the side of the cabinet I placed the power switch , the mains connection plug and 2 inlet ports for air. The inlet ports are located on the opposite side of where the fan is located in an attempt to maximize air flow over the electronic components.

The buttons are placed on the left side of the controller as this felt like the most natural location to me. For example Haas also has their buttons on this side and I am sure there is a good ergonomic reason for it.

A step drill was used to drill out most of the holes. These step drills work very well in thin material.

For the line filter I used self tapping screws. Initially I wanted to use these for most components, since they are easy to install and you can remove them without needing access to the back end such as with a nut and bolt. However, I have less than 10mm of space behind the panel and these screws are too long. In this case I just added some washers to take care of that issue.

For the stepper drives I used regular M4 screws and tapped thread directly into the panel. The panel is quite thin, but since the drivers are not very heavy I think I can get away with this solution.

Since I experienced lost steps with the old controller I decided to use shielded cable wherever possible. For the cables to the stepper motor connectors I used shielded cable with 4 wires of 0.75 mm^2. This should be equivalent to American Wire Gauge Standard (AWG) size 18.

Soldering the GX16 connectors to the shielded wire

The Mains power connector will be placed on the left side. It will be near the bottom when the cabinet is in its upright orientation. I am planning to hang the controller vertically underneath the table for the CNC router.

For the Air inlets and fan I needed to cut 80mm holes. I used a hole saw for this purpose. The RPM should be low enough to prevent the material from melting. I had stalling issues, so I resorted to applying alternating pressure to make sure the plastic did not get too warm from cutting.

The hole for the DDCSV controller is made primarily with a mini hacksaw. This looks like a lot of work, but in real time it took only around 10 minutes to cut out the hole. Some filing was needed to remove the round corners created by the step drill.

The same approach was used with the rectangular hole for the mains power connector. I was a bit on the safe side with the dimensions when cutting the hole with the hacksaw. It is easier to do some additional filing to increase the size of the pocket then it is to make it smaller.

The Mains Connector is fixed using M3 screws. I am using nylon insert lock nuts everywhere in the controller cabinet, to prevent a metal nut from coming loose and possible cause a short circuit somewhere. The mains connector has an integrated fuse holder. The old CNC controller had an 8A fast acting fuse. I am using the same thing here. 8 Amps at 230V would translate to around 1800 watts. This might seem a bit tight since the spindle is rated at 1500 watts and the power supply at 400 watts, but is has been running without issues with an 8A fuse in the old controller, so I will use that. I would rather have a fuse that blows too soon than one that blows too late.

The Video linked in the top section of the article provides an overview of the assembly process.

Work in progress: I will update this article and add a second video soon. These will cover the rest of the build process up to the point where the controller is fully functional. (The controller is already finished. I just need some time to edit the second video and finish this article.)

If you have any questions in the meantime, please let me know in the comments section.


Leave a Reply

Your email address will not be published. Required fields are marked *