code wiki / _hdl_build / nx_paste_gcode.nx
nx_paste_gcode.nx source
↩ module page · 63 lines · 3691 B
1// nx_paste_gcode.nx -- LIB: the PASTE/CONSTRUCTION (concrete) G-code emitter -- 3D-printing workstream R2,
2// growing the material ladder from filament into CONCRETE. Generates printable G-code for a hollow cistern
3// wall (the R-ECO rainwater structure): footprint w x d, height h, printed perimeter-by-perimeter, layer by
4// layer. Construction printing differs from FDM: BIG nozzle + thick layers (read from print:mat:concrete),
5// COLD paste (NO hotend M104/M109), continuous pump extrusion (E grows with path length). CARDINAL 26
6// (never-brick): the vocabulary is movement + extrusion only (G21/G90/G28/G92/G0/G1/M84) -- it CANNOT flash
7// firmware or write EEPROM; output is a .gcode text file. Provenance rides a firmware-ignored comment header.
8// Q14-free integer math throughout (mm units). license_tier: ORIGINAL
9import "nx_print_material.nx"
10import "nx_food_science.nx"
11import "nx_seg_store.nx"
12import "nx_syscalls.nx"
13
14// one extruding move "G1 X<x> Y<y> E<e> F1200"
15func pg_move(out: *u8, off: i64, x: i64, y: i64, e: i64) -> i64 {
16 var o: i64 = off
17 o = as_append(out, o, "G1 X" as *u8); o = fd_apnum(out, o, x)
18 o = as_append(out, o, " Y" as *u8); o = fd_apnum(out, o, y)
19 o = as_append(out, o, " E" as *u8); o = fd_apnum(out, o, e)
20 o = as_append(out, o, " F1200\n" as *u8)
21 return o
22}
23
24// emit construction G-code for a w x d x h hollow wall, using the concrete material profile in `prefix`.
25// Returns byte length (NUL-terminated). E accumulates path length (progressive-cavity pump model).
26func pg_emit(prefix: *u8, w: i64, d: i64, h: i64, out: *u8) -> i64 {
27 var layer_mm: i64 = pm_field_int(prefix, "concrete" as *u8, 4) / 1000 // layer_um -> mm (10)
28 let bead_mm: i64 = pm_field_int(prefix, "concrete" as *u8, 3) / 1000 // nozzle_um -> mm (25)
29 if layer_mm <= 0 { layer_mm = 10 }
30
31 var o: i64 = 0
32 o = as_append(out, o, "; Nishi paste/construction G-code -- concrete cistern wall\n" as *u8)
33 o = as_append(out, o, "; NEVER-BRICK (Cardinal 26): movement + extrusion only; no firmware/EEPROM writes\n" as *u8)
34 o = as_append(out, o, "; material=concrete bead=" as *u8); o = fd_apnum(out, o, bead_mm)
35 o = as_append(out, o, "mm layer=" as *u8); o = fd_apnum(out, o, layer_mm); o = as_append(out, o, "mm\n" as *u8)
36 o = as_append(out, o, "G21\nG90\nG28\nG92 E0\n" as *u8) // mm, absolute, home (movement), reset extruder. NO hotend.
37
38 let nlayers: i64 = h / layer_mm
39 var e: i64 = 0
40 var li: i64 = 0
41 while li < nlayers {
42 let z: i64 = (li + 1) * layer_mm
43 o = as_append(out, o, ";LAYER:" as *u8); o = fd_apnum(out, o, li); out[o] = 10 as u8; o = o + 1
44 o = as_append(out, o, "G1 Z" as *u8); o = fd_apnum(out, o, z); o = as_append(out, o, " F600\n" as *u8)
45 o = as_append(out, o, "G0 X0 Y0\n" as *u8) // travel to corner (no extrude)
46 e = e + w; o = pg_move(out, o, w, 0, e)
47 e = e + d; o = pg_move(out, o, w, d, e)
48 e = e + w; o = pg_move(out, o, 0, d, e)
49 e = e + d; o = pg_move(out, o, 0, 0, e) // close the perimeter
50 li = li + 1
51 }
52 o = as_append(out, o, "; end\nG1 Z" as *u8); o = fd_apnum(out, o, h + 50); out[o] = 10 as u8; o = o + 1
53 o = as_append(out, o, "M84\n" as *u8) // disable steppers (safe)
54 out[o] = 0 as u8
55 return o
56}
57
58// structural concrete volume of the printed wall (cm3): perimeter x bead-width x height.
59func pg_concrete_cm3(prefix: *u8, w: i64, d: i64, h: i64) -> i64 {
60 let bead_mm: i64 = pm_field_int(prefix, "concrete" as *u8, 3) / 1000
61 let perim: i64 = 2 * (w + d)
62 return perim * bead_mm * h / 1000 // mm3 -> cm3
63}