Skip to content

senormeow/bldc_simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BLDC Simulation

Interactive browser-based BLDC (Brushless DC) motor simulation with realistic electromagnetic physics, visual cross-section display, and real-time oscilloscope-style graphs.

Features

  • Motor cross-section visualization — rotor with 8 permanent magnets (4 pole pairs), 12 stator coils (3-phase A/B/C), encoder ring
  • Mouse interaction — click and drag to rotate the rotor like a hand on a record, release to spin with momentum
  • RL circuit model — realistic per-phase electrical simulation with winding resistance, inductance, and back-EMF
  • Connect/disconnect switch — disconnected: motor coasts freely on bearings. Connected at 0V: electromagnetic braking from BEMF-driven currents stops the rotor quickly
  • Phase voltage control — three sliders (-10V to +10V) to energize individual phases and observe magnet locking
  • Open-loop sine drive — controller generates 3-phase sinusoidal voltages with adjustable speed (0–400 RPM) and amplitude (0–10V)
  • Friction slider — adjustable bearing/load friction to simulate different operating conditions
  • Real-time graphs — shaft electrical angle vs drive angle, terminal voltages, and phase currents with adjustable time/div (0.5s–20s)
  • Encoder display — mechanical angle, electrical angle, and RPM readout
  • Pause/resume — freeze the simulation to inspect graphs

Physics

Each phase is modeled as an RL circuit with back-EMF:

dI/dt = (V_applied - I·R - BEMF) / L
BEMF  = Ke × ω × sin(θ_electrical - phase_offset)
τ     = Ke × Σ I_phase × sin(θ_electrical - offset)

The simulation uses coupled sub-stepping (20 steps per frame) where the controller, electrical integration, and mechanical integration all advance together, ensuring back-EMF damping stays synchronized with rotor motion.

Getting Started

npm install
npm run dev

Opens at http://localhost:5173

Architecture

Control logic (controller.js) is strictly separated from physics — it can only read the encoder and set phase voltages, just like a real microcontroller.

Roadmap

  • Spinnable motor with mass, friction, and encoder
  • Magnets and coils (4 pole pairs, 12 stator coils, 3-phase)
  • Three voltage sliders with electromagnetic torque model
  • Open-loop sine drive with speed and amplitude control
  • Real-time graphs with adjustable time/div
  • RL circuit with back-EMF, phase currents, connect/disconnect
  • FOC Park/Clarke transforms

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors