Macro Program skipping around?

Ask the MakerGear community for assistance...
Post Reply
User avatar
Mike Hunter
Posts: 48
Joined: Thu Oct 09, 2014 10:26 pm
Location: Western Massachusetts
Contact:

Macro Program skipping around?

Post by Mike Hunter » Mon Feb 23, 2015 4:56 pm

Hi,
I've written a G-Code program for one of the Macro buttons (in the S3D control panel) whose purpose is to warm the motors up before printing in the AM, or after a long wait. Unfortunately, I've had an issue which baffles me and I was hoping one of the members here could shed some light on the issue.

I've attached a Zip with 2 versions of the Macro, the first one, as it was written (in S3D) and the second, which the machine runs. The only difference is the Z command marked with asterisks in the lower program. The Z50 moves run right after the Z10 move, even though the program has it running at the end. This is the quandary.

I've been writing G-Code programs for CNC machines for many years and never has a program not done what was written, even if that program was wrong. That's one of the constants in G-Code programming, the machine doesn't have a choice as to the order of commands, it runs what it's told to run, except in this case.

It's not a huge deal as the warm-up program runs and does what I intended. But before I expand on the program, it would be nice to know why this glitch is happening and whether any other "issues" will pop up.

Thanks

Mike H.
Macro files.zip
Current Macro File
(278 Bytes) Downloaded 314 times
Continually learning and discovering.

User avatar
insta
Posts: 2007
Joined: Tue Sep 16, 2014 3:59 am

Re: Macro Program skipping around?

Post by insta » Mon Feb 23, 2015 6:41 pm

Huh, warming up the motors is something I'd never heard of before now.

And, I wonder if Marlin is being too smart for its own good. Marlin does "look-ahead" and path combining of moves to keep speeds up, and I wonder if its' just ignoring some moves since it doesn't see any extrusion?

You can probably accomplish the same thing by just homing and dwelling for 10 minutes. The motors will stay energised and reach operating temperature without having to move around.
Custom 3D printing for you or your business -- quote [at] pingring.org

User avatar
Mike Hunter
Posts: 48
Joined: Thu Oct 09, 2014 10:26 pm
Location: Western Massachusetts
Contact:

Re: Macro Program skipping around?

Post by Mike Hunter » Mon Feb 23, 2015 7:15 pm

insta wrote:Huh, warming up the motors is something I'd never heard of before now.

And, I wonder if Marlin is being too smart for its own good. Marlin does "look-ahead" and path combining of moves to keep speeds up, and I wonder if its' just ignoring some moves since it doesn't see any extrusion?

You can probably accomplish the same thing by just homing and dwelling for 10 minutes. The motors will stay energised and reach operating temperature without having to move around.
Warming (a machine) up is something I did as a machinist to maintain accuracy and minimize wear. It's probably overkill in this situation, but habits are hard to break. I'm familiar with "look-ahead" and would be able to leave it at that, but the M2 doesn't skip steps, in a sense, it moves the Z50 from the end to the middle of the program. Once it finishes the Z50 move, the program continues as written through to the end. I'll see if I can get a better understanding of the Marlin firmware. This could be one of those instances where an explanation is not easily found.

THANKS

Mike H.
Continually learning and discovering.

User avatar
ednisley
Posts: 1188
Joined: Fri Apr 11, 2014 5:34 pm
Location: Halfway up the Hudson
Contact:

Re: Macro Program skipping around?

Post by ednisley » Mon Feb 23, 2015 10:02 pm

Mike Hunter wrote:the second, which the machine runs
Does S3D preprocess the macro text before sending it to the printer or are you deducing the code from watching the motion? It may be doing exactly what S3D told to do, which isn't quite what you told it to do... [grin]

But, with that in mind, Reprap G-Code doesn't behave like "normal" G-Code: many of the things you take for granted just aren't so. As nearly as I can tell, there are no documents other than the (ever changing) source code, so it's programming as an experimental science.

Here's a version of the startup G-Code I use with Slic3r:

Code: Select all

;-- Slic3r Start G-Code for M2 starts --
;  Ed Nisley KE4NZU - 15 Nov 2013
; Z-min switch at platform, must move nozzle to X=130 to clear
M140 S[first_layer_bed_temperature]	; start bed heating
G90				; absolute coordinates
G21				; millimeters
M83				; relative extrusion distance
G92 Z0			; set Z to zero, wherever it might be now
G1 Z10 F1000	; move platform downward to clear nozzle; may crash at bottom
G28 Y0			; home Y to be sure of clearing probe point
G92 Y-127 		; set origin so 0 = center of plate
G28 X0			; home X
G92 X-95		; set origin so 0 = center of plate
G1 X130 Y0 F30000	; move off platform to right side, center Y
G28 Z0			; home Z with switch near center of platform
G92 Z-4.55		; set origin to measured z offset
G0 Y-127 Z2.0 F10000	; set up for priming, zig around corner
G0 X0					;  center X
M109 S[first_layer_temperature]	; set extruder temperature and wait
M190 S[first_layer_bed_temperature]	; wait for bed to finish heating
G1 Z0.0 F500	; plug extruder on plate 
G1 E25 F300		; prime to get pressure, generate blob
G1 Z5 F2000		; rise above blob
G1 X15 Y-125 F30000	; jerk away from blob, move over surface
G1 Z0.0 F1000	; dab nozzle to attach outer snot to platform
G4 P1			; pause to attach
G1 X35 F500		; slowly smear snot to clear nozzle
G1 Z1.0 F2000	; clear bed for travel
;-- Slic3r Start G-Code ends --
I don't see any big differences between the motions in your G-Code and mine, bearing in mind that I put the XYZ origin dead on the glass in the middle of the platform.

But...

Now that I look at it, that G4 P2 should be G4 P1000 or G4 S1. This code descends from the start.gcode I wrote for the Thing-O-Matic running SJFW and, in that G-Code dialect, the time units were seconds.

You had to manually set the origin value with G92 after every G28, because the firmware literally didn't know where it was. Nowadays, that's handled differently, but the code works as-is.

I specify the speed for (almost) every G0 and G1 instruction, having discovered that G0 behaves exactly the same as G1 and doesn't move "as fast as possible" to the target location.

For what it's worth, I manually enable the platform and extruder heaters, load the G-Code, then start the program running when both temperatures have stabilized, which takes maybe five minutes. The motors won't get warm for another ten minutes or so, but I think you're right: the motor temperature won't make any difference in the accuracy of the gooey plastic we're squirting on the platform...

User avatar
Mike Hunter
Posts: 48
Joined: Thu Oct 09, 2014 10:26 pm
Location: Western Massachusetts
Contact:

Re: Macro Program skipping around?

Post by Mike Hunter » Tue Feb 24, 2015 9:22 pm

Hi ednisley,

The second G-code (in the attached file) is the motion of the machine after hitting the Macro button in the Machine control panel. With the exception of the Z50 move being run "out of turn", everything else runs as programmed. It's not the type of issue that will keep me up at night, if you know what I mean :), just like to solve these little mysteries if only for my own piece of mind.

Mike H.
Continually learning and discovering.

User avatar
ednisley
Posts: 1188
Joined: Fri Apr 11, 2014 5:34 pm
Location: Halfway up the Hudson
Contact:

Re: Macro Program skipping around?

Post by ednisley » Tue Feb 24, 2015 9:54 pm

Mike Hunter wrote:With the exception of the Z50 move being run "out of turn"
Oh, this is exactly the kind of thing that keeps you up at night. Just give it a little time. [sigh]

Can you save the G-Code output from the Macro button as a file, perhaps as though sending it to an SD card? If so, then you can peek into the file and see what the actual G-Code looks like.

User avatar
Mike Hunter
Posts: 48
Joined: Thu Oct 09, 2014 10:26 pm
Location: Western Massachusetts
Contact:

Re: Macro Program skipping around?

Post by Mike Hunter » Wed Feb 25, 2015 10:52 pm

I'll give it a try. THANKS ed

Mike H.
Continually learning and discovering.

Post Reply