Observe the system to get a basic understanding of its main features: the d.c. electrical motor is on the right and drives a large wheel. Circular rails are fixed around the wheel and a ball rolls freely inside them. The ball movement is limited to the lower part of the disk to force it to stay in contact with the rails.

For simulation and controller design, the system is represented as a state-space model. It can be split into two subsystems: the electrical drive with the d.c. motor, and the mechanical part with the wheel, rails and ball. These subsystems have a mutual influence, not an input-output connection where causality is clearly defined.

The numerical values given for the parameters correspond to the virtual experiment.

### Electrical drive and wheel

- System input
- u (motor voltage)
- Parameters
- Rm = 1 Ω (motor resistance)
- K = 0.1 N·m/A (motor torque/current constant)
- N = 7 (reduction factor from motor to wheel)
- Jw = 0.02 kg·m
^{2} (moment of inertia of the load)
- R = 0.201 m (rails radius)
- Auxiliary values
- Mw (moment on the wheel produced by the motor)
- theta (angle of the wheel)
- thetaDer (derivative of theta)
- thetaDDer (second derivative of theta)
- F (tangential force applied by ball to wheel at contact point)
- Equations
- Mw = K N (u − K N thetaDer) / Rm
- Jw thetaDDer = Mw - R F

### Wheel and ball

- Parameters
- m = 0.1 kg (ball mass)
- r = 27·10
^{−3} m (rail contact radius of the ball)
- Jb = 36·10
^{−6} kg·m^{2} (moment of inertia of the ball)
- g = 9.81 m/s
^{2} (gravity acceleration constant)
- Auxiliary values
- thetaDDer (second derivative of theta)
- phi (ball angle with respect to ground)
- phiDer (derivative of phi)
- phiDDer (second derivative of phi)
- psi (ball position along rail as an angle from wheel center, 0 at bottom)
- psiDer (derivative of psi)
- psiDDer (second derivative of psi)
- Equations
- m (R − r) psiDDer = F − m g sin psi
- Jb phiDDer = F r
- psi = theta − phi r / (R − r)

### State-space model

Combining these equations gives the following state-space model for the complete system. Because of the intricate influence between the wheel and the ball, to get explicit first-order differential equations, a 2x2 linear system must be solved; hence the auxilairy values a, b, c and d, coming from a 2x2 matrix, and what can be recognized as an inverse.

- States
- theta (angle of the wheel, 0 when rails are horizontal)
- thetaDer (derivative of theta)
- psi (ball position along rail as an angle from wheel center, 0 at bottom)
- psiDer (derivative of p)
- Auxiliary values (constant)
- a = Jw + R Jb (R − r) / r
^{2}
- b = −R Jb (R − r) / r
^{2}
- c = Jb (R − r) / r
^{2}
- d = −m (R − r) − Jb (R − r) / r
^{2}
- Equations (non-linear model)
- theta' = thetaDer
- thetaDer' = ((u − K N thetaDer) d K N / Rm − b m g sin psi) / (a d − b c)
- psi' = psiDer
- psiDer' = ((K N thetaDer − u) c K N / Rm + a m g sin psi) / (a d − b c)

These equations aren't linear with respect to states and input. It isn't a problem for numerical simulation (at least not a difficult one: we're using a Runge-Kutta 4th order integration algorithm with a fixed maximum time step, with a small additional damping on the ball to make sure numerical errors don't make oscillations diverge), but many controller design methods, such as those in frequency domain, require linearity.
Therefore we'll approximate sin psi ≈ psi, assuming psi is small.

This leads to the following linear model, with the same states.

- Equations (linear model)
- theta' = thetaDer
- thetaDer' = ((u − K N thetaDer) d K N / Rm − b m g psi) / (a d − b c)
- psi' = psiDer
- psiDer' = ((K N thetaDer − u) c K N / Rm + a m g psi) / (a d − b c)

### Decoupled model

In the state-space models above, the rotation of the wheel is perturbed by the ball. If we assume the ball effect is negligible, we start from the following equations:

- Equations (decoupled system)
- Jw thetaDDer = Mw
- Mw = K N (u − K N thetaDer) / Rm
- m (R − r) psiDDer = Jb (R − r) (thetaDDer − psiDDer) / r
^{2} − m g sin psi

Approximating sin psi ≈ psi, we eventually obtain the following decoupled linear state-space model:

- Equations (decoupled linear model)
- theta' = thetaDer
- thetaDer' = K N u / (Rm Jw) − K
^{2} N^{2} thetaDer / (Rm Jw)
- psi' = psiDer
- psiDer' = (Jb K N u / (Jw r
^{2} Rm) − Jb K^{2} N^{2} thetaDer / (Jw r^{2} Rm) − m g psi / (R − r)) / (m + Jb / r^{2})

We have here two subsystems connected in series: the first two equations for the d.c. motor and wheel with input u and output theta, and the last two equations for the ball with input theta and output psi. The controller must be robust enough to support all these approximations, in addition to other model structural assumptions, parameter uncertainties and external perturbations.

Two remarks on the ball subsystem:

- Its input is the second derivative of theta (angular acceleration). The wheel angle theta isn't required to simulate or control the ball position. This is also true for the non-linear model.
- The second derivative of psi depends on psi itself, not on its first derivative. This reflects an undamped system.

### Controller structure

The system will be controlled with cascade controllers. The inner loop controls the wheel velocity thetaDer with a P controller whose control signal is the motor voltage u. Since the ball depends only on the wheel acceleration, a velocity steady-state error isn't harmful; no need for an integral term.

The outer loop controls the ball position; its control signal is the wheel velocity, the reference value passed to the inner controller. Both the ball position psi and speed psiDer are assumed to be measured, so no additional state is required for the controller. The reference value is 0: the purpose of the controller is to keep the ball at the central position and to reject perturbations.

The controller equations are given below.

- Controller parameters
- kp1 (proportional gain for the inner loop)
- kp2 (proportional gain for the outer loop)
- kd2 (derivator gain for the outer loop)
- Auxiliary value
- thetaDerRef (reference value of the wheel velocity)
- Equations (cascade P/PD controllers)
- thetaDerRef = −kp2 psi − kd2 psiDer
- u = kp1 (thetaDerRef − thetaDer)

The transfer function of the two subsystems and the controller parameters can be computed with Sysquake.

Type `assist model` and press the Enter button or hit the Return key repeatedly to see how. You can also modify commands, stop the assisted mode, start again, clear the output with `clc` or get help with `doc`.

Javascript is disabled or not available.

Sysquake Mobile relies on Javascript to run in your browser. If you want to use it, please enable Javascript or choose another browser.

# About Sysquake Mobile

**Sysquake Mobile**, a JavaScript version of Sysquake you can rely on wherever you are.