Project Overview

Besides a couple handheld power tools, most of the tools in my shop are ill suited to work with metal. My go to materials have been plastic and wood. I can 3D print the plastic and carve up the wood with my CNC router. However, it has been a longstanding goal of mine to expand the metalworking capabilities of my shop because the ability to make custom metal parts would allow me to build some projects that otherwise would have been impossible. I am getting closer to fulfilling this goal with the acquisition of a Precision Matthews 833TV mill. To expand the capabilities of this benchtop mill, I have decided to convert it to CNC.

The Precision Matthews 833TV. It is an imported Taiwanese benchtop mill that is of slightly higher quality than the average mill of this form factor. Before I get into why this mill stood out to me, I have to be honest with you. My first plan was to buy a commercially available CNC mill from Haas or Tormach to avoid the hassle of converting a manual mill, but these CNC mills are just too expensive for someone like me that doesn’t plan to use his mill to turn a profit, especially when you start to add on fancy features like rigid tapping and work probing. Ultimately, I am happy with my purchase as this will be a great little machine to hone my machining skills on.

Why the PM-833TV?

Dr. D-Flo's with his freshly uncrated PM-833TV

Dr. D-Flo's with his freshly uncrated PM-833TV

So why did I pick this mill and not a more common model like the Grizzly G0704 or PM-25MV? There were three reasons for my choice:

The first reason is that this is one of the larger benchtop mills with a X-axis travel of 22”, Y-axis travel of 11”, and Z-axis travel of 17”. It weighs in at 750 lbs, which is heavy but still manageable for someone who only has access to an engine hoist. When it comes to machining time and part quality, heavier mills are more rigid and can take deeper cuts with less chattering. The 833TV seemed like a mill I could grow into.

The second reason is that this is one of the few mills at this price point and formfactor that comes with a spindle that is directly driven by the motor. This direct, belt drive will not only spin the spindle at almost twice the speed of the geared motors found on other benchtop mills, which is great for me because I plan to cut a lot of aluminum, but it also is quieter. My house is on a zero lot, so my neighbors are feet away.

The third and final reasons was that that this mill had a one-shot oiler installed. This oiler will improve the longevity of this mill. Also, the resale value of mills with one-shot oilers is greater than those without. It is so much easier to keep the ways properly lubricated when it only takes a single pump of the lever. With these lower cost mills, if the ways become damaged from excess friction, then the mill will most likely be scrapped due to the high cost of re-machining the ways. Second-hand buyers will have more confidence that the mill was properly maintained when it has a one-shot oiler.

CNC Conversion

The process of converting a manual mill to CNC may seem intimidating to some, but it is very doable. If you are hobbyist, like myself, then you will most likely find the hardest part of the conversion to be handling the different parts of the mill because of how heavy everything is. Take your time and make sure you have the correct equipment (e.g., engine hoist or fork lift) before you start.

When converting a mill, money and time are inversely related. This principle holds true for most projects. If you want to spend less money, then you are going to have to put more time into the conversion by building some of your own parts or by figuring out how to use free, open-source software. If you are not electrically inclined, then it might make sense to purchase a more expensive but user-friendly control system, like the Centroid acorn. If you do not have access to a mill, then you will have to purchase the motor mounting brackets and plates from a conversion kit provider, like Heavy Metal CNC. Just keep in mind that the Tormach 1100M, a plug-in-play CNC mill, starts out at about $10,000, and you might be surprised by how much money you will have invested into your converted mill when all is said in done.

It’s important to have the correct mindset when converting a mill to CNC. Are you taking on this project because you want to quickly turn a profit by making parts in your garage? Or is your goal to learn about CNC motion and machining by building? In my opinion, the ladder mindset will be more successful. If you are in a hurry, then it is my strong recommendation to purchase a turnkey system.


The BOM contains parts for two configurations: 1) An open-loop stepper motor configuration - cheaper and simpler. 2) A closed-loop AC servo motor configuration - smoother, faster, and positional feedback. Stepper or servo specific parts are denoted in the section headers.

Mechanical Parts
# Part Name Vendor Part Number (SKU) Unit Quantity Link
1 833-TV Precision Matthews N/A Benchtop Mill 1
2 CNC Conversion Kit for 833-TV Heavy Metal CNC N/A Kit 1
Common Electrical Parts
# Part Name Vendor Part Number (SKU) Unit Quantity Link
1 7i76e Mesa N/A Controller Board 1
2 Proximity Switch Amazon N/A PNP, NC, 6-36V 1
3 Intel Nuc 5 Amazon N/A Core i3 - Mini Computer 1
4 Touchscreen Monitor Amazon N/A Tool Height Setter 1
5 Jog Pendant Amazon N/A 4 Axis MPG Handwheel 1
6 CNC Work Probe Hallmark N/A 3 Axis Digitizing Probe 1
7 Touch Plate Amazon N/A Tool Height Setter 1
Stepper Electrical Parts
# Part Name Vendor Part Number (SKU) Unit Quantity Link
1 Nema 34 Stepper Motor Amazon N/A 6A, 8.5Nm (1200 oz-in) 2
2 Nema 42 Stepper Motor Automation Technologies N/A 6.0A, 20.0 N-m (2830 oz-in) 1
3 Stepper Driver Amazon N/A 2.4-7.2A at 36-110VDC 3
4 Unregulated Power Supply Automation Technology N/A 72VDC and 20A 1
5 Triple Output Power Supply Amazon N/A 24V, 12V, and 5V at 5A 1
6 Electrical Cabinet Amazon N/A 20" H x 20" W x 8" D 1
AC Servo Electrical Parts
# Part Name Vendor Part Number (SKU) Unit Quantity Link
1 0.75kW AC Servo Motor DMM 86N-DHT Nema 34 - 2.4 N-m (340 oz-in)† 2
2 1.3kW AC Servo Motor DMM A15-DHT w/Brake Nema 42 - 4.98 N-m (705 oz-in)† 1
3 Servo Drive DMM DYN4-H01A2-00 Drive for 0.75 - 1.0kW motors 2
4 High Amp Servo Drive DMM DYN4-T01A2-00 Drive for 1.3 - 1.8kW motors 1
5 Solid state relay AutomationDirect AD-SSR6M12-DC-200D 3-32V Input, 3-200V, 12A output 1
6 12A Contactor AutomationDirect SC-E03G-24VDC 24V Input, 12A - 3 power poles 2
7 18A Contactor AutomationDirect SC-E04G-24VDC 24V Input, 18A - 3 power poles 1
8 10A Line Filter Digi-Key 817-1275-ND Single Phase EMC/EMI Line 2
9 16A Line Filter Digi-Key 817-1278-ND Single Phase EMC/EMI Line 1
10 1A Line Filter Digi-Key 817-1276-ND Single Phase EMC/EMI Line 3
11 D-sub Connector Male Amazon N/AD 25-pin 2-Row Port Terminal Breakout Solder Type 3
12 Electrical Cabinet Amazon N/A 24" H x 20" W x 12" D 1
# Part Name Vendor Part Number (SKU) Unit Quantity Link
1 Kurt DX6 Vise Amazon N/A 9" Opening, 6" Size 1
2 Kurt Magnetic Jaw and Parallel Set Amazon N/A 6" Size 1
# Part Name Vendor Part Number (SKU) Unit Quantity Link
1 FogBuster Mini Coolant Sprayer First Industrial Supplies 10500 916 Ounce Single Sprayer 1
2 DuraKut DK7000B Amazon N/A Lubricant for MQL systems 1

† AC Servo motors have a low rated torque compared to a similar size stepper motor. However, they possess a high instantaneous torque that can be used intermittently, which makes up for the difference.

The BOM may contain affiliate links that provide monetary kickbacks to Dr. D-Flo. These funds are used to pay for this website and future projects.

Affiliate links may be present.
  •   A little self-promotion here, but if you are new to CNC motion, then checkout my written guide and video on how to build a 3D printer. Many of the concepts that go into building a 3D printer translate over to a mill conversion (just on a larger scale).
  •   The LinuxCNC Wiki and forum are invaluable resources if you use this open-source software to control your mill.
  •   The book CNC Milling in the Workshop is great for beginners
  • If you are using the DMM servo motors, then definitely watch this setup guide for the DYN4 drives and motors.

Walk Through

The video covers most if not all of the mechanical CNC conversion. However, if you want to learn more about the installation of the ball screws and motor plates then checkout the documentation on Heavy Metal CNC (where I bought the conversion kit from). This walkthrough is going to focus on the electrical and software portions of my mill conversion. Whether you are converting an RF-45 clone (e.g. Grizzly, Precision Matthews, etc.) or an old knee mill, most of the information presented here will translate to your conversion. Finally, if you are new to CNC motion, then it would be worth your while to check out my How to Build a 3D Printer Video, which covers a lot of topics needed to successfully build a CNC mill.


I also want to point out that I am NOT an electrical engineer, so the way in which I wired my mill may not be the best or safest way. If you have a safety concern with any of the information provided in this guide please email me directly at [email protected], so that I can make the appropriate changes. With that said, I accept NO liability for any harm or loss resulting from following this guide. Proceed at your own risk.

  A Computer Controlled Milling Machine

Nearly every aspect of the milling process can be computer controlled. Entry level CNC mills will have computer controlled linear motion (i.e. stepper motors) and maybe some homing switches. More sophisticated mills will have robotic arms that load and remove parts, automatic tool changers, and many sensors that monitor the cutting process. A lot of these industrial technologies can be added to DIY CNC mill conversion/builds, so really the only limit is your budget.

The current configuration of my mill is relatively simple. It has three stepper motors, three limit switches, a tool length probe, a work offset probe, and handheld pendant for jogging the axes. In time I will add a power draw bar, automatic tool changer, and coolant, so check back on this project if you want to learn how to expand the capability of your mill. But first let's start with the basics.

Examples of electrical components that can be interfaced with a CNC controller board.
Figure 1: Examples of electrical components that can be controlled by a computer.


Obviously, to run LinuxCNC you need a computer running Linux. This website is a great resource for installing all the different flavors of Linux with real time extensions. The real time extensions will allow LinuxCNC to operate largely uninterrupted, which is critical because CNC motion has strict timing requirements. There are two types of real time extensions: RTAI and Preempt-RT (uspace). The RTAI extension is used for builds that use either a parallel port or PCI for communication with CNC hardware, and the Preempt-RT (uspace) extension is for setups that use a parallel port, PCI, or ethernet. This guide will use the Preempt-RT (uspace) because we will be using a Mesa board connected by ethernet. More on this later. Please note: the RTAI extension has less latency (see latency section below) and may be a good option if you are using a PCI board or parallel port.

If you are new to Linux, then a lot of the terminology may seem overwhelming. I recommend installing Debian 9follow these instructions and then installing Linux CNC 2.8follow these instructions. Debian 9 has backwards compatability for all the old dependancies of LinuxCNC, and I have found stock LinuxCNC to work out of the box with this OS. If you plan on using Probe Basic GUI, which is what I use, then you will need Debian 10 - follow these instructions.

  Which Computer?


But what computer should you use? Is a fast multi-core CPU required? No. In fact, raw CPU power is really not that important. Low-end Atoms and Celerons CPUs are more than sufficient for running LinuxCNC. Typically a computer is selected based off its latency. Latency is defined as “how long it takes the PC to stop what it is doing and respond to an external request.” With LinuxCNC, the computer’s CPU handles the step pulses (in some cases – see below), so any delay (i.e. latency) between when a step pulse needs to be generated and when it is actually generated will directly affect the motor's performance. A computer's latency is a sum of all the delayed caused by active components.

Because latency is not a specification that is reported by manufactures, I believe that it is best to purchase a computer that other have had success with. I used an Intel NUC 5 in my build, but I had to disable the WiFi card, which caused a spike a latency every time it looked for a new data packet to download. There is a database of the realtime performance of various computers/CPU found here.

It may be helpful to point out what computers are not ideal for running LinuxCNC. Laptops are rarely a good fit. All of the power management software that is running in the background to prevent the laptop from overheating eat into the realtime performance. There is more information on what hardware is not ideal for LinuxCNC found here.

With the correct microcontroller, latency is not as important.

This may seem contradictory to the last section, where I preached minimizing latency, but the above advice is most important for older controllers that rely on a feature known as software stepping, where the CPU directly generates the step pulse. In this setup, faster CPU response times equals higher step rates.

Today, most controllers that are paired with LinuxCNC have a hardware step-generator. With this feature, the CPU only has to send over a step frequency (velocity of the movement) and a direction. The hardware on the microcontroller handles generating the step pulses, and thus, the CPU only has to handle changes in gross movement.

Now before you go grab that old laptop with terrible latency, just know that really high latency values can still affect the performance, so I still recommend taking latency seriously and reducing it in any way possible.

Controllers with hardware step-generators will be discussed below.

How to measure latency

Once Linux and LinuxCNC is installed, go to the terminal and type:


A window will pop up with some changing values (Figure 2). If the board that you select uses a hardware step-generator (very likely), then you only need to concern yourself with the Max Jitter for the Servo thread. Compared to the base thread, the servo thread is for components that can handle slower response times. Remember with hardware step-generation the CPU doesn’t have to handle the pulses, so it does not need to be as responsive. This is a good thing. With software step-generation you have to measure latency according to the base thread, which can be fussy and requires a very low max jitter value for proper step-generation.

The max jitter for the servo thread at idle is not very helpful. When controlling the mill the computer will have its hands full. Intuitively, the more tasks the computer is completing the longer it will take to respond to a request (higher latency). This is a little bit of an oversimplification because your computer should be running the Real-Time version of Linux, which in theory should have the same latency regardless of what it is doing. However in practice, more activity does increase latency. So for proper results, you should stress your computer by moving windows around, transferring files from an flash drive, and really anything else that “distracts” the computer. The latency test needs to be run for at least 10 minutes.

For optimal performance you want a max jitter <100ns. However, there have been reports on the forum that value up to 300ns will work, but you might encounter following error.

Latency test LinuxCNC
Figure 2: Latency test running on my Intel Nuc 5. The servo thread is low enough < 100ms for hardware stepping application. However, the base thread is way too high for software stepping. As a side note, I determined after this picture was taken that my wifi card was causing the base thread's high latency. Disabling the wifi card in the bio decreased the latency to 35,000.
How to improve latency

In many cases, Latency can be drastically improved by disabling non-mission critical features in the bios, such as:

Turn off each of these features one at a time and re-check the latency.

If you plan on sending G-code files over to the mill via the cloud, then not having wifi would be a pain. If you determine that the internal wifi module is a source of latency (like it was for me), then you can purchase a wifi usb dongle, which should not add latency.

  Linux CNC Controller Boards

The controller board is the bridge between the computer and the CNC hardware (e.g. the stepper drivers, limit switches, coolant pumps, etc.). LinuxCNC can communicate with the controller over PCI, PCIe, and Ethernet. USB is not an option for LinuxCNC because it introduces a significant amount of latency.

Mesa Boards

The most popular controller boards paired with LinuxCNC are Mesa’s FPGA cards. FPGA is an acronym for Field-Programmable Gate Array, and basically, the logic of these semiconductors can be reprogrammed after being manufactured (in other words, can be programmed out in the “field”). Simply put, Mesa’s FPGA cards are extremely flexible and can be molded to fit specific applications like running a mill, lathe, or a multi-axis robotic arm.

Mesa 7i76e FPGA
Figure 3: Mesa 7i76e with interfaces with up to 5 Axes of drives, spindle encoder, and two MPG encoders. Further, the 7i76e has 32 sinking inputs and 16 sourcing output.

Mesa offers cards that communicate with Linux over both PCI/e (5i25 or 6i25) and ethernet (7i76e). Which is better PCI/e or ethernet? In theory, you can use the RTAI extension with the PCI/e boards and achieve lower latency, but remember latency is not as important for these boards because they have hardware step-generation. The downside of the PCI/e boards are that you need a full size computer with a PCI/e slot. For this reason, you can’t use a small form factor PC (e.g., Intel Nuc) or an all-in-one with a PCI/e card. Further, the PCI/e cards need to be combined with the 7i76 (not to be confused with the 7i76e) daughter board to get IO needed for the stepper/servo drivers and peripherals.

I went with the 7i76e (Figure 3) because of the compatibility of the small form factor computer and because ethernet cables and connections are ubiquitous. It was easy to find panel mount to bring the ethernet cable into the electrical cabinet, where the 7i76e was mounted.

Unfortunately, the documentation for the Mesa cards is not written for a layman. This includes the manual for the 7i76e. A user over on the LinuxCNC forum posted the pinout for the 7i76e board, which helped in making the following diagram (Figure 4) as well as understanding the role of all the different jumpers on the board.

Mesa 7i76e pinout and wiring diagram.
Figure 2: The pinout of the Mesa 7i76e.



  Electricity is dangerous. Mistakes can cause injury and be expensive. Find out how to work on electrical components safely...

  Connecting components to the Mesa 7i76e

You can click through the tabs below to see how I wired up different components to the Mesa 7i76e. I included some tips like how to wire an NPN vs PNP switches to the Mesa board and what is going on with all the different jumpers.

The 7i76e has 13 jumpers that handle an array of settings from the pullup voltage to the IP address of the board. Study the diagram (Figure 3) below and adjust the jumpers of your board to match. Jumpers W7, W10, W11, and W13 differ from the default jumper configuration. Make sure your board matches the orientation of the schematic below (ethernet port is on the left).

Mesa 7i76e jumper locations for the Mesa 7i76e
Figure 4: The recommended jumper locations for the Mesa 7i76e.
Ethernet Connection

This section will be a quick guide to connecting the Mesa 7i76e over ethernet. This process can vary based on the Linux OS and the ethernet adaptor that is being used. The steps below are numbered for organizational purposes, but they do not need to be followed in order.

1. The default IP address of the Mesa 7i76e is To avoid IP address overlapping, it is recommended to set the address of the 7i76e to by setting the W3 Jumper to up and W2 Jumper to down. This was illustrated in Figure 3. After changing Jumpers, the board must be power cycled.

2. Next the static IP address on the host computer must be set to include the 7I76E's new IP address in its masked range. This takes a couple steps (labeled alphabetically):

2a.) Determine the name of your local ethernet by typing the following in the command terminal:

ip a

The local ethernet name will look something like the following: eth0, eno1, or enp0s7. Write this down.

2b.) Open the network interfaces file by navigating to /etc/network/ and open the interfaces file via your file explorer or terminal. Add/change the text in this file to conform to the code below. Eth0 will be replaced by the name of your computer's local ethernet name.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces (5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# Ethernet interface naming scheme has changed over the years
# Replace: eth0 with your computer's local ethernet name
auto eth0
iface eth0 inet static

#If you have an Intel ethernet controller, disable IRQ coalescing
hardware−irq−coalesce−rx−usecs 0

3. Ping the Mesa board by typing the following in the terminal:


Receiving a response means that you have correctly configured the network settings. Hooray! The first ping will have the longest response time, but each subsequent ping should be under 0.1 ms for optimal communication with the board. Response time >0.2 ms will cause problems. If you are using an Intel ethernet controller, then disable IRQ coalescing in the interfaces file. See example code above.

4. In your HAL file (this has not been introduced yet, see below), the IP address of the board will need to be updated:

loadrt hm2_eth board_ip="" config="firmware=hm2/7i76/7i76e.BIT num_encoders=1 num_pwmgens=0 num_stepgens=3 sserial_port_0=2xxxx"

5. It seems that this ethernet connection process changes with LinuxCNC updates and new ethernet chips and drivers. This short guide may not work for you for this reason. For up-to-date information, I recommend reading this thread over at LinuxCNC forum (update: If you are using Debian 10 Buster then click that link).

  LinuxCNC Configuration Files

I’m more of a hardware guy, so learning how to adapt LinuxCNC to my custom milling machine was definitely a challenge. The amount of information that is available on the LinuxCNC Wiki is overwhelming, but I strongly recommend putting the time in upfront and reading through as much of this documentation as possible because it will save you a lot frustration when setting up the software side of your mill.

  Picking a GUI: Probe Basic

LinuxCNC has different graphical user interfaces (GUIs) with some being more optimal for touch screens and others giving the user access to complex probing macros with a push of the button. There is not going to be a performance difference between the different GUIs, but some designs result in higher productivity than others. My favorite GUI is Probe Basic (Figure 10). Probe basic is the only LinuxCNC GUI that looks like it is from the 21st century, and it doesn’t just have the looks. It is chalked full of probing subroutines that allows you to accurately set the work coordinates with a push of a button. Here is a list of some of the other GUIs that are avialble.

GUIs require different packages to be installed and may require a special distribution of Linux, so I recommend picking out a GUI prior to installing LinuxCNC.

How to wire an MPG Pendant to a Mesa 7i76e
Figure 10: Probe Basic: A graphical user interface for LinuxCNC that is user friendly and greatly reduces set up times through its many subroutines for probing

  Download, Install, and Setup LinuxCNC

If you are going to use Probe Basic as your GUI of choice then you can follow the full installation instructions provided by the Probe Basic team found here. If you are using a different GUI and/or prefer a different Linux operating system, like Mint or Ubuntu, then follow instructions found here.

If you are using a Mesa ethernet card, then after installing OS and LinuxCNC it is very important to configure the network adapter to get along with the Mesa card. Configuring the network adapter is slightly different process for Debian 9, Linux Mint 19, and Lubuntu 19.04.   This is a very important step - do not forget!

  Run the Mesa Configuration Wizard

The Mesa boards and LinuxCNC go together like peanut butter and jelly. The best example of this compatibility is the Mesa Configuration Wizard that is automatically installed when LinuxCNC is installed. The Mesa Configuration Wizard is better known as PNCconf. A great step-by-step guide for how to use PNCconf is found on the LinuxCNC website. You can test your latency and motor wiring in PNCconf. Try and fill in as much information about your CNC machine into the configuration wizard as possible. Use the 7i76e wiring diagrams I made above to accurately tell PNCconf which components (stepper motors, limit switches, etc.) are plugged into which pins. Next I will go over how to customize the files that are outputted by PNCconf to match the LinuxCNC configuration files exactly to your mill’s setup.

After completing PNCconf, there will be new folder located in your LinuxCNC/configs folder. This folder, named after your mill's configuration, will contain a couple different files but the HAL and INI files are the most important.

  Tweaking the HAL File

The Hardware Abstraction Layer or HAL file is the most intimidating file for those who are new to LinuxCNC. While the Mesa Configuration Wizard gets you pretty close to a completed HAL file, manual edits are needed if you are looking to add complex features to your CNC mill like a jog pendant or multiple probes (e.g. work and tool probes).

I am not going to pretend like I fully understand the intricacies of the HAL file. I have yet to finish reading the 100 page manual on how the HAL file works and all of its components. Everything I know has been from trial-and-error, so it may not be 100% accurate (just a heads up).

In my eyes, the main role of the HAL file is to act as a link between hardware and digital components. For example, let’s say you have the limit switch for the X-axis plugged into digital input pin 4 on the Mesa board. How in the world will LinuxCNC know that? Well, that information is defined in the HAL file, and it looks like this:

net home-x <= hm2_7i76e.0.7i76.0.0.input-04-not

The net command creates a connection between the Mesa pin, which is input 4 in this example, and the digital X-axis limit signal (home-x). This is the limit switch that will be triggered when the mill is instructed to home, which is why it is home-x. The "<=" syntax is optional, but it makes the code easier to read. Following input-04 the word "-not" inverses the signal. This limit switch is normally connected (NC), and therefore input-04 will be at 24V until the limit switch is tripped. Therefore, when input-04 is not connected to 24V the limit switch has been tripped (i.e. home-x should be true).

Setting up a probe is just as easy as setting up a limit switch:

net probe-in => motion.probe-input <= hm2_7i76e.0.7i76.0.0.input-20

Here we have tied together three items: 1. the probe-in signal, 2. the state of the input-20 pin, and the digital motion.probe-input pin. During a probing move if the state of input-20 changes from false to true then so will the motion.probe-input, which signals to LinuxCNC that probe has been tripped during a move.

While setting up one probe was somewhat trivial, connecting two probes (tool height probe and work offset probe) is a trickier example because LinuxCNC only recognizes one probe signal. There is not a probe-in-2 signal. This isn’t a huge deal because we will never use both probes at the same time. You could wire both probes to one input and then net that single input from the 7i76e to the probe signal in the HAL file. However, there can be issues with this approach depending on the type of sensor/switch the probes act as. In the HAL file we can connect two inputs to the single probe signal digitally through an or2 component. The or2 component takes input from two pins (say from a work probe and tool probe) and outputs a true/false value similar to how or statements are used in other programming languages like Python. If either the work or tool probe input is true, then the output of the or2 will be true. The output of the or2 can then be connected to the probe signal via a net. To initialize the or2 component you have to both load the component by using a loadrt command and add it to the "thread" so that the component is updated (i.e. constantly checking for changes in the state of the inputs) through the addf command. The loading and adding commands precede the use of the or2 function. This can be a little confusing. I had to read the Basic HAL Tutorial a couple of times before everything clicked. Below is everything written out.

loadrt or2 [count=1]
addf or2.0 servo-thread	

or2.0.in0 <=hm2_7i76e.0.7i76.0.0.input-20
or2.0.in1 <=hm2_7i76e.0.7i76.0.0.input-21

net probe-in => motion.probe-input <= or2.0.out

This definitely looks more complicated than the previous probing example, but I hope it makes sense. Notice the .0 in the or2.0. If you need another or2 component later on then you will have to load and add another or2 statement, which is accomplished by modifying the top code code to:

loadrt or2 [count=2]
addf or2.0 servo-thread
addf or2.1 servo-thread

Your next use of or2 will be or2.1. Don't forget: in computer programming counting starts at 0!

  Configuring MPG pendant in HAL

One of the hardest parts of this entire build was configuring the HAL file to read the inputs from a pendant with a jog wheel. All of the HAL examples online did not seem to work with my setup, which was very frustrating. However, after I got everything set up the pendant has worked flawlessly. I hope my code, which is below, speeds your build along! Read through it and the inline comments then I will discuss how it works below.

# sserial_port_0 needs to be set to 2xxxx. This changes the 7i76e to Mode 2
# and allows it to accept two seperate MPG inputs on pins 16/17 and 18/19
loadrt hm2_eth board_ip="" config="firmware=hm2/7i76/7i76e.BIT num_encoders=1 num_pwmgens=0 num_stepgens=3 sserial_port_0=2xxxx" 

# The mux4 component will be used to switch jog increment
loadrt mux4 count=1
addf mux4.0

# --- MPG --- 
# In linux 2.8 "joints" (i.e. your motors) and axes (your directions x, y, z) are seperated.
# However, for my simple three axis mill with one motor per axis this is not particularly 
# useful. We need to tie the joints to the axes (joint.0 = axis.x, joint.1 = axis.y,
# and joint.2 = axis.z)

# When jog-vel-mode is set to 0 the axis will move jog-scale
# When jog-vel-mode is set to 1 the axis will stop when the 
# handwheel stops turning 

setp joint.0.jog-vel-mode 0
setp joint.1.jog-vel-mode 0
setp joint.2.jog-vel-mode 0

setp axis.x.jog-vel-mode 0
setp axis.y.jog-vel-mode 0
setp axis.z.jog-vel-mode 0

# This sets the scale that will be used based on the input to the mux4
# This mill reads in metric units so jog scale is 1mm, 0.1mm, and 0.01mm
setp mux4.0.in0 1
setp mux4.0.in1 0.01 
setp mux4.0.in2 0.1

#The inputs to the mux4 component
net scale1 mux4.0.sel0 <= hm2_7i76e.0.7i76.0.0.input-10
net scale2 mux4.0.sel1 <= hm2_7i76e.0.7i76.0.0.input-11

#The output from the mux4 is sent to each axis jog scale
net mpg-scale <= mux4.0.out
net mpg-scale => joint.0.jog-scale => axis.x.jog-scale 
net mpg-scale => joint.1.jog-scale => axis.y.jog-scale 
net mpg-scale => joint.2.jog-scale => axis.z.jog-scale 

#The Axis select inputs
net mpg-x joint.0.jog-enable <= axis.x.jog-enable <= hm2_7i76e.0.7i76.0.0.input-07
net mpg-y joint.1.jog-enable <= axis.y.jog-enable <= hm2_7i76e.0.7i76.0.0.input-08
net mpg-z joint.2.jog-enable <= axis.z.jog-enable <= hm2_7i76e.0.7i76.0.0.input-09

#The encoded output counts to the axis. Only selected axis will move.
net encoder-counts <= hm2_7i76e.0.7i76.0.0.enc0.count
net encoder-counts => joint.0.jog-counts =>axis.x.jog-counts
net encoder-counts => joint.1.jog-counts => axis.y.jog-counts
net encoder-counts => joint.2.jog-counts => axis.z.jog-counts

The 7i76e has three software modes (0, 1, and 2). Mode 2 “activates” the 2 MPG encoders on inputs 16,17 and 18,19, which is how the board will measure how far the handwheel on the pendant has been rotated. Switching to Mode 2 is accomplished through setting the sserial_port_0 equal to 2xxxx . I don’t want to get in too much detail, but basically this sserial_port_0 is an entry in the configuration string that is passed to the Mesa 7i76e on start up.

I want to quickly point out that LinuxCNC 2.8 can be used to control many different CNC machines, including complex robotic arms. To make LinuxCNC work with all of these different applications they have separated the motors, which are known as “joints”, from the cartesian coordinates, which are known as “axes.” If you have a CNC machine where you need to move multiple motors to get movement in one direction (or axis), then you can assign all of these “joints” to a single “axis.” This mill is hardly a complex CNC machine and each axis is driven by one motor. You will see throughout the code that I have tied the X, Y, and Z joints to their respective X, Y, and Z axes.

Most pendants have one hand wheel and at least two knobs that allow you to select which axis you want to move and at what step size. Let’s focus in on the step size. The step size is referred to as the jog scale. Each click of the handwheel will correspond to whatever jog scale is active. Most pendants let you choose between three or more different jog scales. My mill reads metric units, and I found 1mm, 0.1mm, and 0.01mm to be good range of jog scales, where 1mm is sufficient for moving the mill quickly to a rough location and 0.01mm being adequate for precise movements.

If you reviewed the wiring diagram for connecting the MPG pendant to the Mesa 7i76e (above), then you may have realized that the jog selector is a simple switch that connects the active jog scale to common (in our case 24V). Therefore, a pendant with three jog scales will have three wires for each scale as well as a common wire. You would think that the 7i76e would look to see which wire is at 24V to figure out which jog scale LinuxCNC should use when moving the mill. You would be right, but there is a small caveat we need to concern ourselves with. LinuxCNC likes 4-to-2 bit binary outputs from its switches. I know I am going to lose some people here but as its name suggest, a 4-to-2 bit binary outputs takes four inputs and distills them down to two outputs. How is this possible? Well, it’s based on truth table, where the absence of signal is also a signal. You can read more about them here. These 4-to-2 binary outputs mean you only need two pins on the 7i76e to read 4 inputs, so this conserves those limited number of digital inputs.

The LinuxCNC component that reads these 4-to-2 binary outputs is known as mux4. If you are wondering where this name comes from, multiplexing is also known as muxing. The conversion of 4 inputs to two outputs is multiplexing. I strongly recommend you read about how the mux4 component works here. The mux4 is initialized just as the or2 was in our previous example.

So most cheap pendants don’t have this 4-to-2 binary output, so what dcan be done? Well, we can kind of pretend. If you think about it we technically only need two wires for three inputs. Because if neither wire one nor wire two is connected to common then by default wire three must be (assuming there is no faults in the wiring). This is why I was able to get away with only two pin inputs for the mux4 (hm2_7i76e.0.7i76.0.0.input-10 and hm2_7i76e.0.7i76.0.0.input-11). When you read the truth table on the mux4 documentation this will hopefully make sense. The output of the mux4 is outputted to the jog-scale of each axis/joint.

If your pendant has 4 jog inputs, then you will have to use a mux8.

Perhaps confusingly, the selector for which axis you want to move does not require a mux4 component. This is because of the way the jog-enable signal works. Technically, you could enable and move multiple axes at once (not recommended), so we only need to net together the enable signal with the input pin on the 7i76e that corresponds to the appropriate axis/wire on the selector.

Finally, we net the input from the encoder that the MPG is plugged into to the axis/joint jog-counts, which results in the moving of the axis that is enabled by the jog-scale.

If you are able to successfully hook up and run an MPG, then no task involving the HAL file is too difficult. Similar methods are employed to setup coolant pumps and even automatic tool changers.

Download my HAL file and adjust it to your needs.

  The .INI file

The INI file is also outputted by PNCconf. If you have ever set up a configuration file below when building a 3D printer, then the INI file will have a lot of variables that look familiar, like the maximum acceleration and velocity of each axis and the location of the limit switches. If you fill out all of the fields in PNCconf then almost no adjustments to the INI file are necessary. However, if you find that you inputted the wrong steps/unit because you actually have a 20 tooth pulley instead of a 30 tooth pulley you can quickly change that in the INI file.

Download my INI file to see how my mill is setup. Note: most of my acceleration/velocity values are conservatives, because I havn't stressed tested this mill yet.

Discussion and Feedback

Let me know in the feedback form below if you found this small LinuxCNC tutorial helpful. I saw a need for a LinuxCNC guide that was more digestable to newcomer. If there is enough interest I can expand on this content.

Do you need more help? The best way to get your questions answered by Dr. D-Flo and other DIYers is to post a question on the forum. Click here for the forum topic specific to this project.

Rate this Project: or

Did you encounter broken links or misinformation while reading this article? Please bring these issues to our attention by providing your feedback below.

We'll never share your email with anyone else.