Week 2: Project progress & combining functionalities

 About week 2

The aim of this week was to get everyone's individual aspects of the project integrated and working together. For example we had one of the members of the group working on controlling the motors with the L298N controller and another member was working on the autonomous navigation around the animal enclosure (software). Amongst other elements we needed to combine which will be elaborated throughout the blog.

Motor controls & Autonomous navigation 

This week Brandon and Aaron looked to put into practice the algorithm for navigating the animal enclosure by calling the functions made to control the motors via the L298N. The general code to control the motors was figured out in week one by Brandon and a provisional code/plan of attack to navigate the enclosure was generated by Aaron. So, they both spent a session working together to tweak each other’s code and get them working together. The approach they have decided to use was a lawnmower pattern of covering the enclosure as they will typically be rectangular in shape.

Lawn-mower logic

  •          The vehicle will be placed in the bottom left corner front end facing right
  •          The vehicle will move forward base across the width of the enclosure in a straight line.
  •         Once the vehicle approaches the wall it triggers to turn at a set distance. This distance is measured using the ultrasonic sensor mounted on the front of the vehicle.
  •          Once its detected that it approached the wall (At a set distance x) it should turn 90 degrees move forward (up the rectangular pen) then turn 90 degrees again before moving forward towards the left wall of the enclosure and repeat.

An important thing to remember is that when the vehicle is moving from right to left it will need to turn left as it approaches the wall and when moving right to left it will need to turn right. We have encoded this into the program using a counter variable to that for an even or odd value the program will know what direction. 

Visual representation of pathing generated by the logic. 

The code that we used to create this pattern was all from re-using the old code but combining them and adding a small delay to adjust the distance we want to move forward.
This code initializes the turn, but in the function of the normal turn, it starts the motors again so we'll use that to make the car go forward but we'll add a delay which can be adjusted when we're tweaking the car to determine how far the car will be going between each row of the lawnmower pattern. Afterwards it stops the motor and makes the same turn again to make it face the direction it supposed to be going in. We have the same code for both the left turn and right turn with the only difference being which wheel is going forward and backwards, and they both get used in our executeTurn() function where it'll determine which turn will happen based on the turn counter which alternates every full turn that occurs.


Setting up the SD Card to create a CSV file to store data

The SD card that arrived in week 2 proved challenging to figure out as there was issues in finding a way for it save the information that it was receiving from the Arduino to a CSV file which can then be represented as data on a X&Y plot with a heat map.  The group as whole had a meeting at the end of week 2 to find a solution for the SD card issue and it began by making sure the SD card was working as it needed to be and not just for the case of the distance or temperature readings. A basic CSV file was tested to see if a message written within the code naturally save into a file with a chosen name that was also given in the code, once we had seen that this was working fine then the next objective was to have this same outcome however with the data that is being fed into the Arduino from some live testing with the ultrasonic sensor. After some trial and error with a variety of codes we was able to get the SD card to save some readings into the CSV file we desired.

Developed an understanding of how to utilise the generated CSV file within the MATLAB environment 

This code uses MATLAB's 'csvread' function to load data from the CSV file stored on the SD card. It then extracts the temperature and humidity columns from the data stored on the SD card to generate the map in a way that makes sense to the user showing the temperature and humidity for each step the car moved on the pen. 


% Load the CSV file
data = readtable('path_to_your_file/data.csv');

% Assuming the CSV has columns: Timestamp, Temperature, Humidity
% Extract Temperature and Humidity
temperature = data.Temperature;
humidity = data.Humidity;

% Create a figure with 2 subplots
figure;

% Plot Temperature
subplot(2,1,1); % This creates a subplot with 2 rows, 1 column, and selects the first plot
plot(temperature, 'r-'); % 'r-' specifies a red line
title('Temperature over Time');
xlabel('Time');
ylabel('Temperature (°C)');

% Plot Humidity
subplot(2,1,2); % Selects the second plot for humidity
plot(humidity, 'b-'); % 'b-' specifies a blue line
title('Humidity over Time');
xlabel('Time');
ylabel('Humidity (%)');


Producing a mount for fixing all the components to the vehicle chassis 

After week one it was painfully clear that we wouldn’t have adequate space on the chassis to mount and hols all of our components so Brandon designed an Chassis ‘extension’ to be 3-D printed and added to the chassis so we can secure all our components to the vehicle. Thankfully the chassis we are using is designed in a way that allows us to easy add this module on utilising the cute outs in the aluminium body. To avoid making it awkward to attack the module we just need to insert it into 4 of the openings and slide it up to fix it to the body no glue/screws required. 

Improvement made on the mount for the ultrasonic sensor 

During the lab session this week a number of decisions were made to what would be happening to all the other components that would be on the body of the vehicle alongside the ultrasonic sensor. A separate platform would be constructed on the CAD software Inventor by Brandon that would allow the instruments to have more area as well as being able to apply specific holes to be made on the platform using the CAD software to firmly fix in all the parts. The change that has been mentioned would have an impact on the mount for the ultrasonic sensor, as this would mean that instead of being placed onto the chassis itself it would be placed onto the new platform. Altercations have also been made to the design of the mount since the first model (Figures 6 &7) from week 1. The design of the first model when discussed as a group was not seen to be able to keep the sensor as gripped as initially thought. The two large holes on the first model was replaced by 4 identical screw size holes that are equivalent to the holes that is located on the ultrasonic sensor, meaning the sensor can be fixed strongly to the mount with a significantly less chance of it falling out. The next steps from week 1 were able to be achieved with fixing points for the mount extruded out that fit in with the dimensions of the new platform. As well as this the final  touches was made to smooth out the sharp edges. The improved model can be seen below:












Comments

Popular posts from this blog

Week 4: Finalising Week

Week 1: Setting responsibilities, goals and making a start on our project