Jan 16, 2014

Another way to use high end CNC as DIY 3d printer with Mach3 software

Another way to use high-end CNC machine as (low end) simple 3d printer. This project is done by Chin-Kai Chang, Rand Voorhies and Lior Elazary at University of Southern California(USC) iLab.
Personally, I don't think it makes much sense to do it in their setup with this big expensive CNC, but maybe someone will find a use for their hack.

From project description:
This is a in progress project that we try to use convention CNC mill/router as a 3D printer. Here, we use Mach3 control software which reads g-code and control the CNC movement. In this setup, we don't need to change the original setup and be able to switch CNC/printing jobs easily.

Here is a post about Mach3 software addon that enables it to to all the 3d printing required processing and slicing inside the program:

Details and downloads:
Instructions from the Thingiverse:

1. Printer Head mount:
We choose Makerbot Plastruder MK5( as our print head. The mount plate and MK5 model can be found at
2. Reprogram extruder controller board:
In our version of firmware, we implemented a simple serial protocol that takes a serial command to set/read temperature and control DC motor speed.
For example, send "T220" to set temperature to 220C and send "M255" to set motor pwm to 255. Send "R" to read current temperature and so on.
In addition, we also use one digital I/O pin(D9) as motor start/stop input which will connect to the computer parallel port used by Mach3. You can find the firmware in download section(iLabProto.pde)
3.Create the Mach3 setting file. We create a new Mach3 setting file named "PCNC770M3_Metric_3DP.xml" which is a copy from original CNC setup. Also, we add a new macros folder "PCNC770M3_Metric_3DP" under "C:_Mach3_macros" with all the extruder related M-code(M101,M103,M104,M108,M113,M200,M201,M5) that will generate from skeinforge.
In each M-code .m1s file , it looks like:
'M104 Macro Setting the temperature
Dim P
Dim Q
Dim R
Dim Temp as integer
Temp = R
Message("Setting Temp to " & Temp)
Call SendSerial ("T" & Temp & chr(13))
This allows Mach3 send serial command and talk to Extruder

4.Setup Mach3 serial and parallel connection to extruder controller board.

The idea to have both serial and parallel connection is because we assume there will be some latency of serial command in Mach3. So, we use the serial to set target temperature(M104) and motor speed(M108 because this command does not require very precise timing. Then, we use the parallel port to control the feeder to start/stop(M101/M103) as this command needs to run very fast.
In the serial connection, we need to remove the green pin(RTS#) because when Mach3 try to send a serial command, it will also sent a reset signal which cause extruder MCU to reset and lost all current temp/motor setting. In this way, we can even use a serial terminal to check/set other status when Mach3 is running but not sending any serial command.
Here, we hack the coolant pump signal(M8/M9) to replace our Motor start/stop command(M101/M103). We will replace all M101/M103 words to M8/M9 in the g-code later.
5.Generate the g-code from ReplicatorG, as a normal 3D printing procedure. We choose "Cupcake Basic" as our machine driver.
6.Run perl script to create Mach3 usable code.
Even we had implemented all the M-code in Mach3, the g-code still not able to run under Mach3 and requires some adjustment.

First, Mach3 doesn't use "S" word in M code because it conflicts with spindle speed code. So, we need to replace all "S" word to "R" word. For example "M108 S220" becomes "M108 R220".
Second, skeinforge will generate G1 code with "X Y Z F" in each single line. This will totally mess-up Mach3's movement because CNC mill requires some acceleration and deceleration. The solution is remove all redundant feed rate commands and let Mach3 has enough time to accelerate/decelerate. For example:
Original skeinforge g-code:
G1 X-24.09 Y-12.52 Z0.52 F780.0
G1 X24.1 Y-12.52 Z0.52 F780.0
G1 X24.1 Y12.52 Z0.52 F780.0
G1 X-24.19 Y-5.27 Z1.16 F173.333
G1 X-17.28 Y-12.18 Z1.16 F173.333
G1 X-20.78 Y-10.37 Z2.02 F693.333
G1 X-20.78 Y-8.64 Z2.02 F693.333
G1 X10.41 Y-8.64 Z2.02 F693.333
After clean up
G1 X-24.09 Y-12.52 Z0.52 F780.0
G1 X24.1 Y-12.52 Z0.52
G1 X24.1 Y12.52 Z0.52
G1 X-24.19 Y-5.27 Z1.16 F173.333
G1 X-17.28 Y-12.18 Z1.16
G1 X-20.78 Y-10.37 Z2.02 F693.333
G1 X-20.78 Y-8.64 Z2.02
G1 X10.41 Y-8.64 Z2.02
Third, replace all M101/M103 motor start/stop commands to M8/M9 as we use coolant pump signal to control the feeder. Notice that before you turn on the motor, you must use "M108 Rxxx" to set motor speed. If you do not set speed first, M8/M9 will not work because motor speed still zero.
7. Now everything is ready to run , all you need to do is hit start button in Mach3 and watch your CNC transform itself to a 3D printer.