Brian Millier constructed a microcontroller-based, G-code controller for a CNC router. So, we gave the retired instrumentation engineer space to publish a two-part series about his project.
In Part 1 (Millier-CC-2013-04-Issue 273), Millier explains the basics of G-code and how it is converted into three-axis motion, via the router’s three stepper motors. In Part 2, he describes his design of the router’s axis controller (powered by three small microcontrollers) and the host controller (powered by a more powerful microcontroller).
He calls the project one of the most challenging he has ever tackled.
So why bother? Especially when the combination of a PC and ArtSoft’s Mach3 software is a common and affordable approach to running a CNC router? Well, like most DIYers, Millier couldn’t resist an opportunity to learn.
“I want to be upfront and say that this is probably not the most practical project I have ever done,” Millier says in Part 1. “You can usually pick up a used PC for free, and the Mach3 software is professional-grade and handles much more complex G-code programs than my DIY controller will. However, it did provide me with a challenging programming task, and I learned a lot about designing a program with many concurrent tasks, all of which are quite time critical. Even if you are not interested in building such a controller, you may find interesting some of the techniques and tricks I used to provide the multi-axis stepper-motor motion.”
Millier’s two articles focus on the two main tasks of his project.
“The first was to understand the G-code language used to program CNC machines well enough to be able to write the firmware that would parse the G-code commands into something that a microcontroller could use to control the stepper motors used for each of the three axes,” he says. “The second task was to design the hardware/firmware that would actually control the three stepper motors, all of which had to move synchronously at accurate, ramped speeds.”
Millier wraps up his project by saying: “This was probably the most challenging project I’ve tackled, outside of work projects, in many years. In particular, the Basic program code for both of the controllers ran beyond 3,500 lines.”
UPDATE: The link to the article code has been updated – you can now find it here.
Circuit Cellar's editorial team comprises professional engineers, technical editors, and digital media specialists. You can reach the Editorial Department at firstname.lastname@example.org, @circuitcellar, and facebook.com/circuitcellar