;Original Code by Dustin Neumann, Modified by Dane Ocampo for 2GBP 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) ;#######################################[ P A R A M E T E R S ]######################################## ; Movement speed #<_speed> = 3100 #<_mss> = 1.25 (1.28) (Margin Speed Scalar: the return speed on the margin) #<_ext_rate> = 0.00002 ;extrusion rate #<_purge_ext_rate> = 1.5 ;purge extrusion rate (gets the stream going before actual print) #<_reverse> = 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) ;originally .0001 ;work dimensions #<_l> = 36 (mm length) #<_width> = 36 (mm width) #<_delta> = .75 (mm inter-row&column spacing) #<_layerH> = .08 (mm half-layer height) ;#######################################[ I N I T I A L I Z E ]######################################## ;coordinates #<_z0> = 3 (mm Initial Height of Needle Tip) #<_zz> = #<_z0> #<_x0> = 0 (initial x) #<_xx> = #<_x0> (x) #<_y0> = 0 (initial y) #<_yy> = #<_y0> (y) ;counters #<_zstep> = 0 #<_step> = 0 ;#<_step> = 20 ;uncomment to skip purge #<_done> = 0 ;counter maximums #<_layers> = 23 #<_ystepf> = FIX[#<_l>/#<_delta>] (FIX operator rounds the argument down to integer) #<_xstepf> = FIX[#<_width>/#<_delta>] ;#######################################[ P U R G E C O D E ]############################################ #<_yy> = [#<_yy> + 20] ;position purge routine (y) #<_xx> = [#<_xx> - #<_width>+14] ;position purge routine (x) G0 X[#<_xx>] Y[#<_yy>+4] Z[#<_zz>] ;position purge routine M3 S[#<_purge_ext_rate>] ;purge extrusion rate (should be faster than normal extrusion rate) o105 while [#<_step> LE 20] ;#<_yy> = [#<_yy> + #<_delta>] (shows iterations for debugging) #<_xx> = [#<_xx> + 0.5*#<_width>*[2*[#<_step> MOD 2]-1]] ;note: [2*[#<_step> MOD 2]-1]] alternates between +/-1 with each step G1 X[#<_xx>] F#<_speed> #<_step>=[#<_step> + 1] o105 endwhile ;reset variables assumed to have previously stated initial values #<_xx> = #<_x0> #<_yy> = #<_y0> #<_step> = 0 M5 ;######################################[ M A T R I X C O D E ]########################################## G1 X[#<_xx>] Y[#<_yy>] Z[#<_zz>] F#<_speed> M3 S[#<_ext_rate>] ; set extrusion rate M68 E0 Q2 ;turn on HV o110 while [#<_zstep> LE FIX[[#<_layers> - 1]/2]] #<_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>] #<_xx> = #<_x0> #<_xx> = [#<_x0> + [[0.5*#<_delta>]*[#<_zstep> MOD 2]]] ; causes layers to stager #<_yy> = [#<_y0> - #<_margin>] #<_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 #<_zstep> = [#<_zstep> + 1] ;============================[ E L E C T R O S P U N L A Y E R ]================================ ; o111 if [#<_zstep> MOD 3 EQ 0] ;electrospin 1 layer for every 3 printed layers ; G1 Z[#<_zz> + 165.1] F2000 ;165.1 mm = 6.5 in ; M68 E1 Q1.5 ;extrude at 1.5 mL/hr ; M68 E0 Q2 ;turn on HV ; G4 P600 ;electrospin for 600s (10 min) ; M68 E0 Q0 ;turn off HVcd linuxcn ; G1 Z[#<_zz>] F2000 ;quick move back to where it was (G0 causes error) ; o111 endif ;================================================================================================ o110 endwhile ;################################[ F I N I S H I N G S E Q U E N C E ]################################### M68 E0 Q0 ; turn off HV ;move out of the way G0 X-25 Y150 Z80 ;back up extruder to relieve excess pressure and prevent drops M4 S0.05 o101 while [#<_done> LE 0] ('timer') G1 X[#<_xx>] F#<_speed> #<_done>=[#<_done> + 1] o101 endwhile M5 ;Stop Spindle M2 ;End Program