Can Bluetooth
Can Bluetooth
Electrical &Computer
ENGINEERING
© Copyright 2006-2015, Philip Koopman, All Rights Reserved
http://www.sailmagazine.com/
cup-watch/wings-next-
generation
Where Are We Now?
Where we’ve been:
• RTOS
• SW Quality
• Final projects
Preview
Controller Area Network (CAN)
• Important automotive network protocol
• Bit dominance
• Binary countdown
Bluetooth
• Wireless protocol
• Gaussian Frequency Shift Keying
• Frequency Hopping Spread Spectrum
4
Embedded Communications
So far this semester mostly just one microcontroller
[Leen02]
7
8
CAN History and Applications
Developed and published in 1980s by Robert Bosch GmbH
• Originally developed to deal with the complexities of automotive networks
• Today almost every automobile has at least one CAN network
2-wire bus
GND
Receiver subtracts two
voltages
INVERSE BUS DATA
• Eliminates common mode
voltage bias
• Leaves any noise that
affects lines differently GND
BUS DATA
UNCERTAIND VALUE
GND 11
H L L H
END SYNC ONE ONE ZERO ONE ZERO ZERO ZERO ONE END SYNC …
PREVIOUS SUBSEQUENT
MESSAGE MESSAGE
L H H L H L L L H H
12
Non-Return to Zero Encoding (Remember this?)
Example: Send a Zero as LO; send One as HI
• Worst case can have all zero or all one in a message – no edges in data
• Simplest solution is to limit data length to perhaps 8 bits … BUT
– CAN uses “bit stuffing” instead of fixed byte size
– Extra reverse polarity “stuff” bit is inserted after 5 values the same in a row
• Bandwidth is one edge per bit
13
Resistor
ON OFF OFF
[Siemens]
15
16
Example: Binary Countdown
Value seen
on bus
0 0 0 1 0 0 0 Node 8 message
Node 9
ID=0001001 0 0 0 1 0 0 1
Node 10
ID=0001010 0 0 0 1 0 1 9 drops out
Node 12
ID=0001100 0 0 0 1 1 10 drops out
Node 17
ID=0010001 0 0 1 12 drops out
Time
17 drops out (stops competing for the bus) 17
CAN Tradeoffs
Advantages
• Very low overhead (minimum size is only 44 bit message with 11 bit ID)
• High throughput under light loads
• Global prioritization possible, basically for free
• Arbitration is part of the message - low overhead
Disadvantages
• Requires bit dominance
– Restricts physical layer choices
• Unfair access - node with a high priority can "hog" the network
– Can be reduced in severity by using Message type instead of Node # for header
– Can, in principle, use a bus guardian to limit duty cycle of each node
– You have to pay attention to real time (e.g., Deadline Monotonic Scheduling)
• Poor latency for low priority nodes
– Starvation is possible
Typical performance:
100 bit messages @ 1 Mbit/sec 10,000 msgs/sec
20
Wireless Embedded Network:
Bluetooth
Bluetooth
Open wireless protocol standard
• Published by Bluetooth Special
Interest Group (SIG)
• http://www.bluetooth.org
[Wikipedia]
22
Bluetooth - History and Applications
Harald Blåtand (Bluetooth in English)
• Viking and king of Denmark between 940 and 981
• One of his skills was to make people talk to each other
• During his rule Denmark and Norway were united
… what they don’t tell you is that his murder was arranged by his son, who
coveted the throne
23
Ad-hoc network
• Any nodes that come within range can form small network called a “piconet”
– Nodes can dynamically join and leave the ad-hoc network
– Nodes can belong to multiple piconets
• 1 master node and up to 7 slave nodes in a piconet
• Elects a new master if master leaves network
Scatternets
• If a node is part of two different piconets, can share information across them
24
Bluetooth - Physical Layer
Bluetooth uses RF as a wireless medium
• Uses the unlicensed 2.4 GHz Industrial-Scientific-Medical (ISM) radio
frequency band bit 0 bit 1 bit 2 bit 3 bit 4
• Why is ISM at 2.4 GHz?
Bits are sent using frequency
modulation (FM)
Carrier
26
Bluetooth - Master Slave
Master broadcasts every other message
• Sends data and declares who goes next; master relays data to other nodes
Time Division Duplex
• Time divided into slots
• All slave nodes synchronize to master node’s clock (start of message)
• Use a different frequency each time slot
“Node 1: Go” “Node 2: Go” “Here is some data for node 3; [Bluetooth Core Spec 3.0]
Node 3: Go”
f Piconet 1 Piconet 1
4
f Piconet 1 Collision
3
Baby Monitor Piconet 1
f
2
Frequencies
f
1
f Piconet 1
0
Time
28
Bluetooth - General Message Format
Access Code
• Want to keep messages from two piconets separate if they happen to use same
frequency pattern
• Master node defines an access code for its piconet
• Any message must first have a valid access code
• Includes some serious error detection/error correction
Header
• Contains destination or source address, packet type, flow control, and error
checking code
Payload
• Application data, often voice or other media
• Includes 16-bit CRC to catch corrupted data 29
Bluetooth Tradeoffs
Advantages
• No wires!
• Ad-hoc networking
– Nodes can join and leave whenever they want
– Overlapping/interacting/hierarchical networks (scatternets)
Disadvantages
• No way to distribute power (everything has to have a battery or power plug)
• Geometry may introduce standing waves/fading
• Interference from other RF emitters (EMI = ElectroMagnetic Interference)
• Limited spectrum space
• In general, unsuitable for use in critical applications that aren’t fail-safe!
Also, cost
• Bluetooth cheap, but still working on being super- “cheap”
• Has to be able to beat a piece of copper and a plastic connector
30
CAN/Bluetooth Comparison
Both:
• Relatively efficient for relatively short messages
• Optimized for single-hop network to connect physically close devices
• Give predictable and bounded worst-case message delays
CAN:
• Wired network for critical control applications
• Assumes fixed network configuration known at design time
• Prioritized message sequence supports rate monotonic scheduling
• Optimized for extremely short data payloads (e.g., 1-byte payloads)
Bluetooth:
• Wireless network for consumer electronics data exchange
• Higher overhead, but longer maximum message size for bulk data transfer
• Round-robin message sequencing for fairness
31
Infrared – IrDA
• Infrared Data Association
– http://en.wikipedia.org/wiki/Infrared_Data_Association
• TV remotes … but also data transfers up to 1 Gbit/Sec with GigaIR
• Good for indoors within same room; no RF interference from WiFi
– Wii uses Bluetooth for data communications, IR for pointing
32
Review
Controller Area Network (CAN)
• Bit dominance and binary countdown
Bluetooth
• Wireless protocol
• Frequency hopping to minimize effects of collisions
33