Friday 3 October 2014

Basic Building Blocks: Frequency, Relays, Logic Circuits

Basic Building Blocks: Frequency, Relays, Logic Circuits

Introduction:
In this lab we will experiment with some of the basic building blocks that we will use throughout the quarter. The first part of the lab asks you to experiment with an instrument called an oscilloscope that you can use to "watch" signals that vary rapidly in time. You will use the oscilloscope (also called simply "scope") to look at the shape, amplitude, and period of some typical signal waveforms. You will experiment with how these signals sound, and how they look when we use them to turn a light on and off. You will experiment with how fast your eyes and ears can respond to sound and light signals.
One recurring topic in this course is the variety of "switches" used in electrical engineering. You will use two types of automatic switches in this lab. The first is called a relay. A relay is an electromechanical device used as a switch. With a relay we can allow a control circuit operating at small currents and voltages (like a computer) to control another device which operating at higher currents or voltages (like a motor). In this lab we will use the relay to control a light. The second type of switch we will use is a device called a transistor (more precisely, a bipolar junction transistor or BJT). The transistor is smaller, lighter, and faster than a relay (each of these by one or more orders of magnitude) but may not be able to handle as much current.
Finally, you will begin to learn how to use switches (in particular, BJTs in a particular configuration) to make circuits, called logic circuits, which can, in effect, evaluate a sequence of conditions and "decide" what action to take. This concept is the heart of digital electronics, which itself is the heart of much of current electrical and computer engineering. In the next lab we will use transistors that are manufactured, many at a time, in an integrated circuit, or "chip"
Some advice for this lab: be sure to select resistors carefully---using the wrong resistance value (for instance 10kW instead of 1kW or vice-versa) can keep your circuit from working properly.
Pre-lab Preparation:
  1. Read the lab.
  2. Answer the 6 Pre-lab questions (designated Q0 to Q5) in your notebook.
  3. Bring your lab notebook.
Part I - Frequency
0. Because we are going to be discussing frequency and voltage in this lab, let us begin with a pre-lab question which every electrical engineer should be able to answer. Q0: What are the voltage and frequency normally provided for lighting and everyday use in the United States If you are native of another country, what are these values in your home country? Note that there are exceptions for items such as electric stoves and for industrial applications.
1. In this part of the experiment you will use a function generator to drive an audio speaker. The function generator can produce a sinusoidal waveform, a square wave (i.e. a train of pulses whose amplitude alternates rather abruptly between +V and -V volts in a periodic fashion), and a triangle wave (which changes linearly between +V and -V volts in a periodic fashion). If you use the sinusoidal waveform to drive the speaker: Q1: What change in the sound do you expect to hear when you increase the amplitude of the sinusoidal signal on the function generator? Q2: What change in the sound do you expect to hear when you increase the frequency of the sinusoid? Configure the Tektronix function generator to produce a sinusoidal signal at a frequency of 1 kHz with a 10 volt peak-to-peak level (± 5 volts). Observe the function generator output waveform on the oscilloscope using a BNC cable.
2. Use the BNC "T" to connect the function generator output signal to both the oscilloscope and one of the audio speaker provided in a box in the lab. What happens to the peak voltage level seen on the oscilloscope when you "load down" the function generator by connecting to the speaker? (Note: If you use one of the smaller speakers which were purchased recently, it is likely that nothing will happen. In that case, explain what would happen if you used a larger speaker, which has a smaller resistance.) Vary the frequency and amplitude of the sinuosoidal signal. Do what you hear (speaker) and measure (oscilloscope) make sense? Were your answers to Questions 1 and 2 above correct? (It's fine if they were not correct, just comment on this here.) Determine the frequency of the waveform using the "Measure" button on the oscilloscope. How well do the oscilloscope and the signal generator agree?
3. Determine the upper and lower frequency limits of the speaker/human ear system. What is the highest frequency that you can hear? Do both members of your team have comparable low and high frequency limits on what they can hear? The commonly quoted limits of human hearing are 20 Hz to 20 kHz. Can you get close to those values? If not, any idea why not? How does the loudness of the sound change as you change frequencies? which frequencies sound loudest? Gently touch the speaker diaphragm as the speaker is operated. What frequency vibrations can you feel? Why do you think this frequency range is different than the frequency range for hearing?
4. For this part, you will work with your neighbors at an adjacent workbench. Have one team play a sinusoidal tone into a speaker at a frequency between 500 and 2 kHz. Without knowing the frequency, the second team is to vary the frequency of its generator until an audio "match" is detected between the two speakers. How closely can you match up the tones using your ears? Record both the parameters you choose for your experiment with your neighbors and your quantitative results, that is, how close you got to matching.
5. Change the frequency back to 1 kHz. Compare the sounds emitted by your speaker when the driving signal is a sinewave versus a squarewave. You may have to listen quite closely to hear the difference, and you should try to compensate for the difference in loudness when you compare (this is hard to do precisely with this function generator). The squarewave contains frequencies that are integral (specifically 3,5,7...) multiples of 1 kHz. These are called harmonics.
6. One way that messages are sometimes sent in a digital communications system is to use a technique called Frequency Shift Keying (FSK). In the simplest case of FSK, we send a binary message, that is, a string of ones and zeros. The "zero" symbol is signaled by sending one frequency, and the "one" symbol by sending another frequency. Suppose ECE students Sally Static and Vince Voltage decide to use this scheme so that Sally can send Vince her e-mail address. Vince will have to decide which sinusoid has been sent in order to decode each symbol that Sally is sending. Since Sally might well be sending two consecutive ones or two consecutive zeros, the two of them must agree ahead of time how long the sinusoidal signal for each symbol will last. For example (these numbers are not realistic, they are just for illustration), suppose they decide a zero will be signaled by sending a 1 kHz sinusoid and a one by sending a 2 kHz sinusoid and Vince needs 1 second to determine which sinusoid is being sent. So if Vince sees 3 seconds of a 2 kHz sinusoid followed by 1 second of a 1kHz sinusoid, he knows that Sally is sending him the string 1110. Their message rate is 1 bit per second (which is pretty slow, so it is good that she is only sending an e-mail address!)
     Experiment with using the function generator-speaker setup as an FSK system. Remember that the message (i.e. the one and zero symbols) do not correspond to the sound being on or off, respectively, but instead are signaled by recognizing which of the two frequencies is being sent. Try to determine how many bits (that is, symbols) you can reliably send per second. Record the parameters of your FSK system; the frequencies used and the resultant signal bit rate in bits/second. What limits your bit rate? (This is a very slow, primitive FSK system; the reason for this exercise is to get the idea of what a FSK system does. In real communication systems the frequency change and the detection are done automatically by electronic circuits.)
Ask if these instructions are confusing!
Part II - Electromechanical Relays
CAUTION - you will be switching 120 VAC mains during this experiment. Have the instructor or the TA inspect your circuitry before you attach the plug to the 120 VAC receptacle.
1. Collect a relay and lamp assembly from the cabinet in the laboratory. Remove the relay from its socket and inspect it. Can you figure out how it works?
2. Plug the relay back into its socket. Attach the black wire to the negative terminal of the DC power supply at your workbench. Set the voltage to 12 VDC. Note what happens to the relay when you momentarily touch the red wire to the positive terminal of the power supply. What causes the clicking sound?
3. Attach the plug on the relay assembly to a 120 VAC receptacle. Note what happens to the lamp when you attach the red wire to the positive terminal of the DC power supply. Explain.
4. Experiment with toggling the lamp using the relay and function generator. Use the square wave output of the function generator to turn the relay on and off. Since the relay will close again after a short delay when you reverse the current, you will need to use the "DC Offset" function on the generator to get +12 volts on the "HI" part of the square wave and 0 volts on the "LO" part. (Alternately, you may have a diode connected across the relay input that will short out the current through the relay in one direction.) Observe the generator output with the oscilloscope set on "DC Coupling" to make sure that you know what the output is.
What is the maximum switching frequency at which you can see the light turn on and off? Is this the same maximum frequency as you found in Lab 1, Part III, when you connected the LEDs to the function generator? If it is different, why do you think it is different? Try this experiment using all three types of signal waveforms on the function generator. Make a table showing the maximum switching frequency you can see for each type of waveform, as well as whether it looks always on or always off when you exceed that frequency. Summarize your results.
Part III - Simple Logic Circuits
This series of experiments deals with digital electronics. By digital, we refer to circuits designed to process signals with input and output levels that represent clearly distinct high and lowconditions. high might be a voltage level between 4 and 5 volts, for instance, while low might be a level anywhere between zero and 2 volts. We do not care about the precise value of a voltage provided it is within one of these two bands so that we can easily ascribe the level to either the high or the low state. We will be using the terms high and low synonymously with the "logical states" 1 ("True") and 0 ("False"), respectively. All of this is in contrast to analog electronics where we are often concerned with the precise values of voltages or currents at any given node in a circuit. You experimented with analog voltages in Part I. when you hooked the sinusoidal generator to a speaker. As you gradually changed the amplitude of the sinusoidal voltage, the sound changed too. You also worked with digital states in Part II: the relay-lamp assembly was either ON or OFF.
Bipolar junction transistors (BJTs) are three-terminal semiconductor devices made from silicon and other elements. You will learn about the fabrication, physics, and engineering uses of these devices as amplifiers and switches in a more formal manner later in the ECE curriculum, but in today's experiment, you will be using them as solid state switches. The schematic symbol and equivalent circuits for an NPN BJT is shown in Figure 1 below. The three terminals on the transistor are the collector (C), the base (B) and the emitter (E). The TA will show you in the lab how to recognize which is C and which E; B is the middle one. Record the pin diagram in your lab book so you won't have to ask again!
A BJT can approximate a single-pole-single-throw (SPST) switch between terminals C and E by changing the voltage across terminals B and E. The transistor is turned ON (closing the circuit between C and E, thereby allowing current to flow between these terminals) by applying a positive voltage of about 1 volt across BE. (The arrow between B and E indicates the direction of the control current; a small current from B to E will allow a much larger current to flow from C to E - the direction is important!.) Then the On Model shown below gives a reasonable approximation for the how the transistor behaves. The transistor is turned OFF (opening the circuit between C and E, thereby preventing current from flowing between these terminals) by removing the control voltage and shutting off the current from B to E. The model for this state is the Off Model shown below. Note that the function of the transistor is very similar to the function of the relay in Part II.
Figure 1. Bipolar transistor symbol and simple on and off models.
BJT's can be used as switches to create gates that implement logical operations on digital signals. The gates you will build below are called Resistor-Transistor Logic (RTL) because they depend on using transistors as switches with "pull-up" or "pull-down" resistors to make the logic functions work properly.
1. Configure the "Emitter Follower" circuit shown in Figure 2 using one of the transistors supplied. Use a +6V supply to the collector of the transistor. Is the output high or low when the input is 6 volts (high, a logical 1)? What is it when the input is 0 volts (low, a logical 0)? Reproduce the input/output table shown in your notebook and fill in the experimentally determined values of voltage measured when the output is 1 or 0. A circuit that performs a logic function like this is called a "gate". The input/output table you just produced is called a "truth table". Its purpose is to show the output under all possible input conditions. Here you have only one input, which can have only two states (HIGH or LOW, 1 or 0). Q3: If you had two inputs, how many rows would you need for your table? Three inputs? N inputs? Q4: Why is the "pull down" resistor needed between the emitter and ground? (Hint: Use the equivalent circuit models - the 'On' and 'Off' circuits above - to try to understand the answer. Is it possible to determine what Vout would be when the transistor is off if there were nothing connected to the emitter terminal? What would happen if we were to replace the resistor with a length of wire to accomplish pull-down?) The value of the resistor is chosen to limit the amount of current that flows from the power supply, through the collector-emitter terminals, and then to ground when the transistor is on.
Figure 2. Emitter follower circuit
2. The "complement", or opposite, of a logic level is obtained using a NOT gate having logic as shown in Figure 3. Note that a pull-up resistor is used in this circuit rather than a pull-down resistor. When the transistor is OFF, the output signal is pulled HIGH by the resistor. When the transistor is ON, the output signal is LOW since it is connected to ground through the CE junction. The letter with the bar over it means logical complement, or the opposite state, of the logic variable. Q5: What would happen if the resistor were removed or replaced by a length of wire? Construct the circuit shown and verify its operation by constructing a truth table indicating the actual voltages measured.
Figure 3. NOT gate implemented using an NPN transistor.
3. Configure an OR gate using a pair of transistors as shown in Figure 4. An OR gate is a circuit whose output is HIGH if either input (or both) is HIGH, and LOW only if both inputs are LOW. (Note that the logic term "HIGH" means a that a voltage is somewhere between 4 and 6 volts; whereas a "LOW" level is a voltage is near zero volts, say zero to 0.5 volts) Connect and disconnect wires from +6 V to points A and B to pull the inputs high (logic 1 or +4V to +6V) or low (logic 0, <0.5V). Remember that when the base voltage goes HIGH the transistor turns on and the collector and emitter are connected to each other as in the 'On Model' circuit above. When the applied input base voltage is removed the transistor turns off. NOTE: The base inputs need not be grounded in this case; they may be left floating. The logic symbol and input-output "truth table" for an OR gate are shown below. Verify the operation of this circuit by fabricating it on your breadboard and filling out a truth table including the output voltages actually measured in your notebook.
Figure 4. OR gate implemented using NPN transistors.
4. Configure an AND gate using a pair of transistors as shown in Figure 4. The output of an AND gate is HIGH only if both inputs are HIGH, and LOW otherwise. Control the input signals as discussed in the previous problem. This AND gate circuit is very sensitive to the values selected for the resistors which may differ depending on the individual transistors used - even different transistors from the same bin. (This is one reason that the RTL logic gates that we have constructed has been superceded by TTL gates that we will use in the next lab.) Experiment to find the value of R required for proper operation for all possible inputs. The logic symbol and truth table for the AND gate are shown below. Verify the operation of this circuit by fabricating it on your breadboard and filling out a separate truth table (including actual voltages measured) in your notebook.
Figure 5. AND gate implemented using NPN transistors.

>>When you get the circuit in Figure 5 working, get the lab instructor or TA to sign your lab book under your diagram of the circuit to indicate that it worked.<<
5. RTL Implementation of NAND or NOR gate. The NOT function can be combined with AND and OR gates to form NAND and NOR gates having the logic symbols and truth symbols shown in Figure 6 below. Note that the difference between the symbol for an AND (or OR) and a NAND (or NOR) is the little circle at the output end of the diagram. Construct either one of these gates and verify its operation by completing a truth table from your measurements. Note that you do not have to build both gates, just one of them. You can use pushbutton switches (circuit symbol shown in Figure 7) to control the inputs, or just use wires.
   
Figure 6. NAND and NOR gate symbols and truth tables.

Figure 7. Circuit symbol for switch.

No comments:

Post a Comment