Before you can make a decision about modifying an existing condition, you have to sense what the current condition is. An awful lot can be done with the five senses we all have, but for many other things that are important in our everyday lives we need help. We get this help from electronic sensors. These sensors convert the information in the system into information we can absorb using our five senses. The preferred sensory input in humans is visual and auditory, but we often also use touch. Smell and taste are used less often and are usually reserved for organic inputs, sometimes those indicating a hazard or danger.
The following are some unusual examples of how we use our five senses.
Sight Automobile traffic is controlled basically by three colored lights.
Hearing The elevator beckons us with a ping.
Touch The cell phone vibrates (if set to do so).
Smell Gasoline contains an additive to help us detect its dangerous presence.
Taste The DEA agent can recognize cocaine by its taste (at least on TV).
When we think about sensing something our human senses cannot detect, we are usually thinking about signals that, to us, are weak or hard to differentiate in the ambient noise. These are signals that need to be filtered and amplified and then converted to signals we can recognize. As you read this, a few hundred television and radio broadcasts are zipping past your brain that you are completely oblivious to. If you know what frequencies to look for, how to filter out the signal you want from them, and then how to present it to the human eye and ear, you could watch and hear the data being broadcast. Cable network subscriptions seem to indicate this is worth a lot of money every month!
Thus, there are four main aspects of sensing.
We must have a knowledge and understanding of the existence of the signal.
We must find a filter that will isolate and identify the signal.
We must amplify the signal if it is weak.
We must convert the signal to accommodate a human sense, or transform it into something detectable by a machine or instrument, which we can then interact with.
Only then are we in a position to make an intelligent decision about the signal.
One more important thing: We need to have a very good idea of what we are trying to do in order to make sure we end up with the signal we are interested in. It won’t do to have an instrument that tells us the humidity, when what we were really interested in was the temperature.
The world is full of many exotic and interesting things to experiment with and detect, but in these discussions we will concentrate on those things we might find in an everyday engineering school laboratory or amateur engineer’s workshop. We will not discuss anything for which a sensor itself cannot be purchased for less than $30 (U.S. dollars). We will stick to using only a few sensors and employ them in many different ways. The sensors/detectors/transducers we select must be readily available and be interface-able with a small microcontroller. Even so, other efforts must be undertaken before we have a viable instrument or controller—something which we will discuss later in Chapters 15 to 22.
We cannot do anything about the signal, however, if we don’t know where to find it or know that it even exists. The signal also must have a sensor we can use, that will respond to it, and it is preferable that the sensor respond only to the signal we are interested in. All other responses detract from the task at hand and can be considered part of the general “noise.”
Some of the most exquisitely sensitive sensors are biological. The antennae of the moth can recognize the pheromones it has evolved to detect in the parts per billion or less. These sensors are so sensitive they can even detect the gradient in the scent, allowing the moth to move towards its target. Here it is important to note that in a three-dimensional space, one part in 1,000,000,000 means that the molecules being detected are 1000 molecules apart. Since the antennae are many millions of molecules long, quite a few particles are possibly being intercepted at any one time at these seemingly minute concentrations. (We are just beginning to see the use of biological/chemical elements in our most sophisticated and cutting edge electric/electronic instruments.)
In most cases, we are interested in linear space rather than three-dimensional space, as mentioned earlier. In most cases, if we can detect about 1 part in 10,000, we are quite happy. One part in 10,000 refers to being able to detect a change of 1 part within the entire range from 1 to 10,000. To use a real-world example, consider the common voltmeter, which can detect from 0 to 1000 volts with a sensitivity of 0.1 volts. This is the approximate range of our most common instruments, but of course we use both much coarser and much finer instruments also. The following lists some common examples we are all familiar with.
Since we are interested in the use of sensors that connect to microcontrollers, we will restrict ourselves to those sensors that provide an electrical signal or a signal that is easily converted into an electrical signal. Signals that are easy to interface to a microcontroller are signals that have (changing) electrical properties like…
Resistance
Voltage
Capacitance
Reluctance
Frequency
What competencies must be mastered in order to create microcontroller-based instruments and controllers? Basically, you have a signal that must be transformed into a reading of some sort in a one- or two-line display, or something similar. What you must master is the process between the two. Thus, the tasks involved break down this way:
1. Understanding the problem (this is much more important than it seems)
2. Capturing the signal
3. Filtering out the part you want
4. Conditioning the signal to make it acceptable to the PIC
5. Converting it to a digital format
6. Manipulating the digital data to create a readable value
7. Doing one or more of the following:
Displaying the value on the LCD
Transmitting the value to a computer for collection and storage
Turning external device(s) on and off as necessary
Essentially, the chapters in this tutorial are devoted to these tasks.
Why would I want to build an instrument when
instruments to measure almost everything I am
interested in are already available off the shelf?
The answer to this question is neither simple nor short.
First: Almost all the instruments you need are not available off the shelf. More accurately stated, only bits and parts of the instruments you require are available. The instruments we will build will be more useful than their generic off-the-shelf siblings, and in some ways are more specifically targeted to the task at hand. Since we know exactly what we need, we will design an instrument that provides exactly what we want. We do not have to compromise on any property of the instrument. Also, our instruments will be able to provide other intelligence functions, like turning other laboratory equipment on and off as needed by our experiments, and as determined by the conditions the instrument is monitoring in real time. This is a very useful feature almost never found on an industrial instrument, but that is absolutely essential if we want to automate our processes.
Second: We will be able to automatically send the information being gathered to a computer for analysis, either in real time or on a deferred basis depending on what our overall needs are. We can also gather a lot more information over a longer period of time with our custom instruments because we will now have the ability to automate the process. Transient phenomena that require constant monitoring over long periods of time and produce only in a few important instances can now be monitored continuously and intelligently without concern or added expense.
Third: Our instruments will be able to make intelligent decisions in real time. If data points that are unexpected or extraordinary are encountered, the instrument can call this to our attention so remedial or special (even human) attention can be given to the problem.
Fourth: On the output side, the ability to turn pumps, fans, heaters, and the like on and off automatically, based on the information sensed by the instrument cannot be dismissed out of hand. Very few off-the-shelf volt-/ohmmeters can turn an ancillary piece of equipment on or off at a given voltage. Most do not even have an output that we could connect to if we so desired. However, with our custom-designed instruments, it will be easy. Few ohmmeters can send the value read to a computer every second or every hour. But with the instruments we will build, it will be easy. No off-the-shelf instruments can be reprogrammed in BASIC with one click of the mouse. With the instruments that we will create, however, this will be the case. The instruments we shall design and build will be intimately familiar to us, so modifying them will be relatively easy. Once the input-output appurtenances have been decided on and connected to the microcontroller, the rest will be controlled by the software we will write. If we feel the instrument is not responding the way we want it to, we can modify it with minimal effort.
Fifth: Specialized instruments can often be made for a lot less than you may think!
Sixth:You will develop critical skills you can use the rest of your life. This in itself might be more important than anything else. (After all, we live in the information age, no?)
We can say with some confidence that with a little learning and effort on our part, we are can create instruments tailored to our needs that will help us be more productive. (And in the process make our lives more interesting.)
So what kinds of things can be sensed easily? We need to know what we can sense because what we sense will be the data source we feed into our microcontroller-based instrument/controller.
Inexpensive sensors are readily available for most of the following:
Humidity
Gravity
Level
Acceleration
Resistance
Capacitance
Voltage
Frequency
Magnetic field
Hall effect sensor
Pressure
Altimeter
Vacuum
Distance
Sonic
Thermal
Infrared
Temperature
Light
Chemical sensors
PH
Sound
Noise
Sound pressure
Contour or roughness
Speed
RPM
Position
GPS
Orientation
Gravity sensors for two and three axes
We will, of course, use only a couple of these sensors because our interest is not primarily in the sensors but in manipulating the information we get from the sensors, no matter what type of sensors they are. In order to do that, we must learn how to effectively connect to whatever is provided to us and provide outputs that can control the devices we are interested in manipulating. One chapter in this book is devoted to making the connections on the input side, while one concerns making the connections on the output side. In the eight projects we will undertake, the following sensor interfacing problems will be addressed:
Counting the frequency of a pulse train |
|
2. Metronome |
Creating accurate timed intervals (frequencies) |
3. Marbles counter |
Exploring various counting techniques and how to implement them |
4. Dual thermometer |
Reading analog signals and displaying them |
5. Artificial Horizon |
Providing a stable horizontal surface with an unusual instrument |
6. Touch screen |
Making control panels through a useful technique |
7. Single-point controller |
Controlling one variable (derived from item 4 of this list) |
8. Solar collector |
Exploring data collection over a long time period; data logging |
These eight projects are designed to familiarize you with the basic techniques needed to build instruments and controllers in today’s engineering laboratories and on hobbyist workbenches.
RadioShack has a sensors learning laboratory (~$50) that provides an inexpensive way to access a family of sensors that can be used with our instruments.
The McGraw-Hill book Electronic Sensors for the Evil Genius discusses a number of interesting sensors and explains how to use them. These techniques, and others that are modifications of them, can be used in the instruments and controllers we shall create.