Sunday, December 10, 2017

06 December '17- Project 3- Rocket Payload

Project 3:
Our lab group consisted of Matthew, Richard, and I.  we decided to utilize the MPU 9255 9 axis sensor along with an SD card to store the data and an arduino Nano to run out program on.  We were initially given an arduino micro but quickly found out we did not have enough storage to fit our entire code onto.  Once we could fit our program on the Nano, we began to put all the sensors together and start soldering.  I initially thought it would be better to solder everything onto a perforated board.  Professor mason advised that it would be easier to solder everything directly to the board directly without having to use perforated board.  I continued on my initial plan of using the board and quickly understood why he suggested against it.  The board was insufficient in keeping any sort of solder properly secured onto it and also the pins soldered onto the arduino didn't absorb any solder when heated up.  So, after having most of the components on the perforated board i had to discard of the pins and find another Nano to use since the pins would not unsolder.  After lots of desoldering and soldering the payload was tested out with the final iteration of the code.  At first it seemed fine but realize there needed to be some modifications to account for certain values.  On launch day, the class was at a mad scramble to finishing packaging the rocket payloads, finding center of gravity, adding nose weight, and folding parachutes.  At the end of the day everyone had a successful launch and every group was able to successfully retrieve data from the payloads.
(screen shot for the initial startup for the payload; we would eventually scrap it due to storage limitations on the board) 
(The Nano we initially used but was not working and replaced afterwards)
(we had took a picture f the error that  kept popping up when trying to upload the program; problem was the usb cable we were using)


(Screen shot from Matthews laptop of the program that would go onto the Nano)





(testing out the payload after completing the assembly) 




(using styrofoam board for packing into rocket)



(Matthew, David, and I after walking out to where the rocket landed.  unsuccessful launch,  the motor tube centering ring came out and separated from the bottom half of the rocket.  Richard can be seen in the distance picking up the bottom half)


(the data from our rocket launch; includes: acceleration, gyro, magnetic field, yaw, pitch, roll, pressure, and altitude; our max altitude was 1940.6 ft)

30 November 2017- Day 26- Real Time Telemetry/ MPU 9255/ Complex Class

Day 26: Todays lab was introducing u to real time telemetry and the MPU 9255.  The real time telemetry module is often used for quad copters and is a fairly inexpensive option for seeing what is going on as its happening.  a simple usb connection to the computer, RX and TX connection on arduino with power and ground, and this module is simple to setup.  One other necessity is to download another serial monitor to be able to see live data stream onto your computer.

(connection made to Arduino for real time telemetry.)
The other portion of the lab was to setup up a MPU9255. This sensor is a 9 axis MEMS sensor with an integrated BMP 280 pressure sensor.  This module can read acceleration, gyro, and magnetic field in 3 directions along with the pressure and altitude.  My lab partners had success in getting both the telemetry and also the MPU9255 to work and sen back data to the serial monitor.  This was critical portion in our project to be able to get and record data for the flight of our rocket.

(fritzing diagram for the MPU9255)
After the lab we began discussion on Complex class with overload operators.  Professor Mason began to talk about complex number and also complex roots for the quadratic equation and thats where i began to get lost.  At this point in the class i began to put most of my focus on project 3, which was getting the rocket payload to work properly with my lab partners.  Matthew and Richard both tackled the coding while I worked on building the rocket we would launch and also the hardware soldering and packaging of our arduino into the rocket payload section.



28 November 2017- Day 25- EEPROM and C++ classes

Day 25: Lab began with learning about another way to store data collection but on the arduino board itself.  EEPROM stands for Electrically Erasable Programmable Read-Only Memory. 
The neat thing about this form is that it can remember things even when there is no power.  this kind of memory can store generated due inside of a sketch on a more permanent basis.  Certain situations such as a cycle counter where a user is not allowed to reset the count could be useful for this type of memory.  It is also possible to add more EEPROM storage external with the addition of I2C EEPROM chips that can greatly increase the Arduino storage.  For the lecture portion of class we began discussion of C++ classes.  These classes are separated into two parts: the declaration and the implementation.  The body of the class declaration has declaration statements for the data members and function prototypes for the function members. Class implementation consists of all the member defined functions.  We also discuss constructor functions.  These functions are special member functions that are automatically called when an object in that classed is declared.   Another topic we went over in class what the class operators.  The ability for the user to overload operators in C++ is a powerful feature that can be as easily as predefined data type.  

Saturday, December 9, 2017

21 November '17- Day 24- Python Visualization and MPU 6050

Day 24 started with a Mega Lab as Mason describes it.  This lab was to include a visual representation of objects in motion using Python and also involved the usage of the MPU 6050.  The python lab was a bit of a disappointment on my end since my laptop was unable to download all the necessary software to use in the lab.  My lab partners were successful in getting the python running on their laptops.  I stood by and watched as they adapted the Python code into the Arduino IDE.  One of the sensors that first utilized in python was the ultrasonic HC-SR04 sensor.  This sensor can give an accurate distance of an object.  The Python visualization portion of it allowed the program to change the length of a cylinder by integrating the distance sensors reading when moving your hand toward and away from it.  The MPU 6050 is an Inertial Measurement Unit.  This device can measure with an integrated accelerometer, gyroscope, magnetometer, and altimeter.  Once we got the python visualization to work properly on the computer we then carried on to the sensor and getting data to read back from it.  The sensor gave our lab group some initial troubles since our data was not quite exact to what other groups were getting.  We found out later on that we had the wrong sensor and had to find the correct one to use.  Once we got situated the sensor values came out as predicted.

(An example of how the accelerometer function in the IMU)

(interfacing the MPU6050 with the arduino)
(implementing the sensor for our rocket project; the pitch, yaw, and roll of the rocket described above )





16 November 2017- Day 23- C++ Skills Improvement/BMP180 Pressure Sensor

Day 23: The lab for today included the BMP180 sensor.  This sensor is capable of reading pressure value range between 30,000 and 110,000 Pascals.  The board also include a temperature sensor that is capable of detecting a range between 0 and 65 C.  This sensor is ideal for measuring pressure changes and can be utilized for altimetry inside of our rocket project.  The board is I2C compatible which makes it a great addition to any related projects using this digital interface.


(A simple connection to the Arduino board for the BMP180)
 Note that this sensors maximum supply voltage is 3.6v.  Do not connect it to the 5v pin on the arduino.
For the lecture portion of class we were given more insight on a C++ program that can determine which direction the trade winds will be blowing.  This following is the program for the tradewinds:
#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
/*  Declare variables.  */
int r, c, k, maxk=0;
int grid[5][5], category[8]={0,0,0,0,0,0,0,0};
double perc;
char* direction[8]={"N  ","NE ","E  ","SE ","S  ",
"SW ","W  ","NW "};
ifstream winds;
/*  Read and print information from the file.  */
winds.open("winds1.txt");
if (winds.fail())
     cout << "Error opening input file." << endl;
else
     {
     for (r=0; r<=4; r++)
          winds >> grid[r][0] >> grid[r][1] >> grid[r][2]
          >> grid[r][3] >> grid[r][4];
     //  Determine sums for the direction categories.
     for (r=0; r<=4; r++)
          for (c=0; c<=4; c++)
          {
          k = grid[r][c];
          category[k]++;
          }
//  Determine category with maximum sum.
     for (k=0; k<=7; k++)
          if (category[k] > category[maxk])
               maxk = k;
//  Print report.
cout.setf(ios::fixed);
cout.precision(1);
perc = (double)category[maxk]/25*100;
cout << "The wind is blowing from the " << direction[maxk–1]
<< perc << "% of the time." << endl;
//  Close file.
winds.close();
}
//  Exit program.
return 0;

}

For homework, we took this program and modified it to output a percentage and direction of the winds blowing, a possible hurricane/cyclone output, and also read from a data file of 100 rows by a 100 columns.  

14 November 2017- Day 22- Introduction to C++ and logging with SD cards

Day 22:
The affordable nature of working with arduino and the ease of implementation for just about any electronic sensor allows this platform to be an ideal solution for collecting large amounts of data.  The only drawback to the arduino is the limited space available on the chip for storing data.  One way around these restrictions is to include an SD card to store .csv files that can be easily retrieved and also stored in large data sets.  A good example is a weather station.  They require to be put in remote locations and left to collect for long periods of time.  Storing all the information such as pressure, wind speed, temperature, and humidity can be easily accessed in an excel file.
Before starting to use an SD card you must format the card to the proper file system type.  The arduino also comes with an SD library with all necessary functions to properly implement into your program.  When writing to an SD card it is important to note that the file names must be in 8.3 format.  This means the extension can only be 3 characters and the name must be 8 characters or fewer.  Reading from an SD card can be helpful for setting program parameters. For homework we were required to implement the SD card and a temp sensor to collect the temperature once a min and store into an excel file.

(example of the program for saving to SD card.)
(SD card shield hooked up to Arduino; buttons were just left on breadboard)

For the lecture we were introduced to the C++ language.  We noticed of the bat that a lot of the same features in the C language translate almost verbatim to the C++.  C++ also had some new features but not much different than its predecessor.  The following are a side by side example of the same program in both C and C++ to see the differences between the syntax but have the same output:
 Velocity/Acceleration Program in C:
#include <stdio.h>
#include <math.h>

int main(void)
{
/* Declare variables. */
double time, velocity, acceleration;
/* Get time value from the keyboard. */
printf("Enter new time value in seconds: \n");
scanf("%lf",&time);
/* Compute velocity and acceleration. */
velocity = 0.00001*pow(time,3) - 0.00488*pow(time,2) + 0.75795*time + 181.3566;
acceleration = 3 - 0.000062*velocity*velocity;
/* Print velocity and acceleration. */
printf("Velocity = %8.3f m/s \n",velocity);
printf("Acceleration = %8.3f m/sˆ2 \n",acceleration);
/* Exit program. */
return 0;
}

Same program in C++:
#include <iostream>
#include <cmath>
using namespace std;
int main(void)

{
// Declare variables.
double time, velocity, acceleration;
// Get time value from the keyboard.
cout << "Enter new time value in seconds:" << endl;
cin >> time;
// Compute velocity and acceleration.
velocity = 0.00001*pow(time,3) - 0.00488*pow(time,2)
+ 0.75795*time + 181.3566;
acceleration = 3 - 0.000062*velocity*velocity;
// Print velocity and acceleration.
cout.setf(ios::fixed);
cout.precision(3);
cout << "Velocity = " << velocity << " m/s" << endl;
cout << "Acceleration = " << acceleration << " m/s^2" << endl; // Exit program.
return 0;
}


First off, you notice the input and output statements at the beginning of the program. Also, the print statements have a different syntax with cout and << for setting what needs to print out from the program.     We start to find out that the same way functions, arrays, and data files are used in C are also used similarly in C++.  

09 November 2017- Day 21- Dynamic Data Structures

Day 21: Class began with the lab using more interrupts with timer this time. This time we used a speaker that would pay a certain note scale that would change by an octave when a button was pressed at any point in the progression.  The volatile variables change inside the interrupt.  Also, the timer interrupt function is set to milliseconds.

(fritzing diagram for the speaker interrupt lab)
The class lecture was on dynamic data structures.  Data structures can store data and allocate memory, when required, depending on the size of the data file.  also, they can shrink and grow during the execution of a program.  There are certain pre defined data structures in C such as, int, boolean, and character.  These are known as primitive data structures.  There's also user defined data structures such as arrays, lists, and files.  Lists have both linear and non-linear forms.  There are certain advantages and disadvantages to each type.

07 November '17- Day 20- Arrays Structures and Timer interrupts part 1

Day 20: the day of reckoning. As we began the class, we felt a eerie aura surround professor mason as he walked into the classroom grinning from ear to ear.  He had a look in his eyes that would make any grown person tremble to the bone.  His long strides felt thunderous as he made his way to the front of the classroom.  He carried his head high and peaked out to the students as their lingered over their keyboards as they furiously try to finish whatever work they hadn't finished.  It has become apparent that most students have succumbed to the ever dreary nearing end of the semester.
The lab began with introduction into interrupt timers.  This neat little trick allow the Arduino to work almost simultaneous with multitasking.  In essence, it effectively can weave tasks together.  Using hardware interrupts are triggered depending on the state, or change of state, of an input I/O pin.  this allows you to not have to poll the state of a button each time through the loop.  hard ware interrupts are a trade off from polling input pins.  to ensure the arduino is listening for the interrupt you must declare the variable with volatile before the variable you want to watch.  part of the homework was to implement a CdS sensor to immediately change an LED red when the sensor goes dark.
(the program for the interrupt lab)
After the lab professor mason introduced us to the arrays of structures in C.  Structures allow us to sort information in arrays with multiple variables and be able to access within the array for any structure. Again for homework we have to categorize hurricanes and be able to utilize the structures to input names, categories, and also dates for each storm.

(given table of information for homework)

For homework we had to use this table to write a program that will be accessible for modifying and printing out different data sets.