 [](https://crates.io/crates/prinThor)  [](https://coveralls.io/github/cbruiz/printhor?branch=main)[](https://opensource.org/licenses/MIT) 
If you are using this product or like the project, please ★ this repository to show your support! 🤩
# Overview Printhor is a generic and hardware-agnostic (firmware) framework for FDM printers, CNC, Engravers and robots implemented in Rust. Basically, it's a GCode interpreter capable to process a stream of GCodes (position and control orders), schedule them, compute a motion profile on the fly and finally perform the hardware level instructions (step pulses, PWM signals, ... or even dataframes broadcast for a dedicated break-board) in real time. There are many productive firmwares in the community like gbrl, marlin, reprap, etc. Each single one have a concrete approach and guidelines. This one aims to provide a research environment for not strictly productive purpose, but a reliable platform with the following goals: * Robustness. * Numerical stability. * Efficient resources utilization and close-to-preemptive multitasking. * Leverage async multitasking. * Maintain busy waits to a minimum. * Ensure leverage of DMA transfers as much as possible. * Ensure of leverage of FPU when present. * Simplicity. * Clarity and readability. Which means the principal short-term goal is not to develop a productive firmware for final user rather than providing an environment in which anyone can test and experiment any concrete approach to feed the community with good quality, state-of-the-art or innovative feature increments. ## Documentation (work in progress) [Documentation and guides](doc/README.md) ## Features * "Clean" hardware abstraction. * Vector geometry / linear algebra calculus for kinematics * Smooth acceleration and jerk limited motion plan leveraging "Trajectory with Double S Velocity Profile" [1]. Briefly explained at [Plan implementation](printhor/src/bin/motion/profile.rs) and visually explained in [Printhor motion plan. A simplified overview of the velocity integration](https://www.geogebra.org/m/hwpnmhcu) (GeoGebra). "[1] Biagiotti, L., Melchiorri, C.: Trajectory Planning for Automatic Machines and Robots. Springer, Heidelberg (2008). [DOI:10.1007/978-3-540-85629-0](https://doi.org/10.1007/978-3-540-85629-0)" * High precision and deterministic kinematics and computations with configurable resolution. Briefly explained at [Stepper Task](printhor/src/bin/tasks/task_stepper.rs). * Simple and efficient cornering algorithm based on pure linear algebra. Foundation implicitly explained at [Printhor naïve cornering algorithm](https://www.geogebra.org/m/ft8svrwd) (GeoGebra). * Precise thermal control plan with PID. Briefly explained at [Temperature Task](printhor/src/bin/tasks/task_temperature.rs). * Simple, secure and efficient resource and peripherals sharing. * Clean and simple async tasks coordination/intercommunication with event based primitives. * High behavior customization. * Low level action distribution leveraging dedicated break-boards. * Wide GCode standard coverage. * Native simulation for development and benchmarking. * Many others coming. ## Overall status| Feature | Status |
|---|---|
| Simulation | Functional |
| I/O | Functional |
| State and logic | Testing |
| Motion Planner | Functional |
| Kinematics | Testing |
| Thermal Control | Incubation |
| Display | TODO |
| Laser/CNC | Draft |
| M-Code | Mode | Description | Status |
|---|---|---|---|
| M | * | List all supported m-codes | DONE |
| M0 | * | Stop or Unconditional stop | WIP |
| M1 | * | Sleep or Conditional stop | WIP |
| M2 | * | Program End | WIP |
| M3 | CNC | Spindle On, Clockwise | WIP |
| LASER | Laser On | WIP | |
| M4 | CNC | Spindle On, Counter-Clockwise | WIP |
| LASER | Laser On | WIP | |
| M5 | CNC | Spindle Off | WIP |
| LASER | Laser Off | WIP | |
| M6 | * | Tool change | ILT |
| M7 | CNC | Mist Coolant On | ILT |
| M8 | CNC | Flood Coolant On | ILT |
| M9 | CNC | Coolant Off | ILT |
| M10 | CNC | Vacuum On | ILT |
| M11 | CNC | Vacuum Off | ILT |
| M13 | CNC | Spindle on (clockwise rotation) and coolant on (flood) | ILT |
| M16 | CNC | Expected Printer Check | TODO |
| M17 | * | Enable/Power all stepper motors | WIP |
| M18 | * | Disable all stepper motors | WIP |
| M20 | * | List SD card | DONE* |
| M21 | * | Initialize SD card | TODO |
| M22 | * | Release SD card | TODO |
| M23 | * | Select SD file | DONE |
| M24 | * | Start/resume SD print | DONE |
| M25 | * | Pause SD print | DONE |
| M26 | * | Set SD position | ILT |
| M27 | * | Report SD print status | TODO |
| M30 | * | Program Stop | TODO |
| M31 | * | Output time since last M109 or SD card start to serial | TODO |
| M32 | * | Select file and start SD print | TODO |
| M33 | * | Get the long name for an SD card file or folder | ILT |
| M37 | * | Simulation mode (Dry run mode) | DONE |
| M73 | * | Set/Get build percentage | TODO |
| M79 | * | Soft reset | DONE |
| M80 | * | ATX Power On | WIP |
| M81 | * | ATX Power Off | WIP |
| M82 | * | Set extruder to absolute mode | WIP |
| M83 | * | Set extruder to relative mode | WIP |
| M92 | * | Set axis_steps_per_unit | WIP |
| M104 | FFF | Set Hotend Temperature | DONE |
| M105 | FFF | Get Hotend and/or Hotbed Temperature | DONE |
| M106 | * | Fan On | WIP |
| M107 | * | Fan Off | WIP |
| M109 | FFF | Set Extruder Temperature and Wait | DONE |
| M110 | * | Set Current Line Number | WIP |
| M111 | * | Set Debug Level | WIP |
| M112 | * | Full (Emergency) Stop | WIP |
| M114 | * | Get Current Position | DONE |
| M115 | * | Get Firmware Version and Capabilities | DONE |
| M116 | * | Wait | WIP |
| M117 | * | Display message | DONE |
| M118 | * | Echo message on host | DONE |
| M119 | * | Get Endstop Status | DONE |
| M120 | * | Enable endstop detection | ILT |
| M121 | * | Disable endstop detection | ILT |
| M140 | * | Set hotbed Temperature (Fast) | DONE |
| M190 | * | Wait for hotbed temperature | DONE |
| M200 | * | Set filament diameter | WIP |
| M201 | * | Set max acceleration | WIP |
| M202 | * | Set max travel acceleration | WIP |
| M203 | * | Set maximum feedrate | WIP |
| M204 | * | Set default acceleration | WIP |
| M205 | * | Advanced settings | WIP |
| M206 | * | Offset axes | WIP |
| M207 | * | Set retract length | WIP |
| M208 | * | Set unretract length | WIP |
| M209 | FFF | Enable automatic retract | WIP |
| M210 | * | Set homing feedrates | WIP |
| M211 | * | Disable/Enable software endstops | WIP |
| M212 | * | Set Bed Level Sensor Offset | WIP |
| M218 | * | Set Hotend Offset | WIP |
| M220 | * | Set speed factor override percentage | WIP |
| M221 | * | Set extrude factor override percentage | WIP |
| M290 | * | Babystepping | WIP |
| M302 | * | Allow cold extrudes | ILT |
| M305 | * | Set thermistor and ADC parameters | ILT |
| M350 | * | Set microstepping mode | WIP |
| M360 | * | Report firmware configuration | ILT |
| M400 | * | Wait for current moves to finish | TODO |
| M401 | * | Deploy Z Probe | WIP |
| M402 | * | Stow Z Probe | WIP |
| M404 | * | Filament width and nozzle diameter | WIP |
| M407 | * | Display filament diameter | WIP |
| M410 | * | Quick-Stop | TODO |
| M422 | * | Set a G34 Point | WIP |
| M450 | * | Report Printer Mode | WIP |
| M451 | * | Select FFF Printer Mode | WIP |
| M452 | * | Select Laser Printer Mode | WIP |
| M453 | * | Select CNC Printer Mode | WIP |
| M500 | * | Store parameters in non-volatile storage | TODO |
| M501 | * | Read parameters from EEPROM | TODO |
| M502 | * | Restore Default Settings | WIP |
| M503 | * | Report Current Settings | WIP |
| M504 | * | Validate EEPROM | TODO |
| M505 | * | Clear EEPROM and RESET Printer | TODO |
| M510 | * | Lock Machine | ILT |
| M511 | * | Unlock Machine with Passcode | ILT |
| M512 | * | Set Passcode | ILT |
| M513 | * | Remove Password | ILT |
| M524 | * | Abort SD Printing | WIP |
| M555 | * | Set compatibility | ILT |
| M563 | * | Define or remove a tool | ILT |
| M851 | * | Set Z-Probe Offset | WIP |
| M862.1 | * | Check nozzle diameter | ILT |
| M862.2 | * | Check model code | ILT |
| M862.3 | * | Model name | TODO |
| M929 | * | Start/stop event logging to SD card | ILT |
| G-Code | Mode | Description | Status |
|---|---|---|---|
| G | * | List all supported g-codes | DONE |
| G0 | * | Rapid Move | WIP |
| G1 | * | Linear Move | WIP |
| G4 | * | Dwell | DONE |
| G10 | * | Retract/Set coordinate system | ILT |
| G11 | * | Unretract | TODO |
| G17 | * | Plane Selection XY (default) | TODO |
| G18 | CNC | Plane Selection ZX | ILT |
| G19 | CNC | Plane Selection YZ | ILT |
| G21 | * | Set Units to Millimeters | TODO |
| G22 | * | Firmware Retract | ILT |
| G23 | * | Firmware Recover | ILT |
| G28 | * | Move to Origin (Home) | WIP |
| G29 | * | Detailed Z-Probe | TODO |
| G29.1 | * | Set Z probe head offset | WIP |
| G29.2 | * | Set Z probe head offset calculated from toolhead position | ILT |
| G30 | * | Single Z-Probe | TODO |
| G31 | * | Set or Report Current Probe status | TODO |
| G38.2 | * | Probe toward workpiece, stop on contact, signal error if failure | ILT |
| G38.3 | * | Probe toward workpiece, stop on contact | ILT |
| G38.4 | * | Probe away from workpiece, stop on loss of contact, signal error if failure | ILT |
| G38.5 | * | Probe away from workpiece, stop on loss of contact | ILT |
| G80 | * | Mesh-based Z probe | ILT |
| G81 | * | Mesh bed leveling status | ILT |
| G82 | * | Single Z probe at current location | TODO |
| G90 | * | Set to Absolute Positioning | DONE |
| G91 | * | Set to Relative Positioning | DONE |
| G92 | * | Set Position | DONE |
| G92.1 | * | Reset axis offsets (and parameters 5211-5219) to zero. (X Y Z A B C U V W) | ILT |
| G92.2 | * | Reset axis offsets to zero | ILT |
| G93 | CNC | Feed Rate Mode (Inverse Time Mode) | ILT |
| G94 | CNC | Feed Rate Mode (Units per Minute) | ILT |