refactor: generate print files separately per known printer

this lets me further tweak settings based on specifics of the material/printer
This commit is contained in:
2025-04-07 18:12:17 +00:00
parent 28dcc72d66
commit 0975bd149e
7 changed files with 164 additions and 146 deletions

163
Makefile
View File

@@ -1,160 +1,87 @@
PREFIX=/usr
SHAREDIR=$(PREFIX)/share/models
PRINT_NOZZLE_DIAM=0.2
PRINT_FILA_DIAM=1.75
# variables for `make upload`
PRINTER_HOST=10.78.79.180
PRINTER_USER=bblp
PRINTER_PASS=$(shell cat ./printer_password)
PRINTER_AUTH=${PRINTER_USER}:${PRINTER_PASS}
# settings for Bambu p1p 3d printer, TPU
# takeaways:
# - bed-temp: 65C
# - first-layer-height: 0.2mm
# - GLUE THE BED AGGRESSIVELY
# - body length: 160mm is too short
# - overhang: 3.0/3.5/6.0mm is too much
#
# runs/data:
# - bed-temp 65C, first-layer-height 0.2mm, 40mm/s, gluestick the bed: print adheres
# - printbed-layer fillets are messy, less messy when turned into chamfers, but still imperfect.
# - bed-temp 40C, first-layer-height 0.2mm, 40mm/s: first layer strings
# - bed-temp 40C, first-layer-height 0.2mm, 40mm/s, light gluestick the bed: first layer strings, then detaches
# - bed-temp 60C, first-layer-height 0.15mm, 40mm/s: first layer doesn't even extrude
# - 50mm/sec w/ bed=65C, raft=2, 0.4diam (wrong!), density 20%: works but causes very rough edges
# - 40mm/sec w/ bed=65C, raft=0, 0.4diam (wrong!), density 20%: fails; infill becomes too sparse
# - 35mm/sec w/ bed=65C, raft=0, 0.4diam (wrong!), density 50%, honeycomb: works, corners are rough
# - 25mm/sec w/ bed=65C, raft=0, 0.2diam, density 75%, rectilinear: fails; detached from bed
# - 35mm/sec w/ bed=65C, raft=0, 0.2diam, density 75%, rectilinear, first-layer 0.2: works, but takes like 6 hours to print
# - 2.5mm thickness => needlessly thick; stiff
# - 160mm length => too short
# - 3/3.5/6.0mm screen overhang => too much (that amount of overhang can't be printed reliably)
# - port cutouts => should extend into more z
PRINT_TEMP=220
PRINT_BED_TEMP=65
PRINT_SPEED=40
PRINT_DENSITY=20
PRINT_FIRST_LAYER_H=0.2
PRINT_RAFT_LAYERS=0
# fill options:
# - <https://manual.slic3r.org/expert-mode/print-settings>
# - line
# - rectilinear
# - honeycomb
# - concentric
# - hilbert
# - archimedes
PRINT_FILL_PATTERN=honeycomb
# XXX: Slic3r doesn't always set the bed temperature correctly. fix by specifying it also for the first layer.
SLIC3R_FLAGS=\
--temperature $(PRINT_TEMP) \
--first-layer-temperature $(PRINT_TEMP) \
--bed-temperature $(PRINT_BED_TEMP) \
--first-layer-bed-temperature $(PRINT_BED_TEMP) \
--nozzle-diameter $(PRINT_NOZZLE_DIAM) \
--filament-diameter $(PRINT_FILA_DIAM) \
--solid-infill-speed $(PRINT_SPEED) \
--first-layer-speed $(PRINT_SPEED) \
--infill-speed $(PRINT_SPEED) \
--raft-layers $(PRINT_RAFT_LAYERS) \
--fill-density $(PRINT_DENSITY) \
--fill-pattern $(PRINT_FILL_PATTERN) \
--use-firmware-retraction \
--first-layer-height $(PRINT_FIRST_LAYER_H) \
--skirts 3
# --brim-width 10 #< combine with raft, if first layer fails to adhere well
# settings for Elegoo 3d printer, Siraya Tech Tenacious Flexible Resin (Shore 65D):
# - <https://siraya.tech/products/tenacious-resin-flexible-resin>
# runs/data
# - defaults: print had entire walls, failed. e.g. volume box had no top.
# - defaults, ACF film: print succeeded, but some walls caved in during print.
# - Siraya recommended settings, ACF film: print succeeded, but some walls caved in during print.
# exposure=3, lift-distance=3, retract-speed=240, lift-speed=45
# - exposure=5, lift-distance=5, retract-speed=150: excellent print
#
# other resins:
# - Elegoo Standard Resin: prints excellent with default settings; zero flexibility, and BRITTLE.
# - SUNLU High Toughness Resin: prints excellent with default settings on ACF film; not flexible enough to accomodate the phone.
# N.B. we rotate the model 90-degrees when slicing else it doesn't fit within print bounds.
MSLICER_FLAGS=\
--rotation 0,0,90 \
--exposure-time 5 \
--first-layers 5 \
--transition-layers 5 \
--lift-distance 5 \
--lift-speed 45 \
--retract-speed 150 \
--first-lift-distance 5 \
--first-lift-speed 45 \
--first-retract-speed 150
# all: build/case.stl build/case.gcode build/case.sl1 build/case.ctb build/case.goo build/pinephone_case.png build/pinephone_case_with_phone.png
all: build/case.stl build/case.gcode build/case.sl1 build/case.goo build/pinephone_case.png build/pinephone_case_with_phone.png
# all: build/case.stl build/case.gcode build/case.sl1 build/case.goo build/pinephone_case.png build/pinephone_case_with_phone.png
all: \
build/elegoo_saturn_4_tenacious_flex/pinephone/case.goo \
build/generic/pinephone/case.png \
build/generic/pinephone/case.stl \
build/generic/pinephone/case_with_phone.png \
build/tpu_bambu_p1p/pinephone/case.gcode \
build/web-viewer/index.html
install:
mkdir -p $(SHAREDIR)
install -m644 build/case.stl $(SHAREDIR)
install -m644 build/case.gcode $(SHAREDIR)
%/pinephone_case.vtk %/pinephone_case.vtk.js: main.py src/*.py
%/case.vtk %/case.vtk.js: %/config main.py src/*.py
mkdir -p "$(@D)"
./main.py --export-vtk $*/pinephone_case.vtk
%/pinephone_phone.vtk %/pinephone_phone.vtk.js: main.py src/*.py
bash -c 'source $*/config && ./main.py --export-vtk $*/case.vtk'
%/phone.vtk %/phone.vtk.js: %/config main.py src/*.py
mkdir -p "$(@D)"
./main.py --render-phone-only --export-vtk $*/pinephone_phone.vtk
bash -c 'source $*/config && ./main.py --render-phone-only --export-vtk $*/phone.vtk'
build/web-viewer/vtk.js: doc.in/vtk.js
mkdir -p build/web-viewer
mkdir -p "$(@D)"
cp $< $@
build/web-viewer/renderWindow.js: doc.in/renderWindow.js
mkdir -p build/web-viewer
cp $< $@
build/web-viewer/index.html: doc.in/index.html build/web-viewer/vtk.js build/web-viewer/renderWindow.js build/web-viewer/pinephone_case.vtk.js build/web-viewer/pinephone_phone.vtk.js
mkdir -p build/web-viewer
mkdir -p "$(@D)"
cp $< $@
build/web-viewer/index.html: doc.in/index.html build/web-viewer/vtk.js build/web-viewer/renderWindow.js build/generic/pinephone/case.vtk.js build/generic/pinephone/phone.vtk.js
mkdir -p "$(@D)"
cp build/generic/pinephone/case.vtk.js "$(@D)"/pinephone_case.vtk.js
cp build/generic/pinephone/phone.vtk.js "$(@D)"/pinephone_phone.vtk.js
cp doc.in/index.html $@
%_case.png: main.py src/*.py
%/case.png: %/config main.py src/*.py
mkdir -p "$(@D)"
./main.py --export-png $@
%_case_with_phone.png: main.py src/*.py
bash -c 'source $*/config && ./main.py --export-png $@'
%/case_with_phone.png: %/config main.py src/*.py
mkdir -p "$(@D)"
./main.py --render-phone --export-png $@
bash -c 'source $*/config && ./main.py --render-phone --export-png $@'
build/case.stl: main.py src/*.py
%/case.stl: %/config main.py src/*.py
mkdir -p "$(@D)"
./main.py --export-stl $@
bash -c 'source $*/config && ./main.py --export-stl $@'
# e.g. build/tpu_bambu_p1p/pinephone.config
# TODO: the dependencies here are overly broad
build/%/config: profile/model/*.env profile/print/*.env
mkdir -p "$(@D)"
# e.g. `cat profile/model/pinephone.env profile/print/tpu_bambu_p1p`
cat profile/model/$(shell basename $*).env profile/print/$(shell basename $(shell dirname $*)).env > $@
# .gcode: for FDM printers
%.gcode: %.stl
%/case.gcode: %/config %/case.stl
mkdir -p $(shell dirname $@)
slic3r $(SLIC3R_FLAGS) $< -o $@
bash -c 'source $*/config && slic3r $${SLIC3R_FLAGS[@]} $*/case.stl -o $@'
# .sl1: for prusa resin-based printers
%.sl1: %.stl
prusa-slicer --export-sla $<
%/case.sl1: %/config %/case.stl
bash -c 'source $*/config && prusa-slicer --export-sla $*/case.stl'
# .ctb: for Gen 3 Elegoo printers (requires `uvtools` package)
%.ctb: %.sl1
%/case.ctb: %/config %/case.sl1
# XXX: UVtoolsCmd exits `1` on success ?? (what does it exit on failure? bleh)
UVtoolsCmd convert $< Chitubox $@ || test -f $@
bash -c 'source $*/config && UVtoolsCmd convert $< Chitubox $@ || test -f $@/
# .goo: for Gen 4+ Elegoo printers (requires `mslicer` package)
%.goo: %.stl
slicer --mesh $< $(MSLICER_FLAGS) $@
%/case.goo: %/config %/case.stl
bash -c 'source $*/config && slicer --mesh $*/case.stl $${MSLICER_FLAGS[@]} $@'
readme: readme_files/pinephone_front_case_with_phone.png readme_files/pinephone_back_case_with_phone.png readme_files/pinephone_side_case_with_phone.png
doc: readme build/web-viewer/index.html
doc: readme build/web_viewer/index.html
clean:
rm -rf build/*
upload: build/case.gcode
lftp -e "set ssl:verify-certificate false; put $<; exit" -u ${PRINTER_AUTH} ftps://${PRINTER_HOST}
# upload: build/case.gcode
# lftp -e "set ssl:verify-certificate false; put $<; exit" -u ${PRINTER_AUTH} ftps://${PRINTER_HOST}
.PHONY: all install readme doc clean upload
# instruct Make to not garbage-collect intermediate targets
.SECONDARY:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

View File

@@ -0,0 +1,25 @@
# settings for Elegoo 3d printer, Siraya Tech Tenacious Flexible Resin (Shore 65D):
# - <https://siraya.tech/products/tenacious-resin-flexible-resin>
# runs/data
# - defaults: print had entire walls, failed. e.g. volume box had no top.
# - defaults, ACF film: print succeeded, but some walls caved in during print.
# - Siraya recommended settings, ACF film: print succeeded, but some walls caved in during print.
# exposure=3, lift-distance=3, retract-speed=240, lift-speed=45
# - exposure=5, lift-distance=5, retract-speed=150: excellent print
#
# other resins:
# - Elegoo Standard Resin: prints excellent with default settings; zero flexibility, and BRITTLE.
# - SUNLU High Toughness Resin: prints excellent with default settings on ACF film; not flexible enough to accomodate the phone.
# N.B. we rotate the model 90-degrees when slicing else it doesn't fit within print bounds.
MSLICER_FLAGS=(\
--rotation 0,0,90 \
--exposure-time 5 \
--first-layers 5 \
--transition-layers 5 \
--lift-distance 5 \
--lift-speed 45 \
--retract-speed 150 \
--first-lift-distance 5 \
--first-lift-speed 45 \
--first-retract-speed 150
)

View File

View File

@@ -0,0 +1,66 @@
# settings for Bambu p1p 3d printer, TPU
# takeaways:
# - bed-temp: 65C
# - first-layer-height: 0.2mm
# - GLUE THE BED AGGRESSIVELY
# - body length: 160mm is too short
# - overhang: 3.0/3.5/6.0mm is too much
#
# runs/data:
# - bed-temp 65C, first-layer-height 0.2mm, 40mm/s, gluestick the bed: print adheres
# - printbed-layer fillets are messy, less messy when turned into chamfers, but still imperfect.
# - bed-temp 40C, first-layer-height 0.2mm, 40mm/s: first layer strings
# - bed-temp 40C, first-layer-height 0.2mm, 40mm/s, light gluestick the bed: first layer strings, then detaches
# - bed-temp 60C, first-layer-height 0.15mm, 40mm/s: first layer doesn't even extrude
# - 50mm/sec w/ bed=65C, raft=2, 0.4diam (wrong!), density 20%: works but causes very rough edges
# - 40mm/sec w/ bed=65C, raft=0, 0.4diam (wrong!), density 20%: fails; infill becomes too sparse
# - 35mm/sec w/ bed=65C, raft=0, 0.4diam (wrong!), density 50%, honeycomb: works, corners are rough
# - 25mm/sec w/ bed=65C, raft=0, 0.2diam, density 75%, rectilinear: fails; detached from bed
# - 35mm/sec w/ bed=65C, raft=0, 0.2diam, density 75%, rectilinear, first-layer 0.2: works, but takes like 6 hours to print
# - 2.5mm thickness => needlessly thick; stiff
# - 160mm length => too short
# - 3/3.5/6.0mm screen overhang => too much (that amount of overhang can't be printed reliably)
# - port cutouts => should extend into more z
PRINT_NOZZLE_DIAM=0.2
PRINT_FILA_DIAM=1.75
PRINT_TEMP=220
PRINT_BED_TEMP=65
PRINT_SPEED=40
PRINT_DENSITY=20
PRINT_FIRST_LAYER_H=0.2
PRINT_RAFT_LAYERS=0
# fill options:
# - <https://manual.slic3r.org/expert-mode/print-settings>
# - line
# - rectilinear
# - honeycomb
# - concentric
# - hilbert
# - archimedes
PRINT_FILL_PATTERN=honeycomb
# XXX: Slic3r doesn't always set the bed temperature correctly. fix by specifying it also for the first layer.
SLIC3R_FLAGS=(\
--temperature ${PRINT_TEMP} \
--first-layer-temperature ${PRINT_TEMP} \
--bed-temperature ${PRINT_BED_TEMP} \
--first-layer-bed-temperature ${PRINT_BED_TEMP} \
--nozzle-diameter ${PRINT_NOZZLE_DIAM} \
--filament-diameter ${PRINT_FILA_DIAM} \
--solid-infill-speed ${PRINT_SPEED} \
--first-layer-speed ${PRINT_SPEED} \
--infill-speed ${PRINT_SPEED} \
--raft-layers ${PRINT_RAFT_LAYERS} \
--fill-density ${PRINT_DENSITY} \
--fill-pattern ${PRINT_FILL_PATTERN} \
--use-firmware-retraction \
--first-layer-height ${PRINT_FIRST_LAYER_H} \
--skirts 3 \
)
# --brim-width 10 #< combine with raft, if first layer fails to adhere well
# variables for `make upload`
PRINTER_HOST=10.78.79.180
PRINTER_USER=bblp
PRINTER_PASS=$(cat ./printer_password)
PRINTER_AUTH=${PRINTER_USER}:${PRINTER_PASS}