diff --git a/chapters/background.tex b/chapters/background.tex index aaa91fb96622d16f2d08a2e6297a5ecf0b9deebf..3a41a17cb0601d3db8070eff8aff03b1327644d5 100644 --- a/chapters/background.tex +++ b/chapters/background.tex @@ -23,6 +23,6 @@ Conex suggested usage of an unmanned quadracopter drone, equipped with sensors t The project is intended to check the feasibility of mapping mine shafts with this method and not to construct a complete product. Thus, unit degradation from dust, moisture or other wear inherent to the workspace is disregarded. - No consideration of falling rocks that could cause the copter to crash will be taken. - It has been presented as a possible failure source, and the copter as suggested cannot feasibly dodge rocks. + No consideration of falling rocks that could hit the copter and cause it to crash will be taken. + It has been presented as a possible failure source, but the copter as suggested cannot feasibly dodge rocks. %TODO: Further limitations? \ No newline at end of file diff --git a/chapters/result.tex b/chapters/result.tex index eb4ef91b7dba31139d6cb97b56c6f43362637843..ed9486b90d091b0b92e26bb8cc56520ad084c6b5 100644 --- a/chapters/result.tex +++ b/chapters/result.tex @@ -42,6 +42,15 @@ The final result of the project, in regards to fulfilled goals, is as follows: The UWB development team encountered several event flags that were not present as one would expect. They also suspect that the ranging functionality file might be better if included as a library, although it is not presented as such. +\subsection{IR - Final state} + \subsectionauthor{Author: Fredrik Grönlund} + Development on IR was halted early in development, as we found that the sonar sensors were perfectly adequate for the application. + In comparison, two IR sensors were required for each sonar, and they still had a worse accuracy, speed and usability. + Thus the developer was moved to SPI and UWB development. + + The sensors were ordered and should accompany this project. + The dev board shield has connectors dedicated to IR sensor connections, although these contacts have since been repurposed as general status LEDs. + \subsection{TODO: COMPONENTS ADD A FINAL STATE. What is done/not done etc.} @@ -57,12 +66,16 @@ The final result of the project, in regards to fulfilled goals, is as follows: The timetables and designs presented early in development were rather quickly abandoned, as they were made with little understanding of the systems. Although the entire team had experience within their separate fields, none had worked on these systems before. Neither had we planned a system of this scale before. - Because of this, timeplans were quickly deemed obsolete as the scale and complexity of the project became obvious. + Because of this, timeplans were quickly deemed obsolete as we realized the scale and complexity of the project. Despite this, we would like to deem this project successful in its primary goal, to test if the idea was feasible. Although some issues were had with some hardware components, this could be resolved by using better components. Software trouble should smoothen out as experience grows, and it did so for our project group. + Team members performed most of their work in the room provided by LTU, letting us cooperate and discuss. + Some uncertainties with the HAL libraries and other functionality was easiest resolved this way, among other general questions regarding development. + This, combined with regular meetings each week allowed us to integrate our work more smoothly, as we were all present anyway. + TODO: Add details from Timers, IMU, SONAR maybe? TODO: Continue this section! diff --git a/components/adc.tex b/components/adc.tex index 6830def484f0663466e9662aa628d11c10313cae..732ac2cf06be68d8f7e78a811fa8186fc85783de 100644 --- a/components/adc.tex +++ b/components/adc.tex @@ -1,10 +1,7 @@ \subsection{ADC} - As the output of the sensors are analogue, the mircroprocessor will require usage of its - internal ADC (Analog-to-Digital Converter). The ADC is configured in the basic Single conversion mode, - as the clock speed is vastly greater than the update frequency of the sensors. ADC conversion is - specified to take at most 15 clock cycles, so the check will block until conversion is complete. - Voltage is mapped through a lookup table (one for each sensor type), approximated using data from the - corresponding data sheets. + Output of the IR sensors is an analogue voltage, so the Analog-to-Digital Converter (ADC) peripherals of the MCU will be used. + The ADC is configured in the basic Single conversion mode, as the clock speed is vastly greater than the update frequency of the sensors. + ADC conversion is specified to take at most 15 clock cycles, making it possible to do in blocking mode without impeding operation too much. \begin{figure}[H] \centering diff --git a/components/ir.tex b/components/ir.tex index 622d11cbc9f176f5c64d141a07903621c5752b81..d471b8a69872bc0407cd0622836053375cfe3f9a 100644 --- a/components/ir.tex +++ b/components/ir.tex @@ -1,27 +1,23 @@ \subsection{IR Sensors} The IR sensors are intended as redundancy to the sonar. - For this task, two different kinds of IR sensors were chosen as redundancy for the sonars. The - long-ranged sensors are meant to cover for the sonar at short range while the short-ranged sensors - are meant to cover the remaining distance. + For this task, two different kinds of IR sensors were chosen as redundancy for the sonars. + The long-ranged sensors are meant to cover for the sonar at short range while the short-ranged sensors are meant to cover the remaining distance. - \subsubsection{Hardware details} - The long-range sensor chosen for the task is - \href{https://www.arrow.com/en/products/gp2y0a710k0f/sharp?wm_g_phyloc=1012273&wm_g_intloc=&gclid=CO%5F1xubhidACFUvqcgodU7cF%2Dw&utm_source=google&utm_medium=cpc&utm_term=sharp+gp2y0a710k0f&utm_campaign=int+%2D+sku+%2D+sharp+%2D+dynamic+inventory}{Sharp GP2Y0A710K0F}. - Its distance measuring range is $\SI{100}{}$ to $\SI{550}{\centi\metre}$. - Accuracy could not be ascertained from the data sheet. - Output of the sensor is a current, where the voltage varies between approx. $\SI{1.5}{} - \SI{3}{\volt} $, where lower values corresponds to longer distance. - Measurements are carried out continuously every $\SI{16.5}{\milli\second}\pm \SI{3.7}{\milli\second}$, - and output is updated after maximum $\SI{5.0}{\milli\second}$.\cite{sheet:ir_long} + The long-range sensor chosen for the task is + \href{https://www.arrow.com/en/products/gp2y0a710k0f/sharp?wm_g_phyloc=1012273&wm_g_intloc=&gclid=CO%5F1xubhidACFUvqcgodU7cF%2Dw&utm_source=google&utm_medium=cpc&utm_term=sharp+gp2y0a710k0f&utm_campaign=int+%2D+sku+%2D+sharp+%2D+dynamic+inventory}{Sharp GP2Y0A710K0F}. + Its distance measuring range is $\SI{100}{}$ to $\SI{550}{\centi\metre}$. + Accuracy could not be ascertained from the data sheet. + Output of the sensor is a current, where the voltage varies between approx. $\SI{1.5}{} - \SI{3}{\volt} $, where lower values corresponds to longer distance. + Measurements are carried out continuously every $\SI{16.5}{\milli\second}\pm \SI{3.7}{\milli\second}$, + and output is updated after maximum $\SI{5.0}{\milli\second}$.\cite{sheet:ir_long} - The short-ranged sensor chosen is - \href{http://www.digikey.se/product-detail/en/sharp-microelectronics/GP2Y0A02YK/425-1165-ND/457883}{Sharp GP2Y0A02YK}. - It has a distance measuring range of $\SI{20}{}$ to $\SI{150}{\centi\metre}$ with an accuracy of - $\pm\SI{10}{\centi\metre}$. Output of the sensor is a current, where the voltage varies between - $\approx\SI{0.5}{} - \SI{2.7}{\volt} $, where lower voltage corresponds to longer distance. - % TODO: Add a picture? - % The voltage curve is demonstrated in Figure \ref{fig:short_ir_voltage}. - Measurements are carried out continuously every $\SI{38.3}{\milli\second}\pm \SI{9.6}{\milli\second}$, - and output is updated after maximum $\SI{5.0}{\milli\second}$.\cite{sheet:ir_short} + The short-ranged sensor chosen is + \href{http://www.digikey.se/product-detail/en/sharp-microelectronics/GP2Y0A02YK/425-1165-ND/457883}{Sharp GP2Y0A02YK}. + It has a distance measuring range of $\SI{20}{}$ to $\SI{150}{\centi\metre}$ with an accuracy of + $\pm\SI{10}{\centi\metre}$. Output of the sensor is a current, where the voltage varies between + $\approx\SI{0.5}{} - \SI{2.7}{\volt} $, where lower voltage corresponds to longer distance. + Measurements are carried out continuously every $\SI{38.3}{\milli\second}\pm \SI{9.6}{\milli\second}$, + and output is updated after maximum $\SI{5.0}{\milli\second}$.\cite{sheet:ir_short} \ No newline at end of file diff --git a/implementation/collision-avoidance.tex b/implementation/collision-avoidance.tex index a35a2aa2ad1dffc9215217defeba0a0308b17c09..3521fe1df79e13a8e123bf4cb7a467de931d52df 100644 --- a/implementation/collision-avoidance.tex +++ b/implementation/collision-avoidance.tex @@ -1,21 +1,29 @@ \subsection{Collision avoidance} \subsectionauthor{Author: Lars Jonsson \\Reviewer: Max Unander} -To be able to fly the copter up and down these shafts without colliding, we have put six ultrasonic sensors on the copter in each direction, see figure \ref{label}. -In this case there will be three pair of sensors, where each pair represent one axis in the Cartesian coordinate system. +To be able to fly the copter up and down these shafts without colliding, we have put six ultrasonic sensors on the copter in each direction. +For this project there will be three pair of sensors, where each pair represent one axis in the Cartesian coordinate system. +In Figure~\ref{fig:twosonarcopter} you can see one of these pairs mounted on the x-axis. + +\begin{figure}[H] + \centering + \includegraphics[width=0.6\textwidth]{Pictures/copter_above} + \caption{Copter at early stage with only one sonar-pair mounted.} + \label{fig:twosonarcopter} +\end{figure} + With help of the measurement from each sensor, a controller for collision avoidance will be implemented. The collision avoidance will consist of three individual PID-controllers, where each one will control the position on each axis. - To get this to work we will have to map the copters movement in the Cartesian coordinate system to roll, pitch and throttle commands that will be sent to the flight controller. This will work in the way that the output from the PIDs in each direction will be represented by either a pitch, roll or throttle command to the flight controller. \subsubsection{PID - controller} -The PID controller will have the difference value between the measurement of the two ultrasonic sensors as control variable, and it's task is to converge this difference into 0. +The PID controller will have the difference value between the measurement of the two ultrasonic sensors as control variable, and it's task is to converge this difference into 0. When the difference value goes to 0 it means that the copter is right in the middle between two objects. The output of the PID will be a number between 1000 and 2000, because that is the input the flight controller can receive. -The input to the flight controller is a linear function where for the roll and pitch command where 1000 represents by a setpoint of $-10^\circ$ and 2000 will induce a setpoint of $+10^\circ$. +The input to the flight controller is a linear function where for the roll and pitch command 1000 represents by a setpoint of $-10^\circ$ and 2000 will induce a setpoint of $+10^\circ$. This function is linear so 1500 represent no inclination. -For the throttle command 1000 will be no throttle at all and 2000 will set full throttle to the motors. +For the throttle command 1000 will be no throttle at all and 2000 will set full throttle to the motors. The yaw command do differ a bit, it will not set a specific set-point, it will instead set an angular velocity to the copter. This so that the copter can spin freely around it's own axis. With this setup we wont have any controller to keep the heading of the copter, which should be implemented in the future. @@ -30,24 +38,37 @@ When we had the hovering function working quite good, we started out with trying To do this we used the SonarDifference algorithm mentioned above. We started out with just the P variable and saw that it "bounced" a lot between the walls. We concluded that we needed the D parameter as well to reduce the bouncing. -When we saw that this worked we started to fine tune the variables. -This was done by logging data while flying, and afterwards we could check the graphs and from those do some conclusions on how we should change the variables. -The graphs from the final tuning of the \texttt{PID\_Roll} is shown in Fiugre~\ref{fig:PIDtuning1}. +When we saw that this worked, we started to fine tune the variables. +This was done by logging data while flying, plotting of the data, and from those do some conclusions on how we should change the variables. +Before tuning the plots did look like the on in Figure~\ref{fig:PIDtuning1}. +In this graph we see that the Roll command is clipped a lot. +This is because the controller is to aggressive and the roll command reaches its maximum/minimum values at 1750 and 1250. +These maximum values are changeable, and we saw that $1500\pm{250}$ worked quite well. \begin{figure}[H] \centering - \includegraphics[width=0.7\textwidth]{Pictures/PIDtuning1} - \caption{This shows how the intended communication between the radio-transmitter, MCU and flight controller was going to be implemented.} + \includegraphics[width=0.6\textwidth]{Pictures/PIDtuning1} + \caption{SonarDiff X, shows the difference between the measurement of two sonars placed on the same axis. ROLL command show the value that is sent to the flight controller. SWH is the switch that starts the PID, how these are mapped on the RC transmitter can be seen in Table~\ref{tab:controller_channels}.} \label{fig:PIDtuning1} \end{figure} \begin{figure}[H] \centering - \includegraphics[width=0.7\textwidth]{Pictures/PIDtuning3} - \caption{This shows how the intended communication between the radio-transmitter, MCU and flight controller was going to be implemented.} + \includegraphics[width=0.6\textwidth]{Pictures/PIDtuning3} + \caption{Plot of the final testing of the gain variables in the \texttt{PID\_ROLL} function.} \label{fig:PIDtuning3} \end{figure} +We tested to lower the P gain and increase the D gain and this resulted in the plots shown in Figure~\ref{fig:PIDtuning3}. +Here we see that the roll command never saturates, and that the Sonar Difference do less oscillations. +Of course these controllers needs to be further improved for an finished product, but this is good enough to show that this is possible. +We used the same variables for the \texttt{PID\_PITCH} function, as the pitch controller is implemented in the same way as the roll controller. + +When trying out these PID's we flew the copter with the RC controller up to a certain height, started the hovering function. +Tried to keep the copter in the middle of the corridor before starting the PID roll or pitch controller. +At this point we could let go of the RC controller and the copter stayed between the walls with some oscillations. +To land we turned off the PID(roll/pitch) started the landing function, lowered the throttle and the copter should land smoothly. +How these functions are mapped on the RC controller is show in Table~\ref{tab:controller_channels}. \begin{table}[h] \centering diff --git a/implementation/flightcontroller_imp.tex b/implementation/flightcontroller_imp.tex index ed5dd4b889f66b2152e9f910bdd1c31472992e7c..189171229ba60b4294bf048b51d39b19c150be08 100644 --- a/implementation/flightcontroller_imp.tex +++ b/implementation/flightcontroller_imp.tex @@ -18,7 +18,9 @@ To be able to do this we need to interact with the flight controller from our MC The flight controller do have support for four different communication protocols. It can take PWM inputs, where one PWM controls one channel. +%It has It have PPM support, which is quite the same as a PWM but it has support for 8 PWM signals on one line. +%does? It do support sBUS, which is some sort of secure serial protocol with inverted signals. The last protocol it supports is called MSP (MultiWii Serial Protocol), which also is a serial protocol. Our first thought was that we wanted to implement both the MSP and PPM protocols to control the copter. @@ -74,7 +76,7 @@ There are some things that was needed to be setup in Cleanflight to be able to f \end{itemize} All our configurations that was set in Cleanflight can be shown in the Appendix \ref{label}. -TODO: Ta config från cleanflight lägga in i en appendix. +TODO: Add the configs from Cleanflight into an Appendix, will be done after Christmas. diff --git a/main.tex b/main.tex index aa530120dd5f02346ddc854c3a77541351006012..c5bd869432a274f16377a3417268c72dc2b12cb8 100644 --- a/main.tex +++ b/main.tex @@ -82,8 +82,8 @@ \input{./components/sonar} \input{./components/spi} \input{./components/uwb} - \input{./components/adc} \label{sec:adc} \input{./components/ir} \label{sec:IR} + \input{./components/adc} \label{sec:adc} \input{./components/flightcontroller} \input{./components/copterparts} \input{./components/circuitboards}