## 2 Materials & Methods
### Software and Control
The motor torque term \(\tau_{mot}\) can be expressed (using Kirchhoff's law and disregarding inductive effects as negligible in the bandwidth of interest) as a linear function of motor excitation voltage V\({}_{mot}\) and angular velocity \(\omega\), by expressing motor torque in terms of motor current, and motor back-emf in terms of angular velocity. Regarding modeling of friction terms, the dynamic case (\(\omega\
eq 0\)) is first considered. The static case and associated static friction treatment will be then addressed. For non-null velocity, friction torque as a function of angular velocity is modeled as a sum of a Coulomb zeroth-order term, plus a viscous linear term, plus a second-degree additional term. Within the previously stated assumptions, the gearmotor equation of motion can be thus rewritten as follows:  
\[\tau_{ext}-\mathrm{a}\omega-\left(\mathrm{b}+\mathrm{c}\omega^{2}\right) \frac{\omega}{|\omega|}+\mathrm{d}\mathrm{V}_{mot}=\mathrm{J}\dot{\omega}\]  
where friction torque is represented by the second and third terms. The experimental values of the ratios \(\mathrm{a}/\mathrm{d},\mathrm{b}/\mathrm{d},\mathrm{c}/\mathrm{d}\) are obtained by best fit during a joint characterization phase, in which a suitable set of values for excitation voltage V\({}_{mot}\) are applied to the motor, under zero external torque, and resulting asymptotic output shaft angular velocity values are recorded. Using the estimated model parameters, transparency is then obtained by dynamically linking the motor voltage to the measured velocity, in order to compensate the friction torque terms. Motor voltage is generated by the inverter stage, by means of standard pwm modulation of the inverter supply voltage, with carrier wave frequency (20 kHz) outside audible range, and duty cycle parameter \(D\in[-1,\ 1]\) dynamically computed as follows:  
\[D=\mathrm{g}\frac{1}{\mathrm{V}_{\mathrm{supply}}}\frac{1}{d}\left(a\omega+ \left(b+c\omega^{2}\right)\frac{\omega}{|\omega|}\right)\]  
where V\({}_{\mathrm{supply}}\) is the measured value of the inverter stage supply voltage; negative duty cycle values are associated with motor voltage polarity reversal. Here, an overall strictly positive gain parameter g is introduced to perform a fine tuning of the compensation degree in order to address the effects of variation of the external parameters affecting the behavior of the joint (as temperature and applied load). However, we empirically discovered that the aforementioned variations in the environment conditions produced a minimal variation in the joint response and did not substantially affect Transparency mode performance. At null velocity, in static friction regime, the above compensation scheme cannot be used. Instead, a low-frequency sine wave voltage is applied to the motor, such that the resulting peak motor torque is slightly less than the experimentally determined static friction maximum value. This allows for a quasi-compensation of static torque at least around the peak of the sine wave, so that the full static friction is only perceived by the patient (when exerting force on the robot) within less than one cycle period, before dynamic conditions are established, thus minimizing motion startup effort. In the Repeat Trajectory mode, the patient is passive as in the Kinematic mode, but the trajectories can be more complex. It reproduces previously saved trajectories recorded either in Kinematic and Transparency modes and allows their combination in sequences, interposing or not temporal pauses of varying duration between one and the other (Figure 8). This is crucial to increase the variability and thus the engagement of the patient during the rehabilitation session. It also enables the therapist to add non-elementary movements to the rehabilitation protocol. The exercises executed in the Kinematic and Transparency modes are sampled at 20 Hz and saved as a collection of temporally equidistant via points.