Complete Tutorial

Simulate kinematic mechanisms in your browser

MechSim is a free, zero-install planar linkage simulator. Drop pins, connect links, and watch your mechanism move — powered by a Newton-Raphson constraint solver.

O₂ O₄ Crank Rocker Coupler
Getting Started

Up and running in 60 seconds

01
📂

Load a preset

Click Crank-Slider or Four-Bar in the sidebar to load a working mechanism instantly.

02

Press Play

Hit ▶ Play or press Space. The simulator takes a snapshot and animates continuously.

03

Reset to edit

Press ↺ Reset to return to the initial snapshot and re-enable all editing tools.

💡
Three modes: MechSim works as a state machine — Edit → Running → Paused → Edit. You can only modify the mechanism in Edit mode. Pressing Play locks the initial state; Reset always returns to that snapshot.
Toolbar Reference

Every tool explained

The vertical toolbar on the left of the canvas holds all building tools. Click or press the keyboard shortcut.

  • Select S
    Click pins or links to open properties. Drag grounded non-crank pins to reposition. Drag empty canvas to pan.
  • Pin J
    Place a free joint anywhere on the canvas. Pins are the joints that connect links.
  • Link L
    Click pin A then pin B to create a rigid link. Length is fixed at creation distance.
  • Ground G
    Toggle any pin between free and grounded. Set ω (rad/s) in the props panel to make it a crank pivot.
  • Weld W
    Click two links that share a pin to make them rigid (fixed angle). A distance constraint locks the triangle formed by the three pins. Click the same pair again to unweld.
  • Actuator A
    Creates a prismatic joint. Can be articulated piston or fixed-axis rail. Supports passive (coupler-driven) mode.
  • Rail Slider R
    Two endpoints define a rigid rail. A slider pin S rides between them. Connect couplers to S for passive mode.
  • Arc Slider C
    Select 3 pins (start → mid → end) to define an arc. Pin S slides along the circular arc.
  • Circle Slider O
    Select center then rim pin. Pin S orbits the full 360° circle. Set speed for continuous rotation.
Keyboard Shortcuts

Work fast

Every tool has a key. Tools are disabled while Running or Paused — press Reset first.

SSelect
JPlace pin
LLink
GGround
WWeld
AActuator
RRail slider
CArc slider
OCircle slider
SpacePlay / Pause
DelDelete
Ctrl ZUndo
Ctrl YRedo
ScrollZoom
DragPan canvas
Edit mode only: J L G A R C O are disabled while Running or Paused. Press ↺ Reset to re-enable.
Additional Features

Background Image, Weld & Recording

🖼 Background Image

Load a reference image (photo, sketch, technical drawing) and overlay it behind your mechanism. Open the Background Image section in the left sidebar:

Load image — select any image file. It centres on your current view at 35% opacity.
Edit image — toggle edit mode to adjust Scale, X, and Y position. The image shows at 60% opacity with a dashed border while editing.
Show image — checkbox to toggle visibility without removing it.
The background image is saved and restored with your project file.

💡
Tip: Load a photo of a real mechanism or a textbook diagram, scale it to match your grid, then trace over it with pins and links to recreate the linkage.

▲ Weld Tool

The Weld tool (W) makes two links sharing a pin move as a rigid body. Click the first link, then click the second — they must share a common pin. MechSim locks the angle between them by adding a distance constraint between their far pins, forming a rigid triangle.

You can create multiple independent welds through the same pin (e.g., weld link A–B and separately weld link C–D, even if all four links share the same pin). Click the same pair again to remove the weld. Welded pins show an marker and a dashed line between the far pins.

⏺ Recording Auto-Pause

When you stop a recording (⏹ Stop rec), the simulation automatically pauses. This lets you review your recorded data without the mechanism continuing to move. Press ▶ Resume to continue, or ↺ Reset to return to the initial state.

⏱ Simulation Timer

The top-right overlay now shows elapsed simulation time in seconds (accounting for speed multiplier). The timer starts from 0 when you press Play and resets to 0 on Reset or Clear.

Mechanism Library

Classic linkages you can build

The fundamental mechanisms of planar kinematics, all assemblable from pins and links.

O₂ O₄ Crank Rocker Coupler
Four-Bar Linkage

Crank, coupler, rocker, ground. Grashof's law governs whether it's a crank-rocker, double-crank, or double-rocker. Foundation of engines, wipers, walking machines.

O A B
Crank-Slider

Converts rotation to reciprocating linear motion. The foundation of piston engines and pumps. Built with a grounded crank, coupler, and a fixed-axis slider pin.

O₂ O₄ C ≈ straight
Chebyshev Linkage

A four-bar where the coupler midpoint traces an approximate straight line — useful for converting rotation to translation without a prismatic joint.

Rail Arc Circle
Rail + Arc + Circle Sliders

Three slider types: straight rail, circular arc (3-point), and full 360° circle. Each slider pin can be passive (coupler-driven) or active (motor speed).

Step-by-Step

Build a four-bar from scratch

The four-bar is the simplest closed kinematic chain. Three links plus the ground.

// Step 1 — Ground pivots Press G (Ground tool) Place two grounded pins — O₂ and O₄ Select O₂ → set ω = 1 rad/s // makes it the crank // Step 2 — Free pins Press J (Pin tool) Place pin A near O₂, pin B near O₄ // Step 3 — Links Press L (Link tool) Connect: O₂ → A // crank arm Connect: A → B // coupler Connect: O₄ → B // rocker // Step 4 — Simulate Press Space → watch it move
📐
Grashof's Law: For a crank-rocker, shortest + longest ≤ sum of the other two. The preset uses L₂=80, L₃=180, L₄=120, L₁=200 which satisfies 80+200 ≤ 180+120.

Slider types: passive vs active

PassivePosition driven by coupler geometry — NR circle∩line intersection
ActiveMoves at set speed (rad/s or u/s), bounces at limits, drives dependent joints
Active + couplerpinS is fixed anchor — NR resolves downstream passive joints from it
Under the Hood

Newton-Raphson constraint solver

Every link contributes a scalar equation f(q)=0. MechSim assembles the Jacobian and iterates:

// Revolute link |A − B|² − L² = 0 // Fixed-axis actuator (B − G) · n̂ = 0 // Rail slider (S on line A→B) (S − A) × (B − A) = 0 |A − B|² − L² = 0 // Arc slider |S − center|² − r² = 0 // Iteration (Levenberg-Marquardt) q ← q − Jᵀ(JJᵀ + λI)⁻¹ f(q)

The tol and iter inputs in the header control convergence. Lower tol = more precise. Higher iter = handles complex configurations.

Tuning: For fast preview use tol=0.1, iter=20. For accurate recording use tol=0.001, iter=100. The Levenberg-Marquardt λ=0.1 prevents divergence near singular positions.

Simulation state machine

EDIT full editing RUNNING snapshot locked PAUSED snapshot locked ▶ Play ⏸ Pause Resume ↺ Reset
LOCKED: NR failed to converge. Usually a link is too short to reach two pins. Fix geometry and press Reset.
FAQ

Common questions

How do I save my mechanism?
Click 💾 Save to download a .mechsim.json file. Click 📂 Open to reload it. No account needed — fully portable.
What does "LOCKED — singular position" mean?
The Newton-Raphson solver couldn't find a valid configuration — usually a link is too short to connect two pins at their current positions. Press ↺ Reset to restore the last valid state, then adjust link lengths.
What's the difference between passive and active sliders?
Passive: position is determined by coupler geometry — NR places the slider at the circle∩line or circle∩circle intersection.

Active: slider moves at a set speed, bounces at limits, and its pinS is treated as a fixed anchor that drives downstream passive joints.
Can I export kinematic data?
Yes. Enable Trace path on any pin. Click ⏺ Record to capture position, velocity, and acceleration at configurable intervals. Export as .csv — timestamps start at zero for easy analysis.
Can an active arc or circle slider drive a passive linear slider?
Yes. Set the arc/circle slider as Active (non-passive, speed≠0). Connect a coupler link from its slider pin to a pin on the passive linear slider. The solver treats the active pinS as a fixed anchor each frame, then resolves the linear slider's position from the coupler constraint.
Why can't I edit while the simulation is running?
When you press Play, MechSim locks the initial snapshot. Edits during simulation would corrupt that snapshot. Press ↺ Reset to return to Edit mode — all tools are re-enabled and the mechanism returns to its initial position.
How does the Weld tool work?
Press W and click two links that share a pin. MechSim adds a distance constraint between their far pins, forming a rigid triangle. You can have multiple independent welds at the same pin. Click the same pair again to remove the weld.
Can I use a reference image?
Yes. In the left sidebar under Background Image, click 🖼 Load image to insert a photo or diagram behind the mechanism. Use ✏ Edit image to adjust its scale and position, then trace over it with pins and links. The image is saved with your project.
Ready?

Open MechSim and start simulating

Free, browser-based, no installation. Works in Chrome, Edge, Firefox and Safari.

▶ Launch Simulator