ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 12.06.2025

Просмотров: 1654

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

Chapter 1: Analog Voltage and Binary States · Page 1

Chapter #1: Analog Voltage and Binary States

This series of experiments introduces analog and digital electronics. What does that mean? In What’s a Microcontroller? we learned that analog is a “continuously variable value”. Another way to think about it is that analog electronics is analogous to nature.

There are lots of continuously variable values in nature, such as motion, light level, and sound. The position of a door as it swings open is a good example of a continuously variable value. As a door swings from all the way closed to all the way open, it visits every value in between. At one instant during its travel, it is 1/3 of the way open. At another instant, it is 1/2 way open, and so on.

INTRODUCTION TO ANALOG AND DIGITAL

Digital simply means represented by digits. Think about how many times each day you encounter analog values that are represented with digits. The temperature is 79.8 degrees. The speed limit is 45 miles per hour, etc. Not surprisingly, digital electronics represents values with digits.

The term digital is also used when referring to binary devices such as the circuitry that makes a calculator work, the microprocessor in a computer, and the BASIC Stamp microcontroller. It's true - they are all digital devices. Binary devices are digital devices using two digits, 0 and 1.

The experiments in What’s a Microcontroller? introduced a variety of techniques for interfacing with the outside world and other devices. These interfaces were mostly binary. This series of experiments extends the capabilities of interfacing by introducing several analog component interfaces and more component interface techniques.

In this first experiment, we'll build a circuit that produces an analog voltage at its output. Remember that analog voltage is continuously variable. The circuit will be adjustable so that it can produce an output anywhere between 0 and 5 volts. We'll also build a circuit called a voltage follower that uses this analog voltage to drive an LED circuit.

Page 2 · Basic Analog and Digital

Volt/Voltage: The volt is a fundamental unit of electrical measurement named after 18th century physicist Allesandro Volta, and a measurement in volts is referred to as voltage.

Most of us encounter this unit of measurement when buying batteries such as the 9 volt (DC) battery that can be used to power the Board of Education. Inside a battery there are two chemical reactions, which are separated from each other by a barrier. One of the reactions creates a surplus or electrons and the other creates a shortage of them.

The electron surplus and shortage sides of the barrier are connected to the negative and positive terminals of the battery respectively. If given a pathway around the barrier, the electrons have the potential to do work to get from the negative to the positive terminal. The volt is a measure of this potential to do work. The volt is also referred to as a unit of electric potential.

The analog voltage will also be connected to one of the BASIC Stamp I/O pins set to input mode. This binary input can actually be used to measure small variations in the analog voltage. PBASIC will be used to program the BASIC Stamp to drive a binary LED circuit, which will indicate when these variations have been detected.

The Debug Terminal is also a useful tool for displaying data the BASIC Stamp collects and sends. It will be used to monitor the binary value that the input pin receives as the analog voltage is varied.

Parts Required

For each experiment you will need a BASIC Stamp 2 and a Board of Education connected to an IBM-compatible PC with Win95/98/NT4.0. You will need to install the BASIC Stamp Editor v 2.0 or higher, which is available for free download from www.parallax.com or on the Parallax CD dated May 2003 or later. In addition, you'll need the following parts for this experiment:

(2) 470 resistors

(2) Red LEDs

(1) 100 k potentiometer.

(6) Jumper wires.

(1) LM358 op-amp

Throughout this series of experiments, we will build circuits from circuit schematics. One of the keys to learning how to read circuit schematics is learning what each symbol on the schematic means. It's also important to learn how to connect a part from the


Chapter 1: Analog Voltage and Binary States · Page 3

Analog and Digital Parts Kit to the Board of Education based on its circuit symbol in a schematic.

Circuit Schematic: Often referred to as a schematic, a circuit schematic is a map that uses symbols to show the components in a circuit and how they are connected. The components are represented by symbols such as the one that represents the LED in Figure 1-1.

Figure 1-1 shows the circuit symbol for an LED on the left and a drawing of an LED from the parts kit on the right. It also shows how the pins on an LED correspond to the terminals on the circuit symbol.

Flat spot on plastic part of LED indicating the cathode.

Figure 1-1

LED Circuit Symbol

_

Compared to the

+

Component

LED

Figure 1-2 shows a drawing of a resistor below its circuit symbol. The circuit symbol typically has the resistance value written below or next to it. The colored stripes on the part drawn below the symbol indicate its value, which is measured in ohms. The omega symbol ( ) is used to denote the ohm. You can use Appendix B to convert the color codes on the resistor to resistance values.

Figure 1-2

470 Ω

Resistor Circuit Symbol

and Corresponding

Component

Page 4 · Basic Analog and Digital

Current/Amp: Current happens when electrons travel from point A to point B. Direct current is what happens when you give the surplus electrons in the negative terminal of a battery a pathway to get to the positive terminal. The amp is the measurement of how many electrons per second are traveling through the pathway.

Resistance/Ohm: Resistance is a property of a material in the pathway the electrons travel through. The more difficult it is for the electrons to get from one end of the pathway to the other, the higher the resistance. A resistor is just such a pathway, and its resistance is measured in ohms ( ).

Ohm's Law: When a resistor is used to provide a pathway between the negative and positive terminals of a battery, you have an electric circuit with voltage, resistance, and current. Ohm's Law relates the three quantities as follows:

V = I x R

V is the voltage measured in volts, I is the current measured in amps, and R is the resistance measured in ohms.

The Other Guys: Ever wonder where the words volt, amp, and ohm come from? They are all named after some of the people who made significant discoveries about electricity. We already know who the volt is named for; what about the other guys? The amp, also called the ampere, is named after 18th century physicist André Marie Ampère. The ohm is named after 19th century physicist Georg Simon Ohm.

The Potentiometer - A Source of Variable Voltage

The potentiometer (pot) has 3 pins on its underside that get plugged into the Board of Education. On the topside, it has a knob you can twist to adjust it. In this experiment, we will use variable resistance to get a variable voltage output. Figure 1-3 shows how the pins on the underside of the pot from the parts kit correspond to the circuit symbol.

Figure 1-3

Potentiometer Circuit

Symbol and Component

Pot


Chapter 1: Analog Voltage and Binary States · Page 5

Figure 1-4 shows what happens inside the pot as it is adjusted. The jagged line represents a resistive element, typically made of carbon. One end of the resistive element is wired to Vdd on the Board of Education, and the other end is wired to Vss. The middle of the three terminals is connected to the “wiper”, and it’s where the variable output voltage is measured. The wiper stays in contact with the carbon element as it moves.

As the wiper gets closer to Vdd, the voltage measured at the wiper terminal will approach the value of Vdd, which is 5 volts. Likewise, when the wiper is closer to Vss, the voltage at the wiper terminal will be closer to Vss, which is 0 volts. As the wiper terminal travels between Vdd and Vss, the output measured at the wiper terminal varies between these two values in a manner analogous to a door as it opens and closes.

Vdd

+

0-100 kΩ Pot

Vss

Figure 1-4

Potentiometer Wiper

Showing how the wiper in a potentiometer travels along the surface of the resistive element as it’s adjusted.

The LM358 Op-amp

An op-amp (operational amplifier) is a building block commonly used in analog circuits. Figure 1-5 shows the circuit symbol and block diagram for the LM358 op-amp used in this experiment. The op-amp circuit used in this experiment is called a voltage follower because the same voltage comes out as goes in. In other words, the voltage at the output "follows" the voltage at the input. The reason it's used in the circuit in this experiment is to electrically separate a potentiometer circuit from an LED circuit. We'll learn more about the usefulness of a voltage follower in Chapter #4.

Page 6 · Basic Analog and Digital

A

LM358

LM358

1

8

2

A

7

3

B

6

4

5

Figure 1-5

LM358 op-amp

The circuit symbol has numbers on each of its terminals that correspond to the numbers on the block diagram.

The block diagram is a top-view of the part from your parts kit with the circuit symbols for the two op-amps in the part drawn in.

Make sure to note the location of pin 1 and the index mark when you place the LM358 on the breadboard. Improper wiring can damage an op-amp.

IMPORTANT: Disconnect the Board of Education's power source while you build the circuit.

The Board of Education

Figure 1-6 shows the remaining circuit symbols used in the first experiment and where to find them on the Board of Education. The symbol for Vdd is the positive 5 volt supply for the BASIC Stamp and the Board of Education. There are 4 sockets along the top side of the breadboard to the left for making connections to Vdd.

Next, the ground symbol is used for Vss. This is the reference terminal for taking measurements, and it's considered to be 0 volts compared to all other voltages on the Board of Education. The four sockets for connecting jumper wires to Vss along the top of the breadboard to the right.

There is a row of fifteen sockets along the left side of the breadboard for connecting to the BASIC Stamp I/O pins. Each I/O pin has a label. I/O pin P0 is connected to the bottom left socket. Pin P1 is the next socket up, and above that socket is the connection to pin P2, and so on through pin P15 at the top left.


X3

X4

P15

P14

P13

P12

P11

P10

P9

P8

P7

P6

P5

P4

P3

P2

P1

P0

Chapter 1: Analog Voltage and Binary States · Page 7

Figure 1-6

Board of Education

Circuit Symbols and where to find them on the Board of Education. Also shown is how each row of 5 sockets on the breadboard is electrically connected underneath.

Figure 1-6 also shows some samples of 5 socket wide rows that are electrically connected underneath the breadboard. There are 34 of these 5 socket wide rows arranged in the two columns on the breadboard. If you want to connect two jumper wires to each other, you can just plug them into the same row of 5. Then the wires are electrically connected. Likewise, if you want to connect one or more wires to the terminal of a part, just plug them into the same row on the breadboard and they'll be connected.

Building the Analog and Digital Comparator

Build the circuit according to the schematic in Figure 1-7. This schematic is like a list of connections between circuit symbols. Try to use this list to build the circuit. Here is a partial list of the connections shown in the schematic:

The wiper terminal of the 100 k pot is connected to pin 3 of the LM358 opamp.

Pin 2 of the LM358 is connected to pin 1 of the LM358.

Pin P7 of the BASIC Stamp is connected to the wiper terminal of the pot.

Pin 8 of the LM358 is connected to Vdd on the Board of Education.

Pin 4 of the LM358 is connected to Vss on the Board of Education.

Keep following the schematic like a list and you'll have the circuit built in no time.

Page 8 · Basic Analog and Digital

Pot with

analog

Op-Amp

Analog LED

Binary

output from

voltage

LED

output

wiper

follower circuit

output.

terminal

Vdd

Vdd

P12

LED

P7

LED

A

100k Ω

LM358

470 Ω

470 Ω

Pot

Vss

Vss

Vss

Vss

Figure 1-7

Circuit Schematic.

Remember to treat this schematic like a list of connections for building your circuit.

Although this circuit only has a few parts, it actually has 4 separate sub circuits, and each has a different function as shown

The potentiometer is what makes the analog output. The op-amp is wired to function as a voltage follower. The voltage follower drives the analog LED output. Then there's a separate circuit that uses a BASIC Stamp I/O pin to drive an LED.

Figure 1-8 shows a breadboard example of the schematic from Figure 1-7. For extra tips on building circuits on the breadboard, consult What’s a Microcontroller?