What is an embedded system?
Whenever the word microprocessor is mentioned, it con-jures up a picture of a desktop or laptop PC running an application such as a word processor or a spreadsheet. While this is a popular application for microprocessors, it is not the only one and the fact is most people use them indirectly in common objects and appli-ances without realising it. Without the microprocessor, these products would not be as sophisticated or cheap as they are today.
The embedding of microprocessors into equipment and consumer appliances started before the appearance of the PC and consumes the majority of microprocessors that are made today. In this way, embedded microprocessors are more deeply ingrained into everyday life than any other electronic circuit that is made. A large car may have over 50 microprocessors controlling functions such as the engine through engine management systems, brakes with electronic anti-lock brakes, transmission with traction con-trol and electronically controlled gearboxes, safety with airbag systems, electric windows, air-conditioning and so on. With a well-equipped car, nearly every aspect has some form of elec-tronic control associated with it and thus a need for a microproc-essor within an embedded system.
A washing machine may have a microcontroller that con-tains the different washing programs, provides the power control for the various motors and pumps and even controls the display that tells you how the wash cycles are proceeding.
Mobile phones contain more processing power than a desk-top processor of a few years ago. Many toys contain microproces-sors and there are even kitchen appliances such as bread machines that use microprocessor-based control systems. The word control is very apt for embedded systems because in virtually every embedded system application, the goal is to control an aspect of a physical system such as temperature, motion, and so on using a variety of inputs. With the recent advent of the digital age replac-ing many of the analogue technologies in the consumer world, the dominance of the embedded system is ever greater. Each digital consumer device such as a digital camera, DVD or MP3 player all depend on an embedded system to realise the system. As a result, the skills behind embedded systems design are as diverse as the systems that have been built although they share a common heritage.
What is an embedded system?
There are many definitions for this but the best way to define it is to describe it in terms of what it is not and with examples of how it is used.
An embedded system is a microprocessor-based system that is built to control a function or range of functions and is not designed to be programmed by the end user in the same way that a PC is. Yes, a user can make choices concerning functionality but cannot change the functionality of the system by adding/replac-ing software. With a PC, this is exactly what a user can do: one minute the PC is a word processor and the next it’s a games machine simply by changing the software. An embedded system is designed to perform one particular task albeit with choices and different options. The last point is important because it differenti-ates itself from the world of the PC where the end user does reprogram it whenever a different software package is bought and run. However, PCs have provided an easily accessible source of hardware and software for embedded systems and it should be no surprise that they form the basis of many embedded systems. To reflect this, a very detailed design example is included at the end of this book that uses a PC in this way to build a sophisticated data logging system for a race car.
If this need to control the physical world is so great, what is so special about embedded systems that has led to the widespread use of microprocessors? There are several major reasons and these have increased over the years as the technology has progressed and developed.
Replacement for discrete logic-based circuits
The microprocessor came about almost by accident as a programmable replacement for calculator chips in the 1970s. Up to this point, most control systems using digital logic were imple-mented using individual logic integrated circuits to create the design and as more functionality became available, the number of chips was reduced.
This was the original reason for a replacement for digital systems constructed from logic circuits. The microprocessor was originally developed to replace a mass of logic that was used to create the first electronic calculators in the early 1970s. For exam-ple, the early calculators were made from discrete logic chips and many hundreds were needed just to create a simple four function calculator. As the integrated circuit developed, the individual logic functions were integrated to create higher level functions. Instead of creating an adder from individual logic gates, a com-plete adder could be bought in one package. It was not long before complete calculators were integrated onto a single chip. This enabled them to be built at a very low cost compared to the original machines but any changes or improvements required that a new chip be developed. The answer was to build a chip that had some form of programmable capability within it. Why not build a chip that took data in, processed it and sent it out again? In this way, instead of creating new functions by analysing the gate level logic and modifying it — a very time-consuming process — new products could be created by changing the program code that processed the information. Thus the microprocessor was born.
Provide functional upgrades
In the same way that the need to develop new calculator chips faster and with less cost prompted the development of the first microprocessors, the need to add or remove functionality from embedded system designs is even more important. With much of the system’s functionality encapsulated in the software that runs in the system, it is possible to change and upgrade systems by changing the software while keeping the hardware the same. This reduces the cost of production even lower because many different systems can share the same hardware base.
In some cases, this process is not possible or worthwhile but allows the manufacturer to develop new products far quicker and faster. Examples of this include timers and control panels for domestic appliances such as VCRs and televisions.
In other cases, the system can be upgraded to improve functionality. This is frequently done with machine tools, tel-ephone switchboards and so on. The key here is that the ability to add functionality now no longer depends on changing the hard-ware but can be done by simply changing the software. If the system is connected to a communications link such as a telephone or PC network, then the upgrade can be done remotely without having to physically send out an engineer or technician.
Provide easy maintenance upgrades
The same mechanism that allows new functionality to be added through reprogramming is also beneficial in allowing bugs to be solved through changing software. Again it can reduce the need for expensive repairs and modifications to the hardware.
Improves mechanical performance
For any electromechanical system, the ability to offer a finer degree of control is important. It can prevent excessive mechanical wear, better control and diagnostics and, in some cases, actually compensate for mechanical wear and tear. A good example of this is the engine management system. Here, an embedded microproc-essor controls the fuel mixture and ignition for the engine and will alter the parameters and timing depending on inputs from the engine such as temperature, the accelerator position and so on. In this way, the engine is controlled far more efficiently and can be configured for different environments like power, torque, fuel efficiency and so on. As the engine components wear, it can even adjust the parameters to compensate accordingly or if they are dramatically out of spec, flag up the error to the driver or indicate that servicing is needed.
This level of control is demonstrated by the market in ‘chipped’ engine management units where third party companies modify the software within the control unit to provide more power or torque. The differences can range from 10% to nearly 50% for some turbo charged engines! All this from simply chang-ing a few bytes. Needless to say, this practice may invalidate any guarantee from the manufacturer and may unduly stress and limit the engine’s mechanical life. In some cases, it may even infringe the original manufacturer’s intellectual property rights.
Protection of intellectual property
To retain a competitive edge, it is important to keep the design knowledge within the company and prevent others from understanding exactly what makes a product function. This knowl-edge, often referred to as IPR (intellectual property rights), be-comes all important as markets become more competitive. With a design that is completely hardware based and built from off-the-shelf components, it can be difficult to protect the IPR that was used in its design. All that is needed to do is to take the product, identify the chips and how they are connected by tracing the tracks on the circuit board. Some companies actually grind the part numbers off the integrated circuits to make it harder to reverse engineer in this way.
With an embedded system, the hardware can be identified but the software that really supplies the system’s functionality can be hidden and more difficult to analyse. With self-contained microcontrollers, all that is visible is a plastic package with a few connections to the outside world. The software is already burnt into the on-chip memory and is effectively impossible to access. As a result, the IPR is much more secure and protected.
Replacement for analogue circuits
The movement away from the analogue domain towards digital processing has gathered pace recently with the advent of high performance and low cost processing.
To understand the advantages behind digital signal process-ing, consider a simple analogue filter. The analogue implementa-tion is extremely simple compared to its digital equivalent. The analogue filter works by varying the gain of the operational amplifier which is determined by the relationship between ri and rf.
In a system with no frequency component, the capacitor ci plays no part as its impedance is far greater than that of rf. As the frequency component increases, the capacitor impedance de-creases until it is about equal with rf where the effect will be to reduce the gain of the system. As a result, the amplifier acts as a low pass filter where high frequencies will be filtered out. The equation shows the relationship where jω is the frequency compo-nent. These filters are easy to design and are cheap to build. By making the CR (capacitor-resistor) network more complex, differ-ent filters can be designed.
The digital equivalent is more complex requiring several electronic stages to convert the data, process it and reconstitute the data. The equation appears to be more involved, comprising of a summation of a range of calculations using sample data multi-plied by a constant term. These constants take the place of the CR components in the analogue system and will define the filter’s transfer function. With digital designs, it is the tables of coeffi-cients that are dynamically modified to create the different filter characteristics.
Given the complexity of digital processing, why then use it? The advantages are many. Digital processing does not suffer from component ageing, drift or any adjustments which can plague an analogue design. They have high noise immunity and power supply rejection and due to the embedded processor can easily provide self-test features. The ability to dynamically modify the coefficients and therefore the filter characteristics allows complex filters and other functions to be easily implemented. However, the processing power needed to complete the ‘multiply–accumulate’ processing of the data does pose some interesting processing requirements.
The diagram shows the problem. An analogue signal is sampled at a frequency fs and is converted by the A/D converter. This frequency will be first determined by the speed of this conversion. At every period, ts, there will be a new sample to process using N instructions. The table shows the relationship between sampling speed, the number of instructions and the instruction execution time. It shows that the faster the sampling frequency, the more processing power is needed. To achieve the 1 MHz frequency, a 10 MIPS processor is needed whose instruction set is powerful enough to complete the processing in under 10 instructions. This analysis does not take into account A/D conver-sion delays. For DSP algorithms, the sampling speed is usually twice the frequency of the highest frequency signal being proc-essed: in this case the 1 MHz sample rate would be adequate for signals up to 500 kHz.
One major difference between analogue and digital filters is the accuracy and resolution that they offer. Analogue signals may have definite limits in their range, but have infinite values be-tween that range. Digital signal processors are forced to represent these infinite variations within a finite number of steps deter-mined by the number of bits in the word. With an 8 bit word, the increases are in steps of 1/256 of the range. With a 16 bit word, such steps are in 1/65536 and so on. Depicted graphically as shown, a 16 bit word would enable a low pass filter with a roll-off of about 90 dB. A 24 bit word would allow about 120 dB roll-off to be achieved.
DSP can be performed by ordinary microprocessors, al-though their more general-purpose nature often limits perform-ance and the frequency response. However, with responses of only a few hundred Hertz, even simple microcontrollers can perform such tasks. As silicon technology improved, special build-ing blocks appeared allowing digital signal processors to be developed, but their implementation was often geared to a hard-ware approach rather than designing a specific processor architec-ture for the job. It is now common for processors to claim DSP support through enhanced multiply–accumulate operations or through special accelerators. It is clear though, that as general purpose processing increases in capability, what was once the sole province of a DSP can now be achieved by a general purpose processor.