Microcontrollers, conversion, and programmable logic
Digital systems meet the analogue world through converters, and are built from microcontrollers and programmable chips that engineers configure with code.
Microcontrollers
A microcontroller combines a processor, memory (flash for programs, RAM for data), and peripherals such as timers, serial interfaces, analogue-to-digital converters, and general-purpose input-output (GPIO) pins on one chip. Families such as Arm Cortex-M, AVR (used in classic Arduino boards), RISC-V, and ESP32 (with Wi-Fi) control appliances, cars, toys, and countless embedded devices.
Analogue-to-digital conversion
An analogue-to-digital converter (ADC) samples an analogue voltage and converts it to a number. An n-bit ADC divides its reference range into \(2^n\) steps: a 12-bit ADC with a 3.3 V reference resolves \(\frac{3.3}{4096} \approx 0.8\) mV per step. The sample rate must be at least twice the highest frequency present (the Nyquist criterion), and anti-aliasing filters remove higher frequencies first.
Digital-to-analogue conversion and PWM
A digital-to-analogue converter (DAC) turns numbers into voltages, for audio output or control signals. Many microcontrollers instead use pulse-width modulation (PWM): switching a pin on and off rapidly, with the fraction of time on, the duty cycle, setting the average voltage. PWM dims LEDs, controls motor speed, and, filtered, produces analogue levels efficiently.
Serial communication
Chips talk over serial buses. UART sends asynchronous bytes over a transmit and receive pair at agreed baud rates such as 115,200 bits per second. I2C uses two wires, clock and data, shared by many devices with addresses. SPI uses separate clock, data-in, data-out, and chip-select lines for faster transfers. USB, CAN (in vehicles), and Ethernet connect larger systems.
Memory technologies
Static RAM (SRAM), built from flip-flop-like cells, is fast and used for caches and microcontroller RAM. Dynamic RAM (DRAM) stores bits as charge on tiny capacitors that must be refreshed thousands of times per second, giving high density for computer main memory. Flash memory keeps data without power by trapping charge, storing firmware, SSD data, and phone storage.
Programmable logic
Field-programmable gate arrays (FPGAs) contain large arrays of configurable logic blocks, look-up tables, flip-flops, and programmable interconnects that can be reconfigured to implement almost any digital circuit. They are used for prototyping chips, high-speed signal processing, networking, and specialised accelerators. Application-specific integrated circuits (ASICs) are custom chips, costly to design but efficient at scale.
Hardware description languages
Digital designs are written in hardware description languages such as Verilog (1984) and VHDL (standardised in 1987), or newer languages such as SystemVerilog and Chisel. Unlike software, HDL describes hardware that operates in parallel. Synthesis tools turn HDL into gates and flip-flops; simulation and formal verification check designs before they are built.
Worked example
A temperature sensor outputs 10 mV per degree Celsius, read by a 10-bit ADC with a 3.3 V reference. Each step is \(\frac{3.3}{1024} \approx 3.2\) mV, about 0.32 degrees. A reading of 233 corresponds to \(233 \times 3.22 \approx 751\) mV, or about 75 degrees Celsius. Using a 12-bit ADC would improve the resolution to about 0.08 degrees per step.
Key takeaways
Microcontrollers integrate a processor, flash, RAM, and peripherals such as timers, ADCs, serial interfaces, and GPIO; Arm Cortex-M, AVR, RISC-V, and ESP32 are common. An n-bit ADC has 2^n steps, about 0.8 mV for 12 bits at 3.3 V, and needs sampling above twice the highest frequency with anti-aliasing filters. DACs and PWM produce analogue outputs; PWM's duty cycle sets average voltage. UART, I2C, SPI, USB, and CAN connect chips and systems. SRAM is fast, DRAM dense but refreshed, flash non-volatile. FPGAs are reconfigurable logic; ASICs are custom chips. Verilog and VHDL describe parallel hardware for synthesis and verification.
Flashcard
Processor, memory, and peripherals on one chip
Check your understanding
A PWM output switches between 0 V and 5 V with a 25% duty cycle. What average voltage does it produce?
