In a direct current circuit, the Voltage (E) current (I) and resistance (R) are related by a simple formula called Ohms Law:
E = IR
where E is measured in Volts, I in Amperes, and R in ohms. Computations involving the three quantities are straightforward.
It turns out that resistances in series are additive, R = R1 + R2 + R3 + ...
whereas those in parallel add in inverses 1/R = 1/R1 + 1/R2 + 1/R3 + ...
When one considers alternating current, the situation becomes more complex. Here, the voltage and current are not constant, but expressed as a sinusoidal wave over time.
E(t) = E0 cos(t+)
and likewise for I
(t) = I0 cos(t+ø).
Using Euler's law, (ei= cos + i sin) these can be expressed as E(t) = E0 ei(wt+) and I (t) = I0 ei(tø) where i is, as usual, .
The time dependent resistance of the circuit, (called the impedance and denoted Z), is affected by resistance and by two other types of components-capacitors and inductance coils. Denoting the three by ZR, ZL, and ZC for impedence due to resistors, capacitors, and impedence respectively, it can be shown that:
ZR = R
ZL = iL where L is the inductance in Henries
ZC = where C is the capacitance in Farads.
These impedances add in series and parallel in the same way as do resistances.
In general, such quantities have both a real part (still called the resistance) and an imaginary part (called the reactance).
Of course, the magnitude |Z| of an impedance Z = Z0 ei is abs (Z) and the phase angle is arg (Z). The effect of an RCL circuit is to filter the current and pass an altered current whose amplitude is reduced by a factor of |Z| compared to the original and whose phase is shifted by a quantity equal to the phase angle of Z.
An interesting property of circuits that have combinations of these three elements is called the transfer function. It is the ratio of the output voltage to the input voltage. Consider the RC circuit in figure 17.3 for instance.
Considering the ratio of the output voltage Vb to the input voltage Va, and denoting the voltage drop at the capacitor by Vc, one has for this circuit the transfer function H given by:
The magnitude of this result is the magnitude of the resulting voltage function, and the phase angle of the result is the shift in phase from the input voltage, which for purposes of making the calculation simple is assumed not to have been shifted at the start. The units of the frequency are radians per second. This particular computation has been encapsulated as follows:
DEFINITION MODULE TransferFunctions; (* This module contains one or more procedures to compute the transfer function or ratio of output voltage to input voltage as a complex quantity. The magnitude of the result is the amplitude of the resulting sinusoidal vave, and the phase angle is the phase shift from the starting phase angle. Each procedure takes parameters for the resistance, capacitance, and/or inductance of the circuit, and frequency of the input wave. *) PROCEDURE RCTransfer (res, cap, freq : REAL) : COMPLEX; (* computes the transfer function for the RC circuit --------|| ---------------- | | | | ~ input R output | | | | --------------------------- *) END TransferFunctions. IMPLEMENTATION MODULE TransferFunctions; FROM ComplexMath IMPORT one, i; PROCEDURE RCTransfer (res, cap, freq : REAL) : COMPLEX; VAR temp: REAL; BEGIN temp := freq * res * cap; RETURN (CMPLX (temp, 0.0) * i) / (one + CMPLX (temp, 0.0) * i); END RCTransfer; END TransferFunctions.
The imports one and i are the complex quantities 1 + 0i, and 0 + i, respectively. Here, the built in function CMPLX is employed to convert a pair of reals (a, b) to the complex quantity a + bi. One may also begin with a complex number and fetch the real and imaginary parts using:
re := RE (z); im := IM (z);
where re and im are both of type REAL and z is of type COMPLEX. RE and IM are standard identifiers.
What follows is a simple module to test this transfer function. It calls for the resistance and capacitance of the RC circuit and a range of frequencies over which to compute the transfer function, then translates this into an amplitude and phase shift for the output wave and prints a little table.
MODULE TestTransferFunctions; (* Module to test transfer functions and illustrate the use of complex numbers by R. Sutcliffe modified 1996 01 12 *) FROM STextIO IMPORT WriteString, WriteLn, SkipLine; FROM SRealIO IMPORT ReadReal, WriteFixed; FROM ComplexMath IMPORT zero, abs, arg; FROM TransferFunctions IMPORT RCTransfer; VAR count : CARDINAL; resistance, capacitance, frequency, startFreq, endFreq, amplitude, phaseShift :REAL; transFactor : COMPLEX; CONST step = 10.0; BEGIN WriteString ("This program determines the magnitude and phase effects "); WriteLn; WriteString ("of an RC circuit over an interval of frequencies "); WriteLn; WriteString ("entered by the user."); WriteLn;WriteLn; WriteString ("Enter the resistance in ohms "); ReadReal (resistance); SkipLine; WriteString ("Enter the capacitance in farads "); ReadReal (capacitance); SkipLine; WriteString ("Enter the starting frequency in radians per second "); ReadReal (startFreq); SkipLine; WriteString ("Enter the ending frequency in radians per second "); ReadReal (endFreq); SkipLine; frequency := startFreq; WriteString ("Frequency Magnitude Phase Shift"); WriteLn; WHILE frequency <= endFreq DO transFactor := RCTransfer (resistance, capacitance, frequency); amplitude := abs (transFactor); IF transFactor = zero (* can't feed to arg or get exception *) THEN phaseShift := 0.0 ELSE phaseShift := arg (transFactor); END; WriteFixed (frequency, 2, 10); WriteFixed (amplitude, 2, 10); WriteFixed (phaseShift, 2, 10); WriteLn; frequency := frequency + step END; WriteLn; WriteString ("Press a key to continue"); SkipLine; END TestTransferFunctions.
Like the constants zero, one, and i, the functions abs and arg are imported from the separate module ComplexMath. abs returns the magnitude of the complex number, and arg returns the angle it makes with the real axis. Runs of this test are printed below:
** Run log starts here ** This program determines the magnitude and phase effects of an RC circuit over an interval of frequencies entered by the user. Enter the resistance in ohms 10000 Enter the capacitance in farads .000002 Enter the starting frequency in radians per second 0 Enter the ending frequency in radians per second 200 Frequency Magnitude Phase Shift 0.0 0.0 0.0 10.00 0.20 1.37 20.00 0.37 1.19 30.00 0.51 1.03 40.00 0.62 0.90 50.00 0.71 0.79 60.00 0.77 0.69 70.00 0.81 0.62 80.00 0.85 0.56 90.00 0.87 0.51 100.00 0.89 0.46 110.00 0.91 0.43 120.00 0.92 0.39 130.00 0.93 0.37 140.00 0.94 0.34 150.00 0.95 0.32 160.00 0.95 0.30 170.00 0.96 0.29 180.00 0.96 0.27 190.00 0.97 0.26 200.00 0.97 0.24 Press a key to continue ** Run log starts here ** This program determines the magnitude and phase effects of an RC circuit over an interval of frequencies entered by the user. Enter the resistance in ohms 100 Enter the capacitance in farads .000002 Enter the starting frequency in radians per second 0 Enter the ending frequency in radians per second 200 Frequency Magnitude Phase Shift 0.0 0.0 0.0 10.00 0.00 1.57 20.00 0.00 1.57 30.00 0.01 1.56 40.00 0.01 1.56 50.00 0.01 1.56 60.00 0.01 1.56 70.00 0.01 1.56 80.00 0.02 1.55 90.00 0.02 1.55 100.00 0.02 1.55 110.00 0.02 1.55 120.00 0.02 1.55 130.00 0.03 1.54 140.00 0.03 1.54 150.00 0.03 1.54 160.00 0.03 1.54 170.00 0.03 1.54 180.00 0.04 1.53 190.00 0.04 1.53 200.00 0.04 1.53 Press a key to continue ** Run log starts here ** This program determines the magnitude and phase effects of an RC circuit over an interval of frequencies entered by the user. Enter the resistance in ohms 30000 Enter the capacitance in farads .000002 Enter the starting frequency in radians per second 0 Enter the ending frequency in radians per second 200 Frequency Magnitude Phase Shift 0.0 0.0 0.0 10.00 0.51 1.03 20.00 0.77 0.69 30.00 0.87 0.51 40.00 0.92 0.39 50.00 0.95 0.32 60.00 0.96 0.27 70.00 0.97 0.23 80.00 0.98 0.21 90.00 0.98 0.18 100.00 0.99 0.17 110.00 0.99 0.15 120.00 0.99 0.14 130.00 0.99 0.13 140.00 0.99 0.12 150.00 0.99 0.11 160.00 0.99 0.10 170.00 1.00 0.10 180.00 1.00 0.09 190.00 1.00 0.09 200.00 1.00 0.08 Press a key to continue
The first run (R = 10000 and C = .000002F) has low frequency currents scarcely making it through the circuit, whereas the higher frequency one are passed almost without distortion. When the resistance is lowered, the lower frequencies are almost entirely cut off, and the phase shift is large. When R is increased to 30000, the effect is present only for the very lowest frequencies. Such circuits (usually with several more elements) are often called filters because of these effects. Numerous other combinations of the resistance, inductance and capacitance are possible in such circuits, and each has its own transfer function.