User:Irshadinst
Embedded Systems
An embedded system is not a microprocessor used in a “traditional” computing application that is desktop, laptop and workstation. An embedded system is a microprocessor used as a component in another piece of technology that is cell phone, digital camera, portable digital assistant, household appliance and automobile antilock brake system. This article introduces the reader to embedded systems.
Introduction
An embedded system is a microprocessor-based system that is incorporated into a device to monitor and control the functions of the components of the device. They are used in many devices ranging from a microwave oven to a nuclear reactor. Unlike personal computers that run a variety of applications, embedded systems are designed for performing specific tasks. An embedded system used in a device (for instance the embedded system in washing machine that is used to cycle through the various states of the washing machine) is programmed by the designers of the system and generally cannot be programmed by the end user. Embedded systems possess the following distinguishing qualities.
Reliability
Embedded systems should be very reliable since they perform critical functions. For instance, consider the embedded system used for flight control. Failure of the embedded system could have disastrous consequences. Hence embedded system programmers should take into consideration all possibilities and write programs that do not fail.
Responsiveness
Embedded systems should respond to events as soon as possible. For example, a patient monitoring system should process the patient’s heart signals quickly and immediately notify if any abnormality in the signals is detected.
Specialized Hardware
Since embedded systems are used for performing specific functions, specialized hardware is used. For example, embedded systems that monitor and analyze audio signals use signal processors. Keywords: Embedded system, micro-controller, simulator, emulator. Figure 1. Embedded and real time systems.
Low cost:
As embedded systems are extensively used in consumer electronic systems, they are cost sensitive. Thus their cost must be low.
Robustness:
Embedded systems should be robust since they operate in a harsh environment. They should endure vibrations, power supply fluctuations and excessive heat. Due to limited power supply in an embedded system, the power consumed by the components of the embedded system should be kept to a minimum.
Embedded systems are often confused with real-time systems. Areal-time system is one in which the correctness of the computations not only depends on the accuracy of the result, but also on the time when the result is produced. This implies that a late answer is a wrong answer. A hard real-time system should always respond to an event within the deadline or else the system fails. Soft real-time systems have less severe time constraints. All embedded systems are not real-time systems and vice-versa. Figure 1 shows the relation between embedded and real-time systems.
Components of an Embedded System
Embedded systems have the following components. (Embedded systems should be highly reliable, responsive, robust and inexpensive)
Processor:
A processor fetches instructions from the memory unit and executes the instructions. An instruction consists of an instruction code and the operands on which the instruction should act upon. The format of instruction code and operands of a processor is defined by the processor’s instruction set. Each type of processor has its own instruction set. Performance of the system can be improved by using specialized processors. These dedicated processors implement algorithms in hardware using building blocks such as hardware counters and multipliers. For example, digital signal processors are particularly designed for implementing digital signal processing algorithms such as the fast Fourier transform (FFT) algorithm and filtering algorithms. For the input x(n), the output y(n) of an FIR filter is given by the equation Y (n) =Σx(n–k)h(k) for n=1,2,…, . Where, k=1 to m The equation clearly shows that filtering involves many multiply and accumulate operations. Hence digital signal processors use a dedicated circuit for performing multiply and accumulate operations. Some embedded processors have special fuzzy logic instructions (such as the fuzzy AND instruction). This is because inputs to an embedded system are sometimes better represented as fuzzy variables. For instance, the mathematical model for a control system may not exist or may involve expensive computing power. Fuzzy logic can be employed for such control systems to provide a cost-effective solution. ( In fuzzy logic variables have value in the range [0, 1], with 0 representing absolute falseness and 1 representing absolute truth.)
Memory
The memory unit in an embedded system should have low access time and high density (a memory chip has greater density if it can store more bits in the same amount of space). Memory in an embedded system consists of ROM (only read operations permitted) and RAM (read and write operations are permitted). The contents of ROM are non-volatile (power failure does not erase the contents) while RAM is volatile. The classification of the ROM is given in Figure 2. ROM stores the program code while RAM is used to store transient input or output data. Embedded systems generally do not possess secondary storage devices such as magnetic disks. As programs of embedded systems are small there is no need for virtual storage.
Peripherals:
Peripherals are the input and output devices connected to the serial and parallel ports of the embedded system. Serial ports transfer one bit at a time between the peripheral and the microprocessor. Parallel ports transfer an entire word consisting of many bits simultaneously between the peripheral and the microprocessor. The microprocessor generally communicates with the peripherals using a programmable interface device. Programmable interface devices provide flexibility since they can be programmed to perform I/O on different peripherals. The microprocessor monitors the inputs from peripherals and performs actions when certain events occur. For instance, Figure 2. Classification of ROMS. when sensors indicate that the level of water in the wash tub of a washing machine is above the preset level, the microprocessor starts the wash cycle. (Due to the absence of secondary storage devices in an embedded system, program code and constant data reside in the ROM. During execution of the program, storage space for variables is allocated in the RAM.)
Hardware Timers
The clock pulses of the microprocessor periodically update hardware timers. The timers count the clock pulses and interrupt the processor at regular intervals of time to perform periodic tasks.
Software
Due to the absence of secondary storage devices in an embedded system, program code and constant data reside in the ROM. During execution of the program, storage space for variables is allocated in the RAM. The programs should execute continuously and should be capable of handling all possible exceptional conditions. Hence the programs generally do not call the function exit. Real-time embedded systems posses an RTOS (real-time operating system). The RTOS consists of a scheduler that manages the execution of multiple tasks in the embedded systems. Unlike operating systems for the desktop computers where scheduling deadlines are not critical, an RTOS should schedule tasks and interrupt service routines such that they are completed within their deadlines. The RTOS provides features that simplify the programmer’s job. For example, an RTOS provides semaphores that can be used by the programmer to prevent multiple tasks from simultaneously writing into shared memory. With the recent developments in VLSI, the processor, memory, peripherals and the interfaces to the outside world are integrated into a single chip resulting in a microcontroller. Figure 3 shows the details of 8051 microcontroller. (With the recent developments in VLSI, the processor, memory, peripherals and the interfaces to the outside world are integrated into a single chip resulting in a microcontroller.)
Example of an embedded system
Consider the anti-lock braking system in a car. When brakes are applied to a car traveling at high speed, the wheels stop much more quickly than the car and ‘lock up’. An anti-lock brake system ensures that the wheels of the car gradually stop when brakes are applied. The anti-lock brake system has the following components. Figure 3. Block diagram of 8051 microcontroller.
Speed sensors:
The speed sensors are located at each wheel and indicate the speed of the wheels.
Valves:
Valves regulate the pressure applied on the brakes. Ann open valve allows pressure to be transmitted to the brake. A closed valve prevents the pressure on the brakes from rising even though the driver pushes the brake pedal harder
Microcontroller:
The microcontroller monitors the speed sensors and checks for rapid decelerations in the wheels. On detecting a rapid deceleration, the microcontroller reduces the pressure on the brake by closing the valves until it sees an acceleration. The microcontroller then increases the pressure on the brakes by opening the valves until it sees a deceleration. This cycle continues and results in the wheel slowing down at the same rate as the car.
Embedded Software Development
Programmers who write programs for desktop computers do their work on the same kind of computer on which their application will run. A programmer developing a program to run on a Linux machine edits the program, compiles it and debugs it on a Linux machine. This approach cannot be used for embedded systems due to the limited hardware and software in an embedded system. For example, the absence of a keyboard in the embedded system rules out editing a program in the embedded system. So, most of the programming work for an embedded system, which includes writing, compiling, assembling and linking the program, is done on a general purpose computer called a host that has all the required programming tools. The final executable consisting of machine code is then transferred to the embedded system (also referred to as target). Figure 4 shows the development of embedded software on the host. Programs are written on the host in a high level language (such as C) or assembly language of the target system’s processor. The program files written in the high level language are compiled on the host using a cross-compiler to obtain the corresponding object files. The assembly language files are assembled on the host using a cross-assembler to obtain the object files. The object files produced by cross-compilers and cross-assemblers contain instructions that are understood by the target’s processor (native compilers and assemblers on the other hand produce object files containing instructions that are understood by the host’s processor). Figure 4. Software development on the host. The object files are linked using a specialized linker called locator to obtain the executable code. This executable code is stored in the ROM. Since the program code already resides in memory, there is no need for a loader in an embedded system. In personal computers, on the other hand, the loader has to transfer the program code from the magnetic disk to memory to execute the program. The binary code obtained by translating an assembly language program using an assembler is smaller and runs faster than the binary code obtained by translating a high level language using a compiler since the assembly language gives the programmer complete control over the functioning of a processor. The advantage of using a high level language is that a program written in a high level language is easier to understand and maintain than a program written in assembly language. Hence time critical applications are written in assembly language while complex applications are written in a high level language. The programs developed for an embedded system are tested using the following tools.
Simulator
A simulator is software tool that runs on the host and simulates the behavior of the target’s processor and memory. The simulator knows the target processor’s architecture and instruction set. The program to be tested is read by the simulator and as instructions are executed the simulator keeps track of the values of the target processor’s registers and the target’s memory. Simulators provide single step and breakpoint facilities to debug the program. Simulators cannot be used if the embedded system uses special hardware that cannot be simulated and the only way to test the program is to execute it on the target. Although simulators do not run at the same speed as the target microprocessor, they provide details from which the time taken to execute the code on the target microprocessor can be determined. For instance, the simulator can report the number of target microprocessor’s bus cycles taken to execute the code. Multiplying this value with the time taken for one bus cycle gives the actual time taken by the target microprocessor to execute the code.
Emulator
An emulator is a hardware tool that helps in testing and debugging the program on the target. The target’s processor is removed from the circuit and the emulator is connected in its place. The emulator drives the signals in the circuit in the same way as the target’s processor and hence the emulator appears to be the processor to all other components of the embedded system. Emulators also provide features such as single step and breakpoints to debug the program.
Conclusion
Embedded systems have requirements that differ significantly from general purpose computers. The main goal of an embedded system developer is to design a lowest cost system that performs the desired tasks without failing. Algorithms can be implemented in hardware or software. While the hardware approach improves performance the software approach provides flexibility. Recent developments in hardware-software co-design permit tradeoffs between hardware and software for cost-effective embedded systems.
Suggested Reading
[1] David E Simon, An Embedded Software Primer, Addison- Wesley Pub Co, 1999.
[2] Michael Barr, Programming Embedded Systems in C and C ++, O’Reilly & Associates, 1999.
[3] Myke Predko, Programming and Customizing the 8051 Microcontroller, McGraw- Hill, 1999.
Md. Irshad Alam is a Master of science in Electronics and Bachelor of Science in Instrumentation Science & Technology from Faculty of Engineering & Technology Jamia Millia Islamia (A Central University) New Delhi Research interests in Scientific & Industrial Devices and Systems Design & developments
Contact:
Md. Irshad Alam
Email:
irshad@obdstech.com