\chapter{Experimental Results}

Several laboratory tests were performed on the gear selector mechanism, to the motor controller printed circuit board, to the \textit{Arduino} code itself and to the ROS Node that communicates with the gear selector mechanism's firmware. This experimental results Chapter is divided in two distinct Sections: the manual mode testing, and the Hardware-in-the-Loop simulation.

\section{Manual Mode Testing} \label{sec:manual_mode_testing}

A variety of tests, performed under the manual mode, were taken on the gear selector system to evaluate the behaviour and performance of two distinct parts:

\begin{itemize}
\item The quality of the motor controller PCB;
\item The robustness and effectiveness of the firmware manual mode;
\end{itemize}

\subsection{Motor Controller PCB} \label{motor_controller_pcb}

After fully soldering all the components on the motor controller printed circuit board, some tests were performed in order to determine possible problems. The first test performed was a continuity test on all the printed circuit pathways along with a careful visual inspection process, to detect possible undesired connections due to errors during the printing process.

One of the biggest concerns associated with the integrity of the control board was the correct soldering of the H-bridges integrated circuits, the VNH3SP30-E depicted in Figure \ref{figure:VNH3SP30-E}. The only components that were not manually soldered into the PCB were the two H-bridges and the two protective N-MOSFETS. These components were soldered using a reflow oven, due to their surface mount nature. The three "Heat Slug" connectors, placed directly under the H-bridges' integrated circuits, are particularly prone to possible soldering failure. In order to check the quality of the soldering process, the pins of both H-bridges were also tested using the multimeter in continuity mode, achieving the desired quality results.

Another major concern associated with the printed circuit board design was the electric current values consumed by the DC motors while in motion. In order to evaluate the current passing through the circuit, a laboratory power supply was used to feed the power circuit. The test consisted on repetitively making the gear selector mechanism run through all the six possible gear positions in sequential mode, first in the upward direction, and then in the downward direction. The first part of the test was performed without any load applied on the gear selector mechanism, and during the second part of the test, a force is manually applied to the mechanism central ring.

While testing the unloaded mechanical system situation, the maximum electric current peak observed in the current gauge is approximately 1.5 A. The equivalent value observed for the loaded mechanism situation was never greater than 5 A, and even this value only occurs during the motors start-up or stop. The power supply used for the test is known to limit current values above 5.5 A, and the DC motor control system never activated the current limiting circuit during the tests performed.

Another parameter that deserved some attention during the previous test was the temperature achieved by the H-bridges' integrated circuit during the normal operation of the system. According to the VNH3SP30-E datasheet, the absolute maximum temperature that the integrated circuit package type can withstand is 150$^{\circ}$ C, which also corresponds to the thermal shut-down protection minimum temperature. Although one of the H-bridges, namely the one responsible for the vertical paths, presented higher temperatures than the other, such high temperature values were never achieved, even after extensive system testing. A termopar, connected to the respective connector on the multimeter, was used to monitor the H-bridges' temperature, showing that the value never ascended the 55$^{\circ}$ Celsius, even after several minutes of continuous operation.

\subsection{Manual Mode Programming Tests}

The manual mode consists of a sequential gear shifting process, as described in Chapter \ref{chap:automatic_gearbox}. Due to the high responsibility role of the gear selector mechanism in the AtlasCar, both the user interface with the \textit{Arduino}, based on the adapted Renault M\'{e}gane audio pad, and the sequential behaviour of the manual mode code needed to be further tested.

The gear pad buttons are already equipped with the necessary pull down resistors, and the input pins on the \textit{Arduino} do not present any unwanted fluctuations. This is the reason why no pull-down resistors are placed in the printed circuit board design on these digital input pins.

Another recurring problem in this kind of button pressing systems is the button de-bouncing. This problem is due to the high frequency voltage peaks that occur prior to the signal stabilization, at the moment of pressing a button. There are two different ways of solving this problem:

\begin{itemize}
\item Hardware de-bounce, using passive, low pass filtering;
\item Software de-bounce, using timers or delays.
\end{itemize}

The up and down-shift buttons do not require any de-bounce methods, because when the user presses them while in manual mode, the system automatically starts moving to the next position, and during this movement process any pulse variation on the button, being it intentional or not, is ignored. The same does not happen with the button used to switch between the manual and the automatic modes. If no de-bounce is executed on this button, the modes can switch very quickly between them, and the user can easily loose track of the mode currently selected. The de-bounce method selected to solve this problem was the software de-bounce, applied directly on the \textit{Arduino} firmware code.

Another situation tested during the manual mode was the communication failure with the PC. The Ethernet connection was deliberately interrupted while the system was both in a stationary position and while moving from one position to another, to ensure that a communication failure did not compromise the normal working of the gear selector mechanism. This fact was confirmed: the communication function running on the \textit{Arduino} is not blocking, and the Ethernet connection can be interrupted at any time, without any damage inflicted to the gear selector mechanism, or the AtlasCar gear system.

\section{Automatic Mode Testing}

In this Section, the tests performed using the gear selected mechanism while in automatic mode will be described.

\subsection{ROS Node Testing}

The number of tests that can be performed using the ROS node created to communicate with the gear selector mechanism, without the system being installed on the AtlasCar vehicle, is very limited. The only two characteristics that could be tested were the frequency at which the device could communicate with the controlling PC, and the quality of the message protocol defined.

In what concerns to the communication frequency, the use of a dummy message cycle within the ROS Node showed that it communicates with the \textit{Arduino} at a steady frequency of 13 Hz, with small fluctuations of 0.5 Hz, even when the DC motors are moving. Similar to what happened during the Manual Mode tests, the interruption of the communication process did not affect the performance of the \textit{Arduino} programming or the gear selector mechanism. The gear change occurring at the time of the communication interruption is completed successfully.

The messaging system established between the gear selector mechanism and the ROS Node was also tested, by forcing all its predicted situations, producing the expected results, since the Node could interpret the message without any trouble, and publish it in the corresponding ROS Topic.

\subsection{"Hardware in the Loop" Testing}

Using the Hardware-in-the-Loop simulator described in Chapter \ref{chap:partial_gearbox_simulator}, some tests were performed on the gear selector mechanism control system. In the following Sub-subsections, two possible real situations are simulated and explored, and the behaviour of the mechanism is monitored and described.

\subsubsection{Test 1 - Normal vehicle driving}

This test is performed using the default initial conditions of the simulator. The description of this test is the following:

\begin{enumerate}
\item The car is already at 10 km/h, without any pressure on the throttle or brake pedal;
\item 5 seconds later, the throttle pedal is set to 20\%;
\item After all the gear changes, the car is accelerated further until it reaches approximately 100 km/h;
\item At second 53, the throttle pedal is set to 0\%;
\item At second 57 the brake pedal is fully pressed;
\item The car reaches a stationary position at second 64.
\end{enumerate}

The result of the Hardware-in-the-Loop test described above is depicted in the graphs on Figure \ref{figure:test_1_graph}.

\begin{figure}[h!]
\centering
\epsfig{file=Images/test_1_graph.eps,width=150mm}
\caption[Graphs representative of the Test number 1.]{Graphs representative of Test number 1. From the top to the bottom, the graphs represent the Throttle Percentage, the Brake Percentage, the Vehicle Speed, the Clutch Percentage and the Gear Numbers. The black line on the "Gear" graph represents the moments at which the gearbox is disengaged from the engine.}
\label{figure:test_1_graph}
\end{figure}

The car starts at 10 km/h with the gear selector mechanism set to the first gear. According to the second gear logic method described in Section \ref{sec:shifting_logic}, and implemented on the simulator version used, the gear should start changing for a vehicle speed greater than 20 km/h. According to the clutch position graph, this gear shift is verified because the clutch starts moving towards its fully activated position at second 6.2, which is also the time value at which the vehicle speed becomes greater than 20 km/h. At this point, a signal is sent to the \textit{Arduino}, to inform it about the number of the following gear needed, and the gear selector mechanism performs the movements required in order to obey that command. Note that while the gear selector system is moving, the clutch stays pressed, until the simulator receives confirmation from the \textit{Arduino} firmware program confirming that the gear change was successfully performed. Similar behaviour can be observed for the following simulated gear changes, except for the final gear shift, which will be explained later.

Another interesting characteristic that can be observed directly on the clutch percentage graph, is the different gear shifting execution times. Although the time represented on the graphs is an estimated value, the time that the clutch stays activated is notoriously different for certain gear shifts. One example of this behaviour can be seen between the $1^{st}$ to $2^{nd}$ gear shift and the $2^{nd}$ to $3^{rd}$ gear shift. This is due to the more complex trajectory that needs to be travelled by the gear lever while moving from the second to the third gear. This trajectory involves moving both DC motors, contrarily to what happens while moving from the first gear to the second, which corresponds to a simple vertical movement. This situation had already been foreseen at the time of writing the \textit{Arduino} firmware program, and is now confirmed with experimental results.

At the second 58, the brake is fully activated and a drastic deceleration is imposed to the vehicle until it reaches a complete standstill at second 64. During this deceleration process, multiple gear numbers are consecutively set on the message sent to the gear selector mechanism. Due to the firmware programming, as soon as the motors start moving the gear shift process can not be interrupted, so once a gear number is set on the message going to the \textit{Arduino}, the mechanism will start executing the required gear change, and will ignore any incoming message updates. This will result on the gear selector mechanism executing some gear shifts that were set from a previous message, while new messages with different requested gears are being sent. However, the simulator is prepared to deal with this situation, and determines if the gear currently read from the device corresponds to the gear sent on the last message, prior to start the de-clutching process. This is the reason why the graphic representation shows a direct change from the fifth gear to the Neutral, while the real behaviour of the gear selector mechanism was a change made from the fifth gear to the fourth, and only then a change from fourth gear to the neutral.

The behaviour of the system while the car is stopped can be watched from the second 63 until the end. This behaviour is comprised of two distinct measures, to prevent the engine from stalling:

\begin{itemize}
\item The clutch is pressed;
\item The Neutral is set on the gear selector mechanism device.
\end{itemize}

\subsubsection{Test 2 - Start-up situation}

Another situation tested using the Hardware-in-the-Loop simulator was the start-up situation, which consists of the interruption of the vehicle's stationary state. This test is depicted in Figure \ref{figure:test_2_graph}. The stationary state can evolve in two distinct movement directions, since the vehicle can move both in the forward direction by inserting the first gear, or in the backward direction, by inserting a reverse.

This test is performed using all the default initial conditions of the simulator, except for the initial speed, that is set to zero. The description of this test is the following:

\begin{enumerate}
\item The simulation starts with the car at 0 km/h, and the neutral inserted. Although the clutch pedal starts on a deactivated position, the simulator starts pressing the pedal automatically;
\item At second 4, the throttle pedal is pressed until it reaches more than 30\% of its total stroke;
\item The car is randomly accelerated and some gear changes take place;
\item At second 36, the car is made to move in the backward direction;
\item At second 45, the brake is activated;
\item At second 49 the car is immobilized again.
\end{enumerate}

\begin{figure}[h!]
\centering
\epsfig{file=Images/test_2_graph.eps,width=150mm}
\caption[Graphs representative of the Test number 2.]{Graphs representative of Test number 2. From the top to the bottom, the graphs represent the Throttle Percentage, the Brake Percentage, the Vehicle Speed, the Clutch Percentage and the Gear Numbers. The black line on the "Gear" graph represents the moments at which the gearbox is disengaged from the engine.}
\label{figure:test_2_graph}
\end{figure}

At the beginning of the simulation, the neutral was already selected on the gear selector mechanism, but the clutch was not pressed. Pressing the clutch is always the first operation executed by the simulator. Soon after detecting more than 20\% of throttle pressed, the car starts moving in the forward direction. Note that for this first start-up situation, the "reverse" push button on the graphical user interface is not pressed.

While the vehicle is running in normal operation, from second 7 to second 21, the gear changes happen sequentially. At second 21 the first brake interval on the simulation starts taking place, until the system reached the stationary state at second 27. Similarly to what happened during test number 1, the gear selector mechanism was sent to a neutral gear, and the clutch is completely actuated, for security reasons and to keep the engine from stalling.

At this point of the simulation, and in order to change the direction of the vehicle movement, the "Reverse" button is pressed. As soon as the throttle pedal is pressed more than 20\%, the gear selector mechanism is set to the reverse gear. The clutch is then deactivated and the vehicle starts moving in reverse.

To end the simulation, at second 45 the brake pedal is pressed again, and as the vehicle looses speed the standard safety measure are taken, namely the complete pressing of the clutch pedal followed by the imposition of a neutral gear on the gear selector mechanism.

\subsubsection{Test 3 - Steep road}

The last situation explored and described in this work is the behaviour of the gear selector mechanism when the vehicle is climbing a steep road using only its inertia. The test is depicted in Figure \ref{figure:test_3_graph}. During this test, the user does not accelerate, and the only forces acting on the vehicle are the gravity force, the rolling resistance force and the drag force. This is the reason why the first graph depicted is not the throttle percentage, like the previous tests. The only input from the driving pedals is the brake action, at the end of the test.

Similarly to what happened in the previous test, all the default initial conditions of the simulator are kept, except for the initial speed, that is set to 120 km/h. The description of this test is the following:

\begin{enumerate}
\item The simulation starts with the car at 120 km/h, and the fifth gear inserted. At this point the vehicle is also on a flat road, as depicted in the first graph;
\item The vehicle looses some speed for approximately 15 seconds;
\item At second 16, the angle of the street suddenly changes from 0$^{\circ}$ to 6$^{\circ}$, which means that the vehicle starts climbing the road, and consequently, loosing speed;
\item At second 43, the car stops and starts moving backwards;
\item At second 51, the user finally presses the brake pedal completely, to stop the vehicle;
\item At second 54 the car is immobilized, and remains like this until the end of the test.
\end{enumerate}

\begin{figure}[h!]
\centering
\epsfig{file=Images/test_3_graph.eps,width=150mm}
\caption[Graphs representative of the Test number 3.]{Graphs representative of Test number 3. From the top to the bottom, the graphs represent the Road Angle, the Brake Percentage, the Vehicle Speed, the Clutch Percentage and the Gear Numbers. The black line on the "Gear" graph represents the moments at which the gearbox is disengaged from the engine.}
\label{figure:test_3_graph}
\end{figure}

At the beginning of this simulation, the vehicle was already running at 120 km/h on a flat ground, the fifth gear was already selected on the gear selector mechanism and the clutch was not activated. During the first fifteen seconds of the simulation, the vehicle looses some speed. Because of the high speed of the car, this loss of speed is mainly due to the drag force, with some contribution of the rolling resistance force.

At second 16, the road angle suddenly changes from the flat ground, or 0$^{\circ}$, to 6$^{\circ}$. This sudden change makes the vehicle loose speed in a fast way, because the $x$ axis gravity force component increases. At second 26 the speed of the vehicle justifies the insertion of a fourth gear. Although the fourth gear is inserted on the gear selector mechanism, at second 30, the speed is evaluated again, prior from releasing the clutch, and another gear shift occurs, and a third gear is inserted soon after second 32.

The car continues loosing speed and at second 34.5 a new gear shift is initiated from the third gear to the second gear, and completed at second 38.8. The car continues running on a second gear, until the speed is too low, and the default process of activating the clutch and inserting the Neutral. Note that, due to the Dijkstra's algorithm, the mechanism was able to skip the first gear.

At second 43 the car stops completely, and since the gravity force continues acting, the vehicle starts moving backwards. Note that the simulator does not insert the Reverse in this situation, since no input from the user is present. At second 51 the user finally presses the brake pedal completely, in order to stop the vehicle, which happens soon after second 54. The Neutral remains inserted in the gear selector mechanism, and the clutch remains pressed.
