EECS 473
Advanced Embedded Systems
Lecture 13
Start on Wireless
Feedback and Upcoming
• Quick survey
– Who has gotten their PCB out?
• PCBs
– All are to be out by 10/31.
– Strongly suggest you get them reviewed
• MS2
– Report due on Tuesday 11/7
– Check-offs due by Wednesday 11/8 @6pm
– MS2 meetings start on Thursday 11/9
Team status updates for Thursday
• Largest roadblock
• Thing you are most pleased with wrt your
project.
Introduction to embedded wireless
Wireless communications
• Next 2.5 lectures are going to cover wireless
communication
– Both theory and practice.
• If you’ve had a communication systems class,
there will be some overlap
– And we will be focusing on digital where we can
• Though that’s still a lot of analog.
Introduction to embedded wireless
Wireless and embedded?
• As should be obvious,
modern embedded
systems are tied
closely to wireless
communication.
– Think about your
projects.
• Applications include
the home…
Introduction to embedded wireless
But certainly reach much farther
Introduction to embedded wireless
Lots of peer-to-peer wireless protocols
• Wi-Fi high-speed data with ranges of about 20-40 meters. Fairly high power consumption.
If you want to get on the Internet, this is usually the way to go.
• Bluetooth is a global 2.4 GHz personal area network for short-range wireless
communication. Device-to-device file transfers, wireless speakers, and wireless headsets
are common users. Range can get quite long with 5.0 (~200 meters)
– BLE is a version of Bluetooth designed for lower-powered devices that use less data. To conserve power, BLE
remains in sleep mode except when a connection is initiated. This makes it ideal for wearable fitness trackers and
health monitors.
• ZigBee is (mostly) a 2.4 GHz mesh local area network (LAN) protocol built on 802.15.4. It
was designed for building automation and still sees a lot of use there.
• RFID Allows passive (unpowered) devices to communicate.
– NFC a protocol used for very close communication. If you wave your phone to pay for groceries, you’re likely using
NFC. Closely related to RFID.
• LoRaWAN is a long-range (1-15km), low-power, low-data rate (~1-50kbits/sec) protocol.
• Z-Wave is a priority protocol design for home automation. <30 meter range. Has some
nice dev kits. Very low power.
• SigFox, Ingenu, Weightless-(N, P, W), ANT, DigiMesh, MiWi, EnOcean, Dash7,
WirelessHART. Probably a lot more.
Mostly from [Link]
Cellular
• Rather than peer-to-peer, we can go through cell
phone towers or even satellites.
– If you want to go *far* the only other real option is
shortwave radio (limited to about 300 baud)
• This used to be very expensive, but for small
amounts of data, it may be viable.
– For example, TruPhone will give you 125MB to use for
5 years for $19.00.
– There are some variations out there (e.g. Cat-M1, G4 )
• Tradeoffs aren’t hugely clear.
Introduction to embedded wireless
Two and half Lectures
• Start at the high-level
– Overview by example: Zigbee/802.15.4
• OSI model
– MAC layer
• Go to low-level
– Source & channel encoding
– Multi-path issues
– Modulation
– Range
Introduction to embedded wireless
Outcomes: Things you should be
able to answer after these lectures.
• Why might I choose the (lower bandwidth) 915MHz
frequency over the 2.4GHz?
– Related: Why are those the only bands I can pick?
– Related: Why can shortwave radio in China reach the US? Why
are their so many Cubs fans? (actually related)
• How do I compute “open space” radio distances?
– How do I convert “open space” radio distances in a specification to
indoor distances?
• How do I deal with a dropped packet?
• How much data can I hope to move over this channel?
Zigbee--basics
Zigbee
• ZigBee is an IEEE 802.15.4-based protocol
– used to create personal area networks with small, low-power digital
radios.
• Simpler and less expensive than Bluetooth or Wi-Fi.
• Used for wireless light switches, electrical meters with in-
home-displays, etc.
• Transmission distances to 10–100 meters line-of-sight
– Zigbee Pro can hit a mile
• Secure networking
– (ZigBee networks are secured by 128 bit symmetric encryption keys.)
• ZigBee has a defined rate of 250 kbit/s, best suited for
intermittent data transmissions from a sensor or input
device.
Zigbee—basics
At the end of the day all wireless
is just sending bits over the air.
• Two issues:
– How you send those
bits (physical layer)
– How you use those bits
(everything else)
• We’ll discuss both
Zigbee—basics
To minimize overhead, Zigbee
skips some layers
Zigbee—basics
From: ZigBee Wireless Networks and Transceivers by Shahin Farahani
Zigbee—basics
OSI basic idea
• Each layer adds some header information to
address a specific problem.
– What task on the target is this message related to?
• A given sensing unit might have a lot of sensors for example.
– What if we have a longer message
than one frame?
• What if one of those
frames gets dropped?
• Example on next pages:
– Data link to Physical.
Zigbee—basics
MAC (data link) layer (802.15.4)
• Frame control basics: • Frame control—frame size
– What type of frame? – Sender/receiver on same
– Security enabled? PAN?
– Need to Ack? – Address size for source and
destination (16 or 64 bit)
– Which standard? (Frame
version)
Zigbee—basics
MAC layer (802.15.4)
• Sequence number • Auxiliary Security
– Used to reassemble header specifies
packets that came out of encryption schemes
order.
• FCS (Frame check
– Or detect a resent packet
sequence)
• PAN IDs and addresses – CRC for detecting errors.
are just what you’d think.
Zigbee—PHY layer
Physical layer
There is a lot about the physical layer to understand. We’ll do some on Tuesday.
PHY layer
Image taken from: [Link]/wiki/File:United_States_Frequency_Allocations_Chart_2003_-_The_Radio_Spectrum.jpg
PHY layer
United States Partial Frequency Spectrum
Image taken from: [Link]/wiki/File:United_States_Frequency_Allocations_Chart_2003_-_The_Radio_Spectrum.jpg
PHY layer
Message, Medium,
and Power & noise
• Message
– Source encoding, Channel encoding, Modulation, and
Protocol and packets
• Medium
– Shannon’s limit, Nyquist sampling, Path loss, Multi-channel, loss
models, Slow and fast fading.
• Signal power & noise power
– Receive and send power, Antennas, Expected noise floors.
• Putting it together
– Modulation (again), MIMO
PHY layer
So starting with the message
• We are trying to send data from one point to the
next over some channel.
– What should we do to get that message ready to go?
– The basic steps are
• Convert it to binary (if needed)
• Compress as much as we can
– to make the message as small as we can
• Add error correction
– To reduce errors
– But, unexpectedly, also to speed up communication over the
channel.
– The receiver will need to undo all that work.
PHY layer
Communicating a Message (1/3)
• Source
Source Channel
Modulator – The message we want to send.
Encoder Encoder
– We’ll assume it’s in binary
already.
Channel
• Source encoding
Source Channel De- – Compression; remove
Decoder Decoder modulator redundancies.
– Could be lossy (e.g. jpeg)
– Called source encoding
because depends on source
type (think jpeg vs mp3)
PHY layer
Communicating a Message (2/3)
• Channel encoder
Source Channel
Modulator – Add error correction.
Encoder Encoder
– Called channel encoder,
because error correction
Channel
choices depend on
channel.
Source
Decoder
Channel
Decoder
De-
modulator
• Modulator
– Convert to analog.
• Figure out how to move to
carrier frequency.
• Lots of options including:
– Frequency modulation
Note: some sources consider
modulation to be part of the channel – Amplitude modulation
encoder. – Phase modulation
PHY layer
Communicating a Message (3/3)
• Channel
Source Channel
Modulator – The medium over which
Encoder Encoder
our encoded message is
sent.
Channel
– For the type of wireless
communication we are
Source Channel De- doing, we are talking
Decoder Decoder modulator about using radio
frequencies (RF) to
• Then the receiver undoes connect two points not
all that (demodulation and connected by a
the two decoders) conductor.
– Often more work than – Lossy.
sending!
Source encoding
• Pretty much traditional • Goal here is to remove
CS techniques for redundancy to make
compression the message as small
– Very much dependent (in bits) as possible.
on nature of source – Can accept loss in
• We use different some cases (images,
techniques for different streaming audio, etc.)
things.
• Huffman encoding is
the basic solution
For more information: [Link]
[Link]
Channel encoding (1/3)
• Error correction and • Idea:
detection – Extra bits add
– We are adding bits redundancy.
back into the message – If a bit (or bits) go bad,
(after compression) to we can either repair
reduce errors that occur them or at least detect
in the channel. them.
– The number of bits – If detect an error, we
added and how we add can ask for a resend.
them depends on
characteristics of the
channel.
Channel encoding (2/3)
• Block codes • Specific coding schemes
– In this case we are working – Add one bit to each block
with fixed block sizes. (parity)
– We take a group of N bits, • Can detect any one bit
add X bits to the group. error.
– Some schemes promise – Take N bits, add ~log2(N)
correction of up to Y bits of bits (for large N)
error (including added bits) • Can correct any one bit
error.
– Others detect Z bits of
error. – Both of the above can be
done using Hamming
codes.
• Also Reed-Solomon codes
and others.
See [Link] for more details.
Figure from Wikipedia
Example block code:
Hamming(7,4)
• Hamming(7,4)-code.
– Take 4 data elements (d1 to d4) • Example:
– Add 3 parity bits (p1 to p3) – Say
• p1=P(d1, d2, d4) • d[1:4]=4’b0011
• p2=P(d1, d3, d4) – Then:
• p3=P(d2, d3, d4) • p1=P(0,0,1)=1
– If any one bit goes bad (p or d) • p2=P(0,1,1)=0
can figure out which one. • p3=P(0,1,1)=0
• Just check which parity bits are
wrong. That will tell you which bit
– If d2 goes bad (is 1)
went wrong. • Then received p1 and p3
• If more than one went wrong, are wrong.
scheme fails. • Only d3 covered by both
• Much more efficient on larger (and only both)
– So d3 is the one that
blocks. flipped.
– E.g. (136,128) code exists.
In-Class Example
• Hamming(7,4)-code. • If we get: 1000101
– Take 4 data elements (d1 to d4) – What was the data?
– Add 3 parity bits (p1 to p3)
• p1=P(d1, d2, d4)
• p2=P(d1, d3, d4)
• p3=P(d2, d3, d4)
• If we get: 1111111
– What was the data?
• If we get: 0100100
– What was the data?
Channel encoding (3/3)
• Turbo codes are a type of
• Convolution codes convolution code that can
– Work on a sliding window rather
than a fixed block. provide near-ideal error
– Often send one or even two parity correction
bits per data bit.
– That’s different than perfect,
• Can be good for finding just nearly as good as possible.
close solutions even if – Approaches Shannon’s limit,
wrong. which we’ll cover shortly.
– Viterbi codes are a very • Low-density parity-check
common type of (LDPC) codes are block codes
with similar properties.
See [Link] for more details.
Modulation
• We take an input signal
and move it to a carrier
frequency (fc) in a
number of way.
– We can vary the
amplitude of the signal
– We can vary the
frequency of the signal.
– We can vary the phase
of the signal.
Figure from [Link]
Terms: “keying”
• Keying is a family of
modulations where we
allow only a
predetermined set of
values.
– Here, frequency and phase
only have two values, so
those two examples are
“keying”
• Note phase and frequency
could be continuous rather
than discrete.
Example:
Amplitude-Shift
Keying (ASK)
• Changes amplitude of the transmitted signal based
on the data being sent
• Assigns specific amplitudes for 1's and 0's
• On-off Keying (OOK) is a simple form of ASK
Figure from [Link]
Example:
Frequency Shift
Keying (FSK)
• Changes frequency of the transmitted signal
based on the data being sent
• Assigns specific frequencies for 1's and 0's
Figure from [Link]
Example:
Phase Shift Keying
(PSK)
• Changes phase of the transmitted signal based on
the data being sent
• Send a 0 with 0 phase, 1 with 180 phase
• This case called Binary Phase Shift Keying (BPSK)
Figure from [Link]
And we can have modulation of a
continuous signal
Figure from [Link]
Back to Keying—M-ary
• It’s possible to do more
than binary keying.
– Could use “M-ary”
symbols
• Basically have an alphabet
of M symbols.
– For ASK this would
involve 4 levels of
amplitude.
• Though generally it uses 2
amplitudes, but has
“negative valued”
amplitudes.
Figure from [Link]
Key “constellations”
Draw the 4-ASK constellation.
New figures from [Link]
Some constellations
16-QAM 4-PSK
8-PSK (Quadrature amplitude) QPSK
4-QAM
(lots of names)
QPSK=quadriphase PSK. Really.
Figures from Wikipedia
QAM
• Can be thought of as
varying phase and
amplitude for each
symbol.
– Can also be thought of
as mixing two signals
90 degrees out of
phase.
16-QAM • I and Q.
(Quadrature amplitude)
Animation from Wikipedia
So, who cares?
Noise immunity
• Looking at signal-
to-noise ratio
needed to maintain
a low bit error rate.
– Notice BPSK and
QPSK are least
noise-sensitive.
– And as “M” goes
up, we get more
noise sensitive.
• Easier to confuse
[Link] symbols!
Modulation
• So we have a lot of modulation choices.
– Could view it all as FSK and everything else.
Wireless messages
• Sending a message
– We first compress the source (source encoding)
– Then add error correction (channel encoding)
– Then modulate the signal
• Each of these steps is fairly complex
– We spent more time on modulation, because our
prereq. classes don’t cover it.
Shannon’s limit
• First question about the medium:
– How fast can we hope to send data?
• Answered by Claude Shannon (given some
reasonable assumptions)
– Assuming we have only Gaussian noise,
provides a bound on the rate of information that
can be reliably moved over a channel.
• That includes error correction and whatever other
games you care to play.
Taken from a slide by Dr. Stark
Shannon–Hartley theorem
• We’ll use a different version of this called the
Shannon-Hartley theorem.
• C is the channel capacity in bits per second;
• B is the bandwidth of the channel in hertz
• S is the total received signal power measured in
Watts or Volts2
• N is the total noise, measured in Watts or Volts2
Adapted from Wikipedia.
Comments (1/2)
• This is a limit. It says that you can, in theory,
communicate that much data with an arbitrarily tight
bound on error.
– Not that you won’t get errors at that data rate. Rather
that it’s possible you can find an error correction scheme
that can fix things up.
• Such schemes may require really really long block sizes and so may
be computationally intractable.
• There are a number of proofs.
– IEEE reprinted the original paper in 1998
• [Link]
– More than we are going to do.
• Let’s just be sure we can A) understand it and B) use it.
Comments (2/2)
• What are the assumptions made in the proof?
– All noise is Gaussian in distribution.
• This not only makes the math easier, it means that because the
addition of Gaussians is a Gaussian, all noise sources can be
modeled as a single source.
• Also note, this includes our inability to distinguish different
voltages.
– Effectively quantization noise and also treated as a Gaussian (though
it ain’t)
• Can people actually do this?
– They can get really close.
• Turbo codes,
• Low density parity check codes.
Examples (1/2)
• If the SNR is 20 dB, and
the bandwidth available is
• C is the channel capacity 4 kHz what is the channel
in bits per second; capacity?
• B is the bandwidth of the – Part 1: convert dB to a
ratio (it’s power so it’s base
channel in Hertz 10)
• S is the total received – Part 2: Plug and chug.
signal power measured in
Watts or Volts2
• N is the total noise, db = 10 log P1/P0
measured in Watts or P1=10db/10 *P0
Volts2
Adapted from Wikipedia.
Examples (2/2)
• If you wish to transmit at
50,000 bits/s, and a
• C is the channel capacity bandwidth of 1 MHz is
in bits per second; available, what S/R ration
• B is the bandwidth of the can you accept?
channel in Hertz
• S is the total received
signal power measured in
Watts or Volts2
• N is the total noise,
measured in Watts or
Volts2
Adapted from Wikipedia.
Summary of Shannon’s limit
• Provides an upper-bound on information over
a channel
– Makes assumptions about the nature of the noise.
• To approach this bound, need to use channel
encoding and modulation.
– Some schemes (Turbo codes, Low density parity
check codes) can get very close.
Acknowledgments and sources
• A 9 hour talk by David Tse has been extremely useful and is a
basis for me actually understanding anything (though I’m by no
means through it all)
• A talk given by Mike Denko, Alex Motalleb, and Tony Qian
two years ago for this class proved useful and I took a number
of slides from their talk.
• An hour long talk with Prabal Dutta formed the basis for the
coverage of this talk.
• Some other sources:
– [Link]
-- A nice set of questions that get at some useful calculations.
– [Link]
[Link] all the path loss/propagation models in one place
– [Link]
[Link] very nice modulation overview.
• I’m grateful for the above sources. All mistakes are my own.
Additional sources/references
General
• [Link]
Modulation
• [Link]
• [Link]
• [Link]
• [Link] (ASK)
• [Link]
11/F/3213/CSE3213_07_ShiftKeying_F2010.pdf
Message, Medium,
and Power & noise
• Message
– Source encoding, Channel encoding, Modulation, and
Protocol and packets
• Medium
– Shannon’s limit, Nyquist sampling, Path loss, Multi-channel, loss
models, Slow and fast fading.
• Signal power & noise power
– Receive and send power, Antennas, Expected noise floors.
• Putting it together
– Modulation (again), MIMO