• aditya mehrotra.

filament labs updates: making the printer a little smarter with Octoprint [updates]

Octoprint, https://octoprint.org, is a 3D printing software that runs on Linux/Mac/Windows (really tailored for raspberry pi) that allows a computer to connect to your printer and become a WiFi server that you can use to monitor and control your printer remotely. You can start your printer, and according to this post, https://community.octoprint.org/t/how-to-set-z-offset-in-octoprint/14093/13 even set the z-offset remotely! We're going to do all of this on a Jetson Nano for now, but at some point in the future, we'll be able to make a 3D printer that runs on Octoprint that doesn't require all the ridiculous things the Tronxy X5SA does as we'll have set it all up using Octoprint.



Using Octoprint we'll be able to use the printer for other functions - such as pick and place and etc since we can program in custom scripts. I don't know what we'd do with that feature but that feature does exist. Our octoprint setup will use an Nvidia Jetson Nano and a USB Webcam USB-ed to the Tronxy X5SA. We want to probably make a little case for the Jetson if we're putting it in the printer enclosure. The real printer in the future would use a raspberry-pi. What would be super cool is if we somehow found a way to make this printer act both as the printer and the filament extrusion system or the sorter, or something that would be a component of the recycling system. Also since Octoprint is open-source, it's possible in the future we can do more advanced things with Octoprint and ROS as well. It's a pip-installable python package right! So we should be able to use the library to build something cool. COOL now after the first few setup instructions if we go to: http://192.168.1.19:5000 then we actually get the system UI to load!



So we'll actually have to setup the system a little later we're waiting for the print that's currently printing to finish. We also will be unable to get the camera working because it's really built for Raspbian at the moment and some packages are not installing. At the moment we won't have any UI or anything running because we don't want to set that up right now. Just the server because then we can fully control everything from the laptops including slicing and etc. We're just having the jetson run this command on startup. We might just end up doing this with ROS later.


Well would you look at that... https://github.com/ielson/octoROS there's actually already a ROS integration between octoprint and ROS! Omg we can do so many cool things with this, webviz, and other things.


Now let's see if we can't startup the octoprint service based on a startup python command. Okay beautiful that worked and now Octoprint runs in the background we simply took it out of the Virtual Environment. We're now going to take a look at the OctoROS thing so we can actually upgrade the Octoprint UI some day.

See? Now we know how to send messages to the Octoprint system it's basically via JSON. So we're going to look into that at some point.



Just waiting for my brother's 3D printed mini-FRC-robot-model to finish in a few hours and then I think by tomorrow we'll have a fully-functional Octoprint setup. Here's something to consider in the meantime.



Maybe what we really should be trying to do is build a pellet-based 3D printer that can also feed in filament but the reason we want to build a pellet-based one is so that we waste the least amount of energy recycling plastic and you can re-load the printer as the printer is printing you don't need to stop we can use a level sensor or something. Or we need to find a way to use the 3D printers extruder to extrude filament as well as print filament for filament style printing. We really want to try to design an all-in-one machine right because the less number of machines we use the better it is for the environment. But then people can't use the printer without recycling their own plastic they'd have to get pellets.


Maybe the original idea of both a printer and an extruder is better because then more people can use the machines for better. And then we can build multiple extruders for places that want to do recycling over printing.


So we need to figure this all out but in the meantime here's the footer for the Filament Labs Website :)





Now back to Octoprint! Looking here: https://www.thingiverse.com/groups/tronxy/forums/general/topic:34241 it seems that the tronxy requires Arduino Drivers which should already be installed on the Jetson so all we're going to do is plug the USB cable straight into the board and see if we can get anything to work on startup. We'll set all of it up from our laptop.



Beautiful! We have it up and running and it is controlling the printer completely wirelessly. Now what we want to do is figure out a few things. First, can we set the z-offset on our own on startup. Check this out: https://all3dp.com/2/z-offset-3d-printing-how-to-adjust-it/


So now that we know a little bit about GCODE we can figure out how to actually how to set that z-0 and we can track it exactly check this out: https://docs.octoprint.org/en/master/features/gcode_scripts.html


So every time we zero here's what do. We get to the zero point, then we move it up about -2.2mm with this nozzle specifically. So we're going to write that startup script. We're going to try to run the following commands.


G28 X0 Y0 Z0 ; home all the axis first
G1 X165 Y165 F2800; move to the center position
G92 Z0 ; set this as Z0
//need to add a wait in here
G1 Z-2.15 F50; move to z = -2.15mm
G92 Z0 ; set this as Z0

That's the whole script and we'll never have to do the z-offset calibration again unless we change out the nozzle then we may have to. So let's try it in terminal. That didn't work because that's not really the place we usually set the Z offset from, we set it from the center which is like X165 Y165. So let's add that.


Now I want to test if this is actually a correct Z-offset and we can print with this before we run the GCODE completely. And finalize that. I want to start a test print so let's see, and we're going to start a large one but by hand right now. Let's start the mini robot and let the first layer or so go down and that's where we will figure out if the Z-Offset we currently have chosen is the right one. We ran those lines of GCODE and now we started a print so let's see. We will need to make sure the build-plate is level at the beginning of every print though. Right now all the things are just sitting in there - we're going to actually make the jetson and the cabling and all nice and neat in a little bit just not right this second (when everything works :).


So after a test layer I think we want to go like 0.15mm higher on that Z-offset which brings us to like 2mm exactly. So let's raise the offset and change the code:


G28 X0 Y0 Z0 ; home all the axis first
G1 X165 Y165 F2800; move to the center position
G92 Z0 ; set this as Z0
//need to add a wait in here
G1 Z-2 F50; move to z = -2mm
G92 Z0 ; set this as Z0

And then re-try this print. Remember we still need figure out how to make this printer do this at the start of a print. Okay so before I continue I'm actually going to check if this bed is Level. Maybe we also want to increase that offset height by 0.1mm it's looking a little low.


G28 X0 Y0 Z0 ; home all the axis first
G1 X165 Y165 F2800; move to the center position
G92 Z0 ; set this as Z0
//need to add a wait in here
G1 Z-1.9 F50; move to z = -1.9mm
G92 Z0 ; set this as Z0

Okay so the bed is pretty level so we're going to try this again. Doing all of this once will mean never ever having to do it again which would be amazing and fantastic. Imagine Filament Labs printers being embedded with Octoprint on startup that would be amazing because Octoprint has so many functionalities that would make it so good to use. Maybe we'd add a better UI or something but still. It'd be great. We're re-testing the 1.9mm because I really don't know sometimes this thing acts weird and jams its nozzle into the plate. And there it is, 1.9mm is giving us a beautiful print! So now we just need to figure out how to run this GCODE on printer CONNECT.



That's a good looking layer we might drop it down by like 0.05mm but we'll see. Now it's time to stick this in the connect GCODE script. We're going to do that over SSH.



G28 X0 Y0 Z0;
G1 X165 Y165 F2800;
G92 Z0;
G1 Z-1.92 F50;
G92 Z0;


Now let's re-connect to the printer and see if it goes through the sequence above! We added these lines to afterPrinterConnected.gcode!


Okay.... it didn't do that so let's go figure out what we missed :( now we're going to reboot and try it again maybe we need to restart the server before we reconnect.



Nevermind we found where we really should be putting it... in the menu! And let octoprint do everything on its own because why are we SSHing anywhere! Let's see if this works... we pasted out GCODE into "after connection to printer is established."


YESSSS ITT DIDDD THE THINGGGGGGGGGGGGGGGG now we really never have to come play with the Z-OFFSET ever again - the only time we'd have to change it is if we changed the nozzle and now we know it's about 0.28mm away from the build plate (about one layer height). Setting it closer for this printer will cause jams. We can get really precise and go down to like 1.97mm or 1.95 but we won't right now. Okay beautiful now I think we can actually print remotely I haven't tried it but we should. For now let's re-try printing a test piece and see how it goes.


To test that what we're going to do is design and print a case for the Jetson Nano for the printer enclosure because right now things are just hopping about inside there's no organization. If we want to add custom controls to the print setup later here we go: https://plugins.octoprint.org/plugins/customControl/ we can also use https://plugins.octoprint.org/plugins/curalegacy/ to slice directly from the browse but we won't for now. I'm going to upload that filament labs logo and see if we can get that to print remotely.



It's definitely going! Now we see the bed temperature heating and then we can see we're just waiting for the nozzle/tool temperature to actually increase to 220C before the thing actually starts printing.


So the nozzle temperature never actually went up, it started printing, and it also never bothered to set the Z-offset. Also it's interesting to note that the system doesn't actually change the printer's UI to something is printing so we'd have to use the actual OCTOPRINT UI.


Okay so the second time we started the print the target temp of 220 actually did come up. So I don't know what happened the first time but let's go down and actually check on the printer hopefully the GCODE file will be followed properly this time.


So here's something. Every time the print actually starts the target temperature drops to OFF for some reason. I don't know why it does that at all but we should check it out. So the thing is remote print isn't really working right now and I'm not sure how to fix it.


Maybe instead of using Octoprint what we really want to do is edit what comes out of the CURA slicer to include Z-Offset. We can do this in: https://community.ultimaker.com/topic/18559-changing-cura-generated-start-code/



So now the full start-code looks like this and the lines we added are colored-in in RED.


M201 X500.00 Y500.00 Z100.00 E5000.00 ;Setup machine max acceleration
M203 X500.00 Y500.00 Z10.00 E50.00 ;Setup machine max feedrate
M204 P500.00 R1000.00 T500.00 ;Setup Print/Retract/Travel acceleration
M205 X8.00 Y8.00 Z0.40 E5.00 ;Setup Jerk
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate

G28 ;Home
G1 X165 Y165 F2800 ;Move to Z-Zero position
G92 Z0 ;Zero the Z
G1 Z-1.92 F50 ;Generate the Offset
G92 Z0 ;Zero the Z

M420 S1 Z2 ;Enable ABL using saved Mesh and Fade Height

G92 E0 ;Reset Extruder
G1 Z2.0 F3000 ;Move Z Axis up
G1 X10.1 Y20 Z0.28 F5000.0 ;Move to start position
G1 X10.1 Y200.0 Z0.28 F1500.0 E15 ;Draw the first line
G1 X10.4 Y200.0 Z0.28 F5000.0 ;Move to side a little
G1 X10.4 Y20 Z0.28 F1500.0 E30 ;Draw the second line
G92 E0 ;Reset Extruder
G1 Z2.0 F3000 ;Move Z Axis up


That's the start-code for the printer and now each time we start a print the Z-0 procedure happens which means we should never have to touch the Z-offset ever again! We might be able to just get rid of Octoprint for now then. Maybe what we really want is just our own. version of CURA: https://github.com/daid/Cura


All we really need is this: https://github.com/probonopd/WirelessPrinting the wireless printing plugin for CURA right? We don't need Octoprint if this is all we're trying to do. https://www.amazon.com/Organizer-ESP8266-Internet-Development-Compatible/dp/B081PX9YFV/ref=asc_df_B081PX9YFV/?tag=hyprod-20&linkCode=df0&hvadid=416694317409&hvpos=&hvnetw=g&hvrand=18399632616170002851&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9004005&hvtargid=pla-903913932459&psc=1&tag=&ref=&adgrpid=94693386435&hvpone=&hvptwo=&hvadid=416694317409&hvpos=&hvnetw=g&hvrand=18399632616170002851&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9004005&hvtargid=pla-903913932459 we'd need to install these into our 3D printer but no matter that's okay what this does mean is in the future when we actually make a printer there's a better solution than octoprint. We can take a look at boards with built-in wifi at some point too: https://all3dp.com/2/5-fantastic-3d-printer-controller-boards/


Let's try slicing and printing something after having added this new set of GCODE.



Mwwwwwwahahahahahaaaaa no more printer Z-Offset calibration here we come it works! And without octoprint with regular old Cura Slicer. Now what we really should do is simply build our own version of CURA that people can install because that would be so much better than trying to build 1000 different web-based UI interfaces and etc. We're going to let this print because I want to run a FULL test on the printer now that the new slicer is setup. But we'll post an update later.


#updates #omgrobots #yay #yeet

1 view0 comments
© copyright 2019 | aditya mehrotra