% ----------------------------------------------------
% ----------------- Hardware Solution ----------------
% ----------------------------------------------------

	The main objective of the first part of this project was the development of a modular, easy-to-use, flexible, non-invasive, robust and low cost system able to collect data from the pedals. 

\section{Sensors}

% -------------------- Sensors -----------------------

	Firstly, it was thought to use only force sensitive resistors (FSRs) to measure the applied forces on pedals; FSRs are often used due to their small size and the applicability as sensing element to measure forces. Nonetheless, there are also other sensors for measuring applied forces such as load cells (LCs). Although there is some reluctance in using LCs, mainly due to their greater dimensions when compared to FSRs, they have higher accuracy and repeatability, which are very important aspects in a system with the mentioned requirements. Therefore, and because both sensors offer complementary characteristics, both FSRs and LCs sensors were used in this system.
	
	Apart from the ability to measure applied forces on the pedals, it is possible to measure the pedal displacement relative to the car floor using another type of sensor. For the purpose of measuring the pedal displacement, infrared (IR) sensors were selected in order to work perfectly for the dimensions of the pedal travel. Here, three types of sensors were used on this system: FSRs, LCs and IR distance sensors.

	The FSRs are very thin sensors that have variable resistance depending on the applied force. There are several FSRs configurations, varying in size and capacity. The FSRs used for this system were long-sized and with the capability to measure forces up to approximately 2 kgf. For higher forces, the sensor saturates without getting permanently deformed \cite{FSR}.
	
	The LCs are sensors composed of strain gauges, usually forming a Wheatstone bridge, applied over a structure element that is deformed when force is applied. According to the applied force, the tension varies on the LC terminals. There are various different types of LCs, such as: 1) single-point load cells, usually used in small jewelry and kitchen scales, 2) button load cells, used in applications that require a thin form factor and 3) s-type load cells, that can be operated in compression or in tension. The type of the LC used for this system was button load cells with the capability to measure forces up to 50 kgf \cite{lc_phidgets}.
		
	The IR distance sensors are built in small packages and have low current consumptions (50 mA @ 4.5--5.5 V). There are mainly two types of IRs: analog, that provide analog information about the distance to an object and digital, that provide a digital (ON/OFF) indication if an object is below a predefined distance or further from it. The analogue version of the sensors have output values as function of the measured distances. For this system, due to the small pedal displacement, have been selected the Sharp 2D120X IR \cite{IR} with the lowest range available, that was from 4 to 30 cm.
	
	In order to read the data from all the three types of sensors, they were connected to a board which is then connected to the computer. The board used on this system was the PhidgetInterface-kit 8/8/8 from Phidgets. An Arduino Nano v3.1 was also used in preliminary tests. The Interface-kit provides 8 digital inputs and 8 analog inputs and outputs, making it possible to connect all the sensors. However, the PhidgetInterface-kit 8/8/8 cannot provide the required signal conditioning so, in order to do that it was necessary to use signal conditioning boards, such as IR adapters and FSR adapters provided from Phidgets and custom LC adapters. 

% ----------------------------------------------------

 \subsection{Force Sensitive Resistor}

% ----------- Force Sensitive Resistor ---------------

The force sensitive resistors (FSR) are flat, robust and polymer thick film sensors that have variable resistance between their pins depending upon the applied force (Figure \ref{fig:FSR}). The sensing film is composed by electrical conducting and non-conducting particles suspended in matrix. When force is applied, those non-conducting particles get in contact with the conducting electrodes, thus changing the electrical resistance of sensor \cite{FSR}. Their working principle is: the higher the force the lower is the resistance.

\begin{figure}[htbp]
\centering
  \includegraphics[width=0.55\textwidth]{images/FSR.jpg}
  \caption[Interlink Electronics 0.5" Circular 20N FSR]{Interlink Electronics 0.5" Circular 20N FSR \cite{FSR}.}\label{fig:FSR}
\end{figure}

	These sensors are easy to use and relatively inexpensive, however, they have some disadvantages such as drift and poor accuracy, with errors up to 25\% \cite{FSR}.
	
	Depending on the time and the strength at which they are pressed, once released the FSR output value will come back to approximately 95\% of its initial value almost instantly, and then drift the final 5\% over a few seconds \cite{FSR}. Hence, these sensors are not the best option when setting up a system that relies greatly on accuracy and repeatability. However, in combination with other sensors, such as load cells, they can be very useful. For instance, even though the FSRs used on this system have the maximum capacity of 20 N, because the driver applies more force on the pedals these sensors will quickly saturate so they can be used to detect smaller forces, such as, for example, if the driver is touching the pedal.

% ----------------------------------------------------


\subsection{Force Load Cell Sensor}

% ----------- Force Load Cell Sensor------------------

	A Load cell (LC) is a sensing module that converts force into an electrical signal (Figure \ref{fig:LC}). The LC has strain gauges mounted in its structure and are collectively deformed when force is applied, in this case 0 to 50 Kg; the strain gauges are responsible for converting the deformation on them into an electrical signal. The electrical signal output is very low, typically in the order of 1 millivolts/volt, thus it is required the use of an instrumentation amplifier \cite{lc_phidgets}. 
	
\begin{figure}[htbp]
\centering
  	\includegraphics[width=0.6\textwidth]{images/LC.jpg}
  	\caption[Button Load Cell (0--50Kg)]{Button Load Cell (0--50kg) \cite{lc_phidgets}.}\label{fig:LC}
\end{figure}	
	
	Most designs of load cells use 4 strain gauges in a Wheatstone bridge configuration, but there are also other types that only use 2 strain gauges, often called half bridges, and one strain gauge (quarter bridge) \cite{lc_phidgets}.
	
	A Wheatstone bridge is an electrical circuit originally used to determine the value of an unknown resistance by balancing two nodes of the bridge circuit. It has two input terminals and two output terminals consisting of four resistors represented in a diamond-like arrangement. In the case of the load cells, these resistors are strain gauges \cite{wheatstone_bridge}.
	
	The load cell electrical output can be converted to force or weight using equation (\ref{eq:FLC_calibration}) \cite{lc_phidgets}:

\begin{equation}
Force=K\times(Measurement - Offset)\label{eq:FLC_calibration}
\end{equation} 
\\Where K is the gain value that will change depending on which are the units being used and mounting arrangements. The offset value varies between individual load cells, so it is necessary to measure the offset for each sensor. By measuring the output of the load cell at rest on a flat surface with no force applied on it, it is possible to find the offset. Once the offset is found and, a known force is exerted on the sensor, it is possible to solve equation \ref{eq:FLC_calibration} for K.

	This calibration is important when the real value of the force is necessary. However, due to the fact that in this monitoring system the data range from the sensors will be different for each user, instead of using equation (\ref{eq:FLC_calibration}) a minimum and a maximum value is used to calibrate the sensors, the minimum value is measured when no force is applied on the pedal and the maximum value when the pedal is pressed till the end.

% ----------------------------------------------------


\subsection{Infrared Distance Sensor}

% ----------- Infrared Distance Sensor----------------

	The Sharp infrared (IR) distance sensor provides information about the distance to an object (Figure \ref{fig:IR}a). These sensors work by the process of triangulation. A pulse of infrared light is emitted and then reflected back, or not reflected at all. When the light returns it forms an angle that is dependent on the distance of the reflecting object. Triangulation works by detecting this reflected beam angle; by knowing the angle, the distance can then be determined (Figure \ref{fig:IR}b) \cite{IR}.


\begin{figure}[htbp]
\centering
  	\subfloat[]{\includegraphics[width=0.4\textwidth]{images/IR.jpg}}
  	\qquad
  	\subfloat[]{\includegraphics[width=0.4\textwidth]{images/sharp_angle.jpg}}
  	\caption[a) Sharp Distance IR Sensor (4-30cm). b) Sharp IR detector angle of reflection.]{a) Sharp Distance IR Sensor (4-30cm) \cite{IR}. b) Sharp IR detector angle of reflection arrival for near and far object \cite{IR}.}\label{fig:IR}
\end{figure}

	Due to the trigonometry involved in calculating the distances based on the reflected light incident angle, the output of the sensor is non-linear (Figure \ref{fig:IR_graph}). By analysing the graph it is possible to observe that the output within the range (4 -- 30 cm) of the sensor is not linear. Also, when the range is closer to the minimum distance (4 cm) the output drops quickly, which means that the system will respond as if the object is moving away instead of in approach. This particular feature could represent a problem for distances lower than 4 cm. In order to solve this issue, the possibility to adjust the IR sensor orientation was added in the system.

\begin{figure}[htbp]
\centering
		\includegraphics[width=0.4\textwidth]{images/IR_non-linear_graph.png}
	\caption[Sharp 2D120X IR (4--30 cm) output voltage vs distance.]{Sharp 2D120X IR (4--30 cm) output voltage vs distance \cite{IR}.}
	\label{fig:IR_graph}
\end{figure}

	
	Regarding the sensor values, it is possible to convert the analog output from the sensor into distance using equation (\ref{eq:IR_CALIB}):

\begin{equation}
Distance(cm)=\frac{2076}{SensorValue-11}\label{eq:IR_CALIB}
\end{equation}
\\Equation (\ref{eq:IR_CALIB}) is only valid for ADC output values between 80 and 530, which represent approximately 0.3V at 30cm and 3.1V at 4cm, based on standard values from Sharp. In order to have a better performance of the sensor it is suggested to derive the equation for the actual sensor values. However, by using the standard equation on this system, the IR sensors provide good results, so it is not necessary to derive their own equation \cite{phidgets_IR}.

% ----------------------------------------------------

\section{Mechanical System}

% ------------ Mechanical System ---------------------

	As mentioned, this system was composed of three different types of sensors: force sensitive resistors (FSR), load cells (LCs) and infrared (IR) distance sensors.
	
	In order to install the sensors on the pedal, an enclosure able to lodge 2 LCs, 2 FSRs and 2 IR sensors was developed. When designing the enclosure, special attention was given to the dimensions, because it cannot become an obstacle for the driver. For this reason, and also to make it lighter, the case was manufactured in aluminium with the smallest dimensions possible to lodge the sensors; 30 x 80 x 14 mm (Figure \ref{fig:case}).\\
	
\begin{figure}[!h]
\centering
		\includegraphics[width=0.95\textwidth]{images/CASE_DRAWING.jpg}
	\caption[Case mechanical drawings.]{Case mechanical drawings.}
	\label{fig:case}
\end{figure}

	The load cells and force sensitive resistors were meant to be fixed on the case, whereas the infrared sensors were planned to be installed on the sides of the case, with the possibility of adjusting their orientation shown in Figure \ref{fig:adjustment_system}. The reduced dimensions of the FSRs made it possible to install them beneath the LCs, making the system more redundant.
	
	The case is composed by two components, the bottom component where the sensors are installed and the top component that consists of a touch sensitive lid. Both bottom and top components cannot be fixed together, otherwise the force applied by the driver on the lid would be transferred through the fastening system instead of being transferred60 through the LCs and consequently the FSRs, as supposed. To accomplish this, it was necessary to use a clamping system by adding both threaded holes on the bottom and through holes on the lid. Both parts were fastened using screws so that the sensors would be just touching not saturated. In addition, for a quick installation/uninstallation of the case on top of the pedals, a fixing system based on Velcro strips was adopted and is shown in Figure \ref{fig:case_mounted}. The exploded view is shown in Figure \ref{fig:exploded_view}.

\begin{figure}[htbp]
\centering
		\subfloat[]{\includegraphics[width=0.35\textwidth]{images/adjust_system_front.png}}
		\qquad
		\subfloat[]{\includegraphics[width=0.35\textwidth]{images/adjust_system_back.png}}
	\caption[Case adjustment system for infrared sensors.]{a) Adjustment system - Front view. b) Adjustment system - Rear view.}
	\label{fig:adjustment_system}
\end{figure}

\begin{figure}[htbp]
\centering
		\subfloat[]{\includegraphics[width=0.35\textwidth]{images/velcro_system.png}}
		\qquad
		\subfloat[]{\includegraphics[width=0.35\textwidth]{images/case_mounted_on_pedal.jpg}}
	\caption[Case to host the sensors.]{a) Case fixing system. b) Case with the IR orientation system installed on a gamepedal.  }
	\label{fig:case_mounted}
\end{figure}


\begin{figure}[htbp]
\centering
	\includegraphics[width=\textwidth]{images/exploded_view.pdf}
	\caption[Exploded view of the case.]{Exploded view of the case.}
	\label{fig:exploded_view}
\end{figure}

% ----------------------------------------------------


\section{Electronic Devices}

% -------------- Electronic Devices ------------------

	As mentioned, the output values of the sensors need to be conditioned, in this case filtered and amplified. In order to do that two different types of boards from Phidgets were used, one for the infrared (IR) distance sensors, and for the force sensitive resistors (FSR), and another custom made board for the force load cell (LC).
	
	The board used for the FSR signal conditioning was the Voltage Divider (Figure \ref{fig:FSR_adapter}), which provides an interface to resistance sensors such as: FSRs, light sensors, heat sensors and bend sensors \cite{phidgets_voltage_divider}. This board has a high precision potentiometer that allows the adjustment of the resistors in the divider. The two resistors form a voltage divider who's output is then connected to the analog input of the interface board. In order to make sure that the sensor value stays within an expectable range, it is possible to optimize the voltage divider; the voltage divider resistance can be adjusted by simply turning the screw on the potentiometer; clockwise to decrease the resistance, and counterclockwise to increase it \cite{phidgets_voltage_divider_guide}.

\begin{figure}[htbp]
\centering
  	\centering
  	\subfloat[]{\includegraphics[width=0.4\textwidth]{images/FSR_adapter_schematic.jpg}}
  	\qquad
  	\subfloat[]{\includegraphics[width=0.3\textwidth]{images/FSR_adapter.jpg}}
  	\caption[Force Sensitive Resistor Adapter.]{a) Force Load Cell adapter circuit scheme. b) Force Sensitive Resistor Adapter \cite{phidgets_voltage_divider}.}\label{fig:FSR_adapter}
\end{figure}

	The LCs are sensors that require an instrumentation amplifier (in-amp) to amplify their output value, which is in the range of millivolts. The reason to use an in-amp is for improved common-mode rejection. Therefore, a circuit board was developed to mount the sensors, amplify the signals and connect to the PhidgetInterfaceKit 8/8/8 responsible for the data acquisition (Figure \ref{fig:LC_adapter}). This board, also named LC adapter, was designed using the CadSoft Eagle Software and hosts an instrumentation amplifier, AD623, with a gain that can be calculated using equation (\ref{eq:gain}):

\begin{equation}
G=1 + \frac{100000}{Rg}\label{eq:gain}
\end{equation}
Where the Rg is the resistor connected between pins 1 and 8 of the in-amp. The resistor installed in the board has 160 $\Omega$; placing this value on the equation it is possible to calculate the gain of the board that is approximately 600.
	
	
\begin{figure}[H]
\centering
  	\subfloat[]{\includegraphics[width=0.4\textwidth]{images/circuit_board.png}}
  	\qquad
  	\subfloat[]{\includegraphics[width=0.4\textwidth]{images/pcb_board.png}}
  	\qquad
  	\subfloat[]{\includegraphics[width=0.6\textwidth]{images/LC_adapter.jpg}}
  	\caption[Force Load Cell Adapter.]{a) Force Load Cell adapter circuit scheme. b)  Force Load Cell adapter PCB circuit. c) Force Load Cell Adapter.}\label{fig:LC_adapter}
\end{figure}


	For the IR distance sensors signal conditioning, the IR Distance Adapter board was used (Figure \ref{fig:IR_adapter}). This board provides an interface to an analog input on the PhidgetInterface-kit 8/8/8 board, mentioned before, and provides a conditioned power source for the connected sensor. Although the specified current consumption of the sensor is low, they may draw much more current for short periods during measurements. Because the system will have several sensors installed, the IR adapter boards are an important aspect to prevent the PhidgetInterfaceKit 8/8/8 from overload due to high current consumption \cite{phidgets_IR_adapter}.


\begin{figure}[htbp]
\centering
  	\centering
  	\includegraphics[width=0.3\textwidth]{images/IR_adapter.jpg}
  	\caption[Infrared Distance Sensor Adapter.]{Infrared Distance Sensor Adapter \cite{phidgets_IR_adapter}.}\label{fig:IR_adapter}
\end{figure}


% ----------------------------------------------------

					
\section{Acquisition System}


% --------------- Acquisition System -----------------

	As mentioned, for the data acquisition, the PhidgetInterfaceKit 8/8/8 board was used and is shown in Figure \ref{fig:phidgets_interfacekit} \cite{phidgets_interfacekit}.  This board is provided with a MCP23S17, which is a 16-bit input/output (I/O) expander with Serial Peripheral Interface (SPI) interface. The MCP23S17 device consists of multiple 8-bit configuration register for I/O and of a system master responsible for enabling and disabling these inputs or outputs. The data for each I/O is kept in the corresponding register and then all registers can be read by the system master \cite{MCP23S17}.  The board has a MCP3008 which is an 8 channel 10-bit analogic to digital converter (ADC) \cite{MCP3008}. Finally, this board has a CY7C64215 that is a full-speed USB controller. This device is responsible for interfacing between SPI and USB \cite{CY7C64215}, which is the protocol used to connect the board to the computer.

\begin{figure}[htbp]
\centering
		\includegraphics[width=0.45\textwidth]{images/phidgets_board.jpg}
	\caption[PhidgetInterfaceKit 8/8/8.]{PhidgetInterfaceKit 8/8/8 Acquisition Board from Phidgets \cite{phidgets_interfacekit}.}
	\label{fig:phidgets_interfacekit}
\end{figure}

	Nonetheless, instead of using the PhidgetInterfaceKit 8/8/8 it is also possible to use an Arduino, for example the Arduino Nano v3.1 (Figure \ref{fig:arduino}) \cite{arduino}.
	The Arduino Nano v3.1 is a single-board microcontroller, with smaller dimensions, more flexible and less expensive than the PhidgetInterfaceKit 8/8/8. Actually, as mentioned above the Arduino Nano was used on preliminary tests to read the data from the sensors, however, due to convenience reasons, the PhidgetInterfaceKit 8/8/8 was used; because the signal conditioning boards were also from Phidgets and so the assembly was easier and the system more robust for a first prototype.
	
\begin{figure}[htbp]
\centering
		\includegraphics[width=0.45\textwidth]{images/arduino_nano.jpg}
	\caption[Arduino Nano v3.1.]{Arduino Nano v3.1 \cite{arduino}.}
	\label{fig:arduino}
\end{figure}	

	However, for a final and large scale production approach, the use of custom electronic devices or existing commercial off-the-shelf, such as Arduino or a single-board computer (SBC) like the Raspberry Pi \cite{raspberry_pi}, would represent a more feasible solution due to their lower costs and firmware flexibility. Nonetheless, to use these solutions, it would be required the use of additional electronic devices to assure proper signal conditioning. 
	
	For instance, when the electronic devices are far away from the sensors, to receive the output from the sensors without any losses it is necessary to convert the output signal of the sensors from voltage to current (V-to-I). Because the current signals are exactly equal in magnitude throughout the circuit a V-to-I converter can be used to prevent signal losses. To do so, several aspects of the setup should be modified: 1) the power source that supplies the sensors must be isolated or different from the power source that supplies the acquisition board, otherwise it will not be possible to read the signal from the sensors, 2) the output signal from the sensors must be connected to the V-to-I converter, 3) after the V-to-I conversion and before the signal reaches the acquisition board, the current must be converted back to voltage by adding a resistor to the circuit. 
	
	In the case of using a Raspberry Pi, it would not be necessary to use a computer to connect all the system. Also, by using the Raspberry Pi, it is also possible to create a network connection, such as Ethernet or Wifi. With this network connection it would be possible to communicate with the system via remote, which could represent a great improvement in the system.

% ----------------------------------------------------


\section{Setup}

% ---------------------- Setup -----------------------

After the conclusion of the hardware and electronic devices, it was possible to assemble all of the components and create a setup to start monitoring the pedals (Figure \ref{fig:setup}). To do so, it was necessary to:

\begin{itemize}
\item Mount the sensors on the case: 2 force load cells, 2 force sensitive resistors and 2 infrared distance sensors;
\item Connect the sensors to the signal conditioning boards: 2 voltage dividers, 2 IR adapter and 2 LC adapter;
\item Connect the signal conditioning boards to the acquisition board, PhidgetInterfaceKit 8/8/8;
\item Connect the acquisition board to the computer, responsible for supplying and for the communication with the board, launch the software interface and start monitoring.
\end{itemize}

\begin{figure}[htbp]
\centering
		\includegraphics[width=\textwidth]{images/setup1.png}
	\caption[Setup scheme.]{Setup scheme. In order to monitor the pedals, the case is mounted on them. The case has LCs,FSRs and IR sensors installed and these are connected to their adapters. The adapters connect to the PhidgetInterfacekit and than to the computer. It is possible to replace these adapters and the PhidgetInterfacekit for other custom devices. Also, it is possible to replace the computer for other device, such as a single board computer (SBC).}
	\label{fig:setup}
\end{figure}


% ----------------------------------------------------
