Introduction to Embedded Systems
An embedded system is a computer built into a product to perform a dedicated job. It may not look like a computer, but it still has a processor, memory, inputs, outputs, firmware, and timing constraints.
A washing machine controller, smart meter, insulin pump, airbag controller, thermostat, router, CNC machine, and motor drive are all embedded systems. Their users care about the product behavior, not the processor inside.
Learning Objectives
By the end of this lesson, you should be able to:
- Define an embedded system in practical engineering terms.
- Identify the input, processing, output, and feedback parts of an embedded product.
- Explain real-time constraints and resource constraints.
- Compare microcontrollers, application processors, and FPGAs at a high level.
- Recognize safety, reliability, and lifecycle issues that make embedded development different from desktop software.
What Makes a System Embedded?
A general-purpose computer runs many unrelated applications chosen by the user. An embedded system is designed around a specific product function.
| Property | General-Purpose Computer | Embedded System |
|---|---|---|
| Purpose | Flexible, user-selected tasks | Dedicated product function |
| Software | Many installable applications | Firmware tied to hardware |
| Hardware access | Mostly through OS drivers | Often direct register and interrupt access |
| Resources | GB of RAM, GHz CPU, large storage | Bytes to MB of RAM, kHz to MHz or low GHz CPU |
| Timing | Usually best-effort | Often deadline-driven |
| Failure mode | App crash or reboot | Product malfunction, field return, or safety hazard |
Anatomy of an Embedded System
Every embedded system follows a sense-decide-act loop.
The input may be physical, such as a sensor voltage, or digital, such as a CAN frame. The output may control power hardware, communicate status, update a display, or store data.
Worked Example: Thermostat Controller
Consider a room thermostat.
| Part | Thermostat Example |
|---|---|
| Inputs | Temperature sensor, buttons, schedule, door/window sensor |
| Processing | Microcontroller compares measured temperature with setpoint |
| Outputs | Relay or triac for heater, display, wireless status |
| Timing | Sample temperature every second; debounce buttons in milliseconds |
| Safety | Avoid rapid compressor cycling; detect sensor failure |
| Non-volatile data | Setpoint, calibration, schedule |
A simple control rule might be:
if temperature < setpoint - hysteresis:
turn heater on
if temperature > setpoint + hysteresis:
turn heater off
The rule is simple, but the real product also needs sensor filtering, relay lifetime protection, power-fail recovery, watchdog handling, and safe behavior when the sensor is disconnected.
Real-Time Requirements
Real-time does not mean "fast." It means "correct within a deadline."
Hard real-time systems require careful interrupt latency, scheduling, worst-case execution time analysis, and testing. A firmware loop that "usually works" is not enough when a missed deadline can damage equipment or harm a person.
Resource Constraints
Embedded systems are constrained because products are constrained.
| Constraint | Why It Matters |
|---|---|
| RAM | Stack, heap, buffers, and global variables must fit reliably |
| Flash | Program code, constants, bootloader, and update images need space |
| CPU time | Control loops, communication, and UI compete for cycles |
| Power | Battery products may sleep most of the time |
| Cost | A few cents matter in high-volume products |
| Pins | Interfaces must fit the selected package |
| Environment | Temperature, vibration, EMI, moisture, and aging affect behavior |
Embedded engineering is often the art of meeting product requirements with the smallest reliable hardware and the simplest maintainable firmware.
Common Processing Choices
| Device Type | Strength | Typical Use |
|---|---|---|
| 8-bit MCU | Low cost, simple, low power | Basic control, small sensors |
| 32-bit MCU | Good peripherals and performance | Motor control, industrial nodes, IoT |
| Application processor | Runs Linux and rich software stacks | HMI, gateways, camera systems |
| FPGA | Massive parallelism and deterministic timing | High-speed I/O, custom logic, signal processing |
The right choice depends on timing, power, development cost, certification needs, available libraries, and production volume.
Embedded Development Stack
Unlike desktop applications, embedded firmware often controls hardware registers directly. A mistake may not produce a friendly exception; it may lock the bus, corrupt Flash, reset the watchdog, or drive an output at the wrong time.
Safety and Reliability Mindset
Even a non-life-critical embedded product should fail predictably.
Designers commonly use:
- Watchdog timers to recover from software lockups.
- Brown-out detection to avoid running at unsafe supply voltage.
- CRC checks for stored settings and firmware images.
- Input validation for communication packets.
- Output defaults that are safe after reset.
- Derating for voltage, current, temperature, and component lifetime.
- Test points and logging hooks for field diagnosis.
For safety-critical products, follow the relevant standard and review process. Examples include IEC 61508 for functional safety, ISO 26262 for automotive, IEC 62304 for medical software, and DO-178C for avionics software.
Common Mistakes
- Starting firmware before defining timing, power, and fault requirements.
- Assuming the main loop is fast enough without measuring worst-case latency.
- Ignoring stack size and interrupt nesting.
- Using blocking delays in code that must service communication or control loops.
- Treating noisy physical inputs as clean digital values.
- Forgetting brown-out, watchdog, and reset behavior.
- Building a prototype that works only on a bench supply and fails in the field.
Practice
Pick one product, such as a smart plug, water pump controller, digital weighing scale, or motorized valve. List:
- Inputs.
- Outputs.
- Processor choice.
- Memory needs.
- Real-time deadlines.
- Power constraints.
- Safe state after reset.
- One likely field failure and how firmware should detect it.
Summary
An embedded system is a dedicated computer inside a product. It senses the world, makes decisions, and controls outputs under limits of time, power, memory, cost, and reliability. Embedded development requires software skill, hardware awareness, and a disciplined approach to failure modes.
Further Reading
- Elecia White, Making Embedded Systems, for practical firmware architecture.
- Jonathan W. Valvano, Embedded Systems: Introduction to ARM Cortex-M Microcontrollers.
- Michael Barr and Anthony Massa, Programming Embedded Systems.
- ARM Cortex-M technical reference manuals for interrupt, memory, and peripheral concepts.
- IEC 61508 overview material for functional safety vocabulary.