Finally in our component tour, we come to crystals . Just as their name suggests, they are small blocks of quartz (silicon dioxide). Quartz crystal is a type of material known as a piezo-electric. This is a substance that generates a voltage when it is stressed (compressed, stretched, twisted). This effect is utilized in microphones. The sound vibrates the piezo-electric material, and it produces a small AC voltage that is directly proportional to the original sound that created it. This voltage is then amplified for broadcast, recording, or processing.
The opposite effect is also true for piezo-electric materials. Apply a voltage and the piezo-electric material will contort or vibrate. Some speakers use piezo-electric materials to produce sound. (However, most use other techniques, such as electro-magnetics.) Most loud buzzers are based on piezo-electrics.
Now, the neat thing about quartz is that for a block of a given size, it will vibrate at a given (and fixed) frequency. As such, it can be used as an oscillator to generate a sine wave, which in turn can be used to generate timing signals for microprocessors and other digital circuits. Just about every computer system will have a crystal (or two) somewhere on its circuit board, generating the timing that ultimately drives the whole machine. That crystal is simply a small block of quartz, plated at either end with wires attached and encased in a metal can.
The schematic symbol for a crystal is shown in Figure 4-54, and a real crystal is shown in Figure 4-55.
Crystals require a drive circuit to make them go. These tend to be a bit temperamental and don't always oscillate at the frequency you expect, due to a range of effects that are hard to track down. Fortunately, there are two easy ways around this problem. The first is that most processors (and other chips requiring timing) have internal oscillator circuits. All you need to do is add the external crystal (and maybe a capacitor or two), and it will work beautifully. For those chips that don't make life quite so easy, you can get complete oscillator modules, which include the crystal and drive circuit. All you need to do is give them power and ground, and they too will work beautifully.
All microprocessors (and quite a few other digital devices too) require a clock. A clock is an output from an oscillator that runs the processor and all system events related to the clock. (And just in case you're wondering, this "clock" has nothing to do with the time of day. Think of it as a stream of digital pulses.) The clock frequency is normally expressed in kiloHertz (kHz), MegaHertz (MHz, 1,000 kHz), or GigaHertz (GHz, 1,000 MHz). The clock frequency of a processor is also known as its clock speed . (Note the capital "H" in Hz. It is never "hz," always "Hz.")
A given processor will have a maximum and a minimum clock frequency. This specifies the range in which the oscillator driving the processor can operate. A processor with a minimum clock speed of zero is said to have static operation , or DC operation . This means that the processor can have its clock stopped and still be able to resume operation at a later time with no ill effect. If the minimum operating frequency of a processor is specified to be greater than zero, then that processor is said to have dynamic operation . If the oscillator frequency falls below the minimum of a dynamic processor, then that processor may suffer corruption of its registers.
The clock speed of a processor relates to how quickly a processor can execute software. A processor running at a faster clock speed will execute software faster than a processor of the same type running at a slower clock speed. But clock speed is not the whole story in terms of processor speed. One processor architecture may take 32 clock cycles to execute an instruction, whereas another processor may complete one instruction every clock cycle. So, even though these two processors are running at the same clock speed, the latter will be significantly faster than the former.
There are several ways of generating a clock. Which is appropriate depends largely on the processor you are using. Some processors expect a digital (square-wave) clock input. For a processor running at common frequencies, and this includes most processors, the best choice is to use a device called an oscillator module (Figure 4-56). These four-pin components provide a square-wave clock output at a given frequency, requiring only power and ground connections. These simplify the system design, as they are "plug and go" devices.
Many processors (including all the microcontrollers I can think of) contain oscillator circuitry and generally require only the addition of an external crystal and bypass capacitors (Figure 4-57). The capacitors remove higher-order harmonics from the oscillation.
Often it is necessary to design a system with minimal power consumption. This may be done to reduce the heat produced by a system or to make the system portable.
The more current that devices within a system use, the hotter they become. Too much heat will cause them to stop working. While it is possible to provide cooling subsystems and temperature monitors, the better approach is simply to reduce the power consumption and therefore the heat. When a system is powered by batteries, the lower its current draw, the longer the batteries will last. For these reasons, low-powered design is advantageous.
Most of the current usage of a digital system occurs during transitions of stateâin other words, during the clock edges. The more frequent the clock edges, the more the average current usage goes up. Therefore, the faster a processor runs, the more power it consumes. Conversely, the lower the processor's operating voltage, the less its power consumption is. Many embedded processors are available in lower-voltage versions. Power consumption can also vary between architectures. An ARM processor running at the same clock speed and operating voltage as a Pentium will have considerably less power consumption. It is for this reason that ARMs are common in PDA devices.
Using chips with static operation allows the clock of the system to be slowed (or stopped), and since power consumption relates directly to speed, this can reduce the overall power usage of the machine. The clock may be slowed in several ways. First, the clock can be kept permanently slow. For an application that does not require a lot of computing power (a traffic-light controller, for example), a processor clock of 32 kHz (rather than, say, 20 MHz) may be used.
Alternatively, in systems that occasionally require heavy computation, the system clock may be slowed only when the processor is idle. Many laptop computers use this technique to reduce their power consumption. The processor runs at full speed when in use. If the system sits idle for 30 seconds, the clock is slowed down into the kHz range. If the system remains idle for several minutes, the clock is slowed down into the Hz range. Since the user is not actively working with the machine (that's why it is idle), the user doesn't notice any difference. The moment the processor is required to perform a task (such as when a key is pressed), the clock is switched back to full speed and normal operation is resumed.
Tip
Palm computers use this technique very effectively. The machines are event-driven, meaning they do something when the user taps the screen, or when an I/O device requires servicing. Therefore, in between events, the processor slows down considerably. When an event occurs, the system switches back to full speed, processes the event, and then returns to idle mode. The processor spends far more time in idle mode than in operating mode, and, therefore, the battery use is minimal. It is by using this technique that Palms get such long operating life from their batteries. It is also why you never see (or shouldn't see) computationally intensive applications on Palm computers. The batteries would be flat in no time.
Some computer systems may even halt the clock completely until the processor is required, at which point an external device reactivates the system clock.
Many processors have SLEEP and HALT modes, reducing the processor's power consumption. Some processors extend this to SLEEP, NAP, DOZE, SNOOZE, etc., each with a different level of power usage and each requiring a different period of time for the processor to "awaken." (The deeper the sleep, the longer it takes for the processor to resume operation.)
This concludes the discussion of electronic components. One major type of component that I haven't covered is transistors. They have been left out simply because they are not commonly seen in embedded systems, and a proper coverage of transistors would occupy a large volume in its own right. If you are interested in learning about transistors, there are plenty of excellent books available. Just visit your local technical bookstore or cruise the Internet.
Get Designing Embedded Hardware, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.