
LEGO CNC Milling Machine
At the end of my first semester of Mechatronics Engineering at the University of Waterloo, we were assigned a design project to make a mechanism using the LEGO Mindstorms NXT robotics system. The requirements for this project were met within a day of work and one of my partners and I wanted to extend the project and see if we could design a LEGO CNC mill inspired by one on youtube.
​
The machine used 3 motors for independent control of its X Y and Z axes each with a touch sensor limit switch for zeroing. A separate high speed LEGO motor was used to spin a 1/16 inch drill bit that the device moved to cut soft "Floral Foam". The foam can be easily crushed if you squeeze too hard and cuts like butter, the perfect material for us to use.
​
In the end, the machine read industry standard g-code used on almost all CNC machines and was capable of cutting very clean 3D shapes. The Iron Man head pictured to the left was cut on the machine in the span of around 3.5 hours.
The design
The first question in the design was how to control the motors accurately enough to follow desired commands. We put a lot of work into testing many different systems. The LEGO motors have built in encoders and with the gear ratios that we selected to achieve a reasonable top speed, one encoder tick represented a movement of about 0.001 inch. With a bit of work, we designed a controller for the motors that was able to hold an average error of less than one tick. The controller was a combination of a feedforward and a PD controller and as there was very little cutting resistance, this simple controller worked very effectively.
​
Once we could control the motors, the next question was how to read the files that contain instructions for CNC machines known as g-code. G-code is well documented, and it was not too difficult to decode all functions that we would need to use but after generating a few g-code files for cutting various objects we found our first major problem. For more complex objects, the files were far too large to completely fit in the LEGO computers memory. Even with custom compression, we still could not get the file size down enough. To solve this we set up a Python server running on a laptop that would send smaller file chunks to the NXT sequentially as they were required. The server would simply monitor for when the current file was deleted and offer the next one with a one file buffer. We did however first run smaller objects successfully prior to implementing this solution.
​
Mechanically, a lot of thought was put into the design to keep the tolerances as high as possible and a lot of testing and development was involved. Linear rails had shims added along their lengths to take up most slack, chain was used in the gear reductions for its lower backlash, and the structure was designed very rigidly to ensure that the machine had minimal low frequency vibration.
​
A video of the competed machine can be seen below.
Related Project Links
I designed my own high end 3D printer instead of buying one for my own projects. My design featured many innovative features that I developed through significant research and testing allowing for unmatched print stability and consistency.
This page outlines only my most recent 3 year's involvement with the First Robotics Competition (FRC). In my last two years, I mentored a world renowned team (1114) and made it to the world finals both years in a pool of 4000+ teams worldwide.