Introduction to Embedded and Real-Time...

Preview:

Citation preview

Introduction to Embedded and Real-Time Systems

School of Architecture, Civil and Environmental Engineering

EPFL, SS 2008-2009

http://disal.epfl.ch/teaching/embedded_systems/

Team beyond this course

http://disal.epfl.ch• Distributed Intelligent Systems and Algorithms Laboratory:

• Main instructor: Alcherio Martinoli• Guest lecturers: Grégory Mermoud, Sven Gowal, Pierre Roduit• Teaching assistants (office hours on the web):

– Grégory Mermoud (head TA, PhD student)‏– Sven Gowal (PhD student)‏– Amanda Prorok (PhD student)‏

• Support staff:– Yvan Bourquin (senior software engineer)– Thomas Lochmatter (PhD student)‏– Pierre Roduit (post doc)‏‏

Course Rationale, Content, and Prerequisites

Rationale (1)‏• Well-balanced course: theory, algorithms, tools

and practical exercises• Understanding the fundamentals of signal

processing • Understanding the fundamentals of embedded and

real-time systems• This course must allow you to become an power

user of the key instruments in environmental engineering used nowadays (sensor networks, meteorological stations, data loggers, etc.) and in the future (exploratory and cleaning robots, robotics sensor networks, etc.)‏

Rationale‏ ‏(2)• This course can be considered as an elevator to the master

course “Distributed Intelligent Systems” (available form the AY 2009-2010) for SSIE/SGC/SIN/SSC (and sometimes students from STI)‏

• It should get SSIE/SGC students prepared for carrying out a semester/master project at DISAL

• Being a power user means not only being an advanced user but also understand enough to collaborate with EE/CS/ME engineers to design the instruments of the future in environmental engineering; idea: complexity shifted more and more from hardware to software → a lot of domain knowledge can be transferred to the instruments at software level

What this course is about• Fundamentals of signal processing:

– Analog/Digital signals, Time/Frequency domains, Filters, Converters

• Fundamentals of computer science (from an embedded systems perspective):– Basics of computer architecture– UNIX (crash course)‏– C programming (vs Java, Matlab)‏

• Fundamentals of embedded and real-time systems:– Microprocessors, microcontrollers, memory– Sensors and actuators– Basic control techniques and concepts

Course Prerequisites

• Basic Matlab knowledge• Fundamentals on programming (you learned

Java/Matlab, you will also learn C)‏• Fundamentals on probability calculus• Fundamentals on analysis (ODE, Fourier

transform)‏

Organization of the Course

Credits and Workload• 3 ECTS• 1 ECTS = 30 h workload → 90 h workload total• Rough breakdown

– 60 h lecture (including reading, exam preparation)‏– 30 h hwk+lab (including preparation + reporting)‏

• 5 hwk+lab of 6 h effort each:– Basics of signal processing (paper/pencil and Matlab)‏– UNIX and C programming– Webots lab– e-puck lab (as static sensor node)‏– Advanced e-puck lab (as robotic sensor node)‏

Grade• Final written exam, summer; 120 minutes• 1/3 performance during semester, 2/3

performance during the exam (compromise US/Europe style)‏

• During semester: performance of lab+hwk(total average), graded exercises returned ‏

• During exam: all covered material is subject to examination, but the exam is open book (no electronic equipment allowed though) ‏

Lecture Notes & Reading• Policy: no manuscript, but slides and your own notes• Preliminary lecture slides in pdf format available for

download on the course web site possibly before each lecture (Thursday early morning, handout format), definitive ones after lecture (couple of days max)‏

• Reading will be added on Moodle as the course progresses

• Moodle URL: http://moodle.epfl.ch/course/view.php?id=4611

• Enrollment key for Moodle: introsyst09

Labs and Hwk (1) • Lab session 08:15-10:00 on Thu, GR B0 01 (possibly

GR C0 02) biweekly, odd weeks (first lab session: week3) ‏

• Mini-tutorial (5-10 min) by the main lab designer at the beginning of the lab

• 2h lab + 4h hwk (including assignment reading and write-up)‏,

• 5 lab + hwk sets total (= 60 h total)‏• Download/upload via Moodle server (see student area

on the course web site). • ers-ta@groupes.epfl.ch for ANY issue!

Labs and Hwk (2) • Wed noon deadline, 13 days time to get write-

ups done; no late submission accepted unless motivated by provable health problems

• Specific projectable issues in attending a lab session/submitting a write-up should be mentioned in advance to the TAs

• Network/moodle server problems → TAs immediately notified

Labs and Hwk (3) • Labs and hwk individually reviewed, distributed

in a timely fashion (target 1 week after submission, commented pdf) ‏

• No official solution of lab+hwk distributed; TAs available during office hours for discussion

• In 2 weeks: lab 1 (signal processing with paper&pencil and Matlab)‏

Suggestions for a Successful Exercise Series

From our teaching experience:• Read the assignment in advance (i.e. before the lab,

you have always a “free” evening), in this way you will be more efficient when the TAs are around for helping you on the toughest questions…

• Have an idea of the point distribution: this roughly correspond to the breakdown in time you should have; if your time is tight invest where it is worth!

• You do not have to achieve always 100/100: bonuses, exam are also great opportunities to round up…

Collaboration Policy

• Lecture and exam preparation: encouraged• Lab and hwk: discussion encouraged but

problem solved and submitted individually! We will be very strict in penalizing too similar write-ups copies because 1/3 of the grade is acquired with lab&hwk (n copies = # of points/n)!

A Final Note

1st course in ENAC (1) ‏• For us, this course is a novel experience for several reasons:

– First course given at bachelor level– First course given in ENAC (new flavor, new focus)‏– First iteration of the course in its current form

• Be indulgent and do not hesitate to provide feedback• Experimental tools shall be reliable and stable (debugged in

prior courses in IC):– 100 e-puck robots– Webots robotic simulator

• Big thanks to CRAFT and EPFL for sponsoring two FIFO projects (Fond d’Innovation pour la FOrmation; simulation and robotic tools)! See http://craft.epfl.ch

1st course in ENAC (2) ‏• Our general goals for this first iteration:

– Get an insight into the background and the interests of SSIE/SGC students at the bachelor level

– Shape up the course for next year (it is going to become a 5 ECTS compulsory course for SSIE students and optional for SGC; it will be taught in English) ‏

– A first attempt to shape up a new generation of environmental and civil engineers with a deep understanding of the instruments used in environmental/structure monitoring and perhaps even controlling

Crash Course in Embedded and Real-Time Systems ‏

Goal of the lecture

• Giving a brief overview of the course• Motivation: why this course is useful to

environmental and civil engineers ‏• Short description of each topic• Key concepts briefly explained (further

detail in the upcoming weeks) ‏• Quick presentation of the team

Applications of Embedded Systems (ES) in Environmental

and Civil Engineering

App #1: Seismic• Interaction between ground motions and

structure/foundation response not well understood.

– Current seismic networks not spatially dense enough to monitor structure deformation in response to ground motion, to sample wavefield without spatial aliasing.

• Science– Understand response of buildings and

underlying soil to ground shaking – Develop models to predict structure response

for earthquake scenarios.• Technology/Applications

– Identification of seismic events that cause significant structure shaking.

– Local, at-node processing of waveforms.– Dense structure monitoring systems.

• ES will provide field data at sufficient densities to develop predictive models of structure, foundation, soil response.Source: D. Estrin, UCLA

Field Experiment

⎜⎯⎯⎯⎯⎯⎯⎯ 1 km ⎯⎯⎯⎯⎯⎯⎜

• 38 strong-motion seismometers in 17-story steel-frame Factor Building.• 100 free-field seismometers in UCLA campus ground at 100-m spacing

Source: D. Estrin, UCLA

Contaminantplume

App#2: ES Research Implications• Environmental Micro-Sensors

– Sensors capable of recognizing phases in air/water/soil mixtures

– Sensors that withstand physically and chemically harsh conditions

– Microsensors• Signal Processing

– Nodes capable of real-time analysis of signals.

– Collaborative signal processing to expend energy only where there is risk.

Source: D. Estrin, UCLA

App#3: Ecosystem MonitoringScience• Understand response of wild populations (plants and animals) to habitats

over time.• Develop in situ observation of species and ecosystem dynamics.

Techniques• Data acquisition of physical and chemical properties, at various

spatial and temporal scales, appropriate to the ecosystem, species and habitat.

• Automatic identification of organisms(current techniques involve close-range human observation).

• Measurements over long period of time,taken in-situ.

• Harsh environments with extremes in temperature, moisture, obstructions, ...

Source: D. Estrin, UCLA

The Need of a Network of Embedded Systems

• Diverse sensor sizes (1-10 cm), spatial sampling intervals (1 cm - 100 m), and temporal sampling intervals (1 ms - days), depending on the target environment.

• Naive approach → Too many sensors → Too many data.– In-network, distributed information processing

• Wireless communication due to climate, terrain, thick vegetation.

• Self-Organization to achieve reliable, long-lived, operation in dynamic, resource-limited, harsh environment.

• Mobility for deploying scarce resources (e.g., high resolution sensors).

This course: only one node! Advanced master course: multiple networked intelligent nodes!

Source: D. Estrin, UCLA

Block I – Fundamentals of Signal Processing

• The concept of signal• Time- and frequency- domains

The Concept of Signal

• A signal is any time- or space-dependent quantity.

• A signal can be (time-)discrete(sequence) or (time-)continuous(function).

• A continuous signal can be sampled, thus resulting in a discrete signal.

• An analog signal may take any continuous value over time; a digital signal can take only a discrete set of values.

Sampling of a continuous signal (in grey) resulting in a discrete signal (in red)‏

Quantization of a continuous signal (in grey) resulting in a digital signal (in red)‏

Some examples of signalsSignal Continuous

DiscreteAnalogDigital

Variation of the temperature during the day

Balance of your bank account

Live performance of Beethoven’s 5th symphony

MP3 of Beethoven’s 5th symphony

f(t) = 10*sin(t)

f(t) = floor(10*sin(t))

JPEG image

Average annual temperatures in Switzerland since 1950

Number of people on Earth since 1950

Some examples of signalsSignal Continuous

DiscreteAnalogDigital

Variation of the temperature during the day continuous

Balance of your bank account continuous

Live performance of Beethoven’s 5th symphony continuous

MP3 of Beethoven’s 5th symphony discrete

f(t) = 10*sin(t) continuous

f(t) = floor(10*sin(t)) continuous

JPEG image discrete (in space)

Average annual temperatures in Switzerland since 1950 discrete

Number of people on Earth since 1950 continuous

Some examples of signalsSignal Continuous

DiscreteAnalogDigital

Variation of the temperature during the day continuous analog

Balance of your bank account continuous digital

Live performance of Beethoven’s 5th symphony continuous analog

MP3 of Beethoven’s 5th symphony discrete digital

f(t) = 10*sin(t) continuous analog

f(t) = floor(10*sin(t)) continuous digital

JPEG image discrete (in space)

digital

Average annual temperatures in Switzerland since 1950 discrete analog

Number of people on Earth since 1950 continuous digital

Time and Frequency Domains• Any signal can be represented in time and in frequency.• One of the greatest discovery of the 20th century is that one

can mathematically switch from one domain to the other using a number of linear transformation (e.g., Fourier transform)

• These mathematical tools allow one to perform frequency analysis of signals and filters.

• Even better, for instance using using a Fast Fourier Transform (FFT), it is possible to compute the discrete Fourier transform and its inverse in an efficient manner.

Block II – Fundamentals of Computer Science

• Computers are Discrete and Digital• Basics of computer architecture• Programming of Embedded Systems

Computers are Discrete and Digital• Whatever quantity a computer processes, it has to be

digital (i.e., it belongs to a finite set of discrete values).– 32-bit signed integers go from −2,147,483,648 to

+2,147,483,647 on most computers• For instance, one can not represent π explicitly in a

computer: we need an approximation (e.g., rounding to the closest discrete value in the set).

• Whatever signal a computer processes, it has to be discrete, otherwise it would require an infinite amount of memory.

• Therefore, any physical signal has to be sampled and digitized in order to be processed by a computer!

Basics of computer architecture• Any computing entity (ranging from a laptop to a wireless

sensor network node) is composed of three fundamental entities:– Processing unit (microprocessor or microcontroller)– Memory (RAM, magnetic disks, flash memory)– I/O (input/output) ports

• A computer is a machine, not a magical entity. Keep in mind the following fundamental and universal limitations:– Processing is limited (in terms of operations per second)– Memory is finite – I/O bandwidth (bits per second) is limited– Energy and power is limited (especially important in

embedded systems, but remains true for any computer)

Programming for Embedded Systems• Embedded systems are limited both in terms of

computation and in terms of memory:– Understanding memory vs computation trade-offs is

crucial!• Embedded systems cannot afford (to date) the price of a

virtual machine and/or an interpreter such as those used by Java and Matlab:– You will need to use (and learn) the C language for

programming embedded systems.• C is quite similar, from a syntax point of view, to Java.

However, C does not manage memory automatically:– You will need to understand the concept of pointer and

memory management.

Block III – Fundamentals of Embedded and Real-Time

Systems

• Example of embedded systems• Webots realistic simulator• Perception-to-action loop

e-puck Block Schema

ActuatorsSensors

Computation and memoryCommunication

I/O

SensorNode (meteo station at EPFL)‏Features:- Very low sampling frequency < 1Hz- Very low power consumption: 25mW- Solar panel- Radio communication

Sensors:- Air Temperature and Humidity- Infrared Surface Temperature- Anemometer- Solar Radiation- Pluviometer- Soil moisture- Soil pressure

Similar architecture (computation, memory, I/O) as

the e-puck, but not mobileVisit http://sensorscope.epfl.ch for further details!

WebotsTM

fast prototyping and simulationsoftware for mobile robots

professional mobile robot simulation

e-puck Simulated Robot

• Discrete sensor and actuators• Noise and nonlinear characteristics faithfully reproduced• Single and multi-robot simulator• Different levels of simulation (different accuracy/faithfulness trade-

offs)‏

Perception-to-Action Loop

Computation

Perc

eptio

n

Act

ion

Environment

Reactive + memoryless (e.g., nonlinear transform, single loop)‏Reactive + memory (e.g., filter, state variable, multi-loops)‏Deliberative (e.g. planning, multi-loops)‏

sensors actuators

Note: real-time aspect emphasized!

Conclusion

Take Home Messages1. First iteration of the course: please give feedback!2. Balanced theoretical contents and hands-on

exercises/laboratories3. Do not worry about C and UNIX! We are here to help

and this is a great opportunity for your to get your hands on these tools!

4. For today, remember:– Discrete vs continuous and digital vs analog– Basics of computer architecture, and fundamental

limitations– Perception-to-action loop

Additional Literature – Week 1Books• Alan V. Oppenheim, Alan S. Willsky, with S. Hamid, "Signals and

Systems: International Edition 2nd Edition – Paper", Prentice Hall, 1996.

Recommended