;Change list: ;Toggle extrusion while keeping smooth movement ;Modify to se x0 and xf to arbitrary functions of step or another parameter ; Hello World G21 (mm) G90 (Absolute distance mode) G55 (Machine Plane Coordinates) G64 (Turn off exact stop check) M5 (Stop the spindle if it's left on) ; Variables for controlling the model ; Movement speed #<_speed> = 1100 (450)(300) #<_mss> = 1 (1.28) (Margin Speed Scalar: the return speed on the margin) #<_ccws> = 0.0006 ;extrude: extruder motor counter clockwise from top (0.005 to 0.007) #<_cws> = 0.005 (extruder back up, used before inter-layer pauses) #<_corners> = 0 (1 extrude on corners, 0 no extrude on corners) #<_margin> = 8 #<_lo> = 2 ; loop offset, used to prevent errors from turn-arounds at row ends #<_pause> = .0001 (wait time, used at corners) ;work dimensions #<_l> = 36 (mm length) #<_width> = 36 (mm width) #<_delta> = .75 (mm inter-row&column spacing) #<_layerH> = .08 (mm layer height) ;coordinates #<_z0> = 0 (Initial Height of Needle Tip) (5) #<_zz> = #<_z0> #<_x0> = 0 (initial x) #<_xx> = #<_x0> (x) #<_y0> = 0 (initial y) #<_yy> = #<_y0> (y) ;counters #<_zstep> = 0 #<_step> = 0 ;counter maximums #<_layers> = 40 #<_ystepf> = FIX[#<_l>/#<_delta>](_____-[#<_l> MOD #<_delta>]/#<_delta>]) #<_xstepf> = FIX[#<_width>/#<_delta>]([_____-[#<_width> MOD #<_delta>]/#<_delta>]) ;#<_yy> = [#<_yy> + #<_l> + 20] ;position purge routine (y) #<_xx> = [#<_xx> - #<_width>+7] ;position purge routine (x) G0 X[#<_xx>] Y[#<_yy>] Z10 ;position purge routine M3 S0.005 ;literal purge o100 while [#<_step> LE 0] ;'timer' for purge ;#<_yy> = [#<_yy> + #<_delta>] (shows iterations for debugging) #<_xx> = [#<_xx> + 0.25*#<_width>*[2*[#<_step> MOD 2]-1]] ;remind linuxcnc how to dance G1 X[#<_xx>] F#<_speed> ;travel (the real time filler) #<_step>=[#<_step> + 1] ;linuxcnc doesn't like infinity... o100 endwhile M4 S0.05 ;back up extruder to relieve excess pressure o101 while [#<_step> LE 0] ;'timer' for purge ;#<_yy> = [#<_yy> + #<_delta>] (shows iterations for debugging) #<_xx> = [#<_xx> + 0.25*#<_width>*[2*[#<_step> MOD 2]-1]] ;remind linuxcnc how to dance G1 X[#<_xx>] F#<_speed> ;travel (the real time filler) #<_step>=[#<_step> + 1] ;linuxcnc doesn't like infinity... o101 endwhile M3 S#<_ccws> ;slow down the extruder and allow the pressure to equilibrate o105 while [#<_step> LE 35] ;G1 X[#<_xx> - #<_margin>*[2*[#<_step> MOD 2]-1]] F#<_speed> ;margin code (equilibration) ;G0 Y[#<_yy>] F#<_speed> ;margin code (equilibration) ;G1 X[#<_xx>] F#<_speed> ;margin code (equilibration) ;#<_yy> = [#<_yy> + #<_delta>] (shows iterations for debugging) #<_xx> = [#<_xx> + 0.5*#<_width>*[2*[#<_step> MOD 2]-1]] G1 X[#<_xx>] F#<_speed> #<_step>=[#<_step> + 1] o105 endwhile #<_xx> = #<_x0> ;reset variables assumed to have previously stated initial values #<_yy> = #<_y0> ;reset variables assumed to have previously stated initial values #<_step> = 0 ;reset variables assumed to have previously stated initial values M5 G1 X[#<_xx>] Y[#<_yy>] Z[#<_zz>] F#<_speed> M3 S#<_ccws> o110 while [#<_zstep> LE FIX[[#<_layers> - 1]/2]] (4) ;G1 Y[#<_yy> + #<_margin>+5] F#<_speed> ;G1 X[#<_x0> - #<_margin>-5] F#<_speed> ;G1 Y[#<_y0>] F#<_speed> #<_xx> = [#<_l> + #<_margin>*0.5] #<_yy> = [#<_y0> + [[0.5*#<_delta>]*[#<_zstep> MOD 2]]] ; causes layers to stager o115 while[#<_step> LE [[#<_ystepf>/2]-1]] #<_step> = [#<_step> + 1] o120 if [#<_corners> EQ 0] (M5) (Causes stop in spite of G64 will need something else.) o120 endif ;G4 P#<_pause> G1 X[[#<_xx> - #<_width> - [#<_margin>]]] F#<_speed> #<_yy> = [#<_yy>+[0.5*#<_l>]] G4 P[#<_pause>] ;margin G0 Y[#<_yy>] X[[#<_xx> - #<_width> - [#<_margin>]*1.5]] F[#<_speed> * #<_mss>] G4 P#<_pause> G1 X[#<_xx> ] F#<_speed> #<_yy> = [#<_yy>-[[0.5*#<_l>]-#<_delta>]] G4 P#<_pause> ;margin G0 Y[#<_yy>] X[#<_xx> + [#<_margin>/2]] F[#<_speed>*#<_mss>] G4 P#<_pause> o115 endwhile #<_zz> = [#<_zz>+#<_layerH>] G0 Z[#<_zz>] ;#<_step> = 0 #<_xx> = #<_x0> #<_xx> = [#<_x0> + [[0.5*#<_delta>]*[#<_zstep> MOD 2]]] ; causes layers to stager #<_yy> = [#<_y0> - #<_margin>] ;These three lines may turn out to be important ;G1 X[#<_x0> - #<_margin>-5] Y[#<_yy> + #<_margin>+5] F#<_speed> ;G1 X[#<_x0> - #<_margin>-5] Y[#<_yy> + #<_margin>+5] F#<_speed> ;G1 Y[#<_y0>] F#<_speed> #<_step> = 0 o125 while[#<_step> LE [[#<_xstepf>/2]-1]] #<_step> = [#<_step> + 1] o130 if [#<_corners> EQ 0] (M5) (Causes stop in spite of G64) o130 endif ;G4 P#<_pause> G1 Y[[#<_yy> + #<_l> +[#<_margin>*1.5]]] F#<_speed> #<_xx> = [#<_xx>+[0.5*#<_width>]] G4 P[#<_pause>/2] ;margin G0 X[#<_xx>] Y[[#<_yy> + #<_l> + [2*#<_margin>]]] F[#<_speed>*#<_mss>] ;G4 P#<_pause> G1 Y[#<_yy> + [#<_margin>/2]] F#<_speed> #<_xx> = [#<_xx>-[[0.5*#<_width>]-#<_delta>]] G4 P#<_pause> ;margin G0 X[#<_xx>] Y[#<_yy>] F[#<_speed>*#<_mss>] o125 endwhile #<_zz> = [#<_zz>+#<_layerH>] G0 Z[#<_zz>] #<_step> = 0 (z++) #<_zstep> = [#<_zstep> + 1] o110 endwhile G0 X-20 Y-20 Z 20 M5 M30