M

DC Motor

Continuous
Run the live example Free · no sign-up · runs in your browser

The DCMotor block models an electromechanical permanent-magnet direct-current motor plant. It captures the dynamic interaction between electrical armature dynamics and mechanical rotor torque balance across 1st, 2nd, and 3rd order modes.

Real-World Analog: Represents standard brushed or brushless DC motors found in robotic joints, electric vehicle wheel drives, drone gimbals, conveyor rollers, and computer cooling fans.

Video tutorial

Mathematical Model

The motor is governed by Kirchhoff's voltage law and Newton-Euler rotor dynamics:

Va(t)−Keω(t)=R⋅ia(t)+L⋅dia(t)dt,Te(t)=Kt⋅ia(t)V_a(t) - K_e \omega(t) = R \cdot i_a(t) + L \cdot \frac{di_a(t)}{dt}, \quad T_e(t) = K_t \cdot i_a(t)
Kt⋅ia(t)−TL(t)=J⋅dω(t)dt+b⋅ω(t)+τcogging(θ)K_t \cdot i_a(t) - T_L(t) = J \cdot \frac{d\omega(t)}{dt} + b \cdot \omega(t) + \tau_{\text{cogging}}(\theta)

Inputs & Outputs

Direction ID Label Type Status
→ In voltage Voltage (Va) number Optional
→ In loadTorque Load Torque (TL) number Optional
→ In p + number Optional
→ In n - number Optional
→ In flange_a Shaft number Optional
→ In flange_b Case number Optional
→ In H H number Optional
← Out speed Speed (ω) number Output
← Out current Current (ia) number Output
← Out torque Torque (Te) number Output
← Out position Position (θ) number Output

Parameters

Parameters Label Type Default Description
preset Motor Preset select custom Select a pre-calibrated physical motor model or configure custom parameters
dynamicsMode Model Dynamics select secondOrder Select dynamical model order and complexity
resistance Resistance (R) number 1 Armature winding resistance [Ω]
inductance Inductance (L) number 0.5 Armature winding inductance [H]
torqueConstant Torque Constant (Kt) number 0.1 Motor torque constant [N·m/A]
backEmfConstant Back-EMF Constant (Ke) number 0.1 Back-EMF constant [V/(rad/s)]
inertia Rotor Inertia (J) number 0.02 Rotor moment of inertia [kg·m²]
damping Viscous Friction (b) number 0.05 Viscous damping coefficient [N·m·s/rad]
brushDrop Brush Voltage Drop (Vbrush) number 0 Total contact voltage drop across carbon brushes [V]. Sets effective voltage to 0 when |Va| <= Vbrush.
currentLimit Current Limit (Imax) number 0 Armature peak current limit [A]. Clamps armature current to ±Imax. 0 = unlimited.
coulombFriction Coulomb Friction / Stiction (Tc) number 0 Breakaway Coulomb friction torque opposing motion [N·m]. Prevents rotation until net torque exceeds Tc.
initialSpeed Initial Speed (ω0) number 0 Initial angular velocity at t=0 [rad/s]
initialCurrent Initial Current (ia0) number 0 Initial armature current at t=0 [A]
initialPosition Initial Position (θ0) number 0 Initial rotor position at t=0 [rad]
coggingTorque Cogging Torque (Tcog) number 0 Peak reluctance cogging torque amplitude due to stator slotting [N·m]. 0 = neglected.
coggingSlots Cogging Slots / Poles number 12 Number of cogging torque periods per mechanical revolution.

Usage Examples

Velocity Step Response and Load Rejection

Simulating a 12V DC motor accelerating to 20.0 rad/s20.0\text{ rad/s} (191 RPM191\text{ RPM}), followed by a 0.5 N⋅m0.5\text{ N}\cdot\text{m} load step at t=2.0 st = 2.0\text{ s} showing speed sag and armature current ramp to 10.83 A10.83\text{ A}.

Closed-Loop PID Servo Position Control

Connecting the DCMotor in thirdOrder mode to a PIDController for angular position regulation (θref=±π rad\theta_{\text{ref}} = \pm \pi\text{ rad}), achieving critically damped settling within 0.35 s0.35\text{ s}.

Remarks & Best Practices

  • Numerical Stability: Default parameters yield balanced time constants (τe=0.5 s\tau_e = 0.5\text{ s}, τm=0.4 s\tau_m = 0.4\text{ s}), well-conditioned for explicit integration.
  • Port Flexibility: The loadTorque input defaults to zero if unconnected.

Frequently Asked Questions (FAQ)

Q: Why does my DC Motor simulation oscillate or become unstable with very small inductance L?

When the electrical time constant τe=L/R\tau_e = L / R is significantly smaller than the simulation step size (Δt=0.01 s\Delta t = 0.01\text{ s}), the differential equation for armature current becomes numerically stiff. If you wish to neglect inductance without changing the simulation step size, select 1st Order in the dynamicsMode dropdown or set L=0L = 0. The block will automatically switch to an exact algebraic calculation of armature current ia=(Va−Keω)/Ri_a = (V_a - K_e \omega) / R, guaranteeing numerical stability.

Related Components