Loading

3D Printing on CNC using Mach3

by kai, published

3D Printing on CNC using Mach3 by kai Dec 20, 2010

Featured Thing!

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.

This work is created by Chin-Kai Chang, Rand Voorhies and Lior Elazary at University of Southern California(USC) iLab. http://ilab.usc.edu

Recent Comments

view all
So this is for a DC-motor with encoder and PWM?

How do I use a Nema-17 stepper motor as the extruder motor and use Arduino to regulate temperature?

I was looking at this: buildlog.net/blog/2011/02/modbus-arduino-mach3-and-brains-oh-my/

Do I just add an axis in Mach-3 config and use ModBus to connect Arduino for temp control?

Any help greatly appreciated.
The easiest way to control temperature is using external PID controller. However, it usually can only set manually. If you want to set temp through Mach3, you will need some temp controller that able take TTL serial packet from Mach3. In my case, I just modify the code of extruder controller to do this. 
Hi Kai, i have a question for you. i have a 4 axis mach 3 breakout board and a plastruder MK7 from makerbot with the controller board, how do i connect the extruder controller to the mach 3 board in order to control the temperture before printing. i have also order a heated and a temperature controller how do i connect that to my mach 3 board in order to regulate the temperature before printing. thank you

Liked By

view all

License

GNU - GPL
3D Printing on CNC using Mach3 by kai is licensed under the GNU - GPL license.

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag. Print Thing Tag

Instructions

  1. Printer Head mount: We choose Makerbot Plastruder MK5(http://www.thingiverse.com/thing:3290) as our print head. The mount plate and MK5 model can be found at http://www.thingiverse.com/thing:5221

  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

P=Param1() Q=Param2() R=Param3() 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 gcode-clean.pl 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.

  1. 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.
So this is for a DC-motor with encoder and PWM?

How do I use a Nema-17 stepper motor as the extruder motor and use Arduino to regulate temperature?

I was looking at this: buildlog.net/blog/2011/02/modbus-arduino-mach3-and-brains-oh-my/

Do I just add an axis in Mach-3 config and use ModBus to connect Arduino for temp control?

Any help greatly appreciated.
Hi Kai, i have a question for you. i have a 4 axis mach 3 breakout board and a plastruder MK7 from makerbot with the controller board, how do i connect the extruder controller to the mach 3 board in order to control the temperture before printing. i have also order a heated and a temperature controller how do i connect that to my mach 3 board in order to regulate the temperature before printing. thank you
The easiest way to control temperature is using external PID controller. However, it usually can only set manually. If you want to set temp through Mach3, you will need some temp controller that able take TTL serial packet from Mach3. In my case, I just modify the code of extruder controller to do this. 
Hi, not sure if you are still pursuing this. I'm very interested in trying it. I have a plastruder mk5, makerbot extruder v3.6 with an ATMega328 on it with their v3.1 firmware. I've not been able to install your firmware - do I need to make any modifications to make it work with my setup?
kai - in reply to Rabs
hi, so far i am not work on it yet. I have made other 4 3D printer already. However, I can still willing to help people who what to do this.

My firmware is written on old extruder v2.2. That's probably the reason not working on your v3.6. However, it shouldn't be too bad to modify the code compatible to v3.6 if you know how to write Arduino code.
Great job! I have a PCNC 770, and I've had this in the back of my mind. Thanks for forging the trail!
why u not used stepper motor? why dc motor, can be possible to run stepper motor instead dc motor

i like stepper.. ;)
hi,can u make wires diagarm,,and ready to burn firmwares,, i don't have arduino only isp programmer,

whats the rating of your dc motor?

any video how do you do it all the setting for mach 3 =-X
Hello Kai,

Any new developments on the CNC and plastruder? How do i get the firmware?

Have you updated it to steppstruder yet?

Thanks

Eduardo
kai - in reply to mpm_dpm
Yes, we don't have board either. You will still able to produce g-code from ReplicatorG without a board.
mpm_dpm - in reply to kai
is it possible to show me what can I do to get a Gcode (from a stl model)

I upload a video that shows my replicatorG.

rapidshare.com/files/460525122/1.exe

thanks
replicatorG can open any type of stl (ascii
&
amp; binary) but can not produce g-code of binary type!

my model was binary, that was the problem.

thanks kai very mach.

:-D
Hi Kai. It appears that Mach 3 pauses when it encounters the M8 and M9 macros. This causes blobs of plastic to form. Do you see this behavior?
Yes, I do have this problem and still working on it. One approach is minimize M8/M9 code when change z height. For example, M8 -
&
gt; Move Z up -
&
gt; M9 becomes just Move Z up without stop/start feeder. This will help in some cases, but there still many chance you will need to stop feeder and travel to some where. So, I think the real solution is using 4-axis and stepper motor for the feeder. In this way, everything is controlled by G-code instead of M-code.
Hi Kai, disregard previous question. I have a new question. I notice you have the RS-485 connected. Now that the extruder controller is reprogrammed and you are communicating with it directly why is the RS-485 still connected to the motherboard. I would assume that the motherboard is no longer needed.
And yes, you don't need motherboard.
hi Scott,

RS485 here only provides power to the extruder controller and hot end, no data communication through this cable. The way I program the extruder controller board is through same USB-TTL cable with Arduino software(remember put RTS green pin back for programming).
Kai, thanks very much for providing the details of getting the extruder working with a CNC machine. How did you get the pde file on the extruder?
Hello Kai, I want to try Mach3 on the machine I''m building. I contacted Mach support and they told me it would not work. Are you willing to help?
Why it would not work? I am running it all the time. It seems complicate to make Mach3 as 3D printer because there are not much information out there. That's why I made this tutorial to help people utilize their CNC machine.
kai, I am working in my second home cnc, once I complete it in two more months I would like to also be able to print in 3D. Can you support me with your knowledge to make the conversion?

Thanks in advance for your help
Sure, let me know if you have any problems. Now I am working on stepper motor version of extruder, that's say "5D" version of g-code. It will take me a while to finish it. However, DC gearhead motor version already running pretty smoothly now.
I'm wanting to do something similar. I'd trying to avoide temp control, and simply put a PID or some other device to just keep the temp constant. I'm no programmer, but thought that a nice introduction to plastruders would be accomplished with as little delving into the electronics as possible. A plastruder with stepper and driver, and a stand alone temp control that just needs power to function would be an idea addition/mod to an existing CNC machine.
beyond incredible. I have a 15 foot by 6 foot shopbot. Man, could I print some stuff!
Kudos!

I'd love to see more of this great work done with EMC2/Axis (Casainho and two or three ppl did some time ago w/reprap). IMHO, the way to go, and unlike Mach3, it is FOSS.
Top