User:Dpatel5391/enes100/Helicopter

Link to project Helicopter team page.

Give instructor top 3 project choice list
My top three project choices are Helicopter, Airplane Float, and Model boat. I am currently working on Helicopter project.

Write problem statement
In previous attempts, the Arduino code (C++) used by Masood Muhammad made it easier to add more functionality, including starting the motors with delay or at once. However, they were unsuccessful at writing a code that operates accelerometer and runs motors at once.

Link to their pictures: Previous Arduino Attempts

Assign Task1
The task I was assigned for Week1 was to learn how to use the Arduino software and download the required libraries to operate motors and accelerometer.

Compare actual work done to Task1
This task was very useful, since now I know how to write and edit a sketch. The work I completed in Task1 was really helpful to me in understanding how the Arduino software works by using C++ codes and libraries. Using the Arduino with my computer helped me understand how writing different codes or making mistakes changes its functionality.

Week1 Narrative
I have downloaded the Arduino Software, you can find the windows version at "WinOS-Downloads". The version I have downloaded is 0022, which is the latest stable release as of today. Before I started to use the software, I needed to learn how to write the sketches, such as C++ codes and libraries. The following are five of the most important guides to learn the software basics.


 * Arduino Development Environment: This is a manual on using Arduino, which explains how to use a text editor for writing code, a message area, a text console, series of menus and toolbars, and also explains how to upload your sketch step by step.


 * Jeremy Blum's video guide: This is a video guide, in which Jeremy explains what an arduino is and goes through the downloading process, materials needed, running the program, writing the code, and uploading it onto the arduino. He has uploaded a total of 13 tutorial videos, in which he guides us through various functionalities of Arduino by writing different, specific codes for each of them. Those videos might be helpful to me in later activities.


 * Arduino Troubleshooting, Archive for the ‘Arduino’ Category, and Correcting Arduino Compiler Errors: These tutorials go over many different errors that we might get when trying to program arduino and show how to resolve them.

I am currently working with three devices, Arduino-UNO, Arduino breadboard, and Accelerometer ADXL335. I couldn't get to work with the accelerometer and the breadboard, since I kept on getting an error when trying to upload the sketch (I used the code from Jeremy Blum's video guide /10:15/ for a test). Everytime, I tried to upload this sketch I kept on getting an error message saying:

Main Error: function 'void setup' is initialized like a variable

sketch_sep25a:10: error: function 'void setup' is initialized like a variable

sketch_sep25a:11: error: expected qualified-id before ')' token

sketch_sep25a:12: error: expected constructor, destructor, or type conversion before '(' token

To correct these errors, I used the link Correcting Arduino Compiler Errors /Line 12 Error/, which explains that I made a mistake when entering the code where I needed to use curly brace "{, }" instead of parenthesis. I corrected my mistake; however, I had another mistake where I forgot to capitalize the letter P in "ledPin." After I corrected all of my mistakes, I successfully uploaded the sketch onto the arduino.

Here's the picture and my sketch of how it should look like after you're done uploading it.

There's also another way to do the same functionality, but in this case the software itself writes the code, which you can upload and don't have to worry about getting any errors.

1) Run the Arduino Software 0022, 2) under File menu, go to Examples > Basics > Blink > Upload.

Besides doing these activities, I also went to College Park Airport located onto 6709 Corporal Frank Scott Dr. for helicopter tail configuration. Mr. Paul had two air crafts disassembled for inspection. For one of them he was working on the main rotors and for the second one he was working on the tail and the engine. He took out the tail and made it easier for me to document the configuration of it and here're some pictures I took. It was really a great experience to see the helicopter and learning about it. From Mr. Paul, I learned so much about why the helicopters are designed in specific ways.

Week1 Peer Review
My comment was regarding to how Matt should share his work with group members.

Assign Task2
I am planning to connect the Arduino with my computer again via USB cable, but this time I am going to upload different types of sketches to run motors using Motor Control Shield for Arduino.

Compare actual work done to Task2
This task was really time consuming, yet interesting, fun, and one of my favorites. The work I completed in Task2 was really helpful to me in understanding how to write different sketches to run four DC-motors using the ports M1, M2, M3, and M4; and also in determining if I was able to run all motors either in the same or different directions at once.

Week2 Narrative
I have downloaded the |944l3|526933304|AFMotor.rar|6|R~D7E9166CDDFC24E3D4BA8A3905932087|0|0 AFMotor library from http://www.ladyada.net/make/mshield/download.html, where you can also download Arduino Stepper/Servo software library with microstepping support and AccelStepper library with AFMotor support. Before I start using the AFMotor library, I needed to know what the library is used for, how it works, and how to install it. The following are three of the most important guides to learn about the libraries.

Arduino Hacks: Libraries. This is a manual on using different types of libraries, which basically explains how to install, import, and use the libraries.

Jeremy Blum's video guide. This is a video guide, in which Jeremy explains and talks about NPN Transistor and PWM, which allows to run a motor faster through arduino. He also talks about using the different motor libraries, and writing appropriate sketches when using different motors, such as DC-motors, survo and stepping motors.

Motor Shield. This tutorial includes powering the DC motors, voltage and current requirements for the first section. The second section is about how to set up the arduino and the motor control shield for powering motors, and the remaining sections cover Survos, DC-motors, and Steppers. The last two sections include step by step directions on how to run the motors using the sketches they have provided. I have tested those sketches and they seem to work very well.

Note: if you were to download the AFMotor library I have provided. Follow these steps:

1) Download and extract the files onto your Desktop.

2) Copy the AFMotor folder and paste it into your existing folder: Arduino-0022/libraries/

Now, you can easily import the library by going to Sketch > Import library > AFMotor. You can also import the motor sketches by going to File > Examples > AFMotor

I am currently working with six devices, including Arduino-UNO, the breadboard, motor control shield, DC-motors, stepping motors, and AC power adapter for arduino. Here's the overall picture of how I connected the Arduino UNO, the motor control shield and the DC-motor.

When trying to upload the first Motor-test sketch, I kept on getting an error message

Problem uploading to board.

Binary sketch size: 3318 bytes (of a 32256 byte maximum)

avrdude: stk500_getsync: not in sync: res=0x30

avrdude: stk500_getsync: protocol error, expect=0x14, resp=0x51

To correct this error, I used the link Arduino Troubleshooting, which was already provided under the error window. There are many questions listed on the page, where I was more interested in "Why do I get errors about an invalid device signature when trying to upload a sketch?" The only answer to this question was that either you have the wrong board selected from the Tools > Board menu or you're not using the right version of avrdude. The problem with me was that I selected the wrong board-COM3 instead of COM4. Now I was able to upload the sketch and run the motor through M4-port of the motor control shield.

There're two ways you can change the directions in which the motors spin. One way is to write a sketch that spins the DC-motors either only in "FORWARD" or "BACKWARD" direction. Another way is to change the order of the wires connected to the ports of the motor control shield (I mentioned about it in My Video). This basically means the motors would start spinning by the time we plug the wires into the ports (M3 & M4) and stops when taking out of the ports. If I want to run the motors in "FORWARD" direction, I would delete the parts which I don't need, including the variables "BACKWARD (reverse)," and "RELEASE (stop)." I used the yellow and red LEDs to test whether the M3 and M4 are both working at the same time or not. Finally, I came up with the Sketch I was looking for and here's the picture showing the two LEDs turned on at once.

Now, it was the time to write a sketch that spins four DC-motors at once; however writing the sketch was pretty easy and straight forward, since all I had to do was to add six more variables to the previous sketch. Here're the changes I made to the previous sketch to get the    Final Sketch:

First I added:

AF_DCMotor motor3(3);

AF_DCMotor motor4(4);

Then under 'void setup' I added:

motor3.setSpeed(200);

motor4.setSpeed(200);

and under the 'void loop' I added:

motor3.run(FORWARD);

motor4.run(FORWARD);

The problem which I was most concerned about was that when I tested the connection of each ports using LEDs, they were all working good (here's My Video); however, when I connected all four motors to it, I saw that only three of the motors were working and one of them didn't even spin once. Here's the Video I took explaining the problem and realizing that the power shortage was the main issue. The problem was fixed when I connected the arduino to AC power adapter; however the power was going back and forth so the motors were also functioning in the same way.

Week2 Peer Review
My comment was again regarding to how Matt should share his work with group members.

Assign Task3
I am planning to continue with the Arduino UNO, and the motor shield but this time I am also going to use the Accelerometer ADXL335 and upload different types of sketches to run steppers and DC-motors all at once using external power supply.

Compare actual work done to Task3
This task was also time consuming, yet exciting. The work I completed in Task3 was really helpful to me in understanding how the accelerometer ADXL335 works using Prototype with whitebreadboard attached to it and all of these attached to the Arduino UNO. It also helped me understand how you can actually run DC-motors and stepping motors at once in which the two DC-motors uses M1 and M2 ports, where as the only one stepping motor uses two ports, M3 and M4. I didn't get to learn much about Accelerometer ADXL 335 and I admit that it's really complicated than I expected.

Week3 Narrative
For this task, I didn't have to download anything since I already have everything I needed from the previous tasks. Like wise, I also had the Stepper librarary which was included in the AFmotor library. Since past two weeks, I've been working with the arduino, motor control shield, whitebread board, and the DC motors. Now it's the time to learn about the Accelerometer ADXL335 and the stepping motor. Here are the links to guides and basic explanation of each guide.

Analog Devices: This is one of the most important guides, which explains everything you need to know about the Accelerometer ADXL335. The link goes through general description of the accelerometer, functional block diagram, specifications, Pin configuration and function description, typical performance characteristics, Mechanical Sensor, Applications information (such as Power Suply Decoupling, Self-Test, Setting the Bandwidth using CX, CY, and CZ), Axes of Acceleration Sensitivity, and Outline its three dimensions (X,Y, and Z). Motor Shield (stepper): This is a guide to learn about stepper motor. It explains how Bi-polar steppers are different from Uni-polar steppers and their differences in writing sketches. There's also a picture of a Bi-polar stepper (4 wires). It also provides a Test-Sketch for it.

Circuit for Bipolar Stepper Motor: This is a diagram of how Bi-polar steppers are different from two pins to four pins.

Circuits for Unipolar Stepper Motors: This is a diagram of how Unipolar steppers are different from two pins to four pins.

Driving a Unipolar Stepper Motor: This tutorial shows how to write a sketch for Unipolar Stepper and run it.

The main difference between DC motors and steppers is that the motor control shield can drive up to 4 DC motors bi-directionally, where as it supports only up to 2 stepper motors. Running a stepper is a little more intricate than running a DC motor. I already have a sketch for running 4 DC motors at once, and now I'm interested in running a stepper motor with 3 DC motors. Here's the list of devices I used for this task:

Arduino UNO

Accelerometer ADXL335

Motor Control Shield

Prototype with Whitebread board

Three DC motors

One Stepping motor

Here's the overall picture of how it should look like after you have attached everything together. (Note: you won't be able to attach the Motor Control Shield and the Prototype to the arduino at the same time.) Picture of Motor Control Shield attached to the arduino, and Picture of Prototype attached to the arduino.

Now, I am more interested in writing a sketch that will run a stepper motor. For the first trial, I used the sketch provided by the AFmotor library. Here's how to access the sketch: Run the arduino software > File > Examples > AFmotor > Stepper motor, then upload this sketch onto the arduino. Once you have uploaded the sketch, Here's how to connect the wires of a Bi-polar stepper motor (4 wires): You have total of 4 wires to a stepper motor. (Note: No matter which side you choose, the connection to the ports is always the same.) The first wire goes into the first port of M3, the second wire goes into the first port of M4, the third wire goes into the second port of M3, and the fourth wire goes into the second port of M4. Here's the Picture of it. As soon you attach the last wire, the motor should start spinning. Here's the overall Picture of how it should look like when you're finished connecting the wires.

Now, I see that the motor spins in both directions; however I want the motor to spin only in one direction as DC-motors in Task2. I also want to add the DC-motors to it, so I can run all at once. So here's how I edited the Sketch. Here's the Picture of it. Hit Next for the other half of the sketch. I have also uploaded my video showing how to run 2 or more DC motors when running with 1 stepper motor; however I couldn't get to run more than 3 DC motors with the stepper motor due to power shortage.

After completing my task for the stepper motor, I started working on the Accelerometer ADXL335.

What is Accelerometer ADXL335? "The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with signal conditioned voltage outputs. It measures acceleration with a minimum full-scale range of ±3 g. It can measure the static acceleration of gravity in tiltsensing applications, as well as dynamic acceleration resulting from motion, shock, or vibration." Applications for which I will need the Accelerometer ADXL335 are Cost sensitive, low power, motion- and tilt-sensing. The motor also creates different sounds which you can refer to for changing the directions of it. Here's a basic Diagram of Accelerometer ADXL335 and Picture of how to connect the Accelerometer ADXL335 to the Arduino UNO. Learning and writing the Accelerometer sketch by self is far more complicated than using a tested-working sketch provided by arduino professionals. Here's the Picture of the sketch I used to test the Accelerometer ADXL335. Hit Next three times to see the complete view of the sketch. Click Here to download the sketch. Here's a Picture of how the accelerometer works using hand coordination and tilting in different directions.

When I was doing an LED-test for the connection of the ports from Prototype while using the Sketch, here's what I found out:

Regular LED Pin#13 - light is off (Note: It only flashes when I hit the "Reset" button).

v6 Pin (next to GND)- light is normal (Red for a red LED)

All connections from v5 of Prototype Board - light is orange (Note: No matter which LEDs I use, the only outcome is an orange light. I tested it by using yellow, green and red LEDs).

Every ports next to Accelerometer ADXL335 - Light is normal; however I accidently put both wires of the yellow LED into the GND ports and the light just went off and didn't work at all. I also smelled something burning from the Whitebread Board, so I suddenly stopped working and thought of testing the ports using different methods. Picture when I was testing the connection going through different ports when using the prototype and accelerometer. If you hit Next arrow, there're 2 more pictures to it.

Here's a Picture of a motor with the helicopter rotors that I made by hand from scratch. I was looking at this Flour Bag that was attached to a red plastic handle. Then, I took out the handle and cut from both sides equally. Then, I attached those two pieces together by burning them with the remaining plastic strip while attached to the motor. I let it cool down for 15 minutes and then attached the motor to arduino to test and it worked very well.

Week3 Peer Review
My comment was still regarding to how Matt should share his work with group members.

Assign Task4
I've found many tutorials to control the stepper motor speed using variable resistors through motor control shield but haven't found any tutorial that clearly specifies how to control the speed and change the direction of a motor using the Accelerometer ADXL335. I am planning forward to use the accelerometer ADXL335 with the Arduino UNO and have a remote controller speeding up, slowing down, and changing the direction of a motor.

Compare actual work done to Task4
The work I completed in Task4 was really helpful to me in understanding how the accelerometer ADXL335 works with prototype shield. There are only limited sketches available to work with accelerometers, and also few tutorials which explain how to write a sketch to program an accelerometer. The task involved many failures due to use of different types of variables and keeping track of each variable and its function.

Week4 Narrative
For this task, I also didn't have to download anything, since the accelerometer library is already included in the software files. I started Task4 by researching information about Accelerometer ADXL335 and prototype shield. I found the following tutorials which I thought were very important.


 * Playing with an Arduino and sensors: is one of the best tutorials available in details and clearly explains all the topics related to any accelerometer. The tutorial includes total of 11 contents which are:
 * 1)  The Hardware;
 * 2)  First software: reading the IMU data;
 * 3)  Getting rid of zero bias, calculating angles for pitch and roll, and a mysterious foo factor;
 * 4)  The mathematically painful bit: the Kalman filter
 * 5)  Intermezzo: an idea for an artificial horizon
 * 6)  What about yaw?
 * 7)  Another intermezzo: alternative hardware
 * 8)  Vertical Acceleration Rejection
 * 9)  Cuidado! Lama!
 * 10) The controller
 * 11) Some filtering required


 * Sensing Orientation With The ADXL335 + Arduino: is a basic tutorial that goes through two main topics: 1) "Basic Understanding Of Accelerometers" and 2) "Code For The ADXL335 Or Other Analog Accelerometer." This link also provides a code which you may want to test to see if it works. I tried to test it, but I wasn't sure about how to setup everything in order for the code to work. Here's the code:


 * Here is another sketch I found that I thought was really helpful.

I was really interested in using the sketch; however, I couldn't get the setup correctly. Every time I tried tilting the accelerometer, but nothing worked. I even tried performing an LED test for both of the sketches, but the lights either stayed on or off and didn't function properly.

Week4 Peer Review
My comment was again regarding to how Matt should at least document some of his work.

Start Next Project Week0 activities
I am planning to keep on working over the same project, since I am getting so close to programming a Quadcopter. For the next step, I am going to test the accelerometer using 5 LEDs, and see how the sensor indicates any change in motion, and also planning to write a sketch so that I will be able to run or turn off a motor by using a switch.