Date post: | 09-Jul-2018 |
Category: |
Documents |
Upload: | truonghanh |
View: | 213 times |
Download: | 0 times |
Classes Objectives
o Giving you an overview on the software used in the IoT community
o Stimulating your curiosityo Providing you with basic tools to
develop simple IoT applicationso Classes time is limited -> Play with
these tools on your own!!
Calendar of upcoming events
o 14 Oct 2016 – Intro, Thingspeak, Node-RED
o 2 Nov 2016 – TinyOSo 9 Nov 2016 – Contiki, Moterunnero 23 Nov 2016 – Riot, Projects
Politecnico di MilanoAdvanced Network Technologies Laboratory
Internet of Things
Applications and enabling tools
Agenda
o A Bit of Context on the IoT and Wireless Sensor Networks (WSNs): n Applications, Challenges and Sensor
Platformso Designing OS for networked sensors
n Requirements and guidelines n The TinyOS example
Politecnico di MilanoAdvanced Network Technologies Laboratory
A Bit of Context on WSNsTechnology, Applications and Sensor Nodes
New Class of Computing
year
log
(peo
ple
per c
ompu
ter)
Mainframe
Minicomputer
WorkstationPC
LaptopPDA
Technology Pusho CMOS miniaturizationo Micro-sensors (MEMS, Materials, Circuits)
n acceleration, vibration, gyroscope, tilt, magnetic, heat, motion, pressure, temp, light, moisture, humidity, barometric
n chemical (CO, CO2, radon), biological, microradar, ...n actuators too (mirrors, motors, smart surfaces,
micro-robots)o Communication
n short range, low bit-rate, CMOS radios (1-10 mW)o Power
n batteries remain primary storage (1,000 mW*s/mm3), fuel cells 10x
n solar (10 mW/cm2, 0.1 mW indoors), vibration (~uW/gm), flow
n 1 cm3 battery => 1 year at 10 msgs/sec
Application Pullo Monitoring Environments
n habitat monitoring, conservation biology, ...n Precision agriculture, land conservation, ... n built environment comfort & efficiency ... n alarms, security, surveillance, treaty verification
o Monitoring Structures and Thingsn structural response, condition-based maintenancen disaster managementn urban terrain mapping & monitoring
o Interactive Environmentsn manufacturing, asset tracking, fleet & franchisen context aware computing, non-verbal communicationn Assistance
o home/elder care
CENS.ucla.edu
Recent applications
o 2015 best IoT products:http://www.postscapes.com/internet-of-things-awards/2015-16/
o Common features:n Low-cost hardwaren Data sensingn Wireless communicationn Data logging
WSNs: Potentials and Challenges
o Potentialsn Cost viabilityn Flexibilityn Short time-to-deployment
(can be built with off-the-shelf technology)n Numbers (# nodes >> # people)
o Challenges at different layersn Energy Efficient protocols design n Self configurability or planningn Robustnessn Coverage & Connectivityn OS Design
Power Unit ANTENNA
Sensor ADCProcessor
MemoryTransceiver
Location Finding System Mobilizer
Sensor Hardware
Mica“Open
Experimental Platform”
Rene’“Experimentation”
Dot“Scale”
Spec“Mote on a chip”
Telos“Integrated Platform”
Mica2Dot
Mica2
20062005200420032002200120001999
IMote
MICAz
Stargate 2.0&
IMote2
Stargate
Sensor Motes Timeline
2008 2009
Epic
2007
Shimmer
Shimmer 2Iris
o Microprocessor: Atmel ATmega128Ln 8 MHz clockn 128 kB of Flash for program memoryn 4 kB of SRAM for data and variablesn 2 UARTs (Universal Asynchronous Receive and
Transmit)n Serial Port Interface (SPI) busn Dedicated hardware I2C bus
o Radio: Chipcon’s CC2420 (IEEE 802.15.4)n 250 kbit/s
o External serial flash memory: 512 Kbn About 100.000 samples
o 51-pin expansion connectorn Eight 10-bit analog I/On 21 general purpose digital I/O
o User interface: 3 programmable LEDso Powered by two AA batteries
MICAz Platform
Logger Flash
ATmega128LµcontrollerAnalog I/ODigital I/O
Freq. Tunable Radio
51-Pin Expansion Connector
Antenna
MMCX connector
LEDs
Rich Sensor board
PHOTO
TEMP
MAGNETOMETER ACCELEROMETER
MICROPHONE
SOUNDER
Mica PINS
ADC Signals (ADC1-ADC6)
I2C BusOn/Off Control
Interrupt
X AxisY Axis
Gain Adjustment
Mic Signal
ToneIntr
2.25 in
1.25 in
Microphone
AccelerometerLightSensor
TemperatureSensor
Sounder Magnetometer
Politecnico di MilanoAdvanced Network Technologies Laboratory
Designing OS for networked sensors
Requirements and guidelines
Traditional Architectures
o Well established layers of abstractions
o Strict boundarieso Ample resourceso Well attended
User
System
Physical LayerData LinkNetwork
TransportNetwork Stack
Threads
Address Space
Drivers
Files
Application
Application
Routers
Kernel Based Architectures
VM I/O Scheduler
Application 1 Application 2
Monolithic kernel
HW
NFS I/O
Scheduler
Application 1
Micro-kernel
HW
IPC VM
o Problemsn Large memory & storage requirement n Unnecessary and overkill functionality n Address space isolation, complex I/O subsystem, UIn Relative high system overhead, e.g, context switchn Require complex and power consuming hardware
support
“General-Purpose” OS?
MANY functionalities & programming APIso Protection between “untrusted” applications
and kerneln Overhead for crossing kernel/user boundary &
interrupt handlingo Multi-threaded architecture
n Large number of threads à large memoryn Context switch overhead
o I/O modeln Blocking I/O: waste memory on blocked threadsn Polling: waste CPU cycles and power
o Need a new OS architecture!
Sensor OS Requirementso Small footprinto Low system overheado Low power consumptiono Application-oriented designo Flexibility in supporting multiple applicationso Solutions:
n TinyOSn Mote Runner n Contikin Riotn NanoRKn LiteOSn FreeRTOS
Politecnico di MilanoAdvanced Network Technologies Laboratory
“TinyOS is an open-source operating system designed for wireless embedded sensor networks”
http://www.tinyos.net/
TinyOS Overviewo Event-driven architecture
n OS operations are triggered by hardware interrupt (asynchronous management)
o Single shared stacko No kernel/user space differentiation
CommunicationActuating Sensing Communication
Application (User Components)
Main (includes Scheduler)
Hardware Abstractions
TinyOS Architecture Overview
I/O COMM . …….
SchedulerTinyOS
ApplicationComponent
ApplicationComponent
ApplicationComponent
o NO Kernel - Direct hardware manipulationo NO Process management - Only one process on the flyo NO Virtual memory -Single linear physical address
space o NO Dynamic memory allocation - Assigned at compile
timeo NO Software signal or exception - Function call
TinyOS “Ingredients”
o TinyOS is not an OS in traditional senseo Provides a programming framework to
build application-specific OS instanceso Programming Framework made of:
n Scheduler (always there)n Components n Interfaces
TinyOS Conceptso Scheduler + Graph of
Componentsn constrained two-level scheduling
model: tasks + events
o A component n specifies a set of interfaces by which
it is connected to other componentsn provides a set of interfaces to othersn uses a set of interfaces provided by
others
o Interfaces are bi-directional include commands and events
o Constrained Storage Modeln frame per component, shared stack,
no heap
Timer Component
StdControl Timer
Clock
provides
uses
StdControl.nc interface StdControl {
command result_t init();
command result_t start();
command result_t stop();
}
Clock.nc interface Clock {
command result_t setRate(char interval, char scale);
event result_t fire();
}
Event implementationo Event is independent of FIFO scheduler
o Lowest level events are supported directly by Hardware interrupt
o Software events propagate from lower level to upper level through function call
TASKSo Provide concurrency internal to a
componentn longer running operations
o Are preempted by eventso Able to perform operations beyond event
contexto May call commandso May signal eventso Not preempted by tasks
{...post TskName();...}
task void TskName(){...}
Typical application use of tasks
o Event driven data acquisitiono Schedule task to do computational portion
event result_t sensor.dataReady(uint16_t data) {
putdata(data);
post processData();
return SUCCESS;
}
task void processData() {
int16_t i, sum=0;
for (i=0; i ‹ maxdata; i++)
sum += (rdata[i] ›› 7);
display(sum ›› shiftdata);
}
• 128 Hz sampling rate• simple FIR filter• dynamic software tuning for centering the magnetometer signal (1208 bytes)
• digital control of analog, not DSP•ADC (196 bytes)
Tasks - Exampleso Transmit packet
n Send command schedules task to calculate CRCn Task initiated byte-level data pumpn Events keep the pump flowing
o Receive packetn Receive event schedules task to check CRCn Task signals packet ready if OK
o Byte-level TX/RXn Task scheduled to encode/decode each complete
byten Must take less time that byte data transfer
TOS Execution Modelo Commands request action
n ack/nack at every boundaryn call cmd or post task
o Events notify occurrencen HW interrupt at lowest leveln may signal eventsn call commandsn post tasks
o Tasks provide logical concurrencyn preempted by events
o Migration of HW/SW boundary
RFM
Radio byte
Radio Packet
bit
byte
pack
etevent-driven bit-pump
event-driven byte-pump
event-driven packet-pump
message-event drivenactive message
application comp
encode/decode
crc
data processing
An Example Application
RFM
Radio byte (MAC)
Radio Packet
i2c
Tempphoto
Messaging Layer
clocksbit
byte
packet
Routing Layer
sensing applicationapplication
HW
SW
ADC
messaging
routing
Event-Driven Sensor Access Pattern
o Clock event handler initiates data collectiono Sensor signals data ready evento Data event handler calls output commando Device sleeps or handles other activity while waitingo Conservative send/ack at component boundary
command result_t StdControl.start() {
return call Timer.start(TIMER_REPEAT, 200);
}
event result_t Timer.fired() {
return call Sensor.getData();
}
event result_t Sensor.dataReady(uint16_t data) {
display(data);
call Led.Toggle();
return SUCCESS;
}
SENSE
Timer Sensor Led
TinyOS Scheduling
o Tasks do computationsn Non-preemptive FIFO schedulingn Bounded number of pending tasks
o Events handle concurrent dataflowsn Interrupts trigger lowest level eventsn Events preempt tasks, tasks do notn Events can signal events, call commands, or
post tasks
Hardware
Interrupts
Even
ts
commands
FIFOTasksPOSTPreempt
Time
commands
TinyOS Scheduling
o Event and Taskn Tasks cannot preempt other tasksn Single shared stack
o Used by both interrupts and function callsn Simple FIFO scheduler n Events can preempt a taskn Events can preempt each othern When idle, scheduler shuts down the node
except for clock
Motivations
o Many software are available for designing WSNs and IoT solutions
o No “standard” configuration is availableo Depending on the application, one solution
may be preferable
o Even the installation of a programming environment itself is a time-consuming task
Example: TinyOS
o TinyOS is quite easy to install on Debian-based systems (Linux)
o For installation under Windows, cygwin is required…
o On Mac OS X…. nightmare!
o All these issues may discourage researchers to play with it
o Similar issues also when installing other products
Solution: Virtual Machine
o A Virtual Machine is an emulation of a particular computer system
o On the class website, a Virtual Machine containing most of the needed tools isavailable:
http://home.deib.polimi.it/redondi/IoT/IOT-ubuntu.ova
VM contents
o Contiki env + exampleso TinyOS env + exampleso Moterunner env + exampleso Xively libraries and exampleso Sicsthsense exampleso Node-RED
How to run it
1. Download Oracle VM VirtualBox for your laptop (make sure to have at least 10 GB of free space on your HD)
2. Download the IOT virtual machine from the class website
3. Open VirtualBox and go to File->Import Appliance and import the file IOT-ubuntu.ova
4. Start using the system! (password is “user”)