% !TEX root = master.tex
\subsubsection{Microcontroller}
% Chris
The microcontroller is arguably the most important part of the smart table (at least the \textit{smart} part). The  microcontroller will have the highest number of tasks of the entire electronic system of the table and process the most code.  As the main processor of the smart table, it will directly control the LED matrix as well as interface with the Bluetooth module to receive various remote commands from the user. In this project, a development board will be used which contains the surface mount microprocessor that will ultimately be utilized in the final project. The development board speeds up initial development and will simplify code debugging.

The main goals for the microcontroller include:
 
\begin{itemize}
	\item Send and receive data to and from the Bluetooth module to perform certain functions and report status of the smart table.
	\item Send signals to the LED matrix to modulate their colors, patterns, and intensity.
	\item Run subroutines for special LED matrix functions such as displaying time, date, and games.
	\item Manage the smart table's power modes.
\end{itemize}

Table \ref{tab:microspecs} shows the specifications of the microcontroller. The microcontroller that was chosen is extremely capable and robust, include a variety of serial communications protocols such as USB, SPI, I2C, uPP, SCI, and McBSP. Although we will ultimately use a custom WS2812 protocol, these features are nice to have for redundancy in the event that a different configuration needs to be implemented to do unforseen circumstances. It is also desirable to have support for a large number of communication protocols in the event that a new feature is going to be added to the smart table that would require one. The dual-core, 32-bit RISC architecture is familiar to the development team and provides enough flexibility and functionality to perform extremely complex calculations require for matrix algebra and manipulation, if utilized. The supply voltage of 3.3 V is compatible with other modules used, such as the Bluetooth module, which means that time and money can be saved on the design of the power system.

\begin{table}[H]
	\centering
	\caption[Specifications for Microcontroller]{Specifications of Microcontroller \cite{C2000}}
	\label{tab:microspecs}
	\begin{tabular}{|c|c|}
		\hline 
		\textbf{Specification} & \textbf{Value} \\ 
		\hline\hline
		Architecture	& Dual-Core 32-bit RISC \\
		\hline
		Frequency & 200 MHz \\ 
		\hline
		RAM & 204 KB \\
		\hline
		ePWM & 24 (PWM), 16 (HRPWM)\\
		\hline
		GPIO & 97 \\
		\hline
		ADC & 4 (12-bit/16-bit)\\
		\hline
		SPI & 2 \\
		\hline
		I2C & 3 \\
		\hline
		USB & 1 \\
		\hline
		Supply Voltage	& 3.3 V \\ 
		\hline 
	\end{tabular}
\end{table}

Also shown in Table \ref{tab:microspecs} is the enhanced pulse-width modulation channels are absolutely essentially to control the LED matrix since PWM will allow for adaptive brightness on the LEDs. The intensity of the red, green, and blue LEDs can be individually varied because each LED will have individual duty cycles. This means that a hiugh number of color combinations can be attained, up to 16 million. The PWM feature of the microcontroller will also allow for power savings, since the LEDs will be cycled on and off rather than being powered on continuously.
 
\begin{table}[H]
	\centering
	\caption[Parts for Microcontroller]{Parts for Microcontroller \cite{C2000}}
	\label{tab:microparts}
	\begin{tabularx}{\textwidth}{|c|X|c|}
		\hline 
		\textbf{Part} & \textbf{Description} &
		\textbf{Cost} \\ 
		\hline\hline
		C2000 LaunchPad & C2000 Delfino MCUs F28379D LaunchPad Development Kit & \$33.79\\
		\hline
		TMS320F28379D & Dual-Core Delfino Microcontroller & \$0.00\\
		\hline 
	\end{tabularx}
\end{table}

Table \ref{tab:microparts} shows a list of components that will be used in the development of the smart table. The microprocessor development board, also known as the LaunchPad, is a familiar format that was used during coursework when learning the basics of embedded systems such as microcontrollers.  The development board will be used in conjunction with a solderless breadboard to interface with a scaled-down one-dimensional LED matrix and the Bluetooth module, and can easily be programmed and powered via USB. This means that for initial prototype testing and demonstration, a custom power supply is not entirely necessary since the development board includes a powered USB header. This setup allows for easy rewiring and on-the-fly code changes without significant effort.

\begin{figure}[h]
	\centering
	\includegraphics[width=0.6\linewidth]{img/c2000-pins}
	\caption[C2000 Pinout Diagram]{Pinout Diagram of the C2000. \textit{Permission submitted to reproduce}.  \cite{C2000}}
	\label{fig:c2000-pins}
\end{figure}

As visible in Figure \ref{fig:c2000-pins}, it could be argued that the smart table has too many GPIO pins for the purposes of the project, however, one must keep in mind the other hardware requirements required to drive hundreds to thousands of pulse width modulated RGB light-emitting diodes. These devices require extremely fast switching, since the human eye can begin to detect flickering and other visual artifacts below a 30 Hz refresh rate, which equate to 30 frames per second. To meet this requirement, a microcontroller capable of operating at high frequencies is needed so that it can maintain a minimum refresh rate under load.

The 200 MHz frequency of the C2000 microcontroller was determined to be sufficient, which gives a lot of leeway when it comes to expanding the LED matrix. The microcontroller not only meets this frequency requirement, but it also has enough RAM to cache frames and manage multiple running programs. The 204 KB of RAM will allow just enough volatile memory to engage in high speed communication via the Bluetooth module and display the various software modules with proper timing. In addition, some software modules will require taxing calculations, such as the video game. Additionally, a potential Fast Fourier Transform demonstration could be used to showcase the power and speed of the C2000 microcontroller.

\begin{figure}[h]
	\centering
	\includegraphics[width=0.8\linewidth]{img/c2000-dims}
	\caption[C2000 Dimensions]{Dimensions of the C2000 Microcontroller. \textit{Permission submitted to reproduce}. \cite{C2000}}
	\label{fig:c2000-dims}
\end{figure}

Figure \ref{fig:led-dims} shows the physical dimensions of the microprocessor that will be utilized after the development board prototype. The development board is only intended to be used to develop a working prototype, after which the surface mounted quad-flatpack package, as seen in Figure \ref{fig:led-dims}, will be directly soldered to a printed circuit board populated only with the pins necessary for the table to function, along with a flash emulation tool and USB header to program the device. Although quad-flatpack packages are a bit more difficult to work with than dual in-line packages since they are surface mount devices rather than through-hole devices, the microcontroller dimensions are still manageable and can be placed on the board with the help of a third party who can apply solder paste, place it using a pick and place machine, and finally baking them onto the board.

The block diagram of the C2000 microcontroller can be observed in Figure \ref{fig:c2000-block}. As can be seen, the microcontroller has many redundant features that allow for a high number of inputs and compatibility. Both CPU cores have access to the same features, represented by the yellow (CPU-1) and green (CPU-2) bus lines. More importantly, this microcontroller has many features built in that most budget microcontrollers do not have, such as enhanced PWM channels to create precise waveforms, 12-bit/16-bit  analog-to-digital converters, and control law accelerators which doubles the processing power of the chip and enables speedy computation of complex mathematics such as DSP algorithms, trignonometry and transforms. The JTAG interface is a welcome edition that will enable advanced debugging features provided the proper device programming hardware such as a FET is available.

\begin{figure}[h]
	\centering
	\includegraphics[width=1.0\linewidth]{img/c2000-block}
	\caption[C2000 Block Diagram]{Block Diagram of the C2000 Microcontroller. \textit{Permission submitted to reproduce}. \cite{C2000}}
	\label{fig:c2000-block}
\end{figure}




