Voltecx is in beta. The macOS build comes first; Windows and Linux packages are still being tested.Beta. macOS comes first; Windows and Linux are still in testing. What's new

A robot joint is a small servo drive: a three-phase inverter, a permanent-magnet motor, an encoder, a gear and a link that carries a payload. A controller wraps three loops around the joint. The innermost loop sets the motor current, the next sets the speed, and the outer one sets the position. Each loop has to be several times faster than the one around it. Getting the three bandwidths right is most of the work of making a joint feel stiff without ringing.

This article sizes the three loops by hand for a real motor and gear, then checks every number in the robotJointServo example in Voltecx.

The joint

Part Choice Numbers used
Link 48 V, the nominal level of a 13S lithium-ion robot battery VdcV_{dc} = 48 V
Inverter Three half bridges of EPC2302 eGaN FETs (100 V) 1.4 mΩ typical, 40 kHz PWM, 50 ns dead time
Motor maxon EC 45 flat, 48 V winding (402687) 6.89 Ω and 5.85 mH phase to phase, 131 mN·m/A, 8 pole pairs, 181 g·cm²
Gear Strain-wave set, ratio 50 (Harmonic Drive CSG-14-50) taken as rigid
Load Link and payload 0.025 kg·m² at the joint
Encoder 18 bits on the motor shaft 262 144 counts per turn

GaN switches let the PWM run at 40 kHz without a heat sink at this power level. A faster PWM means less current ripple and less delay inside the current loop, so that loop can be faster too.

The catalogue gives terminal (phase-to-phase) values for block commutation. A star-connected sinusoidal model takes half of each per phase, RR = 3.445 Ω and LL = 2.925 mH. The magnet flux follows from the torque constant, ψf=Kt/(3 p)\psi_f = K_t/(\sqrt3\,p) = 9.48 mWb. In dq terms the torque is then

T=32 p ψf iq=0.114 N⋅m/A×iqT = \tfrac32\,p\,\psi_f\,i_q = 0.114\ \text{N}\cdot\text{m/A} \times i_q

The gear divides the load inertia by the square of its ratio. The motor sees

Jt=Jm+JLN2=181+250 0002500=281 g⋅cm2J_t = J_m + \frac{J_L}{N^2} = 181 + \frac{250\,000}{2500} = 281\ \text{g}\cdot\text{cm}^2

Loop 1: current

The plant of the current loop is the winding, 1/(R+Ls)1/(R + Ls). Put the zero of a PI controller on the winding's pole (Ki/Kp=R/LK_i/K_p = R/L) and the loop gain becomes a pure integrator:

Li(s)=Kp+Ki/sR+Ls=ωcswithKp=L ωc, Ki=R ωcL_i(s) = \frac{K_p + K_i/s}{R + Ls} = \frac{\omega_c}{s} \quad\text{with}\quad K_p = L\,\omega_c,\ K_i = R\,\omega_c

The closed loop is a first-order lag with bandwidth ωc\omega_c. The limit is the delay of the PWM and the current sampling, about one and a half PWM periods. A common rule keeps ωc\omega_c near a twentieth of the switching frequency: 2 kHz at 40 kHz, so KpK_p = 36.8 V/A.

A digital drive samples the phase currents once per PWM period, at the middle of the ripple. The example does the same with a zero-order hold at the carrier valley. Without it, the 0.1 A of switching ripple feeds straight back through a gain of 36.8 V/A into the modulator, and the small-signal gain of the loop shrinks.

Loop 2: speed

Seen from the speed loop, the closed current loop is almost instant, and the plant is the inertia, Kt/(Jts)K_t/(J_t s). A PI with Kp=Jt ωs/KtK_p = J_t\,\omega_s/K_t crosses over at ωs\omega_s. Putting its zero a factor of 4 below that crossover (Ki=Kp ωs/4K_i = K_p\,\omega_s/4) keeps about 65° of phase margin. With ωs=ωc/10\omega_s = \omega_c/10, a 200 Hz speed loop, KpK_p = 0.311 A·s/rad.

The speed comes from the encoder: the derivative of the angle, filtered at 2 kHz. The filter adds about 6° of lag at the crossover, and the current loop adds another 6°.

Loop 3: position

The position loop only needs a proportional gain. The speed loop's integrator already removes a steady error under a constant load, since the PI integrator holds the torque. With ω∗=Kpp(Nθ∗−θm)\omega^* = K_{pp}(N\theta^* - \theta_m), the loop crosses over at KppK_{pp}. A tenth of the speed loop gives KppK_{pp} = 126 1/s, a 20 Hz position loop.

Measured in the simulation

analysis.loopGain breaks a loop at a signal, injects a sine and measures what comes back around the loop. Here it runs on the switching circuit, with the GaN bridge, the PWM and the encoder's counts all in the loop.

Loop Designed Analytic, with the delays and the filter Simulated (analysis.loopGain)
Current 2 kHz 2 kHz 1.94 kHz, 90° margin
Speed 200 Hz 204 Hz, 65° 214 Hz, 62°
Position 20 Hz 20.8 Hz 20.9 Hz, 90°

Two details matter when you measure the current loop:

  • Open the speed loop. Otherwise the speed loop acts through the encoder in parallel with the current loop, and the reading mixes the two.
  • Use a large enough perturbation. At 0.1 A, the size of the ripple, the result is mostly ripple. At 1 A it reads within 3 % of the design.

Step and disturbance

The example then runs a test sequence:

  1. The joint moves 0.2 rad, limited to a ramp at 2 rad/s (100 rad/s at the motor).
  2. A 1 mrad fine step tests the loops in their linear range.
  3. A 5 N·m load step lands on the joint, like a payload picked up.

The tests compare the switching simulation with the linear cascade (first-order current loop, speed PI, filtered estimate, position gain):

  • Fine step. It follows the cascade within a tenth of the step at every sample from 1 ms to 30 ms.
  • Load step. It pushes the joint back by 112 µrad, as the cascade predicts. The speed integrator then brings the joint back and holds the load with iq=TL/(N Kt)i_q = T_L/(N\,K_t) = 0.88 A.

Try it

Open the example with File › Open Example › Motor drives › Robot joint servo, 48 V GaN, or with file.openExample {"name": "robotJointServo"}. The whole controller is one module, Ctrl, connected to the power stage only by labels: the gate signals, the phase currents and the encoder count. The gains are circuit variables written as the formulas above, so changing fsw, JL or the gear ratio N re-tunes all three loops.

These are simulation results. The example has not been compared with a test bench yet.