Embedded Systems
Overview
Embedded systems are the core hardware carriers of robots. From microcontrollers (MCUs) to high-performance single-board computers (SBCs), different embedded platforms handle various tasks ranging from low-level motor control to high-level AI inference.
MCU vs. SBC vs. SoC
Concept Distinctions
| Type |
Full Name |
Features |
Examples |
| MCU |
Microcontroller Unit |
Single chip integrating CPU+Flash+RAM+peripherals |
STM32, ESP32 |
| SBC |
Single Board Computer |
Complete computer system (board-level) |
Raspberry Pi, Jetson |
| SoC |
System on Chip |
Chip integrating CPU+GPU+NPU+peripherals |
Tegra Orin, BCM2712 |
Detailed Comparison
| Feature |
MCU (STM32H7) |
SBC (RPi 5) |
SBC (Jetson Orin NX) |
| CPU |
Cortex-M7 @480MHz |
Cortex-A76 @2.4GHz x4 |
Cortex-A78AE @2.0GHz x8 |
| RAM |
1MB SRAM |
4/8GB LPDDR4X |
8/16GB LPDDR5 |
| Storage |
2MB Flash |
microSD/NVMe |
eMMC/NVMe |
| GPU |
None |
VideoCore VII |
Ampere 2048 cores |
| AI Performance |
None |
No dedicated accelerator |
100 TOPS (INT8) |
| OS |
Bare-metal/RTOS |
Linux |
Linux (JetPack) |
| Power |
<1W |
5-12W |
10-25W |
| Real-time |
Deterministic latency <1us |
Non-real-time ~ms level |
Non-real-time ~ms level |
| Boot Time |
<100ms |
~20s |
~30s |
| Price |
$5-15 |
$60-80 |
$400-600 |
| Typical Tasks |
Motor control, sensor acquisition |
Lightweight vision, education |
AI inference, autonomous navigation |
STM32 (ARM Cortex-M)
STM32 Series Overview
| Series |
Core |
Frequency |
Flash |
RAM |
Highlight |
Price |
| STM32F1 |
Cortex-M3 |
72MHz |
128KB |
20KB |
Classic entry-level |
$2 |
| STM32F4 |
Cortex-M4 |
168MHz |
1MB |
192KB |
DSP+FPU |
$5 |
| STM32H7 |
Cortex-M7 |
480MHz |
2MB |
1MB |
Highest-performance MCU |
$10 |
| STM32G4 |
Cortex-M4 |
170MHz |
512KB |
128KB |
Motor control dedicated |
$4 |
| STM32L4 |
Cortex-M4 |
80MHz |
1MB |
320KB |
Ultra-low power |
$4 |
STM32H7 Key Peripherals
STM32H750VBT6 Peripheral Resources:
+-- Communication Interfaces
| +-- UART x8 (including LPUART)
| +-- SPI x6
| +-- I2C x4
| +-- CAN FD x2
| +-- USB OTG HS x1
| +-- Ethernet 10/100 x1
+-- Analog Peripherals
| +-- ADC x3 (16-bit, 3.6MSPS)
| +-- DAC x2 (12-bit)
| +-- COMP x2
+-- Timers
| +-- Advanced Timers x2 (Motor control PWM)
| +-- General-Purpose Timers x12
| +-- Basic Timers x2
+-- DMA
| +-- DMA x2 (8 channels each)
| +-- MDMA x1 (Master DMA)
+-- Other
+-- RNG (Random Number Generator)
+-- CRC
+-- DCMI (Digital Camera Interface)
HAL Library Programming Example
// STM32 HAL: Initialize PWM output (motor control)
void Motor_PWM_Init(void) {
TIM_HandleTypeDef htim1;
TIM_OC_InitTypeDef sConfigOC;
htim1.Instance = TIM1;
htim1.Init.Prescaler = 167; // 168MHz / 168 = 1MHz
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 999; // 1MHz / 1000 = 1kHz PWM
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
HAL_TIM_PWM_Init(&htim1);
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 500; // 50% duty cycle
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
}
// Read encoder (quadrature decoding)
void Encoder_Init(void) {
TIM_HandleTypeDef htim3;
TIM_Encoder_InitTypeDef sConfig;
htim3.Instance = TIM3;
htim3.Init.Prescaler = 0;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 65535;
sConfig.EncoderMode = TIM_ENCODERMODE_TI12; // 4x counting
sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
sConfig.IC2Polarity = TIM_ICPOLARITY_RISING;
HAL_TIM_Encoder_Init(&htim3, &sConfig);
HAL_TIM_Encoder_Start(&htim3, TIM_CHANNEL_ALL);
}
int32_t get_encoder_count(void) {
return (int16_t)__HAL_TIM_GET_COUNTER(&htim3);
}
| Tool |
Purpose |
Description |
| STM32CubeMX |
Graphical configuration |
Pin assignment, clock tree, peripheral initialization |
| STM32CubeIDE |
IDE |
Eclipse-based, integrated compile and debug |
| Keil MDK |
IDE |
Industry standard (paid) |
| PlatformIO |
Cross-platform development |
VSCode plugin, supports multiple MCUs |
| OpenOCD + GDB |
Debugging |
Open-source debugging tools |
| ST-Link V3 |
Debugger |
SWD/JTAG interface |
ESP32
ESP32 Series Comparison
| Model |
CPU |
Frequency |
RAM |
WiFi |
BLE |
Highlight |
| ESP32 |
Xtensa LX6 x2 |
240MHz |
520KB |
802.11 b/g/n |
4.2 |
Classic dual-core |
| ESP32-S3 |
Xtensa LX7 x2 |
240MHz |
512KB |
802.11 b/g/n |
5.0 |
AI acceleration |
| ESP32-C3 |
RISC-V |
160MHz |
400KB |
802.11 b/g/n |
5.0 |
Low-cost RISC-V |
| ESP32-C6 |
RISC-V |
160MHz |
512KB |
WiFi 6 |
5.3 |
WiFi 6 |
ESP32 Applications in Robotics
ESP32 Typical Uses:
+-- WiFi remote control (WebSocket/MQTT)
+-- BLE sensor node
+-- Low-cost motion controller
+-- IoT gateway (sensor data upload)
+-- Co-processor (communication with Jetson)
# MicroPython on ESP32: Simple WiFi remote control
import network
import socket
from machine import Pin, PWM
# Connect to WiFi
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('RobotAP', 'password')
# PWM motor control
motor_pwm = PWM(Pin(25), freq=1000, duty=0)
# Simple HTTP server to receive control commands
s = socket.socket()
s.bind(('', 80))
s.listen(1)
while True:
conn, addr = s.accept()
request = conn.recv(1024).decode()
if '/forward' in request:
motor_pwm.duty(512) # 50% duty cycle
elif '/stop' in request:
motor_pwm.duty(0)
conn.close()
Raspberry Pi 5
Specifications
| Feature |
Parameter |
| SoC |
BCM2712 |
| CPU |
Cortex-A76 x4 @2.4GHz |
| GPU |
VideoCore VII @800MHz |
| Memory |
4/8GB LPDDR4X-4267 |
| Storage |
microSD / NVMe (via HAT) |
| Video Output |
2x micro-HDMI (4Kp60) |
| Camera |
2x CSI-2 (4 lanes) |
| GPIO |
40-pin Header |
| USB |
2x USB 3.0 + 2x USB 2.0 |
| Network |
Gigabit Ethernet + WiFi 5 + BLE 5.0 |
| PCIe |
1x PCIe 2.0 (via FPC) |
| Power |
5V/5A (27W max) |
| Price |
$60 (4GB) / $80 (8GB) |
Suitable Robot Scenarios
- Education and prototyping
- Lightweight visual processing (OpenCV)
- ROS2 learning platform
- Projects not requiring GPU-accelerated AI
Raspberry Pi Limitations
- No dedicated AI accelerator (pure CPU inference is very slow)
- Memory is shared with GPU
- Non-real-time system (unsuitable for precise motor control)
- Thermal constraints (active cooling needed)
NVIDIA Jetson Orin Series
Product Line Comparison
| Feature |
Orin Nano |
Orin NX 8GB |
Orin NX 16GB |
AGX Orin 32GB |
AGX Orin 64GB |
| CPU Cores |
6x A78AE |
6x A78AE |
8x A78AE |
12x A78AE |
12x A78AE |
| GPU Cores |
1024 CUDA |
1024 CUDA |
2048 CUDA |
2048 CUDA |
2048 CUDA |
| Tensor Cores |
32 |
32 |
64 |
64 |
64 |
| DLA |
1 |
1 |
2 |
2 |
2 |
| AI Performance (INT8) |
40 TOPS |
70 TOPS |
100 TOPS |
200 TOPS |
275 TOPS |
| Memory |
8GB |
8GB |
16GB |
32GB |
64GB |
| Memory Bandwidth |
68 GB/s |
68 GB/s |
102 GB/s |
204 GB/s |
204 GB/s |
| Power |
7-15W |
10-20W |
10-25W |
15-40W |
15-60W |
| Price |
~$200 |
~$400 |
~$600 |
~$1000 |
~$1600 |
JetPack Software Stack
JetPack SDK:
+-- Linux for Tegra (L4T)
| +-- Ubuntu 22.04
| +-- NVIDIA Drivers
| +-- BSP (Board Support Package)
+-- CUDA Toolkit 12.x
+-- cuDNN 8.x
+-- TensorRT 8.x
+-- VPI (Vision Programming Interface)
+-- Multimedia API
| +-- libargus (CSI cameras)
| +-- GStreamer + nvvidconv
| +-- V4L2
+-- DeepStream SDK
+-- Isaac ROS
Selection Guide
graph TD
A[Robot AI Requirements] --> B{Object detection accuracy requirement?}
B -->|YOLOv8n is sufficient| C{Budget?}
B -->|Need large models| D{Need multi-model parallelism?}
C -->|<$300| E[Orin Nano 8GB]
C -->|<$600| F[Orin NX 8GB]
D -->|No| G[Orin NX 16GB]
D -->|Yes| H[AGX Orin 32GB]
style E fill:#c8e6c9
style F fill:#a5d6a7
style G fill:#81c784
style H fill:#66bb6a
RTOS vs. Linux
RTOS (Real-Time Operating System)
| RTOS |
Features |
License |
Typical Platform |
| FreeRTOS |
Lightweight, large community |
MIT |
STM32, ESP32 |
| Zephyr |
Modern, modular |
Apache 2.0 |
nRF, STM32 |
| RT-Thread |
Chinese-originated, rich components |
Apache 2.0 |
STM32, RISC-V |
| ChibiOS |
Ultra-small kernel |
GPL/Commercial |
STM32 |
Key RTOS Concepts
// FreeRTOS: Create a task
void motor_control_task(void *pvParameters) {
TickType_t xLastWakeTime = xTaskGetTickCount();
const TickType_t xPeriod = pdMS_TO_TICKS(1); // 1ms period
while (1) {
// Read encoder
int32_t position = get_encoder_count();
// PID computation
float output = pid_compute(target, position);
// Set PWM
set_motor_pwm(output);
// Precise delay until next period
vTaskDelayUntil(&xLastWakeTime, xPeriod);
}
}
// Create task (highest priority)
xTaskCreate(motor_control_task, "MotorCtrl",
256, NULL, configMAX_PRIORITIES-1, NULL);
RTOS vs. Linux Comparison
| Feature |
RTOS (FreeRTOS) |
Linux |
| Scheduling Latency |
<10us (deterministic) |
~ms level (non-deterministic) |
| Memory Footprint |
~10KB |
~200MB |
| Boot Time |
<100ms |
~10-30s |
| File System |
Optional (FatFS) |
Full (ext4, etc.) |
| Network Stack |
Optional (lwIP) |
Full (TCP/IP) |
| Driver Support |
Limited |
Extremely rich |
| Package Management |
None |
apt/pip |
| GUI |
None/LVGL |
Full desktop |
| AI Frameworks |
None |
PyTorch/TensorFlow |
Hybrid Architecture
Robot systems typically adopt an MCU + SBC hybrid architecture:
+----------------+ UART/CAN +----------------+
| Jetson Orin |<---------------->| STM32H7 |
| (Linux+ROS2) | | (FreeRTOS) |
| | | |
| - AI inference | | - Motor PID |
| - Path planning| | - Encoder read |
| - Visual | | - IMU data |
| perception | | acquisition |
| - SLAM | | - PWM output |
| - Communication| | - E-stop |
+----------------+ +----------------+
See: Serial and I2C/SPI for more on communication interfaces between MCU and SBC.
Development Workflow
Standard Embedded Development Process
graph LR
A[Requirements Analysis] --> B[Platform Selection]
B --> C[Schematic Design]
C --> D[PCB Layout]
D --> E[Firmware Development]
E --> F[Hardware Debugging]
F --> G[System Testing]
G --> H[Mass Production]
| Tool |
Purpose |
Interface |
| SWD/JTAG Debugger |
Step-through debugging, breakpoints |
ST-Link / J-Link |
| Logic Analyzer |
Protocol analysis (SPI/I2C/UART) |
Saleae / DSLogic |
| Oscilloscope |
Signal waveform observation |
Rigol / Siglent |
| Serial Terminal |
Print debug information |
minicom / PuTTY |
| GDB |
Remote debugging |
OpenOCD + GDB |
Summary
- MCUs are for real-time control; SBCs are for AI and complex computation
- STM32H7 is the top choice for robot MCUs (high performance, rich peripherals)
- ESP32 is suitable for WiFi/BLE communication and low-cost applications
- Jetson Orin series covers AI performance needs from 40 to 275 TOPS
- RTOS guarantees deterministic latency; Linux provides a rich ecosystem
- MCU + SBC hybrid architecture is the best practice
References