Notifications
Clear all

Help with Custom G-Code  

  RSS
JDaweeda
(@jdaweeda)
Member
Help with Custom G-Code

Hi all,

I'm newer to printing, less than a year, and still learning things as I go. I am using Nathan's bulb STL and running into the following problem which is why I am coming to you guys. This is printed using spiral vase mode and this mode does not allow for more than one object to be printed unless done sequentially. If done sequentially then collisions are a concern and these are to tall to print sequentially. 

Nathan used a method with custom G code where he used the print head to push the bulb off the plate and then start printing another, rinse and repeat 50 times. 

I would like to do the same. He does have G-Code available that does this but I was not able to adapt it to work with my Prusa Mini. 

Any help trying to get this to print X amount of times unattended would be greatly appreciated!

Posted : 15/11/2023 2:29 pm
_KaszpiR_
(@_kaszpir_)
Prominent Member
RE:

Looks like he did something liek this:
0. add extra comments in PrusaSlicer > Printer Settings > Custom G-code for each part so it is easier to find block start and end, this will be needed later
1. get model, slice it, get output .gcode file
2. by finding block start and end for each secrion split that gcode file into a separate files:
- start.gcode (like heat up bed, initial purge)
- next_print.gcode - print in vase mode from layer 1 to layer  191
- end.gcode
3. then he created a new gcode snippet (let say glue.gcode) that would run certain command, and some of them are moving print head to certain position to the back of the print bed and move it back to the place the new model will be printed (causing print head to hit the printed model and make it detach from bed, effectively kicking it out and preparing place for a new one)
see line 23107 , code below it adds small retraction , retract and raise Z, wipe out, move back,  down the bed - those cause print head to move back.
next comment causes new print to start
snippet ends in line 23121

Notice that given gcodes he provided quite well describe that in the comments (text after semicolon to the end of the line) so it is quite easy to grasp what was done.

4. create shell script to concatenate scripts together something like

cat start.gcode > sum.gcode
for i in $(seq 1 50); do
cat next_print.gcode >> sum.gcode
cat glue.gcode >> sum.gcode
done
cat end.gcode >> sum.gcode

5. send sum.gcode to the printer

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 15/11/2023 7:48 pm
JDaweeda
(@jdaweeda)
Member
Topic starter answered:
RE: Help with Custom G-Code

_KaszpiR_ your instructions (0, 1, 2, 3) make sense to me. For number 3 how do I determine the g-code for getting the head to move behind the print, lower, then move forward to the end of the plate? I mean I know that has something to do with G90/91 but not sure how to determine the coordinates. 

For number 4 I am not sure why it is separate scripts that need to be concatenated together. Is this just to automate plugging in the same code X amount of times?

Thank you for your help thus far!

Posted : 15/11/2023 10:52 pm
JDaweeda
(@jdaweeda)
Member
Topic starter answered:
RE:

So I have been able to get this far. This code prints one bulb and pushes it off the print bed. 

However, when it goes to print the second bulb it isn't properly adhering to the bed. If someone could take a look at the g-code and see if there is a glaring issue I would appreciate it. 

If you search for "M900 K0.2 ; Filament gcode LA 1.5" it is a good marker near the starting point of each object print.

GCode

This post was modified 1 year ago by JDaweeda
Posted : 16/11/2023 3:57 am
_KaszpiR_
(@_kaszpir_)
Prominent Member
RE: Help with Custom G-Code

> For number 4 I am not sure why it is separate scripts that need to be concatenated together. Is this just to automate plugging in the same code X amount of times?
Yes, exackly.

Here is the example snippet extracted from line 23107 and 23122

;TIME_ELAPSED:895.681848
G1 F4200 E780.38222
M140 S0
M204 S4000
M107
G91 ;Relative positionning
G1 E-2 F2700 ;Retract a bit
G1 E-2 Z0.2 F1600 ;Retract and raise Z
G1 X5 Y5 F3000 ;Wipe out
G1 Z10 ;Raise Z more
G90 ;Absolute positionning
G1 X100 Y100 ;Move Back
G1 Z1 ;Down to bed
M82 ;absolute extrusion mode
M104 S0
;NEXT PRINT

so you can see that some lines are just comments (like first and last line), the ohter are commands and some have comments at the end of the line.
Looks like the snippet.gcode consists of just those lines:

G90 ;Absolute positionning
G1 X100 Y100 ;Move Back
G1 Z1 ;Down to bed

so this instructs the printer to switch to absolute positioning mode and then move print head to X,Y = 100,100 (in milimeters), at the height that currently is set, and then move to Z = 1mm above the bed:


That green line - from the top of the model:
- first it goes slightly to the top and right (not sure which one that is frankly speaking...)
- "G1 Z10 ;Raise Z more" - go straight up
- "G1 X100 Y100 ;Move Back" - go to X100 Y100, wich means it will be horizontal green line from the above the model to the left in the middle of the print bed
- "G1 Z1 ;Down to bed" - move print heat down to the Z1 - so it will move down to the 1 mm just above the bed, which is a green vertical line
- ";NEXT PRINT" - indicates next print moves, in the picture above it is a red line from green line to the underneath the model.

You can visualize gcode in Prusa Slicer after a slicing, or File > G-code Preview ... in the menu, then use bars on the bottom and right to see how it goes, and use different options in the legend in top left corner.

You can also get better info about gocde by opening it in editor, I recommend VSCode which is multiplatform and free https://code.visualstudio.com/
In addition I recommend those two addons:
- https://marketplace.visualstudio.com/items?itemName=appliedengdesign.vscode-gcode-syntax
- https://marketplace.visualstudio.com/items?itemName=Novy.vsc-gcode

this way example code looks like this:

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 16/11/2023 7:18 am
Share: