Edexcel International Advanced Level Computer Science, point 11.1.5
Definition
An embedded system is a computer system built into a larger device, to carry out one dedicated function (or a small set), usually with real-time requirements and limited resources. Examples: washing machine controllers, car engine management, pacemakers, smart thermostats, digital cameras, traffic lights, microwave ovens, fitness trackers.
Function and characteristics
- Dedicated purpose: it does one job, unlike a general-purpose PC.
- Built into a device (it isn't a separate computer to the user).
- Limited resources: small memory, low power, low cost.
- Often real-time: it must respond within a fixed time (airbag, brakes).
- Reliable and long-running, often for years without attention.
- Little or no user interface, or a simple one (buttons, small display).
- Program stored permanently (in flash or ROM, firmware).
a. Hardware components
| Component | Role |
|---|---|
| Microcontroller unit (MCU) | A single chip with CPU, memory and I/O interfaces together. It runs the program and controls the device |
| Memory | Flash/ROM for the program (firmware), RAM for working data; often small |
| I/O interfaces and ports | Connections to the outside: general-purpose I/O pins, serial (UART, I²C, SPI), USB, wireless |
| Sensors | Detect physical conditions and turn them into electrical signals (below) |
| Actuators | Convert the system's output into physical action: motors, valves, heaters, speakers, displays, lights, relays |
| ADC / DAC | Convert between analogue and digital signals (below) |
| Power supply | Battery, mains adapter or energy harvesting, with voltage regulation. Low power is often vital |
Sensors
| Sensor | Measures | Example use |
|---|---|---|
| Accelerometer | Acceleration and tilt | Phone screen rotation, airbag deployment, step counting |
| Vibration | Vibrations and shocks | Detecting machine faults, earthquake alarms |
| Sound (microphone) | Sound waves | Voice assistants, noise monitoring, baby monitors |
| Temperature | Temperature | Thermostats, ovens, engine management |
Analogue-digital conversion (ADC / DAC)
The real world is analogue (continuous), but the MCU is digital. An ADC (analogue-to-digital converter) turns a sensor's analogue voltage into a binary number. A DAC does the reverse, to drive an analogue actuator (for example a speaker).
The ADC has three steps:
- Sampling: measure the signal at regular intervals. The sampling rate is samples per second. To capture a signal accurately, sample at least twice its highest frequency (the Nyquist rule).
- Quantisation: round each measurement to the nearest of a fixed number of levels. An -bit ADC has levels. More bits mean finer steps (higher resolution) and a smaller quantisation error.
- Encoding: write each level as a binary number.
Worked conversion: a 4-bit ADC measures 0 to 3.3 V.
- Levels: (numbered 0 to 15).
- Step size: V.
- A reading of 2.0 V: , which rounds to 9 (quantisation), so the encoded value is
1001. - The quantised voltage is V, so the quantisation error is 0.02 V.
b. Software components
| Component | Role |
|---|---|
| Firmware | Software stored permanently in the device's non-volatile memory (flash/ROM). It starts the hardware and runs the dedicated function |
| Operating system (OS) | Often none (a simple loop on bare metal), or a small real-time operating system (RTOS) that guarantees response times and manages tasks (for example FreeRTOS), or embedded Linux on larger devices |
| Application software | The program that does the job: reads sensors, makes decisions, controls actuators |
| Programming languages | C and C++ (fast, close to the hardware, small), assembly (tiny, time-critical code, 13.1.3), MicroPython (easier, but slower and larger) |
Typical program structure:
Embedded systems compared with general-purpose computers
| Embedded system | General-purpose computer | |
|---|---|---|
| Purpose | One dedicated job | Many different jobs |
| Resources | Limited | Plentiful |
| Software | Fixed firmware | Many programs, installed by the user |
| User interface | Minimal | Full (screen, keyboard) |
| Real-time | Often | Rarely |
| Power | Very low | Higher |
| Cost per unit | Low | Higher |
Benefits and drawbacks
- Benefits: small, cheap, low power, reliable, optimised for one job, fast response, and easy to mass-produce.
- Drawbacks: hard to update (firmware updates are risky), limited processing power and memory, hard to debug (little or no screen), security risks if connected (IoT, 12.2) and never patched, inflexible, and design and testing must be very thorough, since faults (a car brake controller, a pacemaker) can be dangerous.
Worked example
Task: design an embedded system for a plant-watering controller: it measures soil moisture and turns on a pump when the soil is dry.
| Component | Choice |
|---|---|
| Sensor | Soil moisture sensor (analogue voltage) |
| ADC | 10-bit (1024 levels), sampling once a minute (the moisture changes slowly, so a low sampling rate saves power) |
| MCU | Low-power (for example an ARM Cortex-M or AVR), with flash for the firmware and a little RAM |
| Actuator | Pump via a relay, switched by an output pin |
| Power | Battery (or solar), so the MCU sleeps between readings |
| Firmware | Loop: read, compare with a threshold, switch the pump on for 10 seconds if dry, sleep |
| Language | C, for speed and small size |
A reading of 300 out of 1023 (below a threshold of 400) means dry, so the pump runs. Hysteresis (turning off at a higher level, 500) stops it switching on and off repeatedly.
Exam tip: know the hardware parts and what each does, and the three ADC steps (sampling, quantisation, encoding). You may be asked to complete a diagram of an embedded system (sensor, ADC, MCU, DAC, actuator) or an ADC process. Give reasons why an embedded system suits a task (dedicated, low power, real-time).
Check yourself
What is an embedded system?
A computer system built into a larger device to carry out a dedicated function, usually with limited resources and often real-time operation.
What is the job of an ADC?
To convert an analogue signal from a sensor into a binary number the microcontroller can process, by sampling, quantising and encoding it.
What is the difference between a sensor and an actuator?
A sensor detects a physical condition and produces an electrical signal. An actuator turns an electrical output into physical action, such as movement, heat or sound.
What is firmware?
Software stored permanently in the non-volatile memory of a device, which runs the hardware and performs its dedicated function.
How many levels does a 3-bit ADC have?
2³ = 8.