% !TEX root = master.tex
\subsection{Serial Communication Technologies}
% Chris

Wired communications characterize any technology or protocol used to establish communication between components within the hardware design of the product, such as data transfer between a microcontroller and LEDs. Serial communications involve transmitting a single bits of data through a channel sequentially, as opposed to parallel communications, which involve sending multiple bits of data over a number of channels simultaneously. 

Several standardized serial communication methods exist that define methods for sending and receiving data synchronously or asynchronously, bit-by-bit. Synchronous serial communication methods such as I$^\textbf{2}$C and SPI could be useful for interfacing the microcontroller with other hardware subsystems such the Bluetooth module or the LED matrix, whereas asynchronous methods such as UART are useful for transmitting and receiving data between the smart table and external devices. It would be ideal to incorporate hardware with native functionality for these communication methods, but bit-banging, a method to support a communication protocol within the software, is another option that could provide flexibility and a greater hardware selection.

Due to the nature of the smart table, which requires hundreds of LEDs to have a good resolution, using a well-established serial communication protocol is absolutely critical. Many microcontrollers do not have a large number of pins, so a functioning the smart table would be impossible with a serial communication protocol due to the sheer number of wires that would be required for an LED matrix. The smart table needs a way to communicate with and drive the RGB LEDs rapidly, which is heavily dependent on the protocol used and the hardware capabilities of the selected microcontroller. The importance of these communication protocols to a project incorporating such a large number of connections becomes more apparent when discussing buses, which effectively allow for fewer pins to be utilized on the microcontroller.

\subsubsection{I$^\textbf{2}$C}
% Chris

I$^\textbf{2}$C, also called Inter-Integrated Circuit, is a serial communication protocol originally designed in 1982 by Philips Semiconductor, now known as NXP Semiconductors. I$^\textbf{2}$C has undergone a number of substantial revisions since its inception, beginning with Version 1 and arriving at the current Version 6. These versions have been mainly concerned with increasing the speed of signal transmission through the offering of high-frequency modes for the data and clock signals. As of 2006, the protocol is available for use by the general public, royalty-free and without the need for a license, although NXP charges customers to obtain slave addresses. I$^\textbf{2}$C remains a popular protocol and is supported by a large number of devices. It is usually used at low speeds and for communication between integrated circuits.

I$^\textbf{2}$C uses a serial bus to facilitate communication between devices, allowing multiple masters to communicate with multiple slaves. The protocol is primarily intended for use over short distances, such as communication within the same printed circuit board. Conventional I$^\textbf{2}$C has both a 10 Kbps slow mode, a 100 Kpbs standard mode, a 400 Kbps fast mode, and a 3.4 Mbps high speed mode. An I$^\textbf{2}$C bus utilizes 7-bit addresses and is comprised of two signals, known as the two-wire interface (TWI):

\begin{itemize}
	\item Serial data (SDA): The data signal. This is the transmission line through which data is bidirectionally transmitted between masters and slaves.
	\item Serial clock (SCL): The clock signal. The clock signal is created by the master of the bus, however, slaves may command the clock to a lower frequency for extra processing time or when the master is sending too much data.
\end{itemize}

The serial data and serial clock lines use pull-up resistors, with 4.7 $k\Omega$ resistors being common starting values. The protocol identifies connected devices and classifies them into either master or slave roles. Each role defines the behavior of the device and what it is permitted to do at a certain time. The masters and slaves are distinguished as nodes: 

\begin{itemize}
	\item Master node: The node that sets the clock signal and begins transmitting data to the slaves.
	\item Slave node: The node that acknowledges the clock and receives data transmitted from the master.
\end{itemize}

The two-wire bus supports multiple master nodes and can accommodate a staggering 1008 slave nodes. The masters and slaves may even swap roles between signal transmissions. However, the multi-master bus does not permit masters to communicate with other masters simultaneously. There are four modes of transmission that characterize the master-slave nodal behavior:

\begin{itemize}
	\item Master transmission: The master node transmits data to a slave device.
	\item Slave transmission: The slave node transmits data to a master device.
	\item Master reception: The master node receives data from a slave device.
	\item Slave reception: The slave node receives data from a master device.
\end{itemize}

I$^\textbf{2}$C signal transmission is governed by a specific bit manipulation scheme. Messages, denoted in all capital letters, are encoded in the signal such as START, STOP, and ACK (acknowledge). Data is sent in one-byte segments. When the master begins transmitting, it uses a START bit along with the desired slave's 7-bit ADDRESS. The last bit determines if data is being read or written. When a slave receives this message, it transmits an ACK bit, and the master continues to operate in either the transmission or reception mode depending if the starting message encoded the last bit with a (0) for write, or (1) for read. The slave then continues in the appropriate mode; if the master is transmitting, the slave must be receiving, and if the master is receiving, the slave must be transmitting. When either the master or the slave is receiving data, they send an ACK bit after each byte that is received. When the signal transmission is completed, the master send a stops bit to end the transmission or begins a new transmission with another START bit. 

As seen in \ref{fig:i2c}, the microcontroller master node is connected to the SDL and the SDA along with three slave nodes: a microcontroller, a digital-to-analog converter, and an analog-to-digital converter. Pull-up resistors are used to connect the two bus lines to the power supply. It is common for peripheral devices such as these to all be included within the same microcontroller, but none-the-less they serve as good examples. What distinguishes I$^\textbf{2}$C from SPI or UART is that the SDA and SCA bus lines are open-drain. The implication of this is that they can only assert a signal low, rather than high. For this reason, I$^\textbf{2}$C is considered to be active-low.

\begin{figure}[h]
	\centering
	\includegraphics[width=0.7\linewidth]{img/i2c}
	\caption[I$^\textbf{2}$C Bus]{I$^\textbf{2}$C Bus. \textit{The use of this image is governed by the GFDL}. \cite {I2C}}
	\label{fig:i2c}
\end{figure}

The yellow regions in Figure \ref{fig:i2c-transfer} shows that by default, the signal wires are set high using the pull-up resistor. This hardware configuration allows all devices to safely read or write to the SDA and SCL lines at appropriate times. Master devices will wait until a STOP bit has been asserted before trying to write over the bus lines, and slave devices will read the bus lines to check whether the address following the START bit matches. Non-matching slaves will wait until a STOP bit is detected before reading again. Because of the active-low/open-drain format, masters can also utilize a feature known as clock stretching in the event that slaves are unable to keep up with the speed of the master. The advantage to this unique implementation is that the lines are highly resistant to signal conflicts, such as simultaneous high and low assertions from different devices, which could result in corruption of the signal or damaged hardware.

\begin{figure}[h]
	\centering
	\includegraphics[width=1.0\linewidth]{img/i2c-transfer}
	\caption[I$^\textbf{2}$C Timing Diagram]{I$^\textbf{2}$C Timing Diagram. \textit{This image has been released to the Public Domain}. \cite {I2CData}}
	\label{fig:i2c-transfer}
\end{figure}

In the case of the smart table, I$^\textbf{2}$C could be used as the interface which would allow the main microcontroller to serve as the master. Since 3.3 volts and 5 volts are common voltages used for the protocol, I$^\textbf{2}$C wood be an excellent choice for the smart table's microcontroller and wireless communication module. As the master, the microcontroller would control the exceptionally large LED  matrix, and the large number of LEDs in the matrix would be divided into slave groups. This method would allow the use of only a few input pins on the microcontroller, which would be highly manageable. Each slave could have an individual slave address and be assigned assigned to a specific software function, such as displaying time, date, or weather. 

\subsubsection{SPI}
% Chris
The Serial Peripheral Interface Bus, better known as SPI, is a method of serial communication created by Motorola. It is specified for use over small distances and has been considered a standard embedded system communication method for some time due to its simplicity and versatility. SPI is synchronous, which means that the clock signal is used to synchronize data and transmission. Common modern technologies that utilize SPI are LCD screens and SD cards. SPI is extremely simple at its core. Devices that utilize SPI transmit and receive data at the same time, also referred to as full-duplex mode. Like I2C, SPI utilizes the master and slave method. 

SPI buses contain four important wires:

\begin{itemize}
	\item Slave Select: The Slave Select (SS) is the signal that the master uses to choose the slave in which to engage in communication
	\item Serial Clock: The Serial Clock (SCLK) is a clock signal that synchronizes all SPI signals, generated by the master.
	\item Master In Slave Out: The Master In Slave Out (MISO) is a unidirectional data signal that goes from the slave output pin to the master input pin.
	\item Master Out Slave In: The Master Out Slave In (MOSI) is a unidirectional data signal that goes from the master output pin to the slave input pin.
\end{itemize}

The SPI protocol is also called a four-wire interface (FWI), which is a higher number than most other serial communication protocols, namely I$^\textbf{2}$C. The SPI protocol uses a single master but supports multiple slaves. At the start of transmission, the master will generate an SCLK signal at a mutual frequency. This frequency will typically be compatible with the selected slave device. In order to communicate with the slave, the master will then pulls the respective slave select line low and then wait if necessary. Then, the data is transmitting in full duplex mode, with the the master sending data over the MOSI line and the slave sending data over the MISO line. If multiple slaves devices are present, each slave requires its own SS line in order to be addressed by the master.

Figure displays the circular transmission of data between SPI shift registers of the master and slave. During signal transmission, 8-bits of data from a shift registers in the master is swapped with data from a shift register in the slave. The most significant bit from either the master of slave is replaced with the least significant bit from its counterpart. This process is continued for as many clock cycles as it takes until until the shift registers have completely swapped values. After that, the shift registers are reset to prepare for another transmission. When transmission is complete, the slave is released from the SS line.

The signal transmission is all done with respect to the SCLK. With these options, there are four potential modes that communication can occur for most microcontrollers:

\begin{itemize}
	\item Mode 0: CPOL $= 0$, CPHA $= 0$. The SCLK is active high and data is captured on the rising edge.
	\item Mode 1: CPOL $= 1$, CPHA $= 0$. The SCLK is active high and data is captured on the falling edge.
	\item Mode 2: CPOL $= 0$, CPHA $= 1$. The SCLK is active low and data is captured on the rising edge.
	\item Mode 3: CPOL $= 1$, CPHA $= 1$. The SCLK is active low and data is captured on the falling edge.
\end{itemize}

\begin{figure}[H]
	\centering
	\includegraphics[width=0.8\linewidth]{img/spi-timing}
	\caption[SPI Timing Diagram]{SPI Timing Diagram. \textit{The use of this image is governed by the GFDL}. \cite {SPITiming}}
	\label{fig:spi-time}
\end{figure}

Figure \ref{fig:spi-time} shows an accurate timing diagram of SPI signal transmission. The timing of the SCLK signal are characterized by two options: the clock phase (CPHA) and the clock polarity (CPOL). The clock polarity is responsible for the clock signal inversion or noninversion--(0) for active high or (1) for active low, whereas the clock phase is responsible for shifting the sampling edge clock signal--(0) for the rising edge or (1) for the falling edge. 

As previously mentioned, the SPI protocol can be used with a single slave or with muliple slaves. When used with multiples slaves, there are two approaches:

\begin{itemize}
	\item  Independent Slave Select: Each slave has is own select line leading from the master.
	\item  Daisy-Chained Slave Select: There is a single slave select line that branches to each slave.
\end{itemize}

As seen in Figure \ref{fig:spi}, the independent slave select method involves each slave to have its own select line leading from the master. This is the most common method employed for SPI communication. In order to accomplish this, the active slave select must be pulled low while the others are kept high, with a pull-up resistor utilized between the select line and power supply to prevent cross-talk. One MOSI line from the master is branched to each slave. The MISO lines of the slaves are also tied together, however, the active low configuration prevents the other slaves from trying to communicate with the master at the same time. A disadvantage of this method is that it can utilize too many pins on the microcontroller for the select lines.

\begin{figure}[H]
	\centering
	\includegraphics[width=0.7\linewidth]{img/spi}
	\caption[SPI Bus with Individual Slaves]{SPI Bus with Individual Slaves. \textit{The use of this image is governed by the GFDL}. \cite {SPI}}
	\label{fig:spi}
\end{figure}

Figure \ref{fig:spi-daisy} displays the daisy-chain configuration, which involves each slave sharing a single select line that branch off from the master. In this method, each slave is connected together. The MOSI line from the master is connected to the MOSI line of the first slave. The MISO line from that slave is directly connected to the MOSI line of the next slave, until the MISO of the last slave is connect to the MISO of the master. This configuration essentially acts as a circular buffer, with the same data transferred from the shift register of one device to the next on each clock cycle. The advantage to this method is that fewer pins can be utilized due to the use of a single slave select, as well as support for interfaces such as JTAG.

\begin{figure}[H]
	\centering
	\includegraphics[width=0.7\linewidth]{img/spi-daisy}
	\caption[SPI Bus with Daisy-Chained Slaves]{SPI Bus with Daisy-Chained Slaves. \textit{The use of this image is governed by the GFDL}. \cite {SPIDaisy}}
	\label{fig:spi-daisy}
\end{figure}

Overall, SPI is much simpler and faster than I2C due to its full duplex design and can support speeds in excess of 10 Mbps, it requires more signal wires than most protocols and can utilize a large number of slave select lines if used in the standard configuration. There are limitations such as the fact the slaves cannot explicitly communicate to each other, and that only a single master is supported using the protocol. There is no form of slave acknowledgement or error checking functionality. As a result, I2C is generally considered to be the smarter and more robust protocol between the two.

\subsubsection{UART}
% Chris

A UART, short for universal asynchronous receiver/transmitter, is a hardware device that effectively enables serial communication. It is an interface used and supported by many microcontrollers as an interface between parallel and serial connections. At its core, one side of the UART has a parallel bus with multiple data lines, and the other has two simples serial lines: the receiver (RX) and the transmitter (TX). It is implemented by various well-known communication standards such as RS-232.

The UART is responsible for:
\begin{itemize}
	\item Converting the data from the microcontroller received through the parallel bus into serial data sent through the TX serial line.
	\item Converting data received through the RX serial line into data sent over the parallel bus lines understood by the microcontroller.
	\item Checks the parity of transmission by inserting a parity on output signals and removing the parity bit on input signals
	\item Handles interrupts from peripheral devices.
\end{itemize}

\begin{figure}[h]
	\centering
	\includegraphics[width=0.5\linewidth]{img/uart}
	\caption[UART Interface]{UART Interface. \textit{The use of this image is governed by the CC BY-SA 4.0}. \cite {UART}}
	\label{fig:uart}
\end{figure}

As seen in Figure \ref{fig:uart}, serial and parallel data is converted through the use of shift registers within the UART. Since UART supports simplex, half-duplex, and full-duplex operation, this  determines the number of shift registers. For full-duplex operation, two shift registers are required for both transmitted and received data. Bytes of data from the microcontroller are passed through the shift register and transmitted through the serial lines by-by-bit and vice versa. Data manipulated by some UART interfaces may be stored in buffer on a first-in-first-out (FIFO) manner. Data may be added to the buffer by the microcontroller and transmitted in a single burst, or stored in the buffer by the serial RX until the microcontroller can obtain the data.

UART reception is achieved using a clock signal that is a multiple of the baud rate (bits per second), usually 8. When receiving a signal, the RX line looks for the starting bit by checking if the bit is received in half or more of the clock signal time multiple. If the signal is accepted, it is sampled, passed through the shift register, and received by the microcontroller. The UART sets a flag that the data has been received and initiates an interrupt so that the data can be utilized by the microcontroller The clock of the UART is data dependent and synchronized with every new signal reception. 

\begin{figure}[h]
	\centering
	\includegraphics[width=1.0\linewidth]{img/uart-timing}
	\caption[UART Timing Diagram]{UART Timing Diagram. \textit{The use of this image is governed by the CC BY-SA 4.0}. \cite {UARTTiming}}
	\label{fig:uart-time}
\end{figure}

Figure \ref{fig:uart-time} shows how bits are handled through the UART interface. When the microcontroller begins sending data through the shift register, a start  bit, parity bit, and stop bit are created by the UART and the data is sent through the serial TX line. Similarly, the UART sets a flag that signals to the microcontroller that it is busy, indicating that the shift register or buffer contains data.

\subsection{Wireless Communication Technologies}
% Chris

Wireless communications characterize any technology used to establish external communication with the product, such as accessing the product from a smartphone  or computer interface over a local or personal area network. The smart table requires some mechanism for it to communicate externally and wirelessly. 

Wireless communication would allow the smart table to integrate with other commonly used devices and have a minimalistic appearance, without depending on long and unwieldy ethernet cables, which could cause individuals to trip and fall. Wireless communication could also eliminate the need for hardware control mechanisms such as touchscreens, since the device's interface could be provided over the network in the form of a graphical user interface (GUI) to interact with it. The smart table is intended to operate within a typical indoor environment, such as a living room or bedroom, which may contain moderate levels of electromagnetic interference (EMI) presented by other common consumer products such as cellular phones, microwave ovens, laptops, routers, radios, and more. As such, a robust communication protocol that handles noise must be selected.

A number of different solutions exist to provide wireless functionality to the smart table in a compact manner. Radio-frequency (RF) circuit design is widely considered to be difficult, especially for novices, due  to their sensitivity to noise and the tight specifications required to operate on a specific frequency band. The manufacture of RF circuitry can be time intensive, since small defects can negatively impact performance and cause a device to perform outside of its established frequency specifications. A considerable amount of testing is required for RF devices to ensure that they are safe, since leaky RF devices can pose a threat to individuals with medical devices by interfering with their proper operation. The legal restrictions on radiation are established by the Federal Communications Commission (FCC) and may carry with them heavy fines or imprisonment. 

As a result of these difficulties, embedded RF modules exist on the market that have been designed so that they can be easily used within any product that needs wireless communication. There are RF modules that incorporate a number of different wavelengths and frequencies on the electromagnetic spectrum, some of which will be discussed. These devices typically contain all of the necessary hardware in compliance with protocols relevant to the respective underlying technology. They may have internal or external antennas that have been optimized to minimize signal attenuation as much as possible.

The use of a module to incorporate RF communication is suitable for the smart table because it can save a significant amount on the development time, since it would also have a greater success rate. As previously mentioned, there is a low chance that an amateur-designed radio circuit will work due to the advanced nature of RF design. Antenna design in an of itself is a graduate undertaking and would require more time and resources to accomplish. In addition, such a module would be cheaper to implement wireless connectivity for the smart table than a custom solution. A compact embedded module with an integrated antenna would ideally have a wide compatibility with a broad number of devices, such as laptops, cellphones, and computers. The smart table could be conveniently operated with one of these devices in a conspicuous manner without wires. Three wireless communication technologies that immediately come to mind for the purposes of the smart table are infrared, Bluetooth, and Wi-Fi. The advantages and disadvantages of these different types of communication will be discussed in further detail.

\subsubsection{Infrared}
% Chris

Consumer Infrared (IR) refers to a number of different standards that utilize light within the nonvisible infrared  spectrum to facilitate wireless communication. It is a proposed communication mechanism due to the affordable nature of IR transmitters and receivers. Devices that typically employ IR include television as well as remote controls that operate a wide range of devices.  Although there are a number of different implementations, IR transmitters typically operate by sending modulated IR signals encoded with a command to an IR receiver via an IR LED. The IR receiver uses an IR photosensor to detect the signal which is then demodulated and interpreted, which differs by device. The Infrared Data Association (IrDA) is an organization that manages the protocols and standards for products that utilize IR.

Consumer IR has some limitations that may not be well suited to the smart table. Due to the nature of IR light, is unable to penetrate most opaque physical substrates such as walls. As a consequence, the transmitter requires a direct line-of-sight (LOS) to the receiver. This limitation may be a cause for concern in a commercial space or dwelling that may contain many obstacles that would impede transmission, such as individuals or furniture. The smart table would require an omnidirectional IR receiver that would need to be placed in an unobtrusive manner, so that it could be operated without impediment. 

Some modern smartphones conveniently contain IR blasters, which can emulate infrared remote controls. This would facilitate the creation of a mobile application to control the smart table using the smartphone's IR blaster. However, most smartphones do not possess IR blasters, so the smart table would require an external remote control device to serve as the IR transmitter to maintain its accessibility. External hardware such as a remote control is nonideal because it could become lost or separated from the smart table, or break, rendering the smart table uncontrollable. In addition, it would increase the development time of the project due to the separate remote control PCB design and manufacture.

\subsubsection{Wi-Fi}
% Chris

Wi-Fi is a brand developed by the nonprofit organization known as the Wi-Fi Alliance, which encompasses the technology that lets devices connect to a Wireless Local Area Network (WLAN) to communicate with each other. It has emerged as a dominant wireless communication standard present in many electronic devices on the market, and due to its ubiquity, it is widely supported. Wi-Fi devices are certified by the Wi-Fi Alliance for compatibility and usage with other Wi-Fi devices.   Products with Wi-Fi are based on the IEEE 802.11 standard, a series of protocols that describes the characteristics of the physical layer and media access control sublayer of a wireless network. Together, the physical and media access control layers form the backbone of the 802.11 protocol.

\begin{figure}[h]
	\centering
	\includegraphics[width=0.6\linewidth]{img/osi}
	\caption[OSI Model]{OSI Model. The use of this image is governed by the GFDL. \cite {OSI}}
	\label{fig:osi}
\end{figure}

The media access control (MAC) sublayer of the 802.11 is contained within the second lowest layer of the Open Systems Interconnection (OSI) model, a top-level representation of a telecommunication system composed of seven different abstraction layers. The MAC sublayer adds methods to address devices and access channels, which allows multiple devices to connect to a shared network. It has support for both full and half-duplex communication and also provides several additional functions such as error checking.  Due to the MAC sublayer, devices connected to a network are assigned unique MAC addresses which allow them to reliably send and receive data packets. A good analogy is the way that homes with addresses may send and receive mail to other homes. The MAC sublayer essentially connects the physical layer with the the logical link control (LLC) sublayer, which is another layer that allows high-level logical frameworks such as the Internet Protocol (IP) to interoperate with each other over networks.

The physical layer (PHY) of the OSI model is the lowest layer, which is comprised of the  hardware involved in the direct manipulation of the bitstream. The physical layer provides functionality to modulate transmission signals via the Physical Coding Sublayer (PCS). It also provides functionality to connect the MAC layer to the physical transmission medium, such as an antenna or cable, via the Physical Media Dependent (PMD) sublayer.

The 802.11 protocol has undergone many lettered revisions and permits wireless communication over The industrial, scientific, and medical (ISM) frequency bands, which are exempt from FCC licensing. The two main frequency bands that 802.11 family devices chiefly operate on are the 2.4 GHz and 5 GHz ISM bands. The 2.4 GHz band is less heavily regulated, and  devices within this frequency spectrum are sometimes prone to inference from other devices using the frequency, such as microwave ovens. The 802.11 family uses a number of half-duplex modulation techniques, and 802.11 compliant devices can serve as either hubs or terminals to transmit and receive data on a network. 

Wireless routers are 802.11 compliant devices that can serve as a wireless access points (WAP) for other devices to connect over the 2.4 GHz or 5 GHz frequency bands separately or simultaneously. Networked devices (commonly called nodes) that connect to wireless routers utilize transceivers known as wireless network interface controllers (WNIC) to send and receive data through the network in either of two configurations:  infrastructure or ad-hoc. The infrastructure configuration allows nodes to connect to the access point, whereas the ad-hoc configuration allows multiple nodes to connect to each other without a WAP. 

Although Wi-Fi is a very mature platform that has existed in some form since 1997, it may not be explicitly necessary for the smart table. The smart table would be dependent the wireless network, which may not be accessible in all households. The use of a wireless network also introduces the problem of network security. A number of different wireless encryption methods exist for networks, such as Wired Equivalent Privacy (WEP) and Wi-Fi Protected Access 1/2 (WPA1/WPA2). Most consumer wireless networks today utilize either the WEP or non-enterprise WPA2 standards, which allow devices on the same network to view and access each other.

Due to security vulnerabilities in certain Wi-Fi networks, an adversary could gain access to a network and take advantage of devices on them. Networks with weak passwords could be easily accessed by an outsider to gain access to the smart table and exploit it. The malware Mirai is just one recent example of a virus that has been designed to infect consumer Wi-Fi routers with weak passphrases. Once compromised, the malware takes control of IoT devices on the network, such as DVRs, televisions, or even the smart table and uses them in a large-scale botnet. The devices are commanded to flood packets to a target network, called a distributed denial-of-service (DDoS) attack, which effectively takes them offline for the duration of the attack.

Another downside of utilizing Wi-Fi is that wireless networks today are already saturated by a myriad of other Wi-Fi capable devices. Because bandwidth on a wireless network is finite, additional devices could negatively impact the quality of service on the network. Network performance measures, such as the upload and download speeds, are sensitive to the number of devices simultaneously using the network. In an age of increasing internet usage for multimedia downloading and streaming, it would be ideal to avoid this situation entirely by utilizing another equally capable wireless communication technology.  

\subsubsection{Bluetooth}
% Chris

Bluetooth is another branded technology that allows devices to wirelessly communicate across short distances using ultra high frequency (UHF) radio waves in the 2.4 GHz ISM frequency band. Bluetooth was formerly standardized as the IEEE 802.15.1, but has since been maintained by the Bluetooth Special Interest Group (SIG). This standard facilitates the creation of low-powered and portable wireless personal area networks (PAN), which let devices communicate with each other in an ad-hoc manner (although uplinked communication of devices in an infrastructural manner is possible). 

Bluetooth is distinguished from Wi-Fi such that it operates on much lower distances and is not focused on providing communication to devices through an access point. Instead, Bluetooth emphasizing direct communication between devices through a master-and-slave communication scheme and portability as a wire-replacement technology.

%\begin{wrapfigure}{R}{0.7\textwidth}
%	\centering
%	\includegraphics[width=0.7\textwidth]{img/topology.png}
%	\caption{Bluetooth network topology. \cite {Topology}}
%	\label{fig:topology}
%\end{wrapfigure} 

\begin{figure}[h]
	\centering
	\includegraphics[width=0.9\linewidth]{img/topology}
	\caption[Bluetooth Network Topology]{Bluetooth network topology.The use of this image is governed by the GFDL. \cite {Topology}}
	\label{fig:topology}
\end{figure}

Connected Bluetooth devices may swap roles; for example, a car may initiate a connection to a phone as a master, but may then become a slave while operating. Masters can communicate with slaves, however, slaves can not communicate with each other. A Bluetooth network is called a piconet, whereas a scatternet is a higher level topology that consists of multiple piconets. Devices in the scatternet may operate as a master in one piconet, while simultaneously operating as a slave in another piconet. The clocks of the slave devices are synchronized with the clock of the master device. In even time slots, data packets are transmitted by the master and received by the slave, whereas in odd time slots, the reciprocal is true. Bluetooth connections boast a theoretical  distance of 100 meters, depending on the Bluetooth version.

Classic Bluetooth utilizes a modulation technique called Frequency Hopping Spread Spectrum  (FHSS)  to transmit signals. FHSS is accomplished by rapidly "hopping" a  signal between channels. The signal is split into several packets, which are hopped 800 times per second over  79 different 1 MHz channels, which may be adaptively selected by avoiding the channels at heavily trafficked frequencies. In Classic Bluetooth, a master may communicate with up to seven slaves, the maximum of which may differ between devices. Classic Bluetooth has a maximum throughput ranging from 0.7 to 2.1 Mbps.

Bluetooth Low Energy (BLE), also known as Bluetooth Smart, is a newer variation of Bluetooth that uses a smaller number of channels (40) with larger spacing between channels (2 MHz) in its modulation scheme. It does not define a maximum number of slave devices that a master may have. BLE devices typically do not engage in continuous transmission and have a maximum throughput of only 0.27 Mbps. Both of these features lend themselves to the low energy functionality of this Bluetooth variation. The need for BLE is evident based on the growing number of portable devices on the market, which prioritize low energy consumption and long battery life. As such, BLE may not be explicitly necessary in non-battery operated devices, such as those connected to mains electricity.

\begin{table}[h]
\centering
\caption[Wirless Technology Comparison]{Wireless Technology Comparison. \cite{Wireless}}
\label{tab:wireless}
\begin{tabularx}{\textwidth}{|X|X|X|X|}
	\hline
	\textbf{Specification} & \textbf{Serial Infrared (SIR)} & \textbf{Bluetooth 2.1} & \textbf{802.11n (Wi-Fi)}\\ 
	\hline\hline 
	Frequency & 850 - 900 nm (wavelength) & 2.4 GHz ISM Band & 2.4 GHz/5 GHz ISM Bands \\ 
	\hline 
	Maximum Range & 1 m & 100 m & 70 m \\ 
	\hline 
	Maximum Data Rate & 115 Kbps  & 3 Mbps  & 54-600 Mbps \\ 
	\hline 
	Power Consumption & 20-50 mA & 5-15 mA & 50-110 mA \\
	\hline
	Nodes Supported & 1 & 7 & 32 \\ 
	\hline 
\end{tabularx} 
\end{table}

Bluetooth is considered to be the ideal wireless technology to implement in the smart table. In comparison to infrared and Wi-Fi, Bluetooth has excellent range and suitable data rate characteristics as shown in Table \ref{tab:wireless}. There are several different Bluetooth versions in existence, each presented as a revision of the previous version with added features or modified performance specifications. Legacy Bluetooth versions, such as version 2.1, are still commonly used in electronic designs for reasons such as cost, features, and performance. A number of different chips readily available for use in the smart table were examined for suitability based on such factors. 

\subsection{Bluetooth Module Considerations}
% Chris
There are a number of off the shelf Bluetooth modules on the market that can be quickly and easily integrated into the smart table to add wireless communication functionality. Here, we will discuss a couple of popular modules and select one that is most suited to the project.

\subsubsection{RN-42 Bluetooth Module}
% Chris
The RN-42 is a Bluetooth module originally designed and manufactured by Roving Networks, although it has since been acquired by Microchip Technology, Inc. This chip is extremely compact and is suitable for anyone who wants to add wireless communication to their projects. A flexible chip, the RN-42 is compatible with the widely utilized UART and SPI protocols. It has an antenna trace integrated into the PCB, which is suitable for individuals who lack the time and extensive knowledge to design functional antennas. 

The RN-42 is fully certified by the FCC and is a mature and qualified Bluetooth product. It is capable of delivering data at sustained speeds of 1.5 Mbps and burst speeds of up to 3 Mbps in host controller interface modes over a distance of 10 meters.  The chip typically retails for approximately 18 dollars USD. Table \ref{tab:rnspec} shows a list of the module's specifications, availble for comparison with the HC-05 module's specification as seen in Table \ref{tab:hcspec}. 

\begin{table}[h]
	\centering
	\caption[RN-42 Basic Specifications]{RN-42 Basic Specifications \cite{HardwareConsiderations:RN42}}
	\label{tab:rnspec}
	\begin{tabular}{|c|c|}
		\hline 
		\textbf{Specification} & \textbf{Value} \\ 
		\hline\hline
		Class	&  2 \\
		\hline
		Version	& 2.1 + EDR \\ 
		\hline
		Frequency  & 2.4 GHz\\ 
		\hline
		Sensitivity & -80 dBm\\
		\hline
		Supply Voltage	& 3.3 V \\ 
		\hline
		SPP Data Rate & 240 Kbps (slave), 300 kbps (master)\\ 
		\hline
		HCI Data Rate & 1.5 (sustained), 3 Mbps (burst)\\
		\hline
		Transmit Current Draw & 30 mA \\
		\hline
		Power Output & 4 dBm \\
		\hline 
		Interfaces Supported & UART, SPI \\
		\hline 
		Modulation Type & GFSK, FHSS \\
		\hline 
	\end{tabular}
\end{table}

As seen in Table \ref{tab:rnspec}, is important to highlight that this chip utilizes Bluetooth 2.1, which is a significant advantage. This version includes the SPP protocol, otherwise known as the Simple Pairing Protocol. This protocol greatly speeds up and simplifies device pairing by reducing the overall number of step required for devices to become connected. It also adds security through the use of pin codes and the ability for devices to inquire information about each other and filter connections before initialization. It also greatly reduces the power consumption required during the discovery and pairing procedures. The SSP is a highly important feature, which is why Bluetooth 2.1 or higher is desired for the project.

Other features of the RN-42 include: 

\begin{itemize}
	\item An integrated Bluetooth stack that does not require a host processor.
	\item 128-bit encryption for secure connections.
	\item Low power modes accessible to the programmer.
	\item Automatic device pairing and discovery for instant access to Bluetooth-ready devices such as Android phones and iPhones.
	\item Automatic error correction to guarantee the integrity of transmitted data.
	\item A local and wireless UART configurations with access to both both SPP and HCI modes.
	\item A USB interface with access to HCI mode.
	\item Support for human interface device profiles such as controllers, mice, and keyboards.
\end{itemize}

The main disadvantage to using the RN-42 chip is that lack of support for higher Bluetooth version. Many modern devices utilize Bluetooth 4.0+, which offers numerous performance and security improvements. This is a major drawback, because consumers tend to gravitate towards the latest technological standards. However, this disadvantage can be mitigated because most modern devices are backwards compatible with Bluetooth 2.1 or lower. In addition, by using an older, more mature version of Bluetooth, the developers have a greater understanding of the vulnerabilities and problems associated with it, since most of them have already been observed. It is also a much simpler version of Bluetooth to develop with, since later Bluetooth versions have higher hardware requirements.

\subsubsection{HC-05 Bluetooth Module}
% Chris

The HC-05 Bluetooth module is an extremely popular chip that is widely used due to its affordability. For just several dollars, this tiny chip offers an inexpensive solution to hobbyists who need wireless capability in their projects. This chip, like the RN-42, is very tiny and has nearly identical specifications. However, there are some significant differences that must be taken into consideration.

	\begin{table}[h]
		\centering
		\caption[HC-05 Basic Specifications]{HC-05 Basic Specifications \cite{hc05}}
		\label{tab:hcspec}
		\begin{tabular}{|c|c|}
			\hline 
			\textbf{Specification} & \textbf{Value} \\ 
			\hline\hline
			Class	&  2 \\
			\hline
			Version	& 2.0 + EDR \\ 
			\hline
			Frequency  & 2.4 GHz\\ 
			\hline
			Sensitivity & -80 dBm\\
			\hline
			Supply Voltage	& 3.3 V \\
			\hline
			Data Rate & 3 Mbps \\
			\hline
			Power Output & 4 dBm \\
			\hline 
			Interfaces Supported & UART, USB, I2C \\
			\hline 
			Modulation Type & AFH \\
			\hline 
		\end{tabular}
	\end{table}

As seen in Table \ref{tab:hcspec}, the HC-05 module is nearly identical with exception to the AFH modulation type, added support for USB interfacing, and lack of support for the SPI protocol. The advantages of using the HC-05 chip is that it is cheaper than the RN-42 chip by approximately 10 to 15 USD, however, this does not necessarily make it more desirable since the difference is negligible with respect the the overall budget allocated to the development of the smart table. 

Both modules utilize optimized integrated antennas which greatly reduce development time and guarantee functionality from a physical standpoint. Using external antennas would result in greater costs and code overhead to establish functionality. The power requirements for these Bluetooth chips are also expected similar, but entirely marginal since the smart table will be connected to a mains voltage line and does not require strict power saving functionality.

A significant disadvantage of using the HC-05 chip is that it lacks Bluetooth 2.1. Since Bluetooth 2.0 lacks the Simple Pairing Protocol, using HC-05 would be frustrating and inconvenient. This aggravating factor alone makes the RN-42 a superior device to use for the wireless communications of the smart table. In addition, there is very little documentation available for the HC-05 chip, which would negatively impact development time. 