How your EUC stays upright

The inverted pendulum, the IMU, the control loop, and what actually happens between your lean and the wheel's response. The engineering that keeps you off the ground.

You lean forward. The wheel accelerates. You stay balanced. It feels intuitive after a few hours of practice. But what’s actually happening is a high-speed engineering loop running thousands of times per second, solving an inherently unstable physics problem in real time. Understanding it changes how you think about safety margins, cutouts, and the limits of your machine.

The inverted pendulum

Your EUC is an inverted pendulum - a mass balanced on top of a single moving point. Like balancing a broomstick on your palm. The broomstick wants to fall. Your hand moves to stay under it.

When you lean forward by angle θ, gravity creates a torque: τ = m·g·h·sin(θ). Mass times gravity times height of your center of mass times the sine of your lean angle. For small angles, sin(θ) ≈ θ, so the torque is roughly proportional to how far you lean.

Left alone, this torque tips you forward. The controller’s job: generate an equal and opposite torque by accelerating the wheel under you. The ground reaction force shifts in front of your center of mass, creating a restoring moment. You stay upright. This happens continuously - not once, but thousands of times per second.

The sensors: IMU

The controller needs to know your lean angle. It gets this from an IMU - Inertial Measurement Unit - containing a 3-axis gyroscope and a 3-axis accelerometer.

The accelerometer senses gravity and translational acceleration. At rest, it tells you which way is down. In motion, it mixes gravitational and motion-induced acceleration - making it noisy under dynamic conditions.

The gyroscope senses angular velocity - how fast you’re rotating. Integrating gyro rate over time gives angle change. But gyros drift. Over seconds to minutes, the accumulated error grows and the estimated angle walks away from reality.

Neither sensor alone gives a reliable angle. Together, through sensor fusion, they do.

Sensor fusion

The controller blends both sensors to get a stable angle estimate. The most common method is a complementary filter: trust the gyroscope for fast changes (it’s clean on short timescales) and trust the accelerometer for the long-term reference (it doesn’t drift). The formula:

θ_estimated = α × (θ_previous + gyro_rate × Δt) + (1 - α) × θ_accelerometer

Where α is close to 1 (typically 0.95-0.99). This means: mostly follow the gyro for instant-to-instant angle tracking, but slowly correct toward the accelerometer’s gravity reference to prevent drift.

More advanced controllers use Kalman filters - mathematically optimal estimators that model system noise and adjust trust between sensors dynamically. The result: a clean, responsive tilt estimate that doesn’t drift and doesn’t lag.

This estimated tilt angle - updated at kilohertz rates - feeds the control loop.

The control loop

The controller takes the estimated tilt angle, compares it to zero (upright), and computes how much torque the motor should produce.

Most EUCs use PID control - Proportional, Integral, Derivative:

Torque = Kp × θ + Ki × ∫θ dt + Kd × θ̇

The PID gains (Kp, Ki, Kd) are what manufacturers tune. They define how the wheel “feels” - responsive vs sluggish, snappy vs smooth. Different ride modes (soft, medium, hard pedals) are largely different PID gain sets.

Some modern controllers use LQR (Linear Quadratic Regulator) - an optimal control method that minimizes a cost function balancing stability against control effort. LQR excels when the system dynamics are well-modeled. Others use ADRC (Active Disturbance Rejection Control) - which adapts to disturbances like uneven terrain without needing a perfect model.

Regardless of the specific algorithm, the output is the same: a torque command sent to the motor.

From torque command to wheel motion

The torque command goes to the motor controller - a three-phase inverter built from MOSFETs. The inverter converts the DC battery voltage into AC currents that drive the motor phases. If you want the power-electronics version, the MOSFETs and controllers article breaks this stage down.

Inside the motor controller, Field-Oriented Control (FOC) translates the torque command into precise phase currents. FOC decomposes the three-phase motor currents into two components: one that produces torque (q-axis) and one that controls magnetic flux (d-axis). This allows the controller to produce exactly the torque demanded, smoothly, at any speed.

The motor - a permanent-magnet brushless DC motor (BLDC/PMSM) built into the wheel hub - responds by accelerating or decelerating. The wheel moves under you. Balance is maintained.

The full loop: lean → IMU senses tilt → sensor fusion estimates angle → PID computes torque → FOC drives motor → wheel moves → new tilt measured → repeat. At kilohertz rates. Every second you’re riding, this loop executes thousands of times.

What this means for safety

Understanding the balance loop reveals why cutouts happen and why safety margins matter:

The controller can only correct if the motor still has torque reserve. If the motor is already near its limit (because you’re accelerating hard, climbing a hill, or deep in field weakening), there’s little left for balance corrections. A bump that would be invisible at 30 km/h (19 mph) becomes a faceplant at 70 km/h (43 mph) - not because the bump is worse, but because the controller has less torque reserve.

Sensor failure means loss of balance. If the IMU fails or drifts badly, the controller doesn’t know which way you’re leaning. Redundant hall sensors on newer wheels (Inmotion, LeaperKim) exist because losing position sensing means losing commutation - the motor can’t produce the commanded torque.

The loop has latency. Sensors take time to read. Fusion takes time to compute. The inverter takes time to change current. This latency means the controller is always slightly behind reality. At low speed, the latency doesn’t matter - corrections are small and the pendulum is slow. At high speed, the pendulum dynamics are faster, and latency matters more. This is another reason high-speed riding is riskier.

Battery voltage affects everything. The faster the motor spins, the more back-EMF it generates - voltage from the motor opposing battery voltage. The controller needs voltage headroom to change phase current quickly and produce torque. At low battery, voltage sag reduces that headroom, so the wheel has less authority for acceleration, braking, and balance corrections. The loop still runs, but the actuator (motor) is weaker. Same control law, less authority.

Gyroscopic effects

A spinning wheel has angular momentum. This resists changes to its spin axis - the gyroscopic effect. At cruising speed, the wheel’s angular momentum provides some lateral stability (harder to tip sideways). This is why EUCs feel more stable at speed than at standstill.

But the gyroscopic effect doesn’t balance you fore-aft. That’s entirely the control loop. The gyroscope helps with side-to-side stability. The controller handles forward-backward balance. You handle steering.

Why pedal hardness matters

“Hard” pedals mean high PID gains - large Kp. A small lean produces a strong correction. The wheel responds aggressively to keep you upright. The trade-off: the ride feels stiff, reactive, and tiring on rough surfaces because every bump triggers a strong response.

“Soft” pedals mean lower gains. The wheel allows more lean before correcting. The ride feels smoother, more relaxed. The trade-off: less immediate response when you need sudden correction. At high speeds on smooth roads, soft can feel dangerous because the wheel doesn’t react as fast to unexpected tilts.

Most experienced riders find their sweet spot somewhere in the middle and adjust per terrain. The underlying physics is the same - it’s just the PID tuning.

555 take

Your EUC is an inverted pendulum balanced by a control loop running at kilohertz rates. Sensors estimate your lean. A control algorithm computes torque. An inverter drives the motor. The wheel moves under you. This happens thousands of times per second, invisibly.

The system works brilliantly - until it doesn’t have enough torque to correct. That’s what a cutout is: the controller demanded torque that the motor/battery couldn’t deliver. The pendulum tipped. You fell.

Every safety margin discussion - field weakening, voltage sag, battery percentage, battery health, speed limits - comes back to this: does the controller have enough torque reserve to handle the next unexpected event? If yes, you stay upright. If no, physics wins. Physics always wins.