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

Hi, thanks again for your help. This is slowly but surely taking form. Now my question is, how quickly (but still safely) can I send G Code movement updates to the UM3? If I wanted to do something like draw a complex curve by drawing lots of little connected lines while at the same time varying temperature, is that doable? Or are drawing and temperature changing commands blocking? And is there a way to get feedback from the controller as to what it's current state is?

 

If it's possible, it would be great to chat to one of the UM team about this! I think it might ultimately be pretty useful to you, too.

Share this post


Link to post
Share on other sites
35 minutes ago, helical said:

Hi, thanks again for your help. This is slowly but surely taking form. Now my question is, how quickly (but still safely) can I send G Code movement updates to the UM3? If I wanted to do something like draw a complex curve by drawing lots of little connected lines while at the same time varying temperature, is that doable? Or are drawing and temperature changing commands blocking? And is there a way to get feedback from the controller as to what it's current state is?

 

If it's possible, it would be great to chat to one of the UM team about this! I think it might ultimately be pretty useful to you, too.


I might have some DBUS commands that you can use when SSHing into the machine lying around somewhere. It's a bit of a hacked together interface and it comes with absolutely 0 warranty, but it should at least enable you to send raw g-code. 

Share this post


Link to post
Share on other sites

Hi, I did see the dbus and sendcode scripts on the UM so I'm able to send G Code via ssh.  What I'm more interested in is the limits of the G Code for the UM3, whether I can send a lot of movement commands over a short time safely, and whether there is a way to get back a response from the printer when it's finished moving.  I can see on the list of G Code commands on the Sailfish website that some are blocking commands, like moving and printing at the same time, so I assume that there are limits to the amount of instructions that can be sent but I'd like to get a clearer idea what those limits look like.  Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

Hmmm... that link didn't work for me, I get a 404.

 

Also, I've been trying to send G Code and the LED change code and movement code and home position codes work but not any temperature related ones.  these seemt o do nothing:

 

M145 T0 ;enable temp
M104 S200 ; set temp to 200C
M109 S200 ; wait for temp to get to 200
M106 ; set fan speed to full
 
I'm a bit unsure about the syntax for the UM3, it sounds like there's more to it than just G Code from the other posts on the forums? Is that verbose header text from the GCode files required too?  Perhaps someone has an example of manually choosing a print head, setting the temperature, and extruding a line that they can share?  Or is this not possible via the "sendgcode" command?
 
 

Share this post


Link to post
Share on other sites
On 4/27/2018 at 4:42 PM, helical said:
M145 T0 ;enable temp
M104 S200 ; set temp to 200C

this works fine as long as it's directly after eachother, for instance if you paste:

sendgcode M145 T0

sendgcode M104 S200

into the (cmd) shell

After a millisecond it is turned back off. Since the temp is 0 and the target is 0... I think this was done to avoid the hotend error uppo removal of the hotend as much as possible.

Share this post


Link to post
Share on other sites
5 hours ago, robinmdh said:

this works fine as long as it's directly after eachother, for instance if you paste:

sendgcode M145 T0

sendgcode M104 S200

into the (cmd) shell

After a millisecond it is turned back off. Since the temp is 0 and the target is 0... I think this was done to avoid the hotend error uppo removal of the hotend as much as possible.

 

Hi robinmdh,

 

I used the same method but the temperature didn't change at all.  I'm not sure what you mean by "after a millisecond it is turned back off?"

 

I had the LCD showing the current nozzle temperature at the time, could that have something to do with it? Otherwise, how would I know what the current temperature is after executing a command?

Share this post


Link to post
Share on other sites
53 minutes ago, gr5 said:

cut and paste both in simultaneously.

indeed, including enter, I've tested this and it works but you can also set te temperature property.

 

in the debug shell you get by loggin in as ultimaker:
 

select printer printer/head/0/slot/0
set pre_tune_target_temperature 200

 

and since you asked to see the temperature you can also either enter the

list

command or the

get current_temperature

command to see the temperature instead of looking at the screen.

 

the same properties exist for the bed and both hotends, type select <tab><tab> to get an idea of how to set the properties of those sub-systems

 

 

Edited by robinmdh
  • Like 1

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

Announcements

  • Our picks

    • Architect Design Contest | Vehicles.
      We're open for entries! - Design and submit your 3D designs of architectural entourage - vehicles - for a chance to win a large filament pack. Presenting an idea, an architectural design or something as big as an urban project isn't easy. A scaled model can really help to get your idea across.
        • Like
      • 24 replies
    • What The DfAM?
      I'm Steve Cox, an experienced engineer familiar with 3D printing. I wanted to share some DfAM guidelines with this community to help and make stronger parts.
      I'm also an Autodesk Certified Instructor for Fusion 360, so many of the images in ...
        • Thanks
        • Like
      • 23 replies
×

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!