Microcontroller System Development About PICmicro Chips EXERCISE 1: Digital vs. Analog EXERCISE OBJECTIVE When you have completed this exercise, you will be able to compare and contrast digital and analog data. EXERCISE DISCUSSION THE DIGITAL WORLD Much of our everyday information is described in the form of a number. For example: - "It is 2 o'clock." - "The temperature outside is 21 degrees C." - "The car was traveling at 48 kilometers per hour." It is easy to understand data in this form. However, it can get tedious when we are looking at how a quantity, such as the speed of a car, changes over a period of time. The result would be something like this: You might wonder what happened at time 35 seconds? Was it moving faster or slower than 25 km/h then? FACET by Lab-Volt 7
About PICmicro Chips Microcontroller System Development THE ANALOG WORLD Now the information is given in the form of an analogy! In other words, we use something that behaves in a similar way. Here are some examples. 1. The hour glass egg timer The greater the time interval, the deeper the sand in the bottom of the egg timer. 2. The mercury-in-glass thermometer The hotter it gets, the further the mercury moves up the tube. 8 FACET by Lab-Volt
Microcontroller System Development About PICmicro Chips 3. The car speedometer The higher the speed, the further round the dial the pointer moves. The problem is that you have to do some work to extract the data. In the case of the speedometer, and the thermometer, you have to work out where the pointer sits on the scale. On the other hand, you can easily judge how the temperature of a body is changing by watching how quickly the mercury is moving along the tube. ANALOG DATA Many electronic sensors provide signals in analog form. For example, a microphone provides an electrical 'copy' of a sound wave. Here is the circuit diagram for a temperature sensor. The output voltage from this increases when the temperature increases. It is an analog signal because the voltage copies the behavior of the temperature. FACET by Lab-Volt 9
About PICmicro Chips Microcontroller System Development The analog signal can have any voltage value, limited only by the power supply used. In this case, the output of the temperature sensor could, in theory, go as high as 5V, or as low as 0V with many readings in between. Over a period of time, the output voltage could change as follows: This is an analog signal. DIGITAL DATA A digital signal carries its information in the form of a number. Electronic systems use the binary number system, which uses only the numbers 0 and 1 (more of this later). These two numbers are coded as voltages. We could decide on the following code: '0' = a low voltage. '1' = a high voltage. Digital signals then have only two possible voltage values. These are usually the power supply voltages, or as close to them as the system can get, and 0V. How can we enter these numbers into an electronic system? One (very slow) way would be to use a switch (an example of a digital sensor). Look at the next circuit diagram: When the switch is open (not pressed), the output is pulled down to 0V by the resistor. This output could represent the number '0'. When the switch is closed (pressed), the output is connected to the positive supply, and so is 5V in this case. This could represent the number '1'. (Note that it would be possible to reverse the positions of the switch and the resistor in the circuit above. In this case pressing the switch would put a logic 0 on the pin.) 10 FACET by Lab-Volt
Microcontroller System Development About PICmicro Chips This diagram shows a more complex digital signal. The binary number represented by the signal is given under the waveform. ANALOG TO DIGITAL CONVERSION Much of our 'real world' data is analog, but computers (including the PICmicro microcontroller) can only process digital data. Fortunately the PICmicro has a circuit inside it that can convert information inside it from an analog format to a digital format. This is called an Analog to Digital Converter - ADC or A/D for short. The ADC inside the PICmicro chip divides the range of possible analog voltages into equal steps. The first step is given the number 0, and the highest step is given the highest number that the A/D converter can handle. The highest number the ADC can handle is determined by the resolution of the ADC inside the chip. The resolution is determined by the number of 'bits' the internal circuitry of the ADC has. The resolution of PICmicro ADCs is 8, 10 or 12 bit. For example, if the biggest analog voltage is 5V, and the PICmicro has an 8 bit A to D converter: the highest 8 bit number is 1111 1111 (= 255 in decimal) the first step is 0000 0000 (= 0 in decimal) This makes a total of 256 steps, so each step is a voltage jump of 5V/256,which equals about 20mV per step. When the PICmicro is told to look at an analog signal, and convert it, it divides the analog signal by 20mV, to find out how many steps up the signal sits. This gives the digital equivalent of the analog signal. The next graph may make this clearer. In our example, the converter outputs 0 for any analog signal up to 20mV, outputs 1 for analog signals between 20 and 40mV, and so on. FACET by Lab-Volt 11
About PICmicro Chips Microcontroller System Development EXERCISE QUESTIONS If the output voltage from a temperature sensor increases as the temperature increases, the signal is.. c. either analog or digital. If the output voltage from a sensor is translated into a binary number, the signal is.. c. either analog or digital. An ADC converts an analog signal into a digital signal. a. True b. False 12 FACET by Lab-Volt
Microcontroller System Development About PICmicro Chips EXERCISE PROCEDURE Identify the following scenarios as Analog or Digital 1. A ship uses SONAR to explore the ocean floor for shipwrecks. c. either analog or digital 2. The weather station monitors the local temperature. c. either analog or digital 3. A technician takes the EEG (electroencephalogram) of a patient. c. either analog or digital 4. The grocery store uses customer check out to monitor inventory. c. either analog or digital FACET by Lab-Volt 13
About PICmicro Chips Microcontroller System Development EXERCISE CONCLUSION Analog data is collected in a continuous form by using something that behaves in a similar manner, such as an hourglass, thermometer, or electrical signal. Digital data carries information in the form of a number or series of numbers. While much of the data collected is analog, computers can only process digital data. REVIEW QUESTIONS 1. Much of our everyday information is described in the form of a number. a. True b. False 2. An example of information given in the form of an analogy is a(an): a. hour glass. b. thermometer. c. speedometer. d. All of the above are correct. 3. If voltage copies the behavior of a measurable characteristic, such as temperature, the signal is: 4. Electronic systems use the number system to carry digital information. a. real b. imaginary c. binary d. tertiary 5. A PICmicro microcontroller uses a to convert data from analog to digital format. a. Digital Converter (DC) b. Analog Converter (AC) c. Analog to Digital Converter (ADC) d. None of the above is correct. CMS AVAILABLE FAULTS AVAILABLE 14 FACET by Lab-Volt