Make GCode (starting script) Commands wait for G28 and G29 to finish before continuing?

Discussion of ANY 3D printing topic you desire!
Post Reply
DotScott1
Reactions:
Posts: 5
Joined: August 21st, 2018, 11:10 am
3D Printer(s): CR-10 S4

Make GCode (starting script) Commands wait for G28 and G29 to finish before continuing?

Post by DotScott1 » August 21st, 2018, 11:26 am

---------------------------------------------------------------------------------------------
BEFORE READING BELOW, KNOW THESE FEW THINGS:

1. I know that this is different from the starting script that TH3D recommends - this is because I need it to activate specific tasks to prevent sensor interference.

2. I know that there are other ways to prevent signal interference (shielding and grounding cables, separating cables, etc). I'm not looking for alternatives really, just looking to get this script working correctly.

3. My ONLY goal here is to get the starting script to do exactly what I want it to do, regardless of my end goal on the mechanical side of things. I'd like to know what I'm doing wrong in the script.

4. Everything else works just fine. Auto-homes just fine, initiates G29 and creates mesh just fine, everything except for the below issue works fine.

Thanks in advance! Now read:
---------------------------------------------------------------------------------------------

Hey everyone,

I wasn't sure where to post GCode/scripting questions so if you know where, let me know.

I currently have a custom GCode starting script that controls my external heated bed and lighting through a raspberry pi running octoprint and connected to a relay board (to control the power to the LED's and Keenovo heated bed). I also have an EZABL installed so I'm using G29 command to probe the surface.

Anyway, what I'm trying to do is turn OFF the LED's and heated bed during the homing and probing processes (G28 and G29 respectively). What's actually happening is that it turns off the bed and LED's for just a split second and then turns them back on AND THEN does the G28 and G29 commands... it's like G28 and G29 are happening in a split second and it's not waiting for G28 and G29 to finish before turning the heated bed and LED's back on.

Here's my starting script:

NOTES:
ENC O1 S0 = Heated Bed off.
ENC O1 S1 = Heated Bed on
ENC O2 S0 = LEDs off.
ENC O2 S1 = LEDs on
_______________________________________________________________________________________

G28 ; Home all axes - this centersn the EZABL sensor in the middle of the bed.
ENC O1 S1 ; turn heated bed on
ENC O2 S1 ; Turn LEDs on
G4 S420 ; wait 7 minutes (this is when the top of the bed reaches the desired temperature)
M75 ; Start Print Timer and Engage Fil Sensor
M84 E ; Disable E Motor for probe accuracy on direct drive systems
ENC O1 S0 ; turn heated bed off
ENC O2 S0 ; Turn LEDs off
G28 ; home all axes
G28 Z ; home Z to get more accurate Z position
G29 ; EZABL mesh generation
ENC O1 S1 ; turn heated bed on --------------------------- THIS IS THE PART THAT'S NOT WORKING - it does not wait for G28, 29 to finish.
ENC O2 S1 ; Turn LEDs on --------------------------- THIS IS THE PART THAT'S NOT WORKING - it does not wait for G28, 29 to finish.
M500 ; create config-override
M106 S[fan_speed_pwm] ; Turn on cooling fan
M104 S[extruder0_temperature] T0 ; start heating nozzle
M109 S[extruder0_temperature] T0 ; wait for nozzle to reach desired temp.
M117 Purge extruder
G92 E0 ; reset extruder
G1 Z15.0 F200 ; move z up little
G1 X0.1 Y20 Z0.31 F5000.0 ; move to start-line position
G1 X0.1 Y100.0 Z0.31 F1000.0 E15 ; draw 1st line
G1 X0.4 Y100.0 Z0.31 F5000.0 ; move to side a little
G1 X0.4 Y20 Z0.31 F1000.0 E30 ; draw 2nd line
G92 E0 ; reset extruder
G1 Z2 F200 ; move z up little

M117 Printing.....
_______________________________________________________________________________________

Again, it's just not waiting for the autohome and bed leveling (probing) to finish before it turns the heated bed and LED's back on with ENC O1 S1 and ENC O2 S1 (respectively).

I'm sure I could put a timer after the G28 and G29 but... isn't there a way to tell it not to continue UNTIL G28 and G29 are finished?

SETUP INFO:

CR-10 S4 (running latest firmware from TH3D and on a CR-10S board with filament sensor and dual-z motors)
ENCLOSURE PLUGIN used to control relays.
Last edited by DotScott1 on August 22nd, 2018, 1:33 pm, edited 4 times in total.

GrueMaster
Reactions:
Posts: 319
Joined: March 15th, 2017, 8:46 pm
Location: Oregon
3D Printer(s): Hictop 3DP-17, Hictop CR-10S

Re: Make GCode (starting script) Commands wait for G28 and G29 to finish before continuing?

Post by GrueMaster » August 21st, 2018, 8:46 pm

I assume you have the EZABL provided firmware loaded on your printer? Otherwise, G29 will likely be disabled. Does the autolevel actually work? It should move the head and test Z 0 in several locations (matrix grid).

Also, you should heat the bed prior to running autolevel. The headed bed can warp a little, throwing your settings off.

DotScott1
Reactions:
Posts: 5
Joined: August 21st, 2018, 11:10 am
3D Printer(s): CR-10 S4

Re: Make GCode (starting script) Commands wait for G28 and G29 to finish before continuing?

Post by DotScott1 » August 22nd, 2018, 10:56 am

@GrueMaster Thank you for your reply. Yes the EZABL firmware is loaded and everything works EXCEPT for turning the bed and LED's off during the full G29 process. And yes, if you look at my above code, you'll see that it heats the bed for 7 minutes prior to initiating the G29 process.

It's strange because sometimes it will work, and keep the bed and LED's off during the entire G28, G28-z and G29 processes but then other times, it turns the heated bed and LED's back on midway through the G28 process (in my updated starting script below). NOTE: If you look to the right of each line of code, it tells you what it is doing. I also indicate which parts are not working.

ENC O1 S1 ; turn heated bed on
ENC O2 S1 ; Turn LEDs on
G4 P420000 ; WAIT 7 MINUTES FOR BED TO FULLY HEAT - This also allows the sensor to heat up.
M75 ; Start Print Timer and Engage Fil Sensor
M84 E ; Disable E Motor for probe accuracy on direct drive systems
ENC O1 S0 ; TURN HEATED BED OFF ---------------- THIS SEEMS TO ONLY TURN THE BED OFF FOR A FEW SECONDS
ENC O2 S0 ; TURN LED'S OFF ---------------- THIS SEEMS TO ONLY TURN THE LED'S OFF FOR A FEW SECONDS
G28 ; home all axes
G28 Z ; home Z to get more accurate Z position
G29 ; EZABL mesh generation
M500 ; create config-override
M106 S[fan_speed_pwm] ; fan speed
ENC O1 S1 ; TURN HEATED BED BACK ON - THIS IS INITIATING BEFORE THE G28, G28 Z AND G29 PROCESSES BELOW ARE FINISHED
ENC O2 S1 ; TURN LED'S BACK ON - THIS IS INITIATING BEFORE THE G28, G28 Z AND G29 PROCESSES BELOW ARE FINISHED
M104 S[extruder0_temperature] T0 ; bring nozzle to desired temp
M109 S[extruder0_temperature] T0 ; wait for nozzle temp to normalize
M117 Purge extruder
G92 E0 ; reset extruder
G1 Z15.0 F200 ; move z up little
G1 X0.1 Y20 Z0.31 F5000.0 ; move to start-line position
G1 X0.1 Y100.0 Z0.31 F1000.0 E15 ; draw 1st line
G1 X0.4 Y100.0 Z0.31 F5000.0 ; move to side a little
G1 X0.4 Y20 Z0.31 F1000.0 E30 ; draw 2nd line
G92 E0 ; reset extruder
G1 Z2 F200 ; move z up little

M117 Printing.....

Again, everything is working EXCEPT the fact that it's turning the heated bed and LED's before the G28, G28 Z and G29 processes have finished. My goal here is to have the heated bed and LED's turned off during the G28 and G29 processes so that they won't generate interference for the sensor (I know there are other ways around this, this is the way I've chosen. Just need to get the starting script to work properly).

User avatar
LePaul
Reactions:
Posts: 3123
Joined: February 7th, 2016, 10:26 pm
Location: Bangor, Maine USA
3D Printer(s): Ultimaker 2+, FT-5, CR-10, CR-10S, Tevo Tornado
Contact:

Re: Make GCode (starting script) Commands wait for G28 and G29 to finish before continuing?

Post by LePaul » August 22nd, 2018, 11:18 am

I have the Unified Firmware and EZABL on my CR-10S...I think I only pasted in a small section as the instructors advised You have a whole lot more :)

DotScott1
Reactions:
Posts: 5
Joined: August 21st, 2018, 11:10 am
3D Printer(s): CR-10 S4

Re: Make GCode (starting script) Commands wait for G28 and G29 to finish before continuing?

Post by DotScott1 » August 22nd, 2018, 1:22 pm

@LePaul Heh, yes. A lot of people modify the suggested starting and ending script to make it do what they want. With mine, for example, I need it to activate these extra commands in order to prevent signal interference.

DotScott1
Reactions:
Posts: 5
Joined: August 21st, 2018, 11:10 am
3D Printer(s): CR-10 S4

Re: Make GCode (starting script) Commands wait for G28 and G29 to finish before continuing?

Post by DotScott1 » August 23rd, 2018, 10:23 am

UPDATE:

Restarting the printer before I print seems to fix the problem, so I actually don't think it's 100% the script's fault (though I'm sure it could be made to reset the printer on it's own). Still trying different things to narrow down exactly what it is.

DotScott1
Reactions:
Posts: 5
Joined: August 21st, 2018, 11:10 am
3D Printer(s): CR-10 S4

Re: Make GCode (starting script) Commands wait for G28 and G29 to finish before continuing?

Post by DotScott1 » August 24th, 2018, 4:10 pm

UPDATE 2:

It seems that homing the printer manually via the control box of the CR-10 S4 is what is somehow causing the issue. If I restart the printer, it works fine. If I home every axis via a G28 command through the terminal in Octoprint, everything works fine. It's just after I home everything via the control box attached to the printer that this glitch happens. Very strange, not sure how to fix that other than just restarting the printer every time after a manual homing.

User avatar
LePaul
Reactions:
Posts: 3123
Joined: February 7th, 2016, 10:26 pm
Location: Bangor, Maine USA
3D Printer(s): Ultimaker 2+, FT-5, CR-10, CR-10S, Tevo Tornado
Contact:

Re: Make GCode (starting script) Commands wait for G28 and G29 to finish before continuing?

Post by LePaul » August 29th, 2018, 9:45 am

Have you mentioned this anomaly to Tim/TH3D?

Post Reply

Return to “General 3D Printing Conversation”

Who is online

Users browsing this forum: No registered users and 3 guests