Custom Gcode with Bltouch assistance

Please Login to Comment

I just added a bltouch to my setup and it's working just fine but I'd like to heat my extruder after the G29 routine to limit the amount of filament leakage. So ideally I'd like to G28, G29, return to x0y0 heat up my extruder, run my priming line across the front and begin my print. Anyone done this?

This is my curent working script:
G28 ; home all axes
G29 ; auto billinear leveling
G1 X0.0 Y0.0 Z0.3 ; return to home and raise slightly
G1 X60.0 E9 F1000.0 ; START PURGE LINE
G1 X100.0 E12.5 F1000.0 ; FINISH PURGE LINE

with the bltouch I only home x and y at the start - it does not know where z is...

G28 X0 Y0
G1 X0 Y0 Z0.3

..... then purge

if you home z without it knowing where 0 is... it won't work.

Can anyone help me figure out why the firmware isn't actually using the mesh values created by G29? It's going through everything perfectly... then not actually using the values. I have no idea what's going on.

I'm really glad I brought this up, I believe I used a little bit from all of the ideas on here. One thing that is probably unneeded is the G4's I added in but I had a problem initially where on the second print after my first successful print the extruder would crash into the bed. I went through and commented out some Marlin 1.1.2 features I thought were causing problems. One was auto turning off the extruder heating during probing... I believe it was kicking back on around the same time I was returning to xy (0,0) and I creating some kind of error. It would either run up the Z without stopping or crash into the bed without stopping. I went ahead and disabled that feature and the park feature and went ahead with the preheating extruder as recommended by a couple of users here. Perhaps once I replace the springs and hard mount my bed I may consider M420 S1 as the code and do G29's as needed.

From "print" to the actual print beginning it takes 4 minutes and 5 seconds. I'm using eSun Pla+ so my temps are 217C hot end and 60C bed. 9 point bilenear auto level sequence with Bltouch probe on a 200mmx200mm bed.

// Gcode

M140 S[bed0_temperature] ; set bed temp
M104 S160; begin preheating extruder temperature
M190 S[bed0_temperature] ; wait for bed temp

G28 ; home all axes
G29 ; auto billinear leveling

G4 P200; wait 0.2 seconds

G1 X0.0 Y0.0 F2000 ; return to front left corner
G1 Z20.0; Raise to 10 to wait

G4 P200; wait 0.2 seconds

M109 S[extruder0_temperature] T0 ; wait for extruder to heat before creating purge line

G1 Z0.3 F300 ; lower Z to prep for purge line
G1 X60.0 E9 F800.0 ; START PURGE LINE
G1 X100.0 E12.5 F800.0 ; FINISH PURGE LINE

// end Gcode

Why do you do a G29 every time? Do a G29, save the results and the enable the mesh with M420 S1. I do an 11x15 mesh so G29 every print would be pretty time consuming.

Why do you do a G29 every time? Do a G29, save the results

saving a mesh with AUTO_BED_LEVELING_BILINEAR — whut ?!??

G29 ; auto billinear leveling</blockquote

Yes, at least on the current versions of Marlin firmware. Do an M500 after the G29 completes and the mesh will be saved to EEPROM. It is automatically reloaded on startup so you use M420 S1 to enable it. M420 S0 will disable it.

which bed leveling method you currently use?

I'm using bilinear leveling with an 11x15 grid.

what was your option for 11 x 15 point grid and your bed size?

I wasn't aware that you could store the probed bilinear results to the eeprom, just found that out here http://marlinfw.org/docs/configuration/configuration.html#bed-leveling-style

I'm not sure I understand your question. I have a bed that is 300mm x 400mm with a glass build plate. There are some high and low spots of the glass so I use a fairly fine grid to follow the surface as closely as possible.

are you saying during any print if it goes: G28, G29, print.
The G29 is essentially irrelevant unless M500 is used in the start script? I'm not talking about g29 then doing another print without it. I actually prefer a fresh check each time.

You only do the G29 when you think the leveling may be off. After completing the G29 do M500 to save the results. In your startup script you do a G28 to home the printer then you do M420 S1 to enable the leveling mesh that you previously saved.

So are you saying that because it saves time, or because g29 straight to print doesn't actually use the mesh?

Well, I tried your method among in different combinations and nothing seems to work. My mesh isn't working. I'm going to try a 5x5 mesh and see if that makes any difference.

It's purely a time saving issue. It also only works with Marlin versions released in the last 4 months or so. If G29 doesn't take a lot of time on your machine then there's really no reason to worry about it. Because of the number of probes I do, G29 takes about 20 minutes on my printer.

yeah, right now I'm struggling getting g29 to do anything useful. i can tell the mesh is applying changes but it seems to be mirroring the changes that need to take place making the current manual bed level worse. I just ran an 8x8 and will try activating with m420 s1...

what marlin version are you using which g29 works? I'm struggling with the v1.1.2 that was released last week.

I'm running the 1.1.x bug fix version that was current on May 10. I've tried other, more recent, versions but have had issues that have caused me to drop back. This one seems pretty solid for my printer.

my bed is still on the stock adjustment knobs and springs it came with, and my G29 only takes about a minute or so once it starts.

Well, I am sharing my start g-code here too, this is taken from my slic3r setting and would be the same for my s3d as well

M140 S[first_layer_bed_temperature]
M104 S120
G28 X Y
M190 S[first_layer_bed_temperature]
M104 S[first_layer_temperature]
G28 ; home all axes
G92 E0
G1 X130.0 Y190.0 Z0.3 F2000 ; Go to Prime Position
M109 S[first_layer_temperature] ; wait for nozzle
G1 X40.0 E20.0 F1000.0 ; prime
G1 Y180 F2000 ; Go to print area
G92 E0

I set the hotend to 120'c first so that I don't have to wait too long for the hotend to reach target temp. I do this to shave waiting time since my heatbed can take too long to heat up, 10 minutes+ depending on the surrounding temperature.

Having to do g28 then g29 first is good to minimise stringing, but if the time to heat up takes too long, then the firmware usually turns off the stepper motor after some time, you might have coordination issues later. If this doesn't bother you, just don't move any of the axis right after g29

Thank you for the response. I believe I'm going to save this for slic3r since I use that as well but for the S3D side I'm going to try this and kmcclain's M109 setup with the bracketed [first_layer_temp] because I'm thinking that's what allows me to copy paste it to any setup. My bed at 90c (hottest i've had to go for petg) I believe only takes about 3-4 minutes at most (not a very large bed) and when the hotend kicks in it's usually within 1-2 minutes up to temp so I'm not worried about preheating it necessarily... although I may try it because it may make the leveling that much more accurate.

I print with ABS, upon reaching 90 to 100'c, that's the point where things got slow since my heatbed's resistance are quite high, I think around 2-3 ohm, it's a mk2a dual power type heatbed

if you have a typical 12v caged PS you should definitely try and juice your ps to max with the voltage fine-tune adjustment. Mine went from 12v to 13.8v at max adj and it really does help give that little extra oomph

I'm unsure if I should go overvoltage. I had a history of burning 2-3 megas and my setup is ramps1.4. I don't know how the first one got burnt, when that happened, I reduced the volt to 11.5-11.8.

the 2nd and 3rd(I think 3rd does exist), were due to tevo's sd card circuitry. It is a non-standard circuit. Found that out long after I burnt the 2nd and 3rd mega when I decided to use on the same machine again, then the sd card went to overheating when I tried to pull it out

I was almost tempted to do this but I figured the best thing to do was use a seperate mosfet board and second 30amp cheap psu. I am already using a seperate mosfet board with heatsink and it looks like amazon has 30amp psus for $20.

I actually do have the external mosfet, power expander or so what it is called. Supposed to be able to make things faster. I still need to do more proper test on it whether or not it is faster

Yeah, my concern was more about melting my ramps board. I have the Maker Select V2.1 and they're notorious for melted connectors etc, which I actually experienced before. I was doing the ramps 1.4 upgrade and the external mosfet was an obvious critical upgrade because of my previous current and overheating problems.

I last time when I first go into ramps 1.4 on my first 3d printer, I literally melted the bed input connector of the ramps 1.4.

It is because I used wrong type of wire, it is the solid core type wire which is not advisable. I guess what I have to do is to test with the external mosfet and do proper test.

My guess with the overheating is due to low resistance somewhere in the electronics

When I inspected the melzei board on my maker select the first thing I noticed was bad soldering, the connectors themselves were too small ,and I doubt they were rated for the current.

Using Marlin ? Yes, it's possible...

;Sliced at: {day} {date} {time}
;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
;Print time: {print_time}
;Filament used: {filament_amount}m {filament_weight}g
;Filament cost: {filament_cost}
M140 S45; set preheat bed temp
M106 S255; turn on fan to normalize temperature of inductive sensor and prevent oozing of hot filament on bed
M900 K0; disable LINEAR_ADV in prep to retract and purge nozzle
G28 X Y; home Y and Y axes
G1 X0 Y0 F15000; stretch fillament out so it can’t affect Z homing
G28 Z; home Z axis
G1 Y0 F15000; move to edge of bed
G1 Z50 F600; move up and away from bed to prevent inductive sensor heating and allow nozzle cleaning if necessary
M190 S45; wait for preheat bed temp
M140 S[first_layer_bed_temperature]; set first layer bed temp
M109 S190; wait for preheat extruder temp
G91; Switch to relative coordinates
G1 E-3 F1; once preheat extruder temp reached, retract filament slowly a bit to help prevent oozing
G4; wait for move completion
M104 S[first_layer_temperature]; set final extruder temp
M190 S[first_layer_bed_temperature]; wait for final bed temp
M109 S[first_layer_temperature]; wait for final extruder temp
M116; wait for both temps to be reached
G90; Switch to absolute coordinates
G29 S1; `G29` executes auto bed levelling if ABL is enabled in FW; `G29 S1` = turn on bed leveling if MBL is enabled in FW
G1 X0 Y0 F15000.0; go to edge of printing area
;G1 Z-2; move to minimum print level set in FW (will gouge bed if not set correctly in FW !)
;G91; Switch to relative coordinates
G1 Z0.4; give plenty of room for filament to purge under nozzle
G91; Switch to relative coordinates
G1 E3.3 F15000.0; resume start extruder position plus a bit extra to fill directly under the nozzle
G1 X60.0 E13.0  F1000.0; intro line
G1 X40.0 E6 F1000.0; intro line smaller
G1 X2.0 E-0.2 F15000; move off of filament and retract a touch
G1 X1.0 Z-0.1 F15000; move back to print level and move out a bit more
G90; Switch to absolute coordinates
G1 X152 F15000; stretch it out to clean off filament
M107; turn off fan
M900 K80; re-enable LINEAR_ADV in prep for printing (PLA=K80,  PETG=K120)
M117 Printing…

So I was able to get this to work by turning off the check box for "wait for temperature controller to stabilize before beginning" for the hot end in the advanced tabs. This is the code I used:

G28 ; home all axes
G29 ; auto billinear leveling
G1 X0.0 Y0.0 Z0.3 ; return to home and raise slightly

M109 S217 T0; Stabalize extruder temp

G1 X60.0 E9 F1000.0 ; START PURGE LINE
G1 X100.0 E12.5 F1000.0 ; FINISH PURGE LINE

Now the question is, is there a way to use M109 with the syntax such as:
M109 S$ T# instead so I can base it off the selected temps in the tabs so I can just copy paste this script for my other filaments etc? It's fine this way but it would be much simpler to not have to worry about going in and changing temps twice each time I want to make slight changes.

You could use: M109 S[extruder0_temperature] T0

I use it and it works well.


Thank you for the response, I believe is what I might have been looking for. I'll post results in a couple hours once I get everything ready for another series of trial runs.

I guess I could do a G4 instead of a M109?

my post was flagged for moderation, but my startup code (if they allow it through) works around this pretty well using a 175C preheat temp as it greatly limits the oozing range but doesn't really require tweaking for every filament (although I'm sure for some high-temp polycarbonates and such it may not be ideal)

I think I might try something like this but at a lower temp. I think someone else suggested like 120C to at least cut a minute or so off. I'll post my results. I didn't see your gcode come through but I think I have an idea of what you mean from another reply on the page.

Yeah, my start gcode is flagged for moderation (perhaps because it's too long ?) It should come through once the mods wake up :)

PLA doesn't really start flowing until after 175 in my setup, but yeah, you get the idea. The point is to wait for the HB preheat, set final HB temp + set and wait for the HE preheat (i also retract slowly 3mm when i hit that point, since I'm going to just purge it back later, but this is dependant on your specific setup), wait for HB final temp, wait for HE final, then get crackin'