This repository is a DLP 3D-printer control stack built around Raspberry Pi nodes. It coordinates:
- stepper motor motion (X/Y, slice stepping),
- projector/image exposure timing (full-screen image flashes),
- sensor/calibration logic, and
- TCP/serial communication between host and printer nodes.
The codebase has four parts:
- Raspberry Pi slave controller (Python) in
code/scripts/ - Earlier Python prototypes in
code/old/andlegacy code/Python/ - Windows host GUI/controller (C#) in
legacy code/3DSPrinter/ - Arduino motor firmware in
legacy code/ArduinoCode/
Together, these components run a layer-by-layer print cycle:
- move platform/motors,
- display a bright slice image full-screen on one or more projectors,
- wait for exposure time,
- blank the screen,
- repeat.
- Starts a TCP server on the Pi’s local IP and listens on
constants.TCP_PORT. - Accepts command packets from a client and decodes them into a message struct.
- Passes decoded instructions to
ThreadManager. - Handles graceful shutdown with GPIO cleanup.
Messages are encoded with a simple framed protocol:
- Starts with
#(instruction) or@(feedback) - Ends with
! - Comma-separated payload fields:
motor_idinstructiondistance_traveldirectionsensor_onresolutionexposure_timeimg_file
Example shape:
#<motor_id>,<instruction>,<distance>,<direction>,<sensor>,<resolution>,<exposure>,<image>!
- Creates motor and sensor worker threads in slave mode.
- Routes instructions by
motor_id(or0for broadcast/all motors). - Handles instruction categories including:
- motor stop,
- sensor calibration,
- motor/image flash operations,
- optional sensor-engaged motion bounds checks.
These launch Pi slave instances with a motor ID argument (1 or 2):
sudo python .../code/scripts/slave.py 1sudo python .../code/scripts/slave.py 2
Projection behavior is implemented in legacy code/Python/printer.py:
- Opens full-screen OpenCV windows for projector outputs.
- Moves windows to specific monitor offsets.
- Alternates between
blank.jpgand print slice image (square.jpgin sample). - Waits for exposure (
cv2.waitKey(delayMs)), then blanks again.
There is also monitor management in legacy code/3DSPrinter/SerialPortCommunication/MonitorManager.cs:
- Creates borderless full-screen windows on one or more monitors.
- Swaps projector background image between print and blank states.
legacy code/ArduinoCode/MotorControl/MotorControl.ino parses serial commands such as:
G0/G1for speed mode,X...andY...axis movements,- signed values for direction.
It drives pulse/direction/enable pins and replies with OK when movement is complete.
legacy code/Python/printer.pyandprinter2.pysend movement commands over serial.legacy code/3DSPrinter/SerialPortCommunication/CommunicationManager.csand UI in3DSPrinter.csperform similar serial command/ack flow from Windows.
code/scripts/__init__.pyandcode/old/sensor.pycontain RC timing / GPIO logic (RPi.GPIO).- The project includes Adafruit libraries under
code/scripts/devices/adafruit/(ADS/I2C support). threadManager.pyreferencesSensorThreadcalibration and position checks.
- Some critical runtime modules are only present as
.pycfiles (for example motor/sensor thread implementations and constants incode/scripts/).
- Source for those modules is not included, so behavior must be recovered from bytecode or reimplemented.
- Most Python code targets Python 2 era conventions, with partial Python 3 migration in some files.
- Multiple generations coexist; not every folder is part of one single executable pipeline.
- A host (Windows app or Python script) orchestrates print settings and timing.
- Commands are sent over TCP to one or more Raspberry Pi slave nodes.
- Each Pi slave decodes command packets, dispatches motor/sensor/image tasks via worker threads.
- Motor movement is executed through stepper drivers and/or serial-connected microcontroller firmware.
- Projectors display layer masks in full-screen, then blank between slices.
Before bring-up, complete these steps:
- recover/decompile or re-implement missing
.pysources from.pyc, - normalize on one Python version (prefer Python 3),
- reconstruct
constantsvalues (TCP port, instruction IDs, slave IPs), - validate GPIO pin mapping and motor driver wiring,
- verify projector monitor layout and image path handling,
- test serial command compatibility with Arduino firmware.
Because this controls motors and UV/light exposure hardware, test with power limits and safety interlocks before full operation.