Upload
vuque
View
223
Download
5
Embed Size (px)
Citation preview
1
Microcontrollers: Lecture 7 Wireless Sensor Networks, Sensors and
radio Interfaces, Projects, Exercises.
Michele Magno
2
Calendar
07.04.2017: Power consumption; Low power States; Buses, Memory, GPIOs
20.04.2017 Serial Communications
21.04.2017 Programming STM32
27.04.2017 Interrupts, Timers
Exercises
28.04.2017 Programming STM32
04.05.2017 Sensors, ADC and DMA
05.05.2017 Sensors / Radios / short seminar on WSN
Projects presentation and exercises summary.
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
Check the electrical characteristics
8
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
9
Digital Output – I2C Interface- Adapted voltage- Logic level
determined by Vdd- More sensors- Slower
… connect to uC (1)
Communication occurs trough data bus
10
Digital Output – SPI Interface- monodirectional lines- faster- transm freq = uc clk
… connect to uC (2)
11
Sensor
… connect to uC (3) – analog MEMS
Amplifier MicrocontrollerFilter
1212
All the building blocks
Wireless Communication
14
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
15
Radio interface
SPI DATA I/O
TIMER MCU RADIO
ANTENNARADIO SUBSTYSTEM
Radio only performs modulation‐demodulation
SPI serial port for data interface
16
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
17
Radio subsystem architecure
18
Radio module stand alone
FEATURES:
Integrated chip antenna
& crystal
Easy to connect
Ready to use
Internal MCU
Stack protocol on board
Flexible
Internal Flash
19
Radio module interface
20
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
21
Protocol layers
Protocols specific
User specific
User application, usually, are built over Network layer
WSN protocols define lower levels
Physical
Data Link (MAC)
Network
22
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
23
Physical layer
Communication bands and number of channels
24
Physical layer
Spreading and Modulation
25
Physical layer
Data Rate
20, 40, 250 kbps
1, 3 Mbps
54 Mbps
26
Classification of communication networks
27
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
28
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
29
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)
30
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)
31
Network – Structure
Not always predictable but can follow logical structure
Mesh Cluster tree
32
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
33
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
34
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.
35
Protocols – Security (2)
Traditional security techniques cannot be applied due to system constraints
Power
Bandwidth
Computation
Secure protocols uses:
Encription
Data authentication
Data freshness
36
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
37
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
38
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)
39
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
40
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!
42
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.
43
43
Sensori
CPU
Head Up Display
Project Example: Smart Helmet
44
44shelmet: sensors
3-axis Accelerometer
Temperature & Ambient Light Sensors
• Alcohol detection system
45
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 (ARM CORTEX M4F) 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
We have two microcontrollers with the following
specifications
47
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 a analog signal with frequency at 1KHz with a voltage range of 1V. The
required resolution for the ADC is of at least 550µV. For the sensor specification
the sample and hold period should be at least of 90µs.
48
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
49
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 (1KHz) –> It will fix the ADC Clock, and it will depend of the
50
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. Let’s select 15.
- This results on 166.66KHz of minimal clock ADCLK. NOTE IF YOU NEED A FASTER ADCLOCK YOU NEED TO GO FASTER! AND SELECT HIGHER SAMPLE&HOLD CYCLING.
ADCLK depends of Master clock of at least a prescale of /2 /4/6 etc.. Lets chose
6. So the minimal master clock is 1MHz to satisfy the sample and Hold.
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!
n
ref
LSB
VV
2
51
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 Where Tconversion = Tclk*bits.
Tsample = 90us
Tconversion = 66us
TADC= 156us => Maximal frequency 6.4KHz. So we fit the SPECIFICATIONS
and also we could reduce the ADC clock if needed.
52
First Selection to fit the ADC requirements.
Master Clock 1MHz
ADC Clock 166KHz (1MHz/6)
Exercise• Let’s assume we
• two possible microcontrollers as in
table.
• A battery of 100mAh a 3.7V.
• Evaluate the minimal Duty Cycling
that maximize the number of tasks
executed and achieve 2 weeks for
each Microcontroller assuming the
minimal time for the active task is
1s at 16MHz and 2s at 8MHz.
•
53
05.05.2017Presentation 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 [h]
• MCU A -> 50 h
• MCU B -> 33 h (But double number of Tasks)
• Duty Cycling. D = P/T *100.
• Example MCU A => P = 2s , T = 10s -> D= 20%.
• Example MCU B=> P = 1s T= 10s -> D= 10%
54
05.05.2017Presentation 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; P = 1s; D= ?
• MCU A: T = 2000s; P = 2s; D = ?
• Which one last more? How Long?
• Etot (T) = Esleep (T- P) + 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!
55
05.05.2017Presentation Title
56
How select the Microcontroller?
We need to evaluate the power/energy consumption with the previous
results
Power = Voltage * Current = [W]
Energy = P * time in seconds. = [J]
Energy duty cycling period T = 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 * 200µA (1MHz) = 400µW
MCU B Power = 2V * 300µA (1MHz) = 600µW! 33% MORE EXPENSIVE
Energy for one hour -> 1.44J for MCU A.
57
Energy With Duty Cycling
In 4 hours the active mode it is only 36s.
T = 4h. Duty Cycling is 36s / 4h*3600 => 0.0025%
We need to evaluated Psleep
Psleep = Tsleep * Voltage * Isleep
Energy for sleep period
MCU A = 14364s * 2V * 1.2µA = 34.4mJ
MCU B = 14364s * 2V * 0.6µA = 17.2mJ
Energy for period T of 4h Esleep + Eactive
MCU A= 34.4mJ + 36*400µW = 48.8mJ
MCU B = 17.2mJ + 36*600 µW = 38.8mJ
MCU B IS MORE EFFICIENT!
58
Estimation of Lifetime.
Assuming we have 100mAh without conversion losses (battery could works
of more than 2V and MCU works at 2V)
MCU A: Energy per hour -> 48.8mJ / 4 (h) -> 12.2mJ per 1h
MCU B: Energy per hour -> 48.8mJ / 4 (h) -> 9.7mJ per 1h
Average Power = Energy per hour/ 3600s =
=3.38µW (MCU A) and 2.69µW (MCU B)
Average Current MCUA = Power / Volt = 1.69µA
Average Current MCUB = Power / Volt = 1.34µA
Lifetime[years] = 100mAh /Avg. Current => around 6.5y MCUA and 8.5y
MCUB