Embedded SystemUnit 1018 min read
Embedded System Design Case Studies: Real-World Applications & Analysis
Unit 10 of Embedded System explores real-world embedded system projects, their architectures, challenges, and solutions, covering IoT, industrial automation, medical devices, and consumer electronics. Students analyze case studies like smart home systems, automotive ECUs, and wearable tech to understand design trade-of
Why Study Case Studies?
Embedded systems are everywhere—from your smartphone to life-saving medical devices. This unit bridges theory and practice by dissecting real projects, showing how hardware, software, and protocols interact in constrained environments. You’ll learn:
- How design choices (e.g., microcontroller selection, power management) impact performance.
- Common challenges (e.g., real-time constraints, sensor noise, security) and their solutions.
- Industry trends like edge computing, AI in embedded systems, and energy harvesting.
1. Types of Embedded System Case Studies
Embedded systems are classified based on application domains, complexity, and constraints. Below is a comparison of key categories:
classDiagram
class EmbeddedSystem {
<<abstract>>
+Microcontroller/Processor
+Peripherals (Sensors/Actuators)
+Real-Time OS (Optional)
+Power Management
+Communication Protocols
}
class ConsumerElectronics {
+Low Power
+Cost-Effective
+Examples: Smartwatches, Microwaves
}
class IndustrialAutomation {
+High Reliability
+Deterministic Response
+Examples: PLCs, Robotics
}
class MedicalDevices {
+Safety-Critical
+Regulatory Compliance (FDA/ISO)
+Examples: Pacemakers, Glucose Monitors
}
class AutomotiveECUs {
+Real-Time Constraints
+CAN/FlexRay Protocols
+Examples: ABS, Airbag Systems
}
class IoTDevices {
+Wireless Connectivity
+Cloud Integration
+Examples: Smart Thermostats, Security Cameras
}
EmbeddedSystem <|-- ConsumerElectronics
EmbeddedSystem <|-- IndustrialAutomation
EmbeddedSystem <|-- MedicalDevices
EmbeddedSystem <|-- AutomotiveECUs
EmbeddedSystem <|-- IoTDevicesKey Takeaways:
- Consumer electronics prioritize low power and cost (e.g., ESP32 in smart bulbs).
- Industrial systems need deterministic timing (e.g., PLCs using RTOS).
- Medical devices require certification (e.g., FDA approval for pacemakers).
- Automotive ECUs use CAN bus for communication between modules.
- IoT devices rely on low-power Wi-Fi/Bluetooth (e.g., ESP8266 in home automation).
2. Case Study 1: Smart Home System (IoT-Based)
System Overview
A smart home system uses embedded devices to automate lighting, security, and climate control. Key components:
- Microcontroller: ESP32 (Wi-Fi + Bluetooth Low Energy).
- Sensors: PIR motion sensors, temperature/humidity (DHT22).
- Actuators: Relays for lights, smart plugs.
- Communication: MQTT protocol for cloud connectivity.
- Power: Solar panel + battery backup.
How It Works
- Sensor Input: PIR detects motion → sends signal to ESP32.
- Processing: ESP32 checks time/light conditions (via DHT22).
- Actuation: If valid, ESP32 triggers a relay to turn on lights.
- Cloud Sync: MQTT sends status to a dashboard (e.g., Home Assistant).
Challenges & Solutions
| Challenge | Solution | Embedded Technique Used |
|---|---|---|
| Power consumption | Deep sleep mode + solar charging | Low-power modes in ESP32 |
| Wireless interference | Mesh networking (Zigbee + ESP32) | IEEE 802.15.4 protocol |
| Security risks | AES-128 encryption for MQTT | Hardware cryptography (ESP32’s AES module) |
| Latency in cloud updates | Local processing (edge computing) | RTOS tasks for prioritized actions |
Worked Example: Energy-Saving Lighting
Scenario: A room has a PIR sensor + ESP32 controlling a bulb. The bulb should:
- Turn on only if motion is detected after sunset.
- Stay on for 5 minutes after last motion.
Solution Code (Pseudocode):
#include "esp_sleep.h"
#include "driver/gpio.h"
void IRAM_ATTR motionDetected() {
static uint32_t lastMotionTime = 0;
uint32_t currentTime = millis();
if (currentTime - lastMotionTime > 300000) { // 5 min timeout
digitalWrite(BULB_PIN, LOW);
} else {
digitalWrite(BULB_PIN, HIGH);
lastMotionTime = currentTime;
}
}
void setup() {
pinMode(PIR_PIN, INPUT);
pinMode(BULB_PIN, OUTPUT);
attachInterrupt(PIR_PIN, motionDetected, RISING);
// Deep sleep between triggers to save power
}
void loop() {
esp_deep_sleep_start();
}
Real-World Tie-In:
- Khalti’s Smart Home Integration: Khalti partners with IoT firms to let users control smart plugs via their app. The ESP32-based system here is similar to what powers Khalti’s "Smart Home Pay" feature, where payments trigger home automation (e.g., turning on AC when a payment is confirmed).
3. Case Study 2: Automotive Engine Control Unit (ECU)
System Overview
An ECU manages fuel injection, ignition timing, and emissions in cars. Key components:
- Microcontroller: ARM Cortex-M (e.g., STM32F4).
- Sensors: Oxygen sensor, crankshaft position sensor.
- Actuators: Fuel injectors, ignition coils.
- Communication: CAN bus (Controller Area Network).
- Power: 12V car battery + voltage regulators.
How It Works
- Sensor Input: Oxygen sensor measures exhaust O₂ levels.
- Processing: STM32 adjusts fuel injection time via PID control.
- Actuation: Injectors pulse based on calculated duty cycle.
- CAN Communication: ECU shares data with ABS, airbag systems.
Challenges & Solutions
| Challenge | Solution | Embedded Technique Used |
|---|---|---|
| Real-time constraints | FreeRTOS for task scheduling | Priority-based scheduling |
| EMI/Noise in sensors | Differential amplification + filters | Analog front-end design |
| Redundancy for safety | Dual-core MCU + watchdog timer | Fault-tolerant architecture |
| CAN bus load | Message prioritization | CAN identifiers (11-bit vs. 29-bit) |
Worked Example: Fuel Injection Timing
Scenario: An ECU must adjust fuel injection based on engine RPM and throttle position.
PID Controller Pseudocode:
float Kp = 1.5, Ki = 0.1, Kd = 0.05;
float error, integral, derivative, output;
void loop() {
float targetRPM = 3000; // Desired RPM
float currentRPM = readRPM(); // From crankshaft sensor
error = targetRPM - currentRPM;
integral += error;
derivative = error - prevError;
prevError = error;
output = Kp*error + Ki*integral + Kd*derivative;
setFuelInjectorDutyCycle(output); // 0-100% pulse width
}
Real-World Tie-In:
- Ncell’s Telematics: Ncell’s vehicle tracking services use ECU-like embedded systems to monitor fuel efficiency, engine health, and GPS. The CAN bus protocol here is identical to what Ncell’s partners use for real-time diagnostics in commercial fleets.
4. Case Study 3: Medical Infusion Pump
System Overview
An infusion pump delivers precise medication doses. Key components:
- Microcontroller: PIC32 (high reliability).
- Sensors: Flow sensor, pressure sensor.
- Actuators: Motor-driven syringe pump.
- Safety: Watchdog timer, fail-safe mechanisms.
- Compliance: FDA/ISO 13485 certified.
Hardware watchdog for MCU reset (Image: Lambtron, CC BY-SA 3.0, via Wikimedia Commons)
How It Works
- User Input: Nurse sets dose (e.g., 50 mg/hour).
- Processing: PIC32 calculates motor steps per dose unit.
- Actuation: Stepper motor drives syringe at precise rate.
- Safety Checks: Flow sensor detects occlusions; watchdog resets MCU if stuck.
Challenges & Solutions
| Challenge | Solution | Embedded Technique Used |
|---|---|---|
| Patient safety | Triple redundancy checks | Voting algorithm for sensor inputs |
| Battery life | Low-power modes + rechargeable Li-ion | Dynamic voltage scaling |
| Regulatory compliance | Audit logs + tamper-proof memory | Secure bootloader + EEPROM logging |
Worked Example: Occlusion Detection
Scenario: If the flow sensor detects a blockage, the pump must stop and alarm.
Algorithm:
bool isOccluded() {
float expectedFlow = calculateExpectedFlow(currentDose);
float actualFlow = readFlowSensor();
return abs(actualFlow - expectedFlow) > THRESHOLD;
}
void loop() {
if (isOccluded()) {
stopMotor();
triggerAlarm();
logErrorToEEPROM("Occlusion detected at " + String(millis()));
// Enter fail-safe mode
}
}
Real-World Tie-In:
- Nepal’s Hospitals: Many hospitals use infusion pumps from companies like B. Braun or Fresenius, which rely on embedded systems like this. The watchdog timer here is critical—if the MCU fails to reset periodically (e.g., due to a software crash), the pump stops automatically, preventing overdose.
5. Case Study 4: Wearable Health Monitor (eSewa Integration)
System Overview
A wearable ECG monitor tracks heart rate and syncs with eSewa’s health portal. Key components:
- Microcontroller: Nordic nRF52 (Bluetooth Low Energy).
- Sensors: ECG electrodes, PPG (photoplethysmogram).
- Communication: BLE to smartphone → cloud (eSewa API).
- Power: Coin-cell battery + ultra-low-power modes.
How It Works
- Sensor Input: ECG electrodes measure heart signals.
- Processing: nRF52 applies FFT to detect heart rate.
- BLE Transmission: Data sent to smartphone via GATT.
- Cloud Sync: eSewa’s server stores trends for doctors.
Challenges & Solutions
| Challenge | Solution | Embedded Technique Used |
|---|---|---|
| Battery life (weeks) | Duty cycling + sleep modes | nRF52’s "System ON for 1ms" feature |
| ECG noise cancellation | Adaptive filtering (IIR filters) | Digital signal processing (DSP) |
| Secure data transmission | AES-128 for BLE pairing | Nordic’s Secure DFU (Device Firmware Update) |
Worked Example: Heart Rate Calculation
Scenario: Extract heart rate from ECG data using peak detection.
Steps:
- Filter: Apply a bandpass filter (0.5–40 Hz) to remove noise.
- Peak Detection: Find R-peaks in the ECG waveform.
- RR Interval: Measure time between peaks (in ms).
- BPM Calculation:
Code Snippet (Simplified):
float calculateBPM(float* ecgData, int length) {
float peaks[10]; // Store last 10 R-peaks
int peakCount = 0;
for (int i = 1; i < length; i++) {
if (isPeak(ecgData[i-1], ecgData[i], ecgData[i+1])) {
peaks[peakCount++] = i;
if (peakCount >= 2) {
float rrInterval = peaks[peakCount-1] - peaks[peakCount-2];
return 60000.0 / rrInterval; // BPM
}
}
}
return 0; // Error
}
Real-World Tie-In:
- eSewa’s Health Services: eSewa’s telemedicine partnerships use wearable devices like this to let users monitor vitals and share data with doctors. The BLE protocol here is identical to what eSewa’s health tech providers use for real-time patient monitoring in rural areas.
6. Design Trade-offs in Embedded Systems
Every case study involves trade-offs between performance, cost, and power. Below is a comparison:
| Factor | Consumer Electronics | Industrial Automation | Medical Devices | Automotive ECUs |
|---|---|---|---|---|
| Microcontroller | ESP32 (low cost) | PLC (high reliability) | PIC32 (certified) | ARM Cortex-A (high perf) |
| Power | <10 mA sleep | 24V industrial power | Li-ion + backup | 12V car battery |
| OS | Bare metal or FreeRTOS | QNX or VxWorks | Bare metal (safety) | AUTOSAR (standardized) |
| Communication | Wi-Fi/BLE | Profibus/Modbus | ISO 11898-1 (CAN) | CAN/FlexRay |
| Certification | None | IEC 61131 | FDA/ISO 13485 | ISO 26262 (functional safety) |
Key Trade-Offs:
- Cost vs. Performance: An ESP32 is cheap but lacks the precision of an STM32 in automotive apps.
- Power vs. Features: Wearables use ultra-low-power modes but sacrifice processing power.
- Safety vs. Speed: Medical devices prioritize fail-safes over raw speed.
7. Emerging Trends in Embedded Systems
- Edge AI: Running ML models on microcontrollers (e.g., TensorFlow Lite for Microcontrollers).
- Example: Google’s Coral Dev Board (with Edge TPU) runs object detection on ESP32.
- Energy Harvesting: Powering devices from ambient sources (solar, RF, vibrations).
- Example: Daraz’s smart shelves use RF energy harvesting to power RFID tags.
- Security: Hardware-based encryption (e.g., ARM TrustZone, AES accelerators).
- Example: Ncell’s IoT gateways use secure boot to prevent firmware tampering.
- 5G + Embedded: Ultra-low-latency applications (e.g., autonomous drones).
- Example: NTC’s smart grid projects use 5G-enabled embedded nodes for real-time monitoring.
In the Real World
eSewa’s Digital Payments + IoT:
- Idea Used: Secure embedded communication (AES-128 + BLE).
- How: eSewa’s QR code payment terminals use embedded MCUs (e.g., STM32) with secure elements to encrypt transactions. The same BLE protocol seen in wearables is used for contactless POS machines in rural shops.
Pathao’s Ride-Hailing Fleet Management:
- Idea Used: CAN bus + real-time scheduling (FreeRTOS).
- How: Pathao’s electric scooters use embedded systems to monitor battery levels, GPS, and driver behavior. The CAN bus connects the scooter’s ECU to the app, while FreeRTOS ensures real-time route updates.
NTC’s Smart Grid Monitoring:
- Idea Used: Energy harvesting + LoRaWAN.
- How: NTC’s smart meters in Kathmandu use solar-powered embedded nodes (e.g., STM32L4) to transmit power data via LoRaWAN (long-range, low-power). The energy-harvesting technique here avoids battery replacements in remote areas.
Daraz’s Warehouse Automation:
- Idea Used: RFID + embedded controllers (PLCs).
- How: Daraz’s automated warehouses use RFID tags + ESP32-based readers to track inventory. The embedded PLCs manage conveyor belts and sorting robots, with Modbus TCP for communication.
Nepal Rastra Bank’s ATM Security:
- Idea Used: Hardware security modules (HSMs) + RTOS.
- How: ATMs use embedded HSMs (e.g., Infineon SLB9670) to store encryption keys. The RTOS ensures transactions complete within strict time limits, preventing skimming attacks.
Exam Tip
What Examiners Look For
System Architecture:
- Draw a block diagram of the embedded system (MCU, sensors, actuators, communication).
- Label power sources, clock speeds, and interfaces (e.g., SPI, I2C).
- Example: For a smart home system, show ESP32 → PIR sensor (GPIO) → Relay (PWM).
Code Snippets:
- Provide pseudocode or real C for critical functions (e.g., PID control, sensor filtering).
- Use comments to explain trade-offs (e.g., "Using
delay()here blocks the MCU; replace with timers in production").
Real-World Mapping:
- Link your answer to Nepali companies (e.g., "This RTOS scheduling is like Pathao’s fleet management").
- Use local examples (e.g., "NTC’s smart meters use LoRaWAN, similar to this design").
Challenges & Solutions:
- Examiners love tables comparing trade-offs (e.g., power vs. performance).
- Mention regulatory compliance (e.g., "This medical device needs ISO 13485 certification").
Diagrams Over Text:
- Always draw (or describe) a timeline, state machine, or protocol stack (e.g., CAN frame structure).
- Example: For a wearable, show a BLE GATT profile with service/characteristics.
Common Pitfalls to Avoid
- Vague answers: Instead of "it uses sensors," say "an ESP32 reads a DHT22 temperature sensor via I2C."
- Ignoring power: Always mention low-power modes (e.g., "ESP32 enters deep sleep to save battery").
- Overlooking safety: For medical/automotive, state redundancy (e.g., "dual MCUs with voting").
- No math: Show calculations (e.g., "PID constants tuned via trial: ").
Practice Question (Self-Assessment)
Design an embedded system for a smart irrigation controller that:
- Uses a soil moisture sensor and rainfall detector.
- Waters plants only if soil is dry AND no rain is detected.
- Logs data to an SD card for monthly reports.
- Runs on a solar panel + battery.
Your answer should include:
- A block diagram (MCU, sensors, SD card module).
- Pseudocode for the watering logic.
- Power management strategy.
- Real-world tie-in (e.g., "Similar to Daraz’s automated greenhouse systems").
Answer Outline (For Reference):
- Block Diagram:
- Pseudocode:
bool shouldWater() { return (soilMoisture < DRY_THRESHOLD) && !isRaining(); } void loop() { if (shouldWater()) { activateRelay(); logToSD("Watered at " + String(millis())); delay(10000); // 10-second watering } // Enter light sleep to save power esp_light_sleep_start(); } - Power Management:
- Solar panel charges Li-ion battery.
- ESP32 in light sleep between checks (wakes every 30 mins).
- Real-World Tie-In:
- Daraz’s smart farms use similar systems to optimize water usage. The SD card logging here matches Daraz’s IoT-based crop monitoring, where data is later analyzed for yield predictions.
Based on the PU BE Computer (PU) syllabus for Embedded System (ELX320), unit 10.
Discussion
Loading…