14
THE UNIVERSAL INSTRUMENT: A BACKGROUND DISCUSSION

The Properties and Capabilities of a Universal Instrument

Almost all the instruments we will make have some shared characteristics. What are they and what advantages and disadvantages do we get from them? What does having our instruments based on PIC microcontrollers do for us? Asking these questions and understanding basic concepts like these makes it easier for us to proceed with our work.

Let’s look at the properties needed in an instrument by comparing it with an instrument we are all familiar with: a volt/ohm meter or VOM. We will compare its properties and functions to the instruments we are designing to get a better understanding of what we are trying to accomplish and how we might accomplish it.

Each instrument/controller must have the following basic properties:

1. It must have a way to enter information into the device in a convenient manner. In a VOM, we are provided with two probes that we place at various points in the circuitry. In the instruments we make, we will provide connection points for the signals and pulses we are interested in reading, but more importantly we are interested in providing inputs that can be programmed to influence the operation of the instrument in real time. With a little imagination, the instruments we create can be both interactive and intelligent.

2. It must have some form of decision-making capability that allows it to manipulate the information sent to it, and some of this capability needs to be controllable (influence-able) by the operator. In the VOM, there is a selector switch that we use to choose ranges and functions we will use. In our instruments, we will use the computer to set the parameters within which our instrument will operate. We will be able to program the instrument for the task at hand as needed. For our instruments, the computer is the selector switch! (Note that in the newer VOMs, some auto-ranging capabilities are implemented for selecting the range used by the meter. The output, too, is ranged so it can fit in the limited number of characters in the display. To us, this means some of the decision making we might have undertaken has been relegated to the intelligence built into the machine.) The flexibility of our instruments is rooted in the ability to reprogram the instrument with a few keystrokes whenever needed. In order to be able to use this flexibility, we must design the hardware for our instruments in a way that will lend itself to software modification with relatively minimal effort in a relatively short time. We have to think about what the instrument/controller will/can do as we design it so it will perform its intended functions with some elegance. Always keep in mind that the instrument will do only what we design it to do. You must commit this concept to your brain. It is very important.

3. The device must have a way to output information in a useful format. The format can be anything from a simple switch closure to a comprehensive CRT display. On the VOM, a few digits suffice to give us the information we need. On instruments based on PIC microcontrollers, the addition of a two-line display can provide a considerable amount of information. The many output port lines can be used to turn LEDs on and off and to provide other on/off signals. A serial port can be used to send and receive information from a computer. Audio signals can also be added. Versatility will be our strong suit.

4. The information/output desired should be able to be stabilized for a while so we can collect it. Some of the newer VOMs have a storage function that lets you freeze the display at selected peak values or at selected times. Our instruments will be able to do that and send the information to a computer at selected intervals for storage in that computer to facilitate future analysis. They will be able to make decisions in real time when we are not there, and take corrective actions, or summon human intervention. The capabilities we can incorporate into our instruments are limited only by our imagination. We are the designers.

A Basic Temperature-Controlling Device

Next, we will discuss this in the context of a simple temperature-controlling device. Later, we will actually build this device.

What are the basic properties and components of an instrument that can be described as a universal all-purpose single-point controller? Basically, the following functions are called for:

sqr Sense condition

sqr Set a point of control

sqr Compare the preceding two functions

sqr Output a signal

Let’s go over them one at a time.

1. A simple universal controller would allow us to control one set point or property. For the purpose of this discussion, we are assuming this is a temperature. The instrument must allow us to control a temperature. In order to do this, it must have a connection for the temperature sensor, and what we provide will depend on the sensor we have selected. We will use an LM34 temperature-sensing IC as our detector. This device uses a three-wire connection, so we will provide a three-screw terminal for this connection.

2. The device must have an adjustable setting variable of some sort to which the above temperature is to be compared. This is the output set point control device. For our instrument, we will use a potentiometer. Once we have the two signals in our instrument working, we can make a decision as to whether we want to turn on the heat or the refrigeration. This will be determined with the software we will write to control the instrument. (The potentiometer is a three-wire voltage divider that we will use to parallel the input that the temperature detector is providing. This is just like what we discussed earlier in this book, and will make the comparisons easier.)

3. We need a way to turn the actual instrument function on and off. This switch is not the on/off switch for the instrument but another switch that allows us to activate the operational portion of the instrument when we are ready to start the instrument. This switch lets us play with our setup and get everything just right before we activate the instrument. A simple SPST switch will be adequate for this and we will use a small toggle switch for it. Since we may want to mount this switch at a remote location for some of our applications, we will connect the switch to the board via two screw terminals. The major function of a switch like this is to allow our instrument to be controlled by another electronic device! This is a very powerful capability and is the first step in the extended automation process.

4. The controller needs a couple of connectors that the output signal appears on. We will connect the controlled machine component (heater, relay, and so on) to this point. If we have to amplify the control signal, this is where the relay (transistor) or whatever will be connected. If we later want to reverse the signal from normally off to normally on, this is where we program the logic to do so. This is the output of the instrument. We will annunciate the signal with an LED and use two screw terminals as the connection points.

5. The instrument needs some sort of indicator on it to tell us when the output from the instrument is active. This is a convenience item that makes the instrument/controller more user-friendly. We will add an LED to indicate this on our controller. When this LED is on, the instrument is putting out a signal at the output connectors. This LED also lets us see the instrument operating without having to connect up to a real control point, and so on.

The preceding describes almost all instrument/controllers. No matter what you are asked to control, the instrument you design will have the preceding basic modules or components in some form or another. It may control one function, or it may control a hundred functions, but each function will support the previously mentioned abilities.

The controller mentioned earlier is an extension of the thermometer we will construct in one of the projects. Its construction is covered in detail.

Notes

All instruments are assembled from standard hardware and software components, so they tend to have a modular structure. Each module in the instrument provides one function. The following are some common modules you would find on systems based on the PIC 16F877A:

sqr Analog input section

sqr Mathematical manipulations

sqr Set the DEFINEs for the LCD

sqr Display to the LCD

sqr Read a potentiometer or two

sqr Display to displays (CRT)

sqr Read a keyboard

sqr Put out a tone

sqr Read a switch

sqr A communications module

We create our instruments by selecting or designing the modules we need and assembling them into a project. Once you have created a module or subroutine, you can use it again and again in your designs if you create it to be easily transportable to other designs. Taking the time to do so now will save you a lot of time, again and again, in the future.

Notice in the projects that follow that I too use the modules over and over again. I also made a concerted effort to use as few instructions in PIC Basic Pro (PBP) as possible, so the emphasis was on the design of the instruments, not on fancy software tricks and routines.