Skip to the content.
🚀 Launch the Machine Simulator 📊 Launch the Data Parser

This directory contains two calibration simulators for the Maslow CNC machine, both using the shared calibration computation library to ensure identical behavior with the actual machine.

Two Simulators

1. Machine Simulator (index.html)

Provides an accurate simulation of the complete Maslow CNC machine calibration process with synthetic data.

Use this for:

📖 Full Documentation

2. Data Parser (data-parser.html)

Processes real calibration measurement data pasted by the user to compute optimal anchor positions.

Use this for:

📖 Full Documentation

Quick Start

Machine Simulator:

  1. Open index.html
  2. Configure machine parameters
  3. Click “Start Calibration Simulation”
  4. Watch the simulated calibration process

Data Parser:

  1. Open data-parser.html
  2. Paste your measurement data
  3. Click “Parse and Validate”
  4. Click “Compute Anchor Positions”

Code Sharing

Both simulators run calibration-computation.js in this folder, a JavaScript port of the calibration math the machine actually runs. That math lives in the firmware, in Calibration::recomputeAnchorsWithLevenbergMarquardt() (firmware/FluidNC/src/Maslow/Calibration.cpp) — the firmware is the source of truth, and this file is a port kept in step with it by hand.

The port used to be shipped to the machine as well, at ESP3D-WEBUI/www/js/calibration-computation.js. It no longer is: once calibration moved into C++, the web UI stopped calling the JS solver entirely, so it was deleted from the bundle to keep index.html.gz small. This copy is for development and simulation only.

⚠️ If you change the firmware routine, update this file to match — nothing enforces it automatically, and a stale port makes the simulator disagree with the real machine.


Machine Simulator

The machine simulator provides an accurate representation of the Maslow CNC machine’s calibration process with synthetic measurement data.

Key Features

Accurate Machine Simulation

Browser-Side Computation

Real-Time Visualization

How It Works

Calibration Process Flow

  1. Grid Generation (Machine Side)
    • Generates a calibration grid based on frame size and grid density
    • Creates waypoints in a spiral pattern starting from center
    • Defines recompute points where computation should be triggered
  2. Measurement Collection (Machine Side)
    • Moves to each waypoint in sequence
    • Takes measurements of belt lengths to all four anchors
    • Projects measurements to XY plane (accounting for Z-height)
    • Adds configurable measurement error
  3. Data Transmission (Machine → Browser)
    • Sends measurement chunks via CLBM: format messages
    • Triggered at specific waypoints (recomputePoints)
    • Mimics the actual serial communication protocol
  4. Anchor Computation (Browser Side)
    • Receives measurement chunk
    • Runs iterative optimization to find best anchor positions
    • Uses “line walking” algorithm to minimize endpoint distances
    • Updates anchor position estimates
  5. Multi-Stage Refinement
    • Process repeats for each stage (typically 4-5 stages)
    • Each stage uses more measurements for better accuracy
    • Final stage uses all measurements for best fit

Usage

Opening the Simulator

Simply open index.html in a modern web browser. No server or build process is required.

Configuration Options

Machine Configuration:

Simulation Settings:

Running a Simulation

  1. Configure the machine parameters to match your setup
  2. Adjust simulation settings as desired
  3. Click “Start Calibration Simulation”
  4. Watch the visualization as calibration progresses
  5. Review the log for detailed progress information
  6. Check final error measurements when complete

Understanding the Output

Machine Visualization (Left Panel)

Computation Progress (Right Panel)

Log Output

Technical Details

Key Differences from Original Simulation

The original simulation (https://github.com/BarbourSmith/Calibration-Simulation/) processes all measurements at once. This simulation accurately models:

  1. Staged Computation: Anchor positions are recomputed multiple times as more data arrives
  2. Data Chunking: Measurements sent in groups matching firmware behavior
  3. Iterative Refinement: Each stage builds on previous results
  4. Protocol Accuracy: Uses actual CLBM: message format

Algorithm Overview

The calibration algorithm works by:

  1. Drawing “lines” from each anchor point with length equal to measured belt length
  2. Adjusting line angles to make all four lines meet at a single point
  3. Finding anchor positions that minimize the distance between line endpoints
  4. Using an iterative “hill climbing” approach to optimize positions

This “magnetically attracted lines” approach is robust to measurement errors and works well even with poor initial guesses.

Performance Characteristics

Use Cases

Development and Testing

Education and Demonstration

Quality Assurance

Files

Computation library:

Architecture

Where the math lives

The machine runs its calibration solver in C++, in Calibration::recomputeAnchorsWithLevenbergMarquardt() (firmware/FluidNC/src/Maslow/Calibration.cpp). The web UI does not compute anchor positions at all any more — it starts calibration and waits for the firmware’s Calibration complete message.

calibration-computation.js is a hand-maintained JavaScript port of that C++ routine, so these tools can reproduce and inspect what the machine does without a machine attached. It is loaded only by pages in this folder and is never shipped to the device.

Keeping the port honest: the firmware is authoritative, and the port only tracks it because someone keeps it in step. When you change the C++ routine, mirror the change here and re-run the self-test.

Diagram

firmware/FluidNC/src/Maslow/Calibration.cpp   ← SOURCE OF TRUTH (runs on the machine)
        │
        │ hand-maintained port
        ▼
docs/calibration-simulation/
├── calibration-computation.js   ← JS port, dev/simulation only
├── index.html          ─┐
├── data-parser.html     ├─ load calibration-computation.js
├── test.html           ─┘
├── computation-simulator.js (thin wrapper)
├── machine-simulator.js
└── visualization.js

ESP3D-WEBUI/  ← ships index.html.gz; contains no calibration solver

Limitations

This simulation does not model:

These factors exist in the real machine but don’t significantly affect the calibration algorithm’s behavior.

Frame Imperfections

The simulator now includes realistic frame imperfections to better match real-world conditions:

Future Enhancements

Potential improvements:

License

This simulation is part of the Maslow CNC project and follows the same open-source license as the main repository.