Monday, February 8, 2010

Making EMC do the printer dance

After a few days of dry spell, I got back on the 3D printer train today.

I really like the simplicity and low cost of EMC, parallel port, A3982 combo for driving machines.  Unfortunately, the existing open source 3D printing projects don't really fit well into that frame work.  There has been some RepRap/EMC stuff done here, but the it seems kinda kludgy to me.

For example: to turn the extruder head on or off, EMC has to parse a custom M code using an external python module, this module then uses another python module to send a serial command to a RepRap extruder controller, the extruder controller microcontroller then parses this serial request and commands the extruder motor off.

On top of all this, the RepRap extruder controller does not automatically do constant current drive for stepper motors.  This limits your choice of motors and hamstrings their performance.

Since the latest RepRap extruder is designed around a stepper motor, and EMC is natively set up to drive stepper motors, it makes sense to me to have EMC drive the extruder motor as just another machine axis.

At first it looked like this wasn't going to be an easy task.  Both the RepRap host software, and Skeinforge want to generate code like "extruder on, move X,Y,Z a bunch, extruder off" rather than "move X,Y,Z and extruder axis 1mm left, move move X,Y,Z and extruder axis 2mm up".  Fortunately though, I stumbled across something called the "5D firmware" for the RepRap.  This experimental firmware for the RepRap motherboard wants G-code very similar to what I want for EMC.  Better still, Skeinforge version 10, released yesterday!!!, added support for generating 5D G-code.

Now that the stage is set, here is how you generate EMC readable (and almost printable) G-code files with Skeinforge.

  1. Launch Skeinforge
  2. Under the Craft menu, click Dimension...
  3. Check the Activate Dimension box, and the Absolute Extrusion Distance option
  4. Click Save
  5. Load and process your STL file with Skeinforge as normal
  6. Open of the generated G-code file with an editor (or make a script to do the next few steps)
  7. Remove all of the M10X (M101, M103, ...) lines from the file
  8. The file will contain lots of lines like: "G1 X4.8 Y17.21 Z0.72 F186.624 E2.43", change all of the letter "E"s to "A"s.  Find and replace will probably work.
  9. Save the modified G-code file
  10. Lastly, you'll need to modify your EMC machine configuration so that the A axis, probably called AXIS_3, MAX_LIMIT travel parameter is a really big number like 99999.
Once you do all of that, if you fire up a 4+ Axis machine in EMC and load your G-code, you should see something like this:


Original STL:

 Time to get the extruder finished and test some of this out!


  1. Hello :-)

    I saw that you added your site on RepRap EMCRepStrap wiki page :-) Thanks!

    I will follow your work.

    As for heater temperature, you don't even need to control it on gcode. I print my objects with the same temperature... so, an external control circuit could simple mantain the extruder heater at the same temperature.

    I am using the heated bead like that, and external controler :-)

  2. David, I am very interested on your idea!

    5D way should be great control better the extruder. I were talking on IRC channel about this.

    Ideally I would like to have my system as NopHead, where he have almost perfect prints because he is turn his extruder stepper motor in reverse when he stops extruding. On that way there is no losen springs or excess of plastic filament extruder.

    But he controls his machine using Python, not gcode directly... read here:

  3. Cool,

    Thanks for the link- I'll check it out.

  4. David, very cool stuff.

    I am actually very close to doing the same thing with EMC. I've been planning to run 4 steppers directly from the PC, using a Gecko G540. I went through the configuration last week, and haven't seen any reason (yet) why it won't work. I've just got to figure out the heater part, and I'm considering using EMC for that as well, or an Arduino based approach.

    We should compare notes

  5. Hi, have you tried to print anything yet? thanks

  6. Hi David
    You can place a file named replace.csv in the alternate Dir unter Skeinforge xxx.
    Write in this File:
    E tab A
    M101 tab ;M101

    by this way Exxxx will change Axxx
    and no more M101 codes
    This file will run directly in EMS
    I am just setting a and A Axis for Extuder
    Best regards Dieter

  7. Any chance you can provide the G code you came up with?
    Also wondering if you can help me get EMC2 to work with the MK4c, I have the Perusa ready to go and powered everything up, but need to get past setting up the MK4c. I have no problems with Mach3, but based on what I have read and heard using EMC is the way to go for mills and this application.
    Thanks in advance for your help.

    1. This comment has been removed by the author.

  8. EMC have been important since their each phase of development and now such functioning is just another yet interesting example of its applications.
    Emi Shielding Solutions

  9. This is great. Which kind of printer can print the Metal business cards?



About Me

My photo
I'm a graduate student in Information Ecology at the MIT Media Lab interested in the creation of low cost machines that enable personal digital fabrication.