Skip to main content

Send GCode to 3D Printer from Processing

I've written a minimal example Processing sketch of how to read an ASCII GCode file and send the commands to a 3D printer.  The SerialGCodeSender_c class handles all Serial port transactions, reading from an ASCII GCode file, and handles resend requests.

This has been developed against Marlin 1.1.0-RC4 - 24 3D printer firmware available here:
Which is installed on an arduino mega 2560 ramps1.4 system running a serial interface at 115200 baud.

It has been written so that the transmission process is handled by a Processing thread, which means it happens outside the synchronisation of the Processing draw() loop.  This means that you can do some other jobs in the draw() loop and main window.

One thing to note is that the openPort() routine is checking for a specific string to be received from the 3D printer.  This should be the last string your printer transmits after it has boot up.

Other firmwares will probably require some modification.

The source code is available on GitHub.

Popular posts from this blog

DIY Planar Magnetic drivers, part 1

I've been putting together some planar magnetic loud speaker drivers.  There is a wealth of information available at, particularly in this thread.   Inner Fidelity have a nice write up on planar magnetic drivers.  Euwemax documents his DIY planar magnetic drivers for headphones, and he uses etching as his principle method.  I thought I'd attempt to build some using enamelled wire and embroidery hoops.  This post documents my progress so far.  I've made working prototypes, but at the moment the sound is clipping.

Arduino, Smooth RC Servo Motor Control

When using the arduino Servo.h library, you normally use myServo.write(), but you can use myServo.writeMicroseconds().  This lets you write out the controlling squarewave period in microseconds.  The rc servo standard is typically 1000us <-> 2000us, with 1500us as neutral position.  This means that you have a resolution of ~2000 individual steps, rather than the 180 (degree) steps the normal write() would provide - and therefore, the potential for significantly smoother servo motor movements. 

Check out:

Here is the test code I have used to good effect so far, I have been using servo motors with an extended range of uSeconds.  Currently using one pot to set the target position, and the second pot to change the ramping/smoothing fraction.  Ramping/smoothing is done with a technique called easing (see here) which means continually adding a fraction-of-the-difference between target and current position.  See below, very simple…

DS1307 woes, I2C freezes and locks arduino

I've come across a problem with the DS1307 real time clock module and I thought I'd share my work around solution.