Jump to content
Ultimaker Community of 3D Printing Experts
helical

Ways to send gcode direct to printer or control during printing?

Recommended Posts

Hi, I've got a few Ultimakers (2's and 3's) and would like to directly control them from my computer.  That means moving the print head, extruding, controlling temperature, and all functions that can be described in gcode (and more?)  What I would like to do, ideally, is to bypass Cura completely and use a remote control protocol like OSC, or serial, or even JSON to have direct printing control.  But, as you can imagine, these would be time-sensitive commands so I'd require something reliable and quick.  Right now, I'm just looking for options.  I figured direct serial control would work but now I see that UM3's are running a full Linux stack so it's all a black box to me.  As far as I can tell, this hasn't been done before on Ultimakers, although similar things exist for Makerbots, etc.

 

And I'm well aware that there are serious risks of this, it's for a research project and I have experience with hardware and software development.  That said, I'd be an idiot if I said that I know what all of them are before starting, so any warnings and suggestions would be appreciated!

 

Thanks!

Share this post


Link to post
Share on other sites

Well the Um2 is simpler.  You can control it through USB (it's not officially supported but it works pretty well).  It has Marlin firmware which is on hundreds of different types of printers (most printers out there).  There is software called "octoprint" that allows you to control printers through USB or you can simply send gcodes with any software you want to write.

 

The um3 indeed has a linux stack.  You can log in with ssh username and password is root/ultimaker.  You have to put the printer into developer mode first (it's a menu option on the printer).

 

Everything is in python so the source code is all visible and commented on the printer itself.  Well some of it is in json files (javascript).

 

Once in you can go to the /usr/share/griffin folder and do this:

python3 command_util.py

 

Then do "sendgcode" followed by the gcode you want to send.  This might be too slow (not real time enough for you) so you might want to create some kind of web service.  If you do *please* share. :)

 

If you prefer - here is a video of someone doing just what I describe.  There are more details on this forum but you can ask more questions on this topic if you want.  For example the M104 and M109 commands might not work without enabling the hot end.  That gcode is um3 specific and is somewhere on this forum.  But here it is: M145 T0 -- enables ability to heat that core.

 

Oh and be very very careful when editing json files.  If you have a parse error in a json file (missing comma for example), the boot process halts *before* it starts the ssh daemon so you effectively brick the machine but I here are 2 methods for unbricking if that happens - you might want to buy these cables ahead of time if you will be editing json files:

 

 


 

Share this post


Link to post
Share on other sites

Oh and EVERYTHING can be done in gcode.  So there is no "and more".  I mean you can home, turn power on and off, control steps/mm, basically you can do much more from gcode than you can do from menus.  On um3 you can control color of lights from gcode.  On um2 you can change the display message form gcode.  For um2 the best gcode reference is here (just look at Marlin gcodes):

http://reprap.org/wiki/G-code

Share this post


Link to post
Share on other sites

You might want to look at Repetier-Host. RH lets you control - bed temp.; extruder(s) temp.; print speed; filament flow rate and flow %; fans speed; all during the print. You can also send individual lines of g-code to the printer (whether this works during a print I do not know). I have used it to control my prints on my 3ntr for the past 4 years. It has a server version too which allows you to control multiple printers and provides remote access/control. Cura and other slicers can be invoked.

It also provides velocity painting to change the look and feel of the object surface but I have not tried that yet, although the pics look good!

https://www.repetier.com/

Edited by yellowshark

Share this post


Link to post
Share on other sites

poke around.  The code is not on github.  I think.  Not sure.  But it's in /usr/share/griffin I believe.  And subfolders.  Maybe tar that up into a tar zip file and scp it back to your main computer?

 

Or, you can just go to this page, download it and unzip it: http://software.ultimaker.com/jedi/releases/

 

Share this post


Link to post
Share on other sites

Hi again, thanks for all the help.  I've dug through the files and figured out that the UM3 uses a python web app that uses FLASK to manage script/web/printer control. From that, it looks like adding services (FLASK hooks?) to the current web app is the best idea rather than simply sending gcode directly (although one web service could do that pretty easily by sending JSON ).  

 

Now my question is, what's the best way to develop and test my own services?  Obviously, it's hard to do this directly on the UM3 because I'd be worried about bricking it.  Is there a suggested development system for this purpose? I noticed that there is a fake printer ('mock' in the griffin folder) that could be for testing?

Share this post


Link to post
Share on other sites

I recommend you order the cable in my above link - it's not expensive - I think around 10 euros or $10.  Then you don't have to be afraid of bricking the printer - the cable is a serial cable that connects to any computer and you have a terminal window directly into the linux machine and you can see it booting and when it's done booting you can log into root (password ultimaker) and do whatever you want.  The "bricking" that can happen with bad json files still allows the computer to boot - it just blocks the ssh daemon and never tries to connect to the arduino computer.

 

However maybe @Daid can answer your question about flask hooks and the "mock" printer in the griffin folder.  Please publish whatever you come up with on github and link to it here in this subject as many other people can use this kind of 3rd party improvement to the printer.

Share this post


Link to post
Share on other sites

The mock printer hasn't been updated, and thus isn't current, and thus useless.

 

I highly recommend the cable so you can always debug/recover from a brick. Even if the risk is fairly low. The recovery by micro SD card also works to fix a brick.

 

Next to that, you can also run the whole system on a virtual machine, there is actually a software setting somewhere (I forgot where) that allows you to use the "marlin simulator" instead of talking to most of the main hardware. But setting that up is quite a bit of work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!