How to Connect Mach3 to Arduino

This site contains affiliate links to products. We may receive a commission for purchases made through these links.

In this article, we shall be discussing how to connect Mach3 to Arduino without having to use additional hardware. While connecting your Mach3 to Arduino using the tips discussed in this article, you will not have to use Modbus library.

Your Mach3 will have the ability to read an input pin on an Arduino. However, if this still works for you, adding full Modbus to enhance communication will not be a problem.

You should note that Modbus is a software protocol rather than hardware. Therefore, this means that you can use it with rs485 or the other rs232 as well as uart usart. The best part is that it does not matter the amount of connection a hardware protocol uses; generally, it comes down to communication line or half-duplex and full-duplex.

It is best to use RX tx lines when carrying out the communication of Mach3 and Arduino. However, you might as well consider using a USB to rs485 adapter that you will use in connecting RX tx lines. Without further ado, let’s get started on how to connect Mach3 to Arduino.

What is Mach3?

For starters, Mach3 is a CNC controller which is advanced and ideal for DIY. You might as well consider running this particular software on an industrial machine. Mach3 software has been designed to run on most computers with Windows as their Operating System to help in controlling motion of their motors. It achieves this by processing the G-Code.

This software comprises several advanced features, and it is customizable as well as ideal for use on various applications with different types of hardware. If you are in need of a CNC control package, then Mach 3 will be best for you.

AdobeStock 258990954 1


Connecting Mach3 to Arduino is relatively easy. Your Arduino will be receiving 8 bites and will reply with either 01 04 02 00 01 b9 30 or 01 04 02 00 00 78 f0. When it comes to communication, the above packets are a reply from Modbus for the question 01 04 00 00 00 01 31 ca. This is a read input register question.

Therefore, you will have to send a request from Mach3 that will read the input register along with Arduino replies featuring data that contains 1 or 0. Thus you will be able to read the state of input of your Arduino.

Connecting Mach3 to Arduino

You will require a Modbus tester KMtronic_ModBus_Tester. You will then go ahead and upload code at the bottom of this particular page to your Arduino. The attached image is usually from the tester, and automatically, it will show you the port in which your Arduino is connected to and in case you have several ports connected, you should consider disconnecting and check out which port will disappear. Set your Arduino back you will be able to tell which port your Arduino is connected to once you connect it back.

You should then go ahead and set a communication speed of 9600bauts since it is what is often used at mmnt in serial communication in all Arduino programs. For you to communicate with your Arduino, you will have to click Open. 

By doing so, your device will be connected, allowing you to send as well as receive information. Whenever the port is open, there is no other program that will be capable of communicating to the Arduino; this means that you will have to close it in order to allow for communication.

Once you have everything set, you will go ahead and send a request command to your Arduino 01 04 00 00 00 01 which is what a Mach3 is designed to do. You might consider sending 8bytes to an Arduino to help in answering; in this case, the Arduino will not care for the question.

When it comes to the Modbus tester, you will first have to click the close button. If not, the Mach3 will fail to communicate with your Arduino since there will be an existing open com port. To achieve this, you will go to Mach3 top menu and then click on config and then go to ports and pins you will then tick both of these options. For the changes to be applied, you will have to restart your Mach3.

Go to the top menu of Mach3 and click on setup serial Modbus control; once this is done, a popup will appear; here, you will press on test Modbus. The Mach3 will not automatically add a choice for port number; however, this will be the same port in which you had tested earlier; therefore, if it was displayed on Com5, you will go ahead and write Num.:5. Once this is done, you will go ahead and set a communication speed of approximately 9600baud.

You will then go ahead and click open in order to allow for communication to occur on your com port. In case there is something wrong, you will be able to see in a status message. However, in case there is no error, the status will read No error. When pressing the Read button that presents a big data window on the right-hand side, it should be reading 0000.

When Arduino D4 is connected to the ground, you Mach3 will be displayed 0001 once you press on Readbutton. Once you receive such displays on your Mach3, you will have successfully established a connection between Mach3 and your Arduino.

Final Word

Connecting Mach3 to Arduino is relatively easy and can be achieved by anyone regardless of their level of skills. By going through this article and adhering to the tips discussed, you will come to see that the whole process of connecting Mach3 to Arduino is straightforward. 

If you are a DIY enthusiast, mastering this concept is vital since it will come in handy when working on various projects out there. As we come into conclusion, we hope that you find this article to be of great benefit when it comes to understanding how to connect Mach3 to Arduino.

About The Author