ENGG 1015 Tutorial Op Amps and Signals 19 Nov Learning Objectives News Analyze circuits with operational amplifiers Convert between representations of systems HW2 deadline (19 Nov 23:55) Revision tutorial (TBD) Ack.: MIT OCW 6.01, 6.003 1 Simple Op Amps (1) Assume the op-amps are “ideal” Determine the current Ix when V1 =1V and V2 =2V. Determine the voltage VA when V1 =1V and 2 =2V. Determine a general expression for VA in terms of V1 and V2. 2 Simple Op Amps (2) When V1 =1V and V2 =2V, Ix =1A When V1 =1V and V2 =2V, VA = 4V 2 A general expression for VA: 𝑉𝐴 = 𝑉2 + 𝐼𝑥 × 2 𝑉2 − 𝑉1 = 𝑉2 + ×2 1 = 𝑉2 + 2 𝑉2 − 𝑉1 = −2𝑉1 + 3𝑉2 4 2 1 -1 1 3 Non-inverting Amplifier Vn Use a single op-amp and resistors to make a circuit that is equivalent to the following circuit. 𝑉𝑛 𝑅2 = 1+ 𝑉𝑖 𝑅1 𝑉𝑜 𝑉𝑜 𝑉𝑛 𝑅3 = = 1+ 𝑉𝑖 𝑉𝑛 𝑉𝑖 𝑅4 =1 𝑅2 1+ 𝑅1 𝑅1 𝑅4 +𝑅2 𝑅3 +𝑅2 𝑅4 + 𝑅1 𝑅3 4 Voltage-controlled Current Source Use the ideal op-amp model (V+ = V-) to determine an expression for the output current Io in terms of the input voltage Vi and resistors R1 and R2. 𝑣𝑥 = 𝑣𝑖 + 𝑣𝑥 𝑅2 ⇒ 𝑣𝑥 = 𝑣𝑖 𝑅1 𝑅2 𝑅1 + 𝑅2 vi +vx vi +vx vx 𝑣𝑥 1 𝑅2 𝑣𝑖 𝐼𝑜 = = 𝑣𝑖 = 𝑅2 𝑅2 𝑅1 𝑅1 5 Op Amp Configurations (1) Fill in the values of R1 and R2 required to satisfy the equations in the left column of the following table. The values must be non-negative (i.e., in the range [0,∞]) R1 R2 Vo = 2V2 - 2V1 Vo = V2-V1 Vo = 4V2 - 2V1 6 Op Amp Configurations (2) 𝑉+ = 𝑅2 𝑉2 10𝑘+𝑅2 𝑉𝑜 = 10𝑘+𝑅1 10𝑘+𝑅2 × = 𝑉− = 𝑅2 10𝑘 × 𝑉2 − Negative R i.e. Impossible 3rd: 𝑅1 𝑉1 10𝑘+𝑅1 𝑅1 10𝑘 + 10𝑘 𝑉𝑜 10𝑘+𝑅1 × 𝑉1 R1 R2 Vo=2V2-2V1 20kΩ 20kΩ Vo=V2-V1 20kΩ 20kΩ Vo=4V2-2V1 Impossible Impossible 7 Unusual Op Amp Configurations What is Vo? Vo = 0 Vo = V1 – V2 8 Motor Control (1) The following circuit is a proportional controller that regulates the current through a motor by setting the motor voltage VC to VC = K(Id − Io) where K is the gain (notice that its dimensions are ohms), Id is the desired motor current, and Io is the actual current through the motor. 9 Motor Control (2) Consider the circuit inside the dotted rectangle. Determine V1 as a function of Io. V+ = 1/2 x Io = VV- = 100/(100+9900) x V1 V1 = 1/2 x Io x 100 Determine the gain K and desired motor current Id. KCL at -ve input to right op-amp: 𝑉𝑐 − 2.5 2.5 − 0.5 × 𝐼𝑜 × 100 = ⇒ 𝑉𝑐 = 50 0.1 − 𝐼𝑜 10000 10000 10 Multiple Representations of Systems State machines: computationally efficient. Difference equations: mathematically compact. Signal flow graphs: illustrate signal flow paths. Operator representations / z-transforms: analyze systems as polynomials. 11 From Blocks to Equations (1) Determine the difference equation that relates x[·] and y[·]. 12 From Blocks to Equations (1) Assign names to all signals. Replace Delay with R. Express relations among signals algebraically. E = X +W ; Y = RE ; W = RY Solve: Y = RE = R(X +W) = R(X + RY ) RX = Y − R2Y Difference equation: y[n] = x[n − 1] + y[n − 2] 13 Operator Algebra (1) Start with X, subtract 2 times a right-shifted version of X, and add a double-right-shifted version of X 14 Operator Algebra (2) 15 Quick Checking How many of the following systems are equivalent? 3 16 Geometric Growth The value of p0 determines the rate of growth. p0 > 1: magnitude diverges monotonically 0 < p0 < 1: magnitude converges monotonically −1 < p0 < 0: magnitude converges, alternating sign p0 < −1: magnitude diverges, alternating sign 17 Computing Responses (1) A given linear, time-invariant system turns the unit pulse into the triangle: The system is given the following input signal: Sketch the output signal. 18 Computing Responses (2) Consider the system described by y[n] = x[n] + y[n − 1] + 2y[n − 2] . Assume that the system starts at rest and that the input x[n] is the unit-step signal u[n]. We can compute the response through the iterating the difference equation. 19 Analysis of a Simple System (1) Consider a system H which transforms an input signal X into an output signal Y Suppose the input signal is a unit sample: and for that input, the samples of the output response signal are: Block diagram: 20 Analysis of a Simple System (2) Consider the input Let y[n] be the output response to x[n], as given in part 1, above, and let y′[n] be the output response to input x′[n]. y′[n] = y[n] − 16y[n − 4] y′[0] = 1 y′[1] = -2 y′[2] = 4 y′[3] = −8 y′[4] = 16 − 16 = 0 21 Difference Equation Construction (1) Newton’s law of cooling states that: The change in an object’s temperature from one time step to the next is proportional to the difference (on the earlier step) between the temperature of the object and the temperature of the environment, as well as to the length of the time step. Let o[n] be temperature of object, s[n] be temperature of environment, T be the duration of a time step, K be the constant of proportionality 22 Difference Equation Construction (2) The difference equation for Newton’s law of cooling i) the difference (on the earlier step) between the temperature of the object and the temperature of the environment ii) as well as to the length of the time step Be sure the signs are such that the temperature of the object will eventually equilibrate with that of the environment. The system function corresponding to this equation 23 Signals and Feedback Control (1) X : Desired temperature Tset Y : Actual hot water temperature THW The sensor reads THW with gain ks, but has a unit delay. The valve also takes a unit delay to respond, and has some persistence about its motion, characterized by kv. The proportional controller, with setting k, converts the temperature difference between Tset and the sensed temperature to a signal input to the valve. 24 Signals and Feedback Control (2) The difference equation: y[n] = kax[n − 1] − kvy[n − 1] − kskay[n − 2] Assume the system starts at rest, and the input is a unit sample signal x[n] (i.e. x[n] = [1,0,0,0,…]), suppose kv = 0.9 and ka = 0.5 When ks = 0 y[0] = 0 y[1] = 0.5 (1) – 0.9 (0) – 0 = 0.5 y[2] = 0.5 (0) – 0.9 (0.5) – 0 = – 0.45 y[3] = 0.5 (0) – 0.9 (– 0.45) – 0 = 0.405 y[4] = 0.5 (0) – 0.9 (0.405) – 0 = – 0.3645 25 Signal and Feedback Control (3) When ks = – 0.35 y[n] = 0.5 x[n − 1] − 0.9 y[n − 1] − 0.5 ks y[n − 2] y[0] = 0 y[1] = 0.5 (1) – 0.9 (0) – (– 0.35)(0.5) (0) = 0.5 y[2] = 0.5 (0) – 0.9 (0.5) – (– 0.35)(0.5) (0) = – 0.45 y[3] = 0.5 (0) – 0.9 (– 0.45) – (– 0.35)(0.5) (0.5) = 0.4925 y[4] = 0.5 (0) – 0.9 (0.4925) – (– 0.35)(0.5) (– 0.45) = – 0.522 When ks = 1.5 y[0] = 0 y[1] = 0.5 (1) – 0.9 (0) – (1.5)(0.5) (0) = 0.5 y[2] = 0.5 (0) – 0.9 (0.5) – (1.5)(0.5) (0) = – 0.45 y[3] = 0.5 (0) – 0.9 (– 0.45) – (1.5)(0.5) (0.5) = 0.03 y[4] = 0.5 (0) – 0.9 (0.03) – (1.5)(0.5) (– 0.45) = 0.3105 26 Grow, baby, grow (1) In each time period, every cell in the bioreactor divides to yield itself and one new daughter cell. However, due to aging, half of the cells die after reproducing. Po : The number of cells at each time step. Po[n] = 2Po[n−1] − 0.5Po[n−2] Suppose that Po[0]= 10 and Po[n]= 0 if n<0. Po[0] = 10 Po[1] = 2Po[0] − 0.5Po[-1] = 20 + 0 = 20 Po[2] = 2Po[1] − 0.5Po[0] = 40 − 5 = 35 Po[3] = 2Po[2] − 0.5Po[1] = 70 − 10 = 60 27 Grow, baby, grow (2) Your goal is to create a constant population of cells, that is, to keep Po constant at some desired level Pd. You are to design a proportional controller that can add or remove cells as a function of the difference between the actual and desired number of cells. Assume that any additions/deletions at time n are based on the measured number of cells at time n−1. Denote the number of cells added or removed at each step Pinp. The difference equations Po[n] = 2Po[n − 1] − 0.5Po[n − 2] + Pinp[n] Pinp[n] = k(Pd[n] − Po[n − 1]) 28 Grow, baby, grow (3) Draw a block diagram that represents the system Po[n] = 2Po[n − 1] − 0.5Po[n − 2] + Pinp[n] Pinp[n] = k(Pd[n] − Po[n − 1]) Delays + Adders + Gains 29 Stepping Up and Down (1) Use a small number of delays, gains, and 2-input adders (and no other types of elements) to implement a system whose response (starting at rest) to a unit-step signal [1,1,1,…] is [1,2,3,1,2,3,1,…] Draw a block diagram of your system. 30 Stepping Up and Down (3) First find a system whose unit-sample response is the desired sequence. The periodicity of 3 suggests that y[n] depends on y[n − 3]. The resulting difference equation is y[n] = y[n − 3] + w[n] + 2w[n − 1] + 3w[n − 2]. [1,0,0,…] [1,2,3,1,2,3,1,…] 31 Stepping Up and Down (3) Next compute w[n] which is the first difference of x[n]: w[n] = x[n] − x[n − 1]. The result is the cascade of the first difference and the previous result. [1,0,0,…] [1,2,3,1,2,3,1,…] [1,1,1,…] 32 Summary Response Difference equations Signal flow graphs Operator representations Signal flow graphs Difference equations Operator representations Signal flow graphs 33 Appendix: Partial Fractions 1 𝑓 𝑥 = 2 𝑥 + 2𝑥 − 3 The denominator splits into two distinct linear factors: 𝑞 𝑥 = 𝑥 2 + 2𝑥 − 3 = 𝑥 + 3 𝑥 − 1 1 𝑥 2 +2𝑥−3 ⇒𝑓 𝑥 = Multiplying through by x2 + 2x - 3, we have the polynomial identity 1 = 𝐴 𝑥 − 1 + 𝐵 𝑥 + 3 Substituting x = -3 into this equation gives A = -1/4, and substituting x = 1 gives B = 1/4, so that 1 −1/4 1/4 𝑓 𝑥 = 2 = + 𝑥 + 2𝑥 − 3 𝑥 + 3 𝑥 − 1 = 𝐴 𝐵 + 𝑥+3 𝑥−1 34 Appendix: Complex Numbers (1) Complex number z = x (Real) + yi (Imaginary) Complex conjugate of z = x + yi is defined to be x − yi 35 Appendix: Complex Numbers (2) Polar expressions Argument φ and Modulus/magnitude/absolute value r The argument or phase of z is the angle of the radius OP with the positive real axis 36