As part of my school project, I have stl files and I need to print them one by one in 3d printer. How do i send it to the printer? is there a function that does that?
Thank you!
Sending commands to a 3d printer is a very large subject. In short, what has to be done is:
An .stl
file is a collection of polygons. A 3D printer cannot process those. Most 3D printers receive movement commands. These commands are called G code
. Converting stl
files to g codes
is called slicing. There are softwares which do that. For example, the open source slic3r. You can try the console-slic3r
to see how it works and use it within your Java code.
After you have a G code file, you have to send them to the printers. Most 3D printers can communicate with your computer using serial communication. You have to connect to the right port, then start sending the G code line by line. Every time the printer finishes performing a command, it sends back an 'ok' response (It's ok
for Marlin based printers, open a serial monitor and start experimenting yourself to see how your printer behaves). Every time you receive an ok
, you send the next command, until you are out of them.
So basically what you have to do (in steps)
.stl
file to .gcode
file..gcode
file that slic3r has generated.ok
, and send the next line.gcode
lines.If you're new to this subject, I would download the Arduino IDE, open the serial monitor, and start sending some G codes to the printer.
Some examples of G codes
For example, the movement command is G0
or G1
, and it has 6 parameters - X, Y, Z, E and F
(e - extruder, f - speed). Try: (remember to send a newline after that)
G1 X50 Y20 Z10 F5000
And the printer is supposed to move to that coordinate. More information about G code commands can be found here (G code RepRap wiki)