The Virtual Spring Mass Syste J. S. Freudenberg EECS 6 Ebedded Control Systes Huan Coputer Interaction A force feedbac syste, such as the haptic heel used in the EECS 6 lab, is capable of exhibiting a ide range of interesting phenoena. It is useful to reeber that the syste consists of a echanical device (the heel in our case), ith to feedbac loops rapped around it. As shon in Figure, one feedbac loop consists of (i) a sensor such as an encoder, tachoeter, or strain gauge, (ii) a icroprocessor, and (iii) an actuator such as a DC otor. The purpose of the sensor is to easure position, velocity, or force, the purpose of the icroprocessor is to ipleent an algorith (the virtual orld) that taes the sensor input and coputes a force output, and the purpose of the otor is to ipose that force on the haptic device. The other feedbac loop consists of the huan sensing the output of the haptic device through the sin, executing soe behavior in response, and exerting a force on the haptic device through the uscles. behavior sensor (sin surface) Huan actuators (uscles) position velocity force sensor (encoder, tach, strain gauge) Haptic Device CPU algorith (virtual orld) force actuator (DC otor) Figure : Huan Coputer Interaction through Force Feedbac The feedbac loop involving the huan is the ost difficult to analyze because the huan is unpredictable. Nevertheless, e can postulate several possible huan behaviors that can be analyzed. We shall no exaine three of these that ay be explored in the lab. A Step Change in Wheel Position Suppose that e ipleent a virtual orld consisting of a ass, attached to the puc by a spring ith constant (Figure ). Revised Septeber, 5.
Puc z Figure : Virtual Spring Mass Syste The equations of otion of the syste are ẅ + = z. (.) Note that this equation describes a haronic oscillator ith natural frequency ω n = / rad/sec. A bloc diagra representation is shon in Figure. The force exerted on the virtual ass is given by F = (z ). (.) It is this force, hich depends on both the spring constant and the relative position of the virtual ass ith respect to the puc, that the user ill feel exerted on the haptic device by the DC otor. The solution to the differential equation in response to zero initial conditions and a constant input z(t) = z starting at t = t is given by (t) = z ( cos(ω n (t t )), t t. (.) The resulting force exerted on the virtual ass is given by Note several ey points: F (t) = z cos(ω n (t t )), t t. (.) (i). The behavior of the virtual ass (position, velocity, acceleration, natural frequency) depends only on the ratio /. (ii). By varying the spring constant hile eeping the ratio / fixed, e can influence the reaction force required of the DC otor and experienced by the user. (iii). The axiu force experienced by the user ill have agnitude equal to z. It follos fro these observations that e should be able to construct virtual spring ass systes ith a variety of natural frequencies hile eeping the force exerted by the otor in response to an initial oveent of the puc liited to an achievable value. z Σ - F. ẇ. Figure : Bloc Diagra of the Virtual Spring Mass Syste
. The Virtual Wheel/Torsional Spring Syste In fact, our force feedbac syste does not display linear otion, as shon in Figure, but rather it displays rotary otion as shon in Figure. In this figure, the puc is our haptic heel, and is shon connected to a virtual heel by a shaft that is not rigid, and that thus behaves lie a torsional spring. With the angles θ z and θ given in radians, the rotational inertia of the virtual heel is N-/(deg/sec ) and the torsional spring constant is given by N-/deg. The equations of otion of the syste are θ z θ haptic heel virtual heel Figure : Virtual Wheel and Torsional Spring θ + θ = θ z. (.5) Note that (.5) is identical to (.); both describe haronic oscillators. The qualitative behavior of the to systes is thus identical. Hoever, to actually rite ebedded softare to ipleent the virtual orlds, one ust account correctly for the actual values of the constants, and thus also for their units. Suppose that e ish to ove the heel no ore than a fixed aount (say 5 ). The reaction torque generated in response to this otion should be no ore than, say 8N, so that e do not hit the softare liit on duty cycle. The natural frequency of the oscillator should be Hz. We ay siulate this syste ith the SIMULINK odel found in Figure 5. A typical response is shon in Figure 6. heel Position torque angular speed Step thetaz spring constant /J /virtual inertia thetaddot s Integrator thetadot s Integrator theta Virtual heel Position Figure 5: Siulation of Virtual Wheel and Torsional Spring. Nuerically Unstable Ipleentation of the Virtual Wheel/Torsional Spring As e discussed in class, to ipleent the virtual heel/torsional spring syste, it is necessary to nuerically integrate the differential equation (.). We shoed in class ho to do this using the forard Euler ethod. Although forard Euler integration is nuerically unstable, the fact that e are only interacting ith the virtual spring-ass syste for a finite tie, together ith the assuption of a relatively fast saple rate, suggests that this instability ill not be a proble. As it happens, the saple rate e use (T = sec) is not sufficiently fast, and e do see the effect of the instability in the lab, as ell as in Matlab siulations. To illustrate, consider the discrete ipleentation pictured in Figure 7. The resulting response is shon in Figure 8. Note that the virtual torque generated by the nuerical integration increases until it hits the softare liit on duty cycle, and thus on torque.
= 5 N n/deg, =.75 N n/(deg/sec ), f n =.66 Hz 8 continuous syste, no daping 6 6 θ dθ /dt (deg/sec) 8 θ z torque (N ) torque liit 5 6 7 8 9 tie, seconds Figure 6: Response of Virtual Wheel Step thetaz heel Position spring constant /J torque /virtual inertia thetaddot T z Discrete Tie Integrator angular speed thetadot T z Discrete Tie Integrator theta Virtual heel Position Figure 7: Discrete Siulation of Virtual Wheel and Torsional Spring. Analysis of Nuerical Instability Ho ay the instability noted above be resolved? One ay ould be to use a nuerically stable nuerical integration technique, such as the trapezoidal ethod. Another ay ould be to add soe daping to the odel. We no explore the latter ethod. Recall fro the class notes that stability of a continuous tie syste is governed by the characteristic roots. For a continuous tie syste ith state space description ẋ = Ax + Bu, (.6) the characteristic roots are equal to the eigenvalues of A. For a discrete tie syste ith state space description x( + ) = A d x() + B d u(), (.7) the characteristic roots are equal to the eigenvalues of A d. If the discrete tie syste is obtained by approxiating the continuous tie syste using the forard Euler ethod ith saple period T, then A d = I + T A, B d = T B, (.8) here I denotes the identity atrix. Facts fro linear algebra iply that if λ is an eigenvalue of A, then λ d = + T λ is an eigenvalue of A d.
= 5 N /deg, =.75 N /(deg/sec ), f n =.66 Hz 8 discrete syste, no daping 6 6 θ dθ /dt (deg/sec) 8 θ z torque (N ) torque liit 5 6 7 8 9 tie, seconds Figure 8: Instability Due to Nuerical Integration For a second order syste (i.e., a syste ith to state variables), the characteristic equation ay be ritten as s + α s + α =. (.9) If the roots are coplex, then they lie on a circle of radius ω n, and (.9) ay be paraeterized as s + ζω n s + ω n =, (.) here the daping coefficient ζ ust satisfy ζ < in order for the eigenvalues to be coplex. Expressed in ters of natural frequency and daping, the eigenvalues of A are given by Hence the eigenvalues of A d in this case are λ ± = ζω n ± jω n ζ. (.) λ ± d = T ζω n ± jt ω n ζ. (.) It is easy to sho that the discrete eigenvalues fro (.) have agnitude given by λ ± d = T ζω n + T ω n. (.) It follos that if the continuous tie syste has no daping (ζ = ), then the discrete tie eigenvalues ill satisfy λ ± d = + T ωn, lie outside the unit circle, and thus be unstable. By adding daping to the continuous tie syste, the discrete tie syste ill be stable for sufficiently sall values of T : <, T < ζ/ω n, λ ± d =, T = ζ/ω n, (.) >, T > ζ/ω n. It follos that if e ant to ipleent a discrete tie haronic oscillator, then adding daping ζ = T ω n / to the continuous tie syste ill exactly balance the destabilizing effects of the forard Euler nuerical integration. In ters of the coefficients of the characteristic polynoial (.9), it follos that ζ/ω n = T α = T α. (.5) 5
. Application to Virtual Wheel/Torsional Spring The state variable description of the syste described in (.5) and Figures -5 is given by [ ] [ ] ẋ = x + θ / /J z (.6) θ = [ ] x (.7) In the state variable odel (.6)-(.7) the states are the outputs of the integrators: x = θ and x = θ. The reaction torque felt by the user is equal in agnitude and opposite in sign to the torque exerted on the virtual heel: T q = (θ θ z ). (.8) Suppose e ish to add daping to this odel. Then (.5) becoes θ + b θ + θ = θ z + b θz. (.9) Treating θ z as another input, e have the state equations [ ] [ ] [ ] ẋ = x + θ / b/ /J z + θ b/j z (.) The reaction torque is no θ = [ ] x (.) T q = (θ θ z ) b( θ θ z ). (.) Note that to copute the reaction torque e need to easure the angular velocity of the haptic heel. If e are only interested in cases for hich e hold this heel constant (or ove it sloly) then e can ignore this ter, and siulate the virtual heel ith daping as shon in Figure 9. The characteristic equation of (.9)- (.) is given by s + b s + =. (.) Equating (.) ith (.9), and choosing the coefficients according to the rule (.5), shos that e should add daping b = T b = T. (.) Ipleenting the virtual orld as shon in Figure, ith b chosen as in (.), results in the discrete syste being a haronic oscillator, as desired. The response of the siulation in Figure to a 5 step change in heel position is plotted in Figure. Note that, due to the daping added into the odel, the oscillations no longer becoe unbounded. To do so, e ust nuerically differentiate the heel position to obtain its angular velocity. Alternately, e can consider a source of daping that depends on the otion of the virtual heel ith respect to a fixed coordinate syste, instead of otion relative to the physical heel. 6
heel Position torque angular speed Step thetaz spring constant /J /virtual inertia thetaddot s Integrator thetadot s Integrator theta Virtual heel Position b daping Figure 9: Siulation of Virtual Wheel and Torsional Spring ith Daping Step thetaz heel Position spring constant torque /J /virtual inertia thetaddot T z Discrete Tie Integrator angular speed thetadot T z Discrete Tie Integrator theta Virtual heel Position b daping Figure : Discrete Siulation of Virtual Wheel and Torsional Spring ith Daping = 5 N /deg, =.75 N /(deg/sec ), f n =.66 Hz 8 discrete syste ith daping b = T 6 6 θ dθ /dt (deg/sec) 8 θ z torque (N ) torque liit 5 6 7 8 9 tie, seconds Figure : Stable Nuerical Integration 7
Free Response of the Puc/Virtual Spring Mass Syste Consider again the syste in Figure. Suppose that e set the virtual ass in otion by oving the puc a fixed aount and then holding it constant. Then the virtual ass ill be set in otion, and ill oscillate ith a period / radians/second. Suppose next that the user releases the puc. Then the resulting otion ill be that of to asses (one real, one virtual) coupled by a spring. This situation is depicted in Figure. Note that is the virtual ass, and M is the ass of the physical device. M z Define state variables Figure : Coupled Virtual/Physical Masses x = z, x = ż, x =, x = ẇ (.) The dynaics of the syste ith no external forces applied are given by ẋ = x, x (t ) = x (.) ẋ = M ( z) = M (x x ), x (t ) = x (.) ẋ = x, x (t ) = x (.) ẋ = (z ) = (x x ), x (t ) = x. (.5) In atrix for, these equations becoe ẋ = M M x(t ) = x. (.6) It is difficult to analyze the response of the syste in these coordinates. Instead, e define a ne coordinate syste, ith position coordinates given by the center of ass and the distance beteen the to asses: z = Mx + x M +, z = ż, z = x x, z = ż (.7) Substituting (.)-(.5) into (.7), e obtain the state equations ż = ( M + ) z(t ) = z. (.8) It follos fro (.8) that the distance beteen the asses z satisfies the equations of otion of a haronic oscillator ith natural frequency (/M + /) radians/second. The center of ass z, on the other hand, satisfies the equations of otion of a double integrator. Suppose e set the virtual ass in otion by oving the puc to a ne position and holding it there until tie t. With no loss of generality, e ay tae the puc position and velocity just before release to 8
be z(t ) = and ż(t ) =. Upon releasing the puc, the behavior of the to-ass syste is described by (.8), and ill depend on the position and velocity of the virtual ass at the tie of release. It is easy to verify that if ẇ(t ) =, then the center of ass ill reain constant; otherise, it ill drift. In either case, the individual asses ill oscillate about the center of ass. To illustrate, consider the response of the to asses to the initial condition x () = x () =, plotted in Figure. The center of ass and the distance beteen asses are plotted in Figure. 5 M = g, = g distance, eters 5 5 5 5 tie x x Figure : Unforced Motion of Physical and Virtual Masses To apply the above results to haptic heel coupled to a virtual heel, e use state variables x = θ z, x = θ z, x = θ, x = θ. (.9) The equations derived above continue to hold; e siply replace M ith J z and ith. Coupled Masses ith Daping Suppose next that there is virtual daping beteen the coupled asses, as shon in Figure 5. Then the dynaics of the syste are given by ẋ = x, x (t ) = x (.) ẋ = M (x x ) b M (x x ), x (t ) = x (.) ẋ = x, x (t ) = x (.) ẋ = (x x ) + b (x x ), x (t ) = x. (.) In atrix for, these equations becoe b b ẋ = M M M M x, x(t ) = x. (.) b Using the sae paraeter values as before, and ith b =. g/sec, e have the plots shon in Figure 6, shoing that the oscillations in x x die aay ith tie. b 9
M = g, = g distance, eters (Mx + x )/(M + x x 5 5 5 5 tie Figure : Center of Mass and Distance Beteen Masses z M b Figure 5: Coupled Virtual/Physical Masses ith Daping
M = g, = g distance, eters (Mx + x )/(M + x x 5 5 5 5 tie Figure 6: Center of Mass and Distance Beteen Masses, ith Daping b =. g/sec