Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
1
Microcontrollers: Lecture 8 Wireless Sensor Networks, Sensors and
radio Interfaces, Projects, Exercises.
Michele Magno
2
Calendar
26.04.2018 Interrupts, Timers, PMW, DAC
Exercises
27.04.2018 ADC-DMA
Exercises
03.05.2018 Sensors Devices / Radios
Projects presentation and exercises.
Sensors
4
Sensing is a Must
4Departement Informationstechnologie und
5
Digital MEMS block schematic
6
…open the datasheet
You will find a Table with PIN description
Block diagramshowing that thereis more than the micro-mechanicalelement
Indication of referencedirections of the 3 accelerations
7
Interfacing with uC
The LIS3LV02DL (STMicroelectronics) can be accessed through both the
I2C and SPI serial interfaces. The latter may be SW configured to operate
either in 3-wire or 4-wire interface mode.
The serial interfaces are mapped onto the same pads
8
Digital Output – I2C Interface- Adapted voltage- Logic level
determined by Vdd- More sensors- Slower
… connect to uC (1)
Communication occurs trough data bus
9
Digital Output – SPI Interface- monodirectional lines- faster- transm freq = uc clk
… connect to uC (2)
10
Sensor
… connect to uC (3) – analog MEMS
Amplifier MicrocontrollerFilter
1111
All the building blocks
Wireless Communication
13
WSN Protocols
WSN protocol strongly impact on system performance
Choosing the wrong protocol may cause severe inefficiency and prevent the WSN to accomplish user need.
The protocol affect:
Energy dissipation
System cost
Latency
Security
14
Radio interface
SPI DATA I/O
TIMER MCU RADIO
ANTENNARADIO SUBSTYSTEM
Radio only performs modulation‐demodulation
SPI serial port for data interface
15
Radio Subsystem
• Ease of communication with other devices
• Consumption (10 - 100mA)
• Start-up time and available bandwidth
Transceiver
• Chip antenna
• PCB antenna
• External antenna
Antenna
16
Radio subsystem architecure
17
Radio module stand alone
FEATURES:
Integrated chip antenna
& crystal
Easy to connect
Ready to use
Internal MCU
Stack protocol on board
Flexible
Internal Flash
18
Radio module interface
19
Wireless microcontroller
Benefits
Single chip integrates transceiver and microcontroller for wireless sensor networks
Cost sensitive ROM/RAM architecture, meets needs for volume application
System BOM is low in component count and cost
Hardware MAC ensures low power consumption and low processor overhead
Extensive user peripherals
20
Protocol layers
Protocols specific
User specific
User application, usually, are built over Network layer
WSN protocols define lower levels
Physical
Data Link (MAC)
Network
21
Physical layer
Provides mechanical, electrical, functional, and procedural characteristics to establish, maintain, and release physical connections (e.g. data circuits) between data link entities
Communication bands and number of channels
Spreading and Modulation
Data Rate
Cost – Power consumption – Reactiveness
22
Physical layer
Communication bands and number of channels
23
Physical layer
Spreading and Modulation
24
Physical layer
Data Rate
20, 40, 250 kbps
1, 3 Mbps
54 Mbps
25
Classification of communication networks
26
Data link layer (MAC)
Physical
Network
Data LinkMAC Protocol
Layer 2
Layer 3
Layer 1
OSI
Data link layer: Mapping network packets
radio frames
Transmission and reception of frames over the air
Error control Security
27
Data link layer (MAC) (2)
Control access to the shared medium
Avoid interference and mitigate effects of collisions
A B C
A B C D
Hidden terminal problem
Exposed terminal problem
28
Energy efficient MAC
idle listening (to handle potentially incoming messages)
collisions (wasted resources at sender and receivers)
overhearing (communication between neighbors)
protocol overhead (headers and signaling)
traffic fluctuations (overprovisioning and/or collapse)
scalability/mobility (additional provisions)
29
Network layer
Provides functional and procedural means to exchange network service data units between two transport entities over a network connection. It provides transport entities with independence from routing and switching consideration
Organization of the network Network formation
Joining/leaving the network
Routing of packets through the network Shortest path
Energy efficient
Tracing of the status of the links Routing tables
On demand path (e.g. AODV)
30
Network – Structure
Not always predictable but can follow logical structure
Mesh Cluster tree
31
Network – Structure
Not always predictable but can follow logical structure
Clustering:
Balance load among nodes Cluster Head must compute more data
energy efficency
Adapt to network changes
Reduce data transfer
32
Network – Routing
Hard, due to node failure and mobility
Balance between low duty cycle and frequent path updates
Routing algorithm can be classified in three group
Connect dominating
Try to find the shorter path to the destination
Energy dominant
Life of network can be longer if energy consumption is balanced among nodes
Biological model
Ants communication paradigm
33
Protocols – Security (1)
Security Concerns:
Integrity - Ensure that information is accurate, complete, and has not been altered in any way.
Availability - Ensure that a system can accurately perform it’s intended purpose and is accessible to those who are authorized to use it.
Confidentiality - Ensure that information is only disclosed to those who are authorized to see it.
34
Protocols – Security (2)
Traditional security techniques cannot be applied due to system constraints
Power
Bandwidth
Computation
Secure protocols uses:
Encription
Data authentication
Data freshness
35
Bluetooth:2.4GHZ
Frequency Hopping Spread Spectrum(1600 hop/s)
720kb/s up to 3Mb/s (for voice, audio and bulk data)
ZigBee:800 MHz, 900 MHz, 2.4GHz
Direct Sequence Spread Spectrum
250kb/s (Optimised for short packets)
Networking
Dynamic ad-hoc Pico-nets, master negotiation
Extensive profiles to ensure compatibility
Active / Park modes
Hybrid MAC (mostly scheduled, with RT streams)
Networking
Large master-slave networks, with fast access
Slave - initiated communication, (slave energy reduced)
Virtual peer-peer device pairing links
Hybrid MAC (mostly contention)
State transitionsNetwork join time 3s
Sleeping slave changing to active = 3s typ.
Active slave channel access time = 2ms typ.
State transitionsNetwork join time = 30ms typ
Sleeping slave changing to active = 15ms typ
Active slave channel access time = 15ms typ
ZigBee VS BT VS BTLE
BTLE (4.0):2.4GHZ
GFSK @ 2.4 GHz Adaptive Frequency Hopping
Sleep current ~ 1µA
1Mb/s (no optimized for files)
Networking
New ease of discovery & connection
Asynchronous connection-less MAC
Modes:Broadcast, Connection, Event Data Models Reads, Writes
State transitions3ms from start to finish with
Asynchronous
Sleeping slave AsynchronousClient / Server architecture
BTLE (5.0):2.4GHZ
GFSK @ 2.4 GHz AFH
Sleep current nanoA
2Mb/s
Long range
Networking
Asynchronous connection-less MAC
Modes:Broadcast, Connection, Event Data Models Reads, Writes
Mesh Newtwork supported
State transitions>3ms from start to finish with
Asynchronous
Sleeping slave AsynchronousClient / Server architecture
36
ZigBee vs. BTLE
BTLE focuses on low power & low cost communications betweenmobile phones and small sensor devices,
Mobile phones will have several radios (many @ 2.4 GHz): BTLE iscost- and power-wise optimized for sensor connectivity in thisenvironment,
BTLE ~ZigBee in terms of peak power, but due to the higher bit rate, Wibree results in lower energy per bit @ high utilization
ZigBee focuses on home and industry automation.
Wibree does not support mesh networks as does ZigBee
ZigBee support higher range operation
37
Power Consumption in WSN
0
2
4
6
8
10
12
14
16
Po
wer
(mW
)
Power Consumption
Sensing
Communication
Data processing
CPU Sensing TX RX Idle Sleep
RADIO
Usually the Radio is the most power hungry component
Idle mode is needed to allow the node to be reactive but it wastes a lot of power.
Sleep Mode consumption is very low.
• WSN Complex systems made up of a large number of sensor nodes.
Each node has:– Communication
– Sensing
– Computing
– Power (batteries, scavengers)
38
Wake Up Radio Motivations
• Listening mode power consumption of wakeup radio much less than idle power consumption of standard radio
• Using information about traffic in the network, we can make better decisions about how frequently to wake up the microcontroller
Power Characteristics for a CC2520 transceiver
Radio wake
up
Main Radio
Sleep < uW 1 mA
TX/RX < uW 20 mA
39
Wake up radio Concept
CPU
Main
Radio
ON/OFF
Wake up radio
receiver Interrupt
Wake up Message
Main RADIOTon
Wake up radio
receiver
Toff Toff
Wake up Message Always on nano power consumption
t
t
Sleep/wake up radio technique
Project EXAMPLE: Let’s build our smart
home!
41
Projects: You can work and learn on hardware/firmware/software from the project.
HARDWARE:
Design PCB
Sensors Interfaces
Wake up Radio and Analog/Digital Desing
Energy Harvesting and Power Circuits
Software
Firmware for microcontrollers
Firmware to take data from sensors and processing on-board
Firmware and protocols for Radios
Software on application level to get information, processing data.
42
42
Sensori
CPU
Head Up Display
Project Example: Smart Helmet
43
43shelmet: sensors
3-axis Accelerometer
Temperature & Ambient Light Sensors
• Alcohol detection system
44
44
45
Sensors:
WSN for monitoring:
Design WSN
Work with sensors, wake/sleep techniques
Lab testing/characterization
Embedded Systems – Example projects
Integrated Systems Laboratory 45
46
Student projects can involve Hardware implementation and optimization
New PCB with hardware design.
Possible new sensors / LCD Display / Sensor network
Energy Harvesting and power stafges
Firmware implementation
MSP432/STM32 (ARM CORTEX M4F), MSP430, programming
Data acquisition and low power classifier (with deep learning)
Wireless communication
Software power management
Software implementation on Android/iOS
App for data logging
Interfacing with the helmet
Data analysis, clouding, social network, GPS
47
Exercises from previous exams.
48
02 Febrary 2018
EXERCISE II
Consider an MCU powered at 1.2V, with the following power states: SLEEP – consuming
10uA, ACTIVE.SLOW – running at 10MHz and consuming 10mA, ACTIVE.FAST running at
20MHz and consuming 15mA. Power comes from a 400mAh battery at 2.5V, with a DC-DC
converter (2.5V to 1.2V) with efficiency 80% in SLEEP, 90% in ACTIVE.SLOW, and 95% in
ACTIVE.FAST.II.a) Compute the energy consumed (drawn from the battery) for 1 second of operation in
each of the power states above.
II.b) Estimate lifetime when operating from the battery with the following duty cycle: 80% in
SLEEP, 15% in ACTIVE.SLOW, and 5% in ACTIVE.FAST.
II.c) How much would you extend the lifetime with respect to II.b if your DC-DC converter
was completely ideal?
49
04 September 2017
EXERCISE II
Consider a sensor node powered by a 400mAh battery at 3.3V. The node consists of an MCU which can be duty cycled (between
SLEEP and ACTIVE) and an always-on sensor which consumes 50uA with a supply of 2V. The MCU is powered at 1V and
consumes 10uA when in SLEEP and 5mA when ACTIVE. Voltage converters have an efficiency of 90% (efficiency is meant as ɳ
=𝑃𝑂𝑢𝑡/𝑃𝐵𝑎𝑡 where Pout is the power delivered by the converter to the load, and Pbat the power drawn from the battery).
II.a) Compute the lifetime of the battery when the MCU is always active and when the MCU is always in SLEEP state.
II.b) Draw a plot of the lifetime of the battery as a function of the duty cycle of the MCU. If you want to boost your battery
lifetime by 10x with respect to the always-ACTIVE case, what would be the required percentage of SLEEP time for the
MCU?
II.c) Estimate the increase in lifetime if the efficiency of the voltage converters is boosted to 99% (assume that the MCU
is duty cycled at 50%).
50
Exercises
We have two microcontrollers with the following
specifications
MCU A
(1.8V to 3V)
MCU B
(1.5V to 3V)
Active mode200 µA@3V/MHz (up
8MHzMaster Clock)
300µA@3V/MHz(16MHz Master
Clock)
Active mode150 µA@2V/MHz (up to 2Mhz
Master Clock)
180 µA@2V(up to 4Mhz Master
Clock)
Sleep Mode 1.2 uA 0.6 uA
The microcontroller should be selected to be attached to a Analog sensor to
acquire an analog signal with range frequency at 1KHz and a voltage range of 0V-
1V (max value of the signal). The required resolution for the ADC is of at least
550µV (less is better). For the sensor specification the sample and hold period
should be at least of 90µs.
51
ADC Clock Diagram
ADCCLKPrescaler
/2, /4, /6 or /8
Master Clock
3 cycles
15 cycles
28 cycles
84 cycles
58 cycles
Sa
mp
leT
ime
Se
lec
tion
The ADC Block of the internal microcontroller
follows:
Goal:
• Configure the ADC to satisfy the project requirements
• Select the Microcontroller and configuration to satisfy the Project specification and consumes less energy
in continuous mode.
• Quantify the energy consumption
• Estimate the lifetime of a system (for both MCU A and MCU B) that acquires the sensor data every 4 hour
for 36s with a battery of 100mAh, and discuss the best on the best microcontroller.
• Design the block diagram of the system designed
Vref
3V
2V
1.5V
1.1V
Resolutions
12 bits
10 bits
8 bits
6 bits
52
Solution: Configure the ADC
We need to understand
the minimal Frequency needed for the ADC sampling and acquisition.
Constrains:
- Sample and hold time of the sensor (90µ) –> It Will fix the SAMPLE AND HOLD time and the minimal ADC frequency.
- Minimal Resolution of 550µV. -> It will fix Vref and the ADC-bits
- Sample frequency for Nyquist (signal as 1KHz) –> We need at least 2KHz -> It will fix the ADC Clock, and it will depend of the sampling time and conversion time.
53
Solution ADC:
90µs -> 1/T => frequency of 11.11KHz of Sampling and hold.
We can select number of clock cycle of 3/15/28 (come from the architecture). Let’s select 15.
- This results on 166.66KHz of minimal clock ADCLK. NOTE IF YOU NEED A FASTER ADCLOCK YOU NEED TO SELECT HIGHER SAMPLE&HOLD CYCLING to have at least 90us!!!!!
ADCLK depends of Master clock of at least a prescale of /2 /4/6 etc (BE CAREFUL).. IF
you chose 6 for the presacele -> The minimal master clock is 1MHz to satisfy the sample and
Hold.
Sensitivity minimal 550µV -> Sensor has 1V maximum value. We can choose 1.1
For the reference. From:
With 11bits ADC -> 1.1V/211 = 530µV -> OK! BUT IN THE ADC ARCHITCURE WE
HAVE ONLY 10 or 12… SO 12 bits it is your selection
n
ref
LSB
VV
2
54
For Nyquist we need to sample at the double of the frequency of the signal that is
at 1KHz -> so we need to sample at 2KHz.
So we need a conversion time less than 1 / 2KHz = 500µs.
TADC = Tsample + Tconversion <= 500µs
Where Tconversion = Tclk*bits; Tclk is the selected ADCclk (1MHz/6 for us)
Tsample = 90us
Tconversion = 72us (for 12bits ADC convertion)
TADC= 162us => Maximal frequency 6.1KHz. So we fit the SPECIFICATIONS and also
we could reduce the ADC clock if needed!
55
First Selection to fit the ADC requirements.
Master Clock 1MHz
ADC Clock 166KHz (1MHz/6)
To evaluate the lifetime you can apply the formula of the other exercises.
SEE BELOW SPECIFIC EXERCISES!
56
Exercises
57
Example of MCUs
MCU A
(1.8V to 3V)
MCU B
(1.5V to 3V)
Active mode200 µA@3V/MHz (up
8MHzMaster Clock)
300µA@3V/MHz(16MHz Master
Clock)
Active mode150 µA@2V/MHz (up to 2Mhz
Master Clock)
180 µA@2V(up to 4Mhz Master
Clock)
Sleep Mode 1.2 uA 0.6 uA
58
How select the Microcontroller?
We need to evaluate the power/energy consumption with the previous
table
Power = Voltage * Current = [W]
Energy = P * time in seconds. = [J]
Energy duty cycling period Etot = Pactive*Tact + Psleep*Tsleep
T = Tact + Tsleep -> Duty Cycling D = Tact/T *100
In Continues mode D = 100% so Tsleep = 0
MCU A Power = 2V * 150µA (1MHz) = 300µW (CHECK THE NEXT
MATHS)
MCU B Power = 2V * 180µA (1MHz) = 360µW! 33% MORE EXPENSIVE
Energy for one hour -> P*time in second (3600) = 1.296J for MCU A.
59
Energy With Duty Cycling
Let’s assume MCU are in active mode only fir 4s.
Let’s assume the period is T = 1h. Duty Cycling = (4s / 3600s)*100 => 0.11%
We need to evaluated Psleep
Tsleep = T - Tactive = ( 3600) – 4.
Psleep = Tsleep * Voltage * Isleep
Energy for sleep period
MCU A = 3596s * 2V * 1.2µA = 8.63mJ
MCU B = 3596s * 2V * 0.6µA = 4.13mJ
Energy for period T of 1h Esleep + Eactive
MCU A= 8.63mJ + 4s*300µW = 9.83mJ
MCU B = 4.13mJ + 4s*360 µW = 5.57mJ MCU B IS MORE EFFICIENT!
60
Estimation of Lifetime.
Assuming we have 100mAh without conversion losses (battery could works
of more than 2V and MCU works at 2V) – We need to fine the average
current.
MCU A: Energy per hour -> 9.83mJ
MCU B: Energy per hour -> 5.57m
Average Power = Energy per hour/ 3600s =
=2.73µW (MCU A) and 1.54µW (MCU B)
Average Current MCUA = Power / Volt = 1.35µA (per h)
Average Current MCUB = Power / Volt = 0.77µA (per h)
Lifetime[years] = 100mAh /Avg. Current => around 8.5y MCUA and 14y MCUB
Exercise• Let’s assume we
• two possible microcontrollers as in table.
• A battery of 100mAh a 3.7V.
• It is assumed the time for the active task is 1s at 16MHz
and 2s at 8MHz.
• Evaluate the life time of the battery with Duty
Cycling for both MUC of 0.1%.
•
61
02.05.2018Presentation Title
MCU A
(1.8V to 3V)
MCU B
(1.5V to
3V)
Active
mode2 mA (8Mhz)
3 mA
(16Mhz)
Low power
mode0.6 uA 1 uA
• EBattery = 100mAh * 3600s * 3.7V-> 1320J
• Etask = P * time ->
• MCU-A -> P = 2mA*1.8V ; Etask = 3.6mW * 2s = 7.2mJ
• MCU B-> P = 3mA * 1.5V; Etask = 4.5mW * 1s = 4.5mJ
• Theoretical Max Numbers tasks (no dissipation in sleep) : Ebattery / Etask
• MCU A -> 184000
• MCU B -> 296000
• Lifetime in Continuous mode[h]: Battery[mAh] / Current Consumption in active mode [h]
• MCU A -> 50 h
• MCU B -> 33 h (But double number of Tasks)
• Duty Cycling. D = Ton/T *100. (in this caseTactive cannot be decided come from the problem)
• For MCU A => Tactive = 2s (FIXED). IF period is T = 10s -> D= 20%.
• For MCU B=> TActive = 1s (FIXED) IF T= 10s -> D= 10%
• Let’s start evaluating the energy in sleep
62
02.05.2018Presentation Title
Exercise
• ESleep = PLowPowerMode * Sleep time [T-Active Time] ->
• MCU-A -> P = 0.0006mA*1.8V = 3.6µW * 8s = 8.6µJ
• MCU B-> P = 0.001mA * 1.5V = 1.5µW * 9s = 13.5µJ
Exercise I
• Evaluate the life time using the following duty cycling
• MCU B: T= 1000s; Tactive = 1s; D= 0.1%
• MCU A: T = 2000s; Tactive = 2s; D = 0.1%
• Which one last more? How Long?
• Etot (T) = Esleep (T- Tactive) + Etask (T)
• MCU_B => Etask = 4.5mJ ; Esleep = 1.5µW * 999s= 1.498mJ; Etot = 5.99mJ
• MCU_A => Etask = 7.2mJ ; Esleep = 3.6µW * 1998s = 7.19mJ; Etot = 14.49mJ
• LifeTime (s) = (Ebattery / Etot ) * T
• MCU_B => 7 Years!
• MCU_A => 6 years!
63
02.05.2018Presentation Title