code wiki / _hdl_build / nx_metal_gcode.nx

nx_metal_gcode.nx source

↩ module page · 57 lines · 3448 B

1// nx_metal_gcode.nx -- LIB: the METAL (WAAM = Wire Arc Additive Manufacturing) G-code emitter -- 3D-printing 2// workstream R3, completing the material ladder filament -> concrete -> METAL. Deposits steel as weld beads: 3// each layer turns the arc ON (M3 S<amps> + wire feed), traces the perimeter, turns the arc OFF (M5), then 4// DWELLS (G4 P<ms>) for inter-layer cooling -- the WAAM-critical step that prevents heat accumulation/warping. 5// Reads the steel profile from print:mat:steel_waam (thin layers ~1mm). CARDINAL 26 (never-brick): motion + 6// arc-control + wire-feed only (G21/G90/G28/G92/G0/G1/M3/M5/G4/M84) -- NO firmware/EEPROM writes. HONEST SAFETY: 7// arc welding is high-power + hot; a real-hardware run requires operator safety interlocks (future, gated) -- 8// this rung EMITS the G-code file only. Integer mm math. license_tier: ORIGINAL 9import "nx_print_material.nx" 10import "nx_food_science.nx" 11import "nx_seg_store.nx" 12import "nx_syscalls.nx" 13 14func mg_move(out: *u8, off: i64, x: i64, y: i64, e: i64) -> i64 { 15 var o: i64 = off 16 o = as_append(out, o, "G1 X" as *u8); o = fd_apnum(out, o, x) 17 o = as_append(out, o, " Y" as *u8); o = fd_apnum(out, o, y) 18 o = as_append(out, o, " E" as *u8); o = fd_apnum(out, o, e) 19 o = as_append(out, o, " F300\n" as *u8) 20 return o 21} 22 23// emit WAAM G-code for a w x d x h steel wall using the steel_waam profile. Returns byte length. 24func mg_emit(prefix: *u8, w: i64, d: i64, h: i64, out: *u8) -> i64 { 25 var layer_mm: i64 = pm_field_int(prefix, "steel_waam" as *u8, 4) / 1000 // 1mm 26 let bead_mm: i64 = pm_field_int(prefix, "steel_waam" as *u8, 3) / 1000 // 1.2 -> 1mm (int) 27 if layer_mm <= 0 { layer_mm = 1 } 28 29 var o: i64 = 0 30 o = as_append(out, o, "; Nishi WAAM metal G-code -- steel wall (wire-arc bead deposition)\n" as *u8) 31 o = as_append(out, o, "; NEVER-BRICK (Cardinal 26): motion + arc-control + wire-feed only; no firmware/EEPROM writes\n" as *u8) 32 o = as_append(out, o, "; SAFETY: arc welding is high-power + hot -- real-hardware run requires operator interlocks (future, gated)\n" as *u8) 33 o = as_append(out, o, "; material=steel layer=" as *u8); o = fd_apnum(out, o, layer_mm); o = as_append(out, o, "mm\n" as *u8) 34 o = as_append(out, o, "G21\nG90\nG28\nG92 E0\n" as *u8) 35 36 let nlayers: i64 = h / layer_mm 37 var e: i64 = 0 38 var li: i64 = 0 39 while li < nlayers { 40 let z: i64 = (li + 1) * layer_mm 41 o = as_append(out, o, ";LAYER:" as *u8); o = fd_apnum(out, o, li); out[o] = 10 as u8; o = o + 1 42 o = as_append(out, o, "G1 Z" as *u8); o = fd_apnum(out, o, z); o = as_append(out, o, " F200\n" as *u8) 43 o = as_append(out, o, "G0 X0 Y0\n" as *u8) 44 o = as_append(out, o, "M3 S150\n" as *u8) // arc ON + wire feed (150 A) 45 e = e + w; o = mg_move(out, o, w, 0, e) 46 e = e + d; o = mg_move(out, o, w, d, e) 47 e = e + w; o = mg_move(out, o, 0, d, e) 48 e = e + d; o = mg_move(out, o, 0, 0, e) 49 o = as_append(out, o, "M5\n" as *u8) // arc OFF 50 o = as_append(out, o, "G4 P2000\n" as *u8) // inter-layer cooling dwell (WAAM-critical) 51 li = li + 1 52 } 53 o = as_append(out, o, "; end\nG1 Z" as *u8); o = fd_apnum(out, o, h + 20); out[o] = 10 as u8; o = o + 1 54 o = as_append(out, o, "M5\nM84\n" as *u8) // arc off (safety), disable steppers 55 out[o] = 0 as u8 56 return o 57}