Through the course of building our CNC router here at Omni Instruments I ran into a number of unforeseen issues with some of the components. In particular our breakout board had a short across some of the inputs which meant that I was unable to wire in the limit and home switches. As I'm sure you know if you're reading this article, running a CNC router without the proper limit switches can be dangerous to both you and your machine. Not to mention that homing switches just make life so much easier when switching between jobs.
So I was faced with a decision: do I find a way to make this machine work now or do I wait a few weeks for BuildYourCNC.com to provide us with a functional breakout board? Let's just say that BuildYourCNC.com was slow to respond, slow to deliver and gave us a number of wrong parts. I figured I was better off trying to make things work with some bits we already had around the shop.
After a bit of playing around with the Mach3 software I stumbled across some menus that made mention of MODBUS. This led me to do some studying on the capabilities of this feature, during which I determined that I could fix my limit/home switch issues with an RS485 bus. Fortunately for me, we had the parts on the shelf, so I was able to walk back in the stock room and grab them. Nonetheless, if you find yourself in need of a similar solution, these are stock items here at Omni and can usually be shipped the same day.
To implement this solution I used one each of the following items:
- DigiRail-4C, MODBUS transmitter with 4x digital inputs
- USB-i485, RS485 converter with USB interface
- 12V power adapter, generic wall adapter for 120V AC to 12V DC
The DigiRail-4C allowed me to make up for the digital inputs lost by the short in the breakout board, the USB-i485 gave my old Windows XP machine a MODBUS interface, and the 12V power adapter supplied the DigiRail-4C with power and high level voltage for the digital input. Always remember to wire and configure your limit switches to "Active Low", that way if there is a problem with your wiring or configuration the limit will be triggered.
I would cover the Mach3 configuration for MODBUS, but in all reality that would be a waste of time and a duplication of work. If you have any questions on the configuration process you can feel free to get in touch, but the Mach Support Wiki has a great article titled "Modbus in Mach" which should be able to get you through the process without much trouble.
I haven't spent the time to learn scripting for Mach3, but there are a number of ideas for further expansion using the DigiRails and MODBUS. It's good to keep in mind that the DigiRails are not limited to digital input, but also come in a model with 2x analog input and 2x relay outputs.
- Motor calibration using a linear displacement transducer.
- Vacuum table control using pressure transducers, relays and solenoids.
- Tool offset calibration using simple metal-to-metal contact.
Some of these could surely be implemented with a better breakout board, but those can get rather expensive rather quickly. This is a good alternative for smaller additions to your CNC system.
We'd love to hear some of our readers' ideas for CNC expansion through MODBUS, so don't hesitate to post a comment and let us know what you're thinking! We'll also be happy to answer any questions as best we can.