Show understanding of embedded systems

3.1 Computers and Their Components – Embedded Systems

1. Definition and Why Embedded Systems Are Needed

An embedded system is a computer system designed to perform a dedicated function (or a small set of functions) within a larger mechanical or electrical device. It is “embedded” because the hardware and software are built into the host product and are usually invisible to the end‑user. Embedded systems are required when a device must operate autonomously, reliably, and often in real‑time while meeting strict constraints on cost, size, power consumption, and durability.

2. Data Representation (Syllabus Requirement 1)

All digital computers, including embedded ones, store and manipulate data in binary form. The following representations are essential for the Cambridge International AS & A Level Computer Science syllabus.

Representation Key Points Typical Use in Embedded Systems
Binary, Octal, Hexadecimal Base‑2, base‑8 and base‑16 notations; easy conversion using groups of 3 or 4 bits. Memory addresses, register contents, low‑level debugging.
BCD (Binary‑Coded Decimal) Each decimal digit encoded in 4‑bit nibble; simplifies conversion to human‑readable numbers. Display drivers for digital clocks, calculators.
ASCII / Unicode Standard codes for characters; ASCII uses 7‑bits, Unicode extends to 16‑ or 32‑bits. Textual user interfaces, serial communication of commands.
Two’s‑Complement Integer Represents signed integers; range –2n‑1 … 2n‑1‑1 for n‑bit word; overflow detection. Arithmetic in control algorithms, sensor data processing.
Floating‑Point (IEEE‑754) Sign, exponent, mantissa; supports very large/small real numbers; single (32‑bit) and double (64‑bit) precision. Complex calculations in navigation, signal processing, AI inference.
Compression (Lossless & Lossy) Lossless – RLE, Huffman (exact reconstruction).
Lossy – JPEG, MP3 (approximate reconstruction).
Storing sensor logs (lossless) or image/video streams (lossy) on limited flash.

Worked Example – Binary ↔ Decimal conversion

Binary 1101 1010₂ = (1·2⁷)+(1·2⁶)+(0·2⁵)+(1·2⁴)+(1·2³)+(0·2²)+(1·2¹)+(0·2⁰)
                = 128+64+0+16+8+0+2+0 = 218₁₀

3. Hardware & Processor Fundamentals (Syllabus Requirement 3)

This section expands the earlier hardware overview to cover the internal workings of a processor, which are required knowledge for the Cambridge syllabus.

  • CPU Registers
    • General‑purpose registers (e.g., R0‑R15) hold temporary data and intermediate results.
    • Special‑purpose registers: Program Counter (PC), Stack Pointer (SP), Status/Flag register (Zero, Carry, Overflow, Interrupt Enable).
  • Arithmetic Logic Unit (ALU)
    • Performs integer arithmetic, logical operations (AND, OR, XOR, NOT), shift/rotate.
    • Sets condition flags used by branch instructions.
  • Control Unit
    • Generates control signals that orchestrate data movement between registers, ALU, memory, and I/O.
    • Implements the fetch‑decode‑execute cycle.
  • Fetch‑Execute Cycle
    1. Fetch: PC provides address → memory read → instruction placed in Instruction Register (IR).
    2. Decode: Control unit interprets opcode, determines required operands.
    3. Execute: ALU or other functional unit carries out operation; result may be stored back.
    4. PC is incremented (or altered by branch/jump).
  • Interrupts
    • Asynchronous signals that pause the current instruction stream, save context, and jump to an Interrupt Service Routine (ISR).
    • Essential for real‑time response to sensors, communication peripherals, or timer events.
  • Bus Architecture
    • Address bus – carries memory/peripheral addresses (unidirectional).
    • Data bus – carries actual data (bidirectional).
    • Control bus – carries read/write, interrupt, clock signals.
  • RISC vs. CISC
    • RISC (Reduced Instruction Set Computer): simple, fixed‑length instructions, many registers, typically pipelined (e.g., ARM Cortex‑M).
    • CISC (Complex Instruction Set Computer): variable‑length, many addressing modes, historically used in x86.
  • Pipelining
    • Divides the fetch‑decode‑execute cycle into stages; multiple instructions overlap, increasing throughput.
    • Hazard handling (data, control, structural) is a design concern for deterministic embedded timing.
  • Virtual Machines (VMs)
    • Software layer that emulates a hardware architecture (e.g., Java Virtual Machine, .NET CLR).
    • Used in some embedded platforms to provide portability at the cost of performance.
  • Boolean Algebra & Logic Circuits
    • Fundamental gates: AND, OR, NOT, NAND, NOR, XOR, XNOR.
    • Truth tables define output for every input combination.
    • Combinational circuits (adders, multiplexers) and sequential circuits (flip‑flops, counters) are built from these gates.

4. Principal Hardware Components of an Embedded System

Component Role in an Embedded System
CPU (Microcontroller) Executes the control program; contains on‑chip registers, ALU, and often SRAM/Flash.
Main Memory (RAM) Temporary storage for variables, stack, and runtime data.
Secondary (Removable) Storage Holds large firmware images, data logs, or user‑upgradable applications (e.g., SD card, USB flash).
Input Devices (Sensors) Convert physical quantities (temperature, light, motion, etc.) into electrical signals readable by the CPU.
Output Devices (Actuators) Convert CPU commands into physical actions (motors, valves, LEDs, speakers).
Peripheral Interfaces UART, SPI, I²C, CAN, Ethernet, ADC/DAC, timers – provide specialised I/O and timing services.
Power Supply Batteries, mains adapters, or energy‑harvesting circuits; includes regulation to provide stable voltages.
Real‑Time Operating System (RTOS) – optional Manages deterministic task scheduling, interrupt handling and timing services.

5. Memory Types – RAM vs. ROM and SRAM vs. DRAM

Memory Type Volatility Typical Speed Typical Use in Embedded Systems
RAM (Random‑Access Memory) Volatile – loses data when power is removed Fast (nanoseconds) Run‑time data, stack, variables
ROM (Read‑Only Memory) Non‑volatile Slow to moderate (technology‑dependent) Store firmware that never changes
SRAM (Static RAM) Volatile Very fast, no refresh required On‑chip cache, small internal RAM
DRAM (Dynamic RAM) Volatile Fast but requires periodic refresh External main memory in larger embedded boards
PROM / EPROM / EEPROM / Flash Non‑volatile Slower than RAM; EEPROM/Flash can be rewritten Program storage, configuration data, boot code

6. Buffers – Why They Are Needed

A buffer is a temporary storage area that holds data while it is transferred between two components that operate at different speeds or use different protocols. Buffers prevent data loss, smooth timing mismatches and allow the CPU to continue processing while I/O devices complete their operations.

Simple buffer diagram showing CPU ↔ Buffer ↔ UART peripheral
Figure 1 – Buffer placed between the CPU and a UART peripheral. Data written by the CPU is stored in the buffer until the UART can transmit it; incoming data is stored until the CPU reads it.

7. Sensors, Actuators and Feedback (Monitoring & Control)

  • Sensors (inputs) – Convert a physical quantity (temperature, pressure, light, motion, etc.) into an electrical signal that the CPU can read.
  • Actuators (outputs) – Convert an electrical command from the CPU into a physical action (motor rotation, valve opening, LED illumination, etc.).
  • Feedback loop – The sensor measures the effect of the actuator; the CPU compares this measurement with the desired set‑point and adjusts the control signal accordingly.
    Example: A thermostat reads a temperature sensor, compares it with the user‑set temperature, drives a heating element, and then re‑reads the temperature to maintain the set point.

8. Role of Secondary (Removable) Storage

Secondary storage provides non‑volatile space that can be added or replaced after manufacture. In embedded systems it is used for:

  • Storing large firmware images or OS kernels that do not fit in internal flash.
  • Logging data (event logs, sensor recordings) that must survive power loss.
  • Enabling field upgrades – the system can load a new program from an SD card or USB stick without specialised programming equipment.

9. Communication & Networks (Syllabus Requirement 2)

Modern embedded devices increasingly communicate with each other or with cloud services. The following concepts satisfy the Cambridge syllabus.

Concept Key Points Typical Embedded Example
LAN, WAN, Internet, Cloud LAN – local area network (e.g., Ethernet within a factory).
WAN – wide area network (e.g., cellular).
Cloud – remote servers offering storage/computation.
Smart‑meter sending usage data to a utility’s cloud platform.
Network Topologies Bus, Star, Mesh, Hybrid – illustrated with simple diagrams. Star topology for a home automation hub (central controller ↔ sensors).
OSI / TCP‑IP Model 7‑layer OSI (Physical → Application) and 4‑layer TCP‑IP (Link → Application).
Key protocols: HTTP, FTP, SMTP, TCP, UDP, ICMP.
UART → Ethernet PHY (Physical) → IP (Network) → UDP (Transport) → Custom binary protocol (Application).
IP Addressing & Subnetting IPv4 – 32‑bit dotted decimal; IPv6 – 128‑bit hex groups.
Subnet mask determines network vs. host portion.
Device configured with 192.168.1.45/24 on a home LAN.
DNS (Domain Name System) Translates human‑readable domain names to IP addresses. Embedded thermostat resolves api.weather.com to obtain forecast data.
Client‑Server vs. Peer‑to‑Peer Client initiates requests to a server; P2P nodes communicate directly. Firmware update client contacting a server vs. two drones exchanging telemetry directly.
Routing & Packet Switching Routers forward packets based on destination IP; packets may travel via multiple hops. Sensor node → gateway router → cloud server.

10. Design Process – Step‑by‑Step

  1. Define functional requirements and performance constraints (real‑time deadlines, power budget, cost).
  2. Select hardware that satisfies the requirements (CPU core, RAM/Flash size, required peripherals, communication interfaces).
  3. Choose a development environment and, if needed, an RTOS.
  4. Write firmware:
    • Use interrupt‑driven I/O and buffers for deterministic timing.
    • Apply modular programming and, where appropriate, object‑oriented concepts.
  5. Integrate sensors, actuators and feedback logic; verify the control loop with hardware‑in‑the‑loop testing.
  6. Perform system‑level testing (environmental, reliability, power consumption) and verify compliance with relevant standards (e.g., IEC 60730 for safety‑critical devices).
  7. Document the design, produce user manuals, and plan for future firmware upgrades.

11. Embedded vs. General‑Purpose Computers

Aspect Embedded System General‑Purpose Computer
Purpose Single, dedicated function (or small set) Multiple, varied functions
Hardware Optimised, often single‑chip (microcontroller) Modular, expandable (CPU, separate RAM, HDD/SSD, etc.)
Operating System RTOS or bare‑metal Full‑featured OS (Windows, Linux, macOS)
Power Consumption Low – battery or energy‑harvesting Higher – mains powered
Cost per Unit Minimised, mass‑produced Higher, often bespoke
Reliability Requirement Very high – often mission‑critical, long‑run operation Moderate – user can reboot or reinstall

12. Performance Modelling for Real‑Time Tasks

For each periodic task the worst‑case execution time (WCET) must not exceed its deadline \(D\):

\( \text{WCET} \le D \)

When \(n\) periodic tasks share a single processor, Liu & Layland’s bound for Rate‑Monotonic Scheduling must be satisfied:

\( U = \displaystyle\sum_{i=1}^{n}\frac{C_i}{T_i} \le n\bigl(2^{1/n}-1\bigr) \)

where \(C_i\) is the computation time and \(T_i\) the period of task \(i\). The utilisation \(U\) gives a quick check of whether the set of tasks can meet all deadlines.

13. Illustrative Examples of Embedded Systems

  • Automotive Engine Control Unit (ECU) – reads multiple sensors, controls fuel injection and ignition timing.
  • Digital washing‑machine controller – monitors door lock, water level, temperature; drives motor and valve actuators.
  • Smart thermostat – temperature sensor → control algorithm → heating/cooling actuator; communicates with a cloud service for remote control.
  • Medical infusion pump – precise flow sensor feedback drives a stepper motor that delivers medication at a programmed rate.
  • Industrial PLC (Programmable Logic Controller) – I/O modules, real‑time ladder logic for factory automation.
  • Wearable fitness tracker – accelerometer sensor, Bluetooth Low Energy (BLE) communication, on‑board ARM Cortex‑M0+ for activity analysis.

14. Future Trends

  • Internet of Things (IoT) – billions of networked sensors and actuators, often powered by energy‑harvesting techniques.
  • Edge AI – on‑device machine‑learning inference for vision, speech, predictive maintenance, reducing latency and bandwidth usage.
  • Ultra‑low‑power architectures (ARM Cortex‑M0+, RISC‑V) for battery‑operated wearables and medical implants.
  • Hardware‑based security – secure boot, TPM (Trusted Platform Module), cryptographic co‑processors to protect firmware integrity and data privacy.
Block diagram of a typical embedded system
Figure 2 – Block diagram: microcontroller (CPU + on‑chip SRAM/Flash), optional external RAM/DRAM, secondary storage, power‑supply, buffers, I/O peripherals, and external sensors/actuators.

Create an account or Login to take a Quiz

67 views
0 improvement suggestions

Log in to suggest improvements to this note.