Professional Documents
Culture Documents
behavior
position
velocity Haptic force
force Device
sensor actuator
(encoder, tach, CPU (DC motor)
strain gauge)
algorithm
(virtual world)
virtual
wall
z
zw
k
Puck
z
zw
k
Puck m
z
w
k k
ẅ + w= z (1)
m m
- the puck experiences a reaction force equal in magnitude
and opposite in direction to the force exerted on the mass:
F F k F F
Puck m
z
w
k k
ẅ = z− w
m m
has a block diagram (cf. the notes on second order systems
from Lecture 7):
.. .
z w w w
k/m Σ
-
k/m
.. .
z F w w w
Σ k 1/m
-
2
3 4
Velocity
Force
Puck Position
wddot wdot w
z
k 1/m 1 1 1
s s
Virtual Mass
Step 1/virtual mass Integrator Integrator1 Position
spring
constant
• Let us move the puck one unit to the right and hold it there.
- The mass will respond according to (1)
- A reaction force will be exerted on the puck
- This force must be countered by the user to hold the puck
stationary!
• Matlab simulation1 of mass motion, velocity, and force exerted
on the puck (assumes that the puck and mass have no physical
dimension)
k = 10, m = 1, period of oscillation = 1.9869
10
−2
−4
−6
mass position, w
mass velocity, dw/dt
−8 puck position, z
force on mass, F=−k(w−z)
reaction force on puck, −F
−10
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time, seconds
• If puck is not held constant, then the force will depend on the
puck position.
• To simulate the motion of the puck requires that we model
- the response of the puck states (position, velocity) to the
reaction force.
- the effect of the human interacting with the puck
• To implement the haptic interface,
- we measure the position of the puck.
- we do not need to simulate puck motion or human
interaction.
.. .
z F w w w
Σ k 1/m
-
x1 , w
x2 , ẇ
ẋ1 = x2
k k
ẋ2 = − x1 + u
m m
y = kx1 − ku
ẋ = Ax + Bu
y = Cx + Du
where
» – » –
0 1 0 ˆ ˜
A, k ,B , k ,C , k 0 , D , −k
−m 0 m
f(x,u)
T 2T 3T 4T
• Hence
• x1 = position, x2 = velocity
the z-transform is
∞
−k
X
Y (z) = y(k)z
k=−∞
is found from
(b1z + b2)
Y (z) = G(z)U (z), G(z) =
(z 2 + a1z + a2)
• Difference equations
• Transfer functions
T
X1(z) = X2(z)
z−1
T
X2(z) = (k/m)(−X1(z) + U (z))
z−1
2
3
wdot Out2
Out3
z wddot w
Force T T
k 1/m 1
z−1 z−1
Out1
Step
Gain1 Gain2 Discrete−Time Discrete−Time
Integrator1 Integrator
1
In1
2
mass position, w
−1
−2
0 2 4 6 8 10 12 14 16 18 20
time, seconds
ẋ = Ax + Bu (2)
y = Cx + Du
• Difference equations:
where
Ad = I + T A, Bd = T B
Cd = C, Dd = D
0.8
0.6
0.4
0.2
imaginary
−0.2
−0.4
−0.6
−0.8
−1
p
• If T k/m is too large, the algorithm will diverge rapidly
• Other (more complicated) techniques for numerical integration
do preserve stability – but does it matter?
4 num integration.m
2
4
3
Velocity
Puck Position Force
wddot wdot w
z
1 1
k 1/m 1
s s
Virtual Mass
Step 1/virtual mass Integrator Integrator1 Position
spring
constant
2
3
wdot Out2
Out3
z wddot w
Force T T
k 1/m 1
z−1 z−1
Out1
Step Discrete−Time Discrete−Time
Gain1 Gain2
Integrator1 Integrator
1
In1
• Forward Euler:
y((k + 1)T ) = y(kT ) + T u(kT )
1 T
→
s (z − 1)
u(t)
T 2T 3T 4T
t
u(t)
T 2T 3T 4T
t
• Trapezoidal:
T
y((k + 1)T ) = y(kT ) + (u(kT ) + u((k + 1)T ))
2
1 T (z + 1)
→
s 2(z − 1)
u(t)
T 2T 3T 4T
t
1.5
0.5
−0.5
−1
−1.5
−2
0 1 2 3 4 5 6 7 8 9 10
time, seconds
• This procedure will still tend to amplify noise, which may still
need to be removed with a filter:
- analog filter (e.g., op amp circuit)
- digital FIR filter (e.g., moving average filter)
- digital IIR filter (e.g., lowpass filter)
• Issues:
- small step size needed for rapidly varying signals, but can
cause quantization error to accumulate for slowly varying
signals
- long step size better for slowly varying signals, but can
“miss” high frequency variations.