Back

Embedded systems notes

An overview
A typical home computer is a general-purpose system that can easily be adapted to many different applications. We all like to have the best home computer that we can afford so we can do as much as possible with our computers. We want the fastest processor, as much RAM and cache as we can get, the best storage device we can afford such as a DVD writer and the latest peripherals. Embedded systems, on the other hand, are computer systems designed for a very specific purpose. They are often mass-produced for goods such as washing machines, telephones and videos and it is often not at all important to have the fastest processor, the biggest memory and so on. Keeping costs low is a far more important concern and so slower processors and simplified designs are common. Also of concern is the amount of power consumed by the embedded system. It is important for a designer to keep the power consumption of a system low to keep running costs low and power needs simple.

We have already said that washing machines and videos use ‘embedded systems’. They have sensors (the inputs) that read data and pass it to the processor. The processor examines the inputs and decides what outputs to set (the processing). Signals are sent to the actuators (for example, motors and pumps) to actually make things happen (the outputs). We have said that embedded systems often have simplified designs. They often do not have an operating system, a disk drive, a VDU or keyboard. All they have is a processor with a program that reads in input data, processes it and then outputs signals to make things happen. The program is in the machine code of the processor and stored in ROM. The program is relatively simple, requiring only very specific tasks to be done. It will often be written within a loop, so that, once set, the program simply repeats itself until it ends or is aborted.

Whilst home computers generally use either the Intel 80x86 family of processors (for IBM compatible computers) or the 680x0 family of processors (for the Apple Macintosh computers), embedded systems use a wide range of processors. A further development is that the processor is often designed into an integrated circuit along with all of the other circuits needed so that there is just one chip. This helps simplify the design, aids mass production and helps to keep production costs low.

A digital alarm clock - a case study
Consider a modern digital alarm clock. It is an example of where an embedded system is commonly used. The alarm clock is mass-produced. To keep costs low, an integrated circuit (I/C) is designed for it. The I/C will have the processor on it along with any other electronic circuitry needed by the processor, for example, some ROM. The I/C will be connected to the inputs such as the buttons to set the time, and the outputs, such as the time display, beeper and ‘alarm on’ indicator. The ROM chip will be used to hold the program.

embed

    • Function 1. When the ‘Set the time’ button is held down, the time can be set by pressing the ‘Move’ buttons under the display. If a Move button is pressed once then the corresponding part of the time display moves forward by one number. If a Move button is held down, then the corresponding part of the time display moves through the numbers quickly.
    • Function 2. When the ‘Set the alarm time’ button is held down, the alarm time can be set by pressing the ‘Move’ buttons under the display. If a Move button is pressed once then the corresponding part of the time display moves forward by one number. If a Move button is held down, then the corresponding part of the time display moves through the numbers quickly. If the ‘Alarm activated / deactivated’ button is pressed, the alarm is toggled between set and reset. The alarm indicator is lit as appropriate.
    • Function 3. The current time is displayed.
    • Function 4. If the alarm is set then the program needs to monitor the current time and the alarm time. At the appropriate moment, the beeper is made to beep. It continues to beep until the alarm is deactivated or 10 minutes have passed.
    • Function 5. The backlight is turned on whilst the backlight button is pressed.

How would we design the program?
There are different ways we could write a program to control the alarm clock. If we were to use a procedural approach, we would note that there are five different procedures. We could write a program as a set of five procedures. The main program would simply be a loop, calling each procedure in turn. We have seen this idea before. Another slightly different approach might be to design a program where some procedures are called only if an interrupt happens in the main program. For example, instead of calling the procedure to turn on the light behind the display because it is its turn to be called in the main looping program, it only gets called if the backlight button is pressed. When the button is pressed, it sends an interrupt signal to the processor that then reacts by calling the backlight procedure. This has the advantage of not wasting time calling procedures even if they are not needed! They only get called because there has been a signal to say that a function is needed.

We could program the alarm clock using an object oriented approach. We could start by identifying the classes needed. For example, one obvious class is the display. We would identify the data needed for the display and the methods required to set and display the time or alarm time. Another class might be for the beeper. We would need to identify what data would be needed for the beeper and what methods it would need. However the program was written, whatever language was used, it would be translated into object code and then burnt into the ROM chip.

Critical embedded systems
Some embedded systems are critical. By that, we mean that they are in places where they do a very important job and if they fail, it may have catastrophic implications. Embedded systems in planes, for example, are often critical. These types of embedded systems need a different design approach to the embedded systems found in washing machines, for example.
They need to run predictably. When we looked at the alarm clock, one way to design the program was using interrupts. If the backlight button was pressed, then an interrupt occurred that resulted in a procedure being called. If that procedure was called within 3 milliseconds one time and within 20 milliseconds the next time it wouldn’t really matter. With critical systems, it matters a lot. It is very important to be able to predict with accuracy the reaction times to interrupts and the time that some code will run. They need to run reliably. It is important that a mission-critical system will work whatever happens! To achieve this, critical embedded systems have many fail-safe systems built in. They may have a second or even third processor, for example, ready to step in and take over if the main processor fails. They may have methods that allow data to be read in twice using different sensors and checked against each other. They may have sub-systems ready to take action monitoring the main systems. If necessary, a sub-system can, for example, alert a pilot to a problem. They may have software that can attempt to recover from faults. Programming languages such as ADA are designed for this. Critical systems are expensive. They have a lot of extra hardware and software that may never be needed. Although any computerised system can never be 100% reliable, critical embedded systems attempt to reduce the risk to acceptable levels.

The use of embedded systems
Embedded systems are so widespread and taken for granted that you may not realise how widespread they actually are! Estimates differ on the number of embedded systems in a new car these days but estimates somewhere between 30 and 100 seem popular. The average number of embedded systems in a ‘typical’ home may be between 200 and 300. How many are there in your home? You have many devices that have a processor controlling them including alarm clocks, digital wristwatches, toasters, microwaves, washing machines, cookers, central heating systems, Hi-fi equipment, guitars and amplifiers, scanners, digital cameras, TVs, video players, tamagotchi, burglar alarms and the list goes on. There is a shortage of skilled embedded systems designers. It is a very satisfying career because you can be involved in lots of different aspects of the whole design. You may want to look up computer-based courses at university that include at least an element of embedded systems design!

Back