Learning Module 9 Managing the Sensor: Embedded Computing Paul Flikkema Department of Electrical Engineering Northern Arizona University
Outline Networked Embedded Systems Hardware Software Languages Operating systems Energy efficiency
What are embedded systems? Computing systems that interact with the physical world at its time-scale appliances, mobile phones, medical devices Real-time systems: embedded systems that must meet deadlines navigation systems Life-critical systems: reliability, guaranteed responsiveness automobile and aircraft control
Example: ESC
Embedded Systems -- Facts Use 99% of all digital silicon Usually a combination of sensors, actuators, analog/mixed signal electronics, digital hardware and software Often use wired and/or wireless communication and networking
WSN nodes are deeply embedded systems Many nodes => low cost nodes Low cost => Low clock frequency Small program memory Small data memory Long battery life Long battery life => Low power consumption
Digital Logic Standard Logic Progammable Logic (FPLDs) ASICs Full Custom TTL 74xx CMOS 4xxx PLDs FPGAs CPLDs Microprocessor & RAM Gate Arrays Standard Cell Digital logic technologies (Hamblen and Furman) Structured ASIC: generic logic elements (memory, I/O) plus customizable logic. Platform ASICs add complex functional Blocks (e.g., processor cores, memory controllers, Ethernet controllers) CPLD = Complex Programmable Logic Device
Speed, Density, Complexity, Market Volume needed for Product PLDs CPLDs FPGAs ASICs Full Custom VLSI Design (Hamblen and Furman) Engineering Cost, Time to Develop Product Digital logic technology tradeoffs
Energy consumption is a critical factor Would like to have digital hardware optimized for the WSN node application Full-custom is too expensive for smallvolume markets FPGA power consumption is decreasing QuickLogic PolarPro Actel Igloo SiliconBlue ice Need strong peripheral support Software-programmable MCU s still best
Outline Networked Embedded Systems Hardware Software Languages Operating systems Energy efficiency
The hardware must support a sensor node s three main tasks Sense Compute Control Communicate Compute Hibernate 1. CPU 2. Peripherals 3. Power management
Microprocessor (MPU) or Microcontroller (MCU)? An MCU performs dedicated functions within an overall system MCU s contain rich set of on-chip peripherals on-chip program (non-volatile) program memory
MCU market is extremely competitive ~$15B market (2008) strong growth in automotive space Analog Devices, Atmel, Cyan Technology, Freescale, Fujitsu, Luminary Micro, Microchip, Renesas, Silicon Labs, ST Micro, Texas Instruments, Toshiba, Zilog
Computer Hardware Organization Processor Memory Interconnection Structure I/O The interconnection structure is normally one or more busses
Structure of a Processor Control Unit Bus Data Processing Unit Program Counter Address Generation Logic Address Register Control Circuitry Control Signals Status Register ALU Stack Pointer Instruction Register Data Register Register File
Basic Datapath From Data Bus Register File Control Unit selects Registers and ALU function To Data Bus To Address Bus ALU Status to Control Unit
From CPU to MCU (Cyan Technology)
Memory: on-chip (Cyan Technology)
Memory: Off-chip Non-Volatile FLASH Up to ~1M writes NOR fast read slow erase/write random access program storage NAND slow read fast erase/ write serial interface data storage prone to errors FRAM Up to ~10B writes High speed Random access Very low power consumption MRAM coming? Very high speed Larger sizes No known wear-out
Peripherals define MCU s (Cyan Technology)
MCU Peripherals Timers watchdog timers Counters Comparators A/D and D/A converters GPIO PWM outputs Motor control Communication I2C, SPI, serial USB Ethernet Analog peripherals Multiplexers Programmable-gain amplifiers (PGA s)
How can we improve energy efficiency in embedded systems? 1. Ensure that every electronic component uses the minimum amount of energy to do its job Optimize process technologies Digital, analog, RF Improve power regulation and management 2. Ensure that no electronic component uses energy unless it is doing something useful Clock domains (and gating) Power domains (and gating) Dynamic voltage scaling
Example: ST Micro STM32 (ST Micro and Embedded Control Europe)
Example: Texas Instruments MSP430F5XXX
Modern Hardware Support for Debugging In-circuit debugging Hardware support JTAG No hardware overhead Requires custom interface and software Tracing aka logging Requires only serial port Flexible Significant overhead on target hardware New - power debugging
Choosing an MCU for a Sensor Node Design datapath width development toolchain family coverage support! memory OTP or FLASH SRAM power consumption SRAM retention peripherals real-time clock A/D converter resolution speed D/A converter resolution speed communication serial, USB, Ethernet voltage
G2 WiSARD Functional H/W Design 1-Wire Light(4) Temp(4) General Purpose(2) Memory SRAM FLASH/FRAM Brain Board Analog I/O PWM(2) Pwr(2) Radio Board Int Power Micro- Controller PIC18F8720 Power Mgmt System Time Ext Power SPI+ Enclosure Transceiver Micro- Controller PIC18F452 Sensor Board
Outline Networked Embedded Systems Hardware Software Languages Operating systems Energy efficiency
Software Languages C is the lingua franca of embedded systems programming* Up until now, many systems were programmed using assembly language C is close the the hardware, but not too close Reasonable balance of design speed and code efficiency Occasionally write critical sections in assembly language A more high-level language may succeed some day *not including safety-critical systems
Software Design Hierarchy Pre-processor Compiler Assembler Linker Loader Assembly C Language Assembly Language Libraries Hardware
Software Design Hierarchy: with Operating System Application Program Interface C OS Assembly Language Assembly Language Libraries Hardware
Embedded systems software design: knowledge hierarchy Development Tools Existing Codebase MCU-specific Compiler Specific MCU and Board Generic Language (C) Target MCU Family
How to control peripherals: two ways Direct Access direct writes to control and data registers Tedious for programmer Lean and fast Less portable Macros help Library Access access via function calls Easier for programmer Invokes overhead Code: library routine Time: function call More portable Family-specific
Interfacing with the physical world: how to handle asynchronous events Two approaches: Polling: Program explicitly checks whether a signal has changed Interrupts: Program clears, then enables, a latch that will trigger when a signal changes Interrupt handler (or ISR) is a (small) routine that is invoked as soon as possible after the signal change
Asynchronously interrupting the flow of execution Need to save state Can require volatile type qualifier ISR New chips support nested interrupts
The best solution is application-dependent Polling Simple Can waste CPU time and energy Easy to debug Does not scale well Motivates system-level support via timetriggering executive Interrupts Requires special hardware Easy to code, but can cause hard-to-find bugs Elegant solution for handling rare events Used in some MCU programming models
Operating Systems Purposes allocate resources via scheduler time on hardware resources CPU, DMA, peripherals Provide mediated, astracted interfaces to memory (including a file system) Peripherals I/O
WSN engineering invokes cross-layer design challenges! PHY and MAC Routing and Application (selforganization) MAC and Embedded Software (codesign) Embedded Software and ULP MCU s Source and Channel Coding P. Flikkema
Operating systems are a form of executive Type Properties Examples Event loop Simplest Tasks are functions Periodic task execution Hand-written Time-triggered executive Time-triggered Time slotted into frames/slots Scheduler runs once/frame Tasks are functions WiSARD executive FlexRay OSEKtime Distributed RTOS s Cooperative OS Pre-emptive OS Event-driven Task queue with reserved slots NesC Most complex Priority-driven TinyOS Contiki Nut/OS FreeRTOS FreeRTOS Linux Many RTOS s
Innovative software architectures are needed! Programs should be more obvious Prototyping should be easier Time should be a first-class concept Software design process should incorporate co-design with hardware and application energy-awareness minimization of energy consumption
Outline Networked Embedded Systems Hardware Software Languages Operating systems Energy efficiency
The embedded system power grid
Measuring Power and Energy On-line Switched capacitors Current mirror On-chip ADC with precision resistor Monitor regulator Requires switching regulator Difficult to deal with signal measurement
Why is measuring energy difficult? Power signal is wideband Brief pulses (<1 ms) of activity Hours or days of hibernation =>Need high-quality time measurement Power signal is multi-scale in magnitude Up to ~50 ma when active As low as ~2 µa when hibernating Requires scaling of measurement
Precise and accurate measurement of embedded system energy demand
How can we improve energy efficiency? 1. Embedded Systems 1. Ensure that every electronic component uses the minimum amount of energy to do its job Optimize process technologies Digital, analog, RF Improve power regulation and management 2. Ensure that no electronic component uses energy unless it is doing something useful Clock domains (and gating) Power domains (and gating) Dynamic voltage scaling
WSN engineering invokes cross-layer design challenges! PHY and MAC Routing and Application (selforganization) MAC and Embedded Software (codesign) Embedded Software and ULP MCU s Source and Channel Coding P. Flikkema
Example: ST Micro STM32 (ST Micro and Embedded Control Europe)
Example: Texas Instruments MSP430F5XXX (Texas Instruments)
Take away messages WSN node design is complex Hardware platform (MCU) System software Energy efficiency => h/w-s/w co-design New MCUs are expanding potential for energy-efficient design at the cost of increased software complexity New s/w design approaches are needed Time Energy