Motors
de:volt models three motor types: a brushed DC motor, a hobby servo, and a 4-wire bipolar stepper. Each is electrically simulated and reports a live mechanical readout (speed, angle, or step position) alongside the circuit.
All three are inductive loads. Drive them with an H-bridge (L293D, TB6612) or, for a bare transistor switch, add a flyback diode to suppress the inductive kick.
DC Motor
A generic brushed DC motor, modelled as a series R+L winding with a back-EMF source proportional to rotor speed (Vbemf = Ke × ω). Winding current produces torque (Tm = Kt × i), and the rotor follows J × dω/dt = Kt×i − b×ω − loadTorque.
Pinout
| Pin | Label | Description |
|---|---|---|
| m1 | M+ | Positive terminal (drive voltage or H-bridge OUT_A) |
| m2 | M− | Negative terminal (GND or H-bridge OUT_B) |
Defaults
| Parameter | Default | Unit |
|---|---|---|
| windingR | 5 | Ω |
| windingL | 0.002 | H |
| Ke | 0.01 | V/(rad/s) |
| Kt | 0.01 | N·m/A |
| inertia | 1e-5 | kg·m² |
| friction | 1e-5 | N·m·s/rad |
| loadTorque | 0 | N·m |
These can be overridden via the Inspector properties panel.
How it behaves
Speed is proportional to applied voltage. As the rotor speeds up, back-EMF rises and opposes the supply, so current falls. At standstill (ω = 0) there is no back-EMF, so the current is highest — the stall current equals V / windingR. With the default 5 Ω winding and a 6 V supply that is 1.2 A.
The simulator reports rotor speed (ω in rad/s) and RPM in the readout. The speed value drives the back-EMF source only; it is not mechanically coupled to any external load.
Drive method
Use an H-bridge for bidirectional control: connect M+ to OUT_A and M− to OUT_B for forward rotation, then reverse the drive signals for reverse. Reversing the terminal polarity reverses the spin direction. A bare transistor switch needs a flyback diode connected anti-parallel across M+/M− to clamp the voltage spike when the transistor turns off.
Example circuit
Arduino D5 ─── IN1 ┐
Arduino D6 ─── IN2 │ [L293D] OUT1 ─── M+
│ OUT2 ─── M− [DC Motor]
5V ──┴── VCC / VSHobby Servo (SG90)
A PWM-controlled rotary position actuator. A pulse HIGH time of 1–2 ms on the signal pin commands the shaft to a position between 0° and 180°. The servo holds its last commanded angle between pulses.
Pinout
| Pin | Label | Description |
|---|---|---|
| sig | Signal | PWM control input |
| vplus | V+ | Power (4.5–6 V, 5 V nominal) |
| gnd | GND | Ground |
The connector is polarised: signal first, power centre, GND last. Do not reverse it.
Defaults
| Parameter | Default | Unit |
|---|---|---|
| minPulseMs | 1.0 | ms |
| maxPulseMs | 2.0 | ms |
| minAngle | 0 | ° |
| maxAngle | 180 | ° |
| idleR | 330 | Ω |
How it behaves
The signal pin is a high-impedance input (modelled as 1 MΩ to GND); it reads HIGH when V(sig) − V(gnd) ≥ 2.0 V. The power pins draw a small idle current (default load 330 Ω, roughly 15 mA at 5 V).
On each pulse the sim measures the HIGH time and maps it to an angle:
angle = minAngle + (pulseMs − minPulseMs) / (maxPulseMs − minPulseMs) × (maxAngle − minAngle)So a 1 ms pulse gives 0°, 1.5 ms gives 90°, and 2 ms gives 180°. The commanded angle is reported in the readout and held between updates.
Drive method
Drive the signal pin with a 50 Hz PWM signal — use the Arduino Servo library, which generates the 1–2 ms pulses for you. Power V+ from a 5 V rail that can supply the stall current (about 700 mA); for more than one servo use a separate supply rather than the Arduino 5 V pin.
Example circuit
Arduino D9 ─── Signal
5V ─── V+ [Servo SG90]
GND ─── GNDBipolar Stepper Motor (NEMA 17)
A 4-wire bipolar stepper with two independent coils (A and B). Energising the coils in the 4-phase full-step sequence advances the shaft one step at a time. Default: 200 steps/rev (1.8°/step).
Pinout
| Pin | Label | Description |
|---|---|---|
| a1 | A1 | Coil A, A+ |
| a2 | A2 | Coil A, A− |
| b1 | B1 | Coil B, B+ |
| b2 | B2 | Coil B, B− |
Defaults
| Parameter | Default | Unit |
|---|---|---|
| coilR | 10 | Ω |
| coilL | 0.01 | H |
| stepsPerRev | 200 | steps/rev |
How it behaves
Each coil is a series R+L load. Stepping is detected from the sign of the committed coil currents after each solve (±1 mA deadband), giving four phases:
| Phase | Coil A | Coil B |
|---|---|---|
| 0 | A+ | B+ |
| 1 | A− | B+ |
| 2 | A− | B− |
| 3 | A+ | B− |
Advancing one phase (mod 4) moves one step forward; stepping back one phase moves one step back. A non-sequential jump holds position. The simulator reports the accumulated step position. There is no back-EMF in this model.
Drive method
Cycle the full-step sequence with an H-bridge. With an L293D, wire OUT1→a1, OUT2→a2, OUT3→b1, OUT4→b2; with a TB6612, AO1→a1, AO2→a2, BO1→b1, BO2→b2. Each phase transition is one step (1.8° for a 200-step motor). Reversing one coil reverses the rotation direction. Bare-transistor drivers need a flyback diode across each coil — the L293D/TB6612 handle this internally when VM is powered.
Unipolar/ULN2003 5-wire steppers are not modelled in this version.
Example circuit
Arduino D8 ─── IN1 ┐ OUT1 ─── A1 ┐ Coil A
Arduino D9 ─── IN2 │ [L293D] OUT2 ─── A2 ┘
Arduino D10 ── IN3 │ OUT3 ─── B1 ┐ Coil B
Arduino D11 ── IN4 ┘ OUT4 ─── B2 ┘ [Stepper NEMA 17]