Wednesday, May 30, 2012

Matlab - Complex Numbers

Complex numbers with freemat!! And phasors. Wow, wow.


Op-Amps: Practical Integrator

An integrator circuit is built as shown in the figure with the 10 Mohm resistor in parallel with the capacitor for leak resistance.
 



The input and output wave forms for 1kHz square wave inputs is graphed using a computer.

 


When the 10Mohm resistor is removed, there is considerably more noise in the wave form. The 10 Mohm resistor effectively reduces the leak resistance of the capacitor. If we assume a leak resistance of 100 Mohm already in the capacitor, as was discussed in the text, then the 10 Mohm parallel resistor creates a equivalent resistance of 9 Mohm.


So much more noise when compared to the other wave forms.

Impedance and AC Analysis

PROBLEM
We model a "real" inductor. We must include a series resistance to account for the resistance of the many turns of wire in the inductor. The impedance looking into a real inductor: Zreal = R + jwL

METHOD
We measure the inductor's "unknown" resistance with an ohmmeter. R = 7.8 ohms



We set Rext = 68 ohms, measure and record your mounted resistor. Rext(actual) = 68.5 ohms

Energize the FG. Set the frequency to be 20kHz sinusoid. Set RMS to be 5.00. Connect a DMM to the output of the FG and ensure you have 5.00 Vrms out of the FG.

Next we construct a circuit similar to the figure.
Using a DMM, measure Vin and I in.
Vin(rms) =  5.23 V
I in(rms) = 22.11 mA

Calculate the magnitude of the impedance using the voltage and current from above.
Z=V/i = 236.5 ohms

Rewrite input impedance as a complex number: R + jwL = 7.8 + 279j ohms
|Z| = 279 ohms

What is the angular frequency at which the circuit is operating?   w = 40*pi Krad/s


7.8 + 40piKL = 236.5 >> L = 1.82 mH
Consider the circuit below. Suppose our source is set to 20kHz. We wish the capacitor to cancel the inductive part of the real inductor. Calculate the value of the capacitance.
This occurs at resonance >> wL=1/wC >> C=1/(L*w^2) >> C = 28nF


Energize the scope. Connect CH1 Across the DMM. Connect CH2 to the top of the real inductor. Adjust the scope to see both waveforms. Take scope measurements at 20kHz.

Vpeak2peak(CH1) = 10 V
Vpeak2peak(CH2) = 24 V
dt = 14.5 us

phase_difference = Tx(f)(360) = 94 degrees

DATA
Frequency Vin (V) I in(A) |Z in| (ohms)
5 kHz 5.78 7.1 0.814
10 kHz 5.41 20.1 0.269
20 kHz 5.03 60.1 0.084
30 kHz 5.88 0.00 Infinite
50 kHz 8.24 0.00 Infinite



 
 
 

AC Signals

PROBLEM
Consider two signals captured in the same scope display. We find the phase difference between the two signals by measuring the time difference(tx) between corresponding parts of the two waveforms - between the positive peaks. We convert this time measurement into an angle so we need to multiply it by the angular frequency(2*pi*f) and convert the result to degrees(180/pi):

     phase_angle = tx(2pi)(f)(180/pi) = tx(f)(360)

METHOD
Set Function Generator(FG) to CH1, set the FG to produce a 10V peak-to-peak sinusoid at 1kHz.
Calculate the expected Vrms - Expected Vrms = 7.04 V
Calculate the DMM value     - Measured Vrms = 6.7 V


Turn of FG. Set Rbox to 1kOhm. We calculate the complex impedance of the capacitor where Zcap=1/2*pi*f*C >>> Zcap = 1592 ohms

We construct a circuit similar to the figure.
Connect CH1 of the scope to the FG. Connect CH2 to the top of the capacitor (between Rbox and C). Connect Rbox and C as shown. Be sure to make connections as shown. Energize the FG; connect the DMM.
DATA

Measure the peak-to-peak capacitor voltage on CH2: Vcap = 18 V , Vrms(DMM) = 6.36 V
Measure Tx from the two waveforms (Tx is time difference) -- Tx= 0.06 s
Compute the phase angle: phase_angle = 34.3 degrees

CH1 leads CH2 by phase_angle


Increase the FG frequency to 10kHz. Calculate new complex impedance of capacitor.
Zcap = 159 Ohm

Measure the peak-peak capacitor voltage on CH2: Vcap = 3.75 V
Record Vrms from DMM: Vcap(rms) =  0.89 V
Measure Tx from the two waveforms (Tx is time difference) -- Tx= 8 us
Compute the phase angle: phase_angle = 28.8 degrees


RETURN THE FG frequency to 1kHz!!! Increase Rbox to 10kOhms.
Measure the peak-peak capacitor voltage on CH2: Vcap = 1.6 V
Record Vrms from DMM: Vcap(rms) =  1.12 V
Measure Tx from the two waveforms (Tx is time difference) -- Tx= 150 us
Compute the phase angle: phase_angle = 54 degrees

Adjust Rbox until capacitor voltage is 4V peak-to-peak. Record Rbox.  --- Rbox = 4kOhms
Record Vcap(rms) from DMM. --- Vcap(rms) = 2.56 V
Measure Tx from the two waveforms (Tx is time difference) -- Tx= 130 us
Compute the phase angle: phase_angle = 46.8 degrees


Finally, vary the FG from low to high frequency and observe the impact on the capacitor voltage amplitude.

The capacitor voltage amplitude is greatest when the frequency is in the low range, and voltage amplitude is smallest at higher frequencies. This circuit is a lowpass filter. The resistor will always lead even when we adjust the frequency. At high frequencies, the two signals tend to a Tx of 10.5 us.
 

Charging/Discharing a Capacitor

PROBLEM
Design, build, and test a charge/discharge system that utilizes a 9V DC power supply, employs a charging interval of about 20s with stored energy of 2.5mJ, and then discharges that energy energy in 2s.

METHOD
We consider charging and discharging a capacitor. We will toggle a cable connected to the capacitor's "+" terminal from the CHARGE position to the DISCHARGE position. In the CHARGE position, as long as Vs > Vcap, energy is transferred to the capacitor. In the DISCHARGE position, the energy is absorbed by the resistance Rdischarge. In either case, C, Rcharge, and Rdischarge control the rate at which energy is transferred.
Additionally, we will add a leak resistance in parallel with the capacitor to model a "real" storage capacitor and not the ideal case. A circuit is constructed similar to the figure. We compute Thevenin voltage and resistance as "seen" by the capacitor for each case.

"Real" capacitor circuit
Thevenin charge circuit

Thevenin discharge circuit
We first compute the required capacitance. W=1/2CV^2 >> C=2W/V^2 >> 2*2.5/81 = 62 uF
Next, we compute the charging resistance. T=capacitive time constant. T=charge_time/num_charge_intervals =RC >> 20/5=62R >> R=4/62uF >> Rcharge = 64.8 kOhm
Now we can compute the peak current in the charge resistance and the peak power. Where, i=(Vs/R)*e^(-t/T) = 0.936 uA  & P=Vs*i=9*0.936=8.4 uW

We use a similar technique to compute the discharge resistance. T=capacitive time constant. T=charge_time/num_charge_intervals =RC >>2/5=R62uF >> Rdischarge = 6.48 kOhm.
We calculate the peak discharge current and power. V=IR>> I =V/R >> 9/6.48k = 1.389 mA, P=R*I^2 >> (6.48k)*(1.389)^2 >> P= 0.0125 W

charging
charging & discharging



Op-Amps - LM358 & AS35 - Temperature Sensor

PROBLEM
Op-amps are often used in scaling and level-shifting applications. Scaling is simply the process of multiplying a signal voltage/current by a constant in order to change its amplitude, and level-shifting is the process of adding a constant positive or negative voltage/current to a signal. This lab uses scaling and level-shifting of a circuit to process the output signal from an electronic temperature sensor so that it produces temperature readings in Fahrenheit degrees. The sensor produces an output voltage that is proportional to the ambient air temperature according to a scale factor of 10mV/C

METHODS
A circuit is constructed similar to the scaling and level-shifting circuit shown in the figure. The output voltage is converted from a 10Mv/C scale to a 10MV/F scale.

Scaling and level-shifting circuit -- Rvar is used to create the appropriate voltage at the inverting input for the level-shift


The scaling and level-shifting equation. Tf=1.8Tc+32 -- Vc = (1+R2/R1)Vc - (R2/R1)Vref

Hence, R2/R1 = .8 -- R2 = 800 Ohm, R1 = 973 Ohm

The ambient temperature in the room that day was 23C. Tf = 1.8*23 + 32 = 73.4 F


Voltage reading Vf -- 720 mV = 72 F degrees
 The percent error is calculated: absval(actual - theoretical)/theoretical*100% = (72-73.4/72)*100 = percent error = 1.9%err