Documentation gcode after editor java
Purpose of the program
The XXl printer needs two gcode files; one for the master and one for the slave.
The purpose of the program is to take a gcode file from an object as input, and create 2 new gcode files; one for the master and one for the slave printer. It does so by splitting the main object in 4 smaller objects: A, B, C and D. Then it writes A and B to the master file and C and D to the slave file. The program also creates a small overlap between sublayers, so that the sublayers are connected and the final print looks like one object again.
How the program works
The program reads through the input file line by line. And depending on the line it reads it does something else. There are 3 main cases that the program handles:
description
Gcode example
It reads a line starting with G1
G1 X82.648 Y117.955 E6.4378
It reads a new layer comment
; layer 18, Z = 5.250
It reads something else
; a comment
G92 E0
M109 S220 T0
It reads a line starting with G1
First the program checks if there are x and y values in the line. Because there are cases like the example below, where nothing needs to be done.
G1 E-1.0000 F1800 (= movement, retraction, speed)
G1 Z0.150 F1002 (= movement, z-height, speed)
Then it takes the current x, y and e values. And it compares them with the previously read x, y and e values. For each sublayer (A,B,C,D) it checks if there needs to be made a cut.
We want to print the green area. Different cases are:
1: both points are inside the cut lines. So the coordinates don’t need to be changed.
2: both points are outside the cut lines. So the coordinates can be thrown away. This is outside of the sublayer we want to make.
3: one point is to the left of a cutting line, and the other to the right. Here there needs to be made a cut! This means a new point will be inserted on the cutting line.
4: one point is to the left of the left cut line and one point is to the right of the right cut line. Here two new points need to be made. Because even though both points are outside of the printing line, the line in between still needs to be printed.
Making a cut line
The program cuts an object with x xoordinates. We know the current and previous x and y coordinates and we know the x coordinate of the cutting point. For the cut we want to know the y coordinate that belongs to the x xoordinate of the cut line. For this we use the property of a slope.
(y2 – y1) / (x2 – x1) = (y? – y1) / (xcut – x1) ( = slope )
Rewriting this gives:
Y? = (((y2 – y1) * (xcut – x1)) / (x2 – x1)) + y1
The program writes down the new coordinates.
It reads a new layer comment
For each layer the program cuts it in 4 sublayers A, B, C and D. When a new layer is read, we write down all the stored information of the previous layer. We also write down the toolchanges and layerchanges. (that are little pieces gcode that the XXL printer needs)
The master and slave file are written like this:
Master gcode
Slave gcode
Layer 1:
Write sublayer A
Write toolchange right
Write sublayer B
Write layer change
Layer 2:
Write sublayer B
Write toolchange left
Write sublayer A
Write layer change
Layer 1:
Write sublayer C
Write toolchange
Write sublayer D
Write layer change
Layer 2:
Write sublayer D
Write toolchange
Write sublayer C
Write layer change