User Tools

Site Tools


mm-uav_arm_bluetooth_operation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mm-uav_arm_bluetooth_operation [2016/08/02 04:37] dongbinkimmm-uav_arm_bluetooth_operation [2016/10/23 20:22] (current) dwallace
Line 1: Line 1:
 ====== MM-UAV Arm Bluetooth Operation ====== ====== MM-UAV Arm Bluetooth Operation ======
-<!-- Replace the above line with the name of your "How To" Tutorial e.g. How to Laser cut Your Name in Wood --> +**Author:** Dongbin Kim Email: <[email protected]>
- +
-<!-- Everywhere you see <some sentence>, replace it with the answer (be concise), and remove the < and > brackets --> +
- +
-**Author:** <Dongbin KimEmail: <[email protected]> <!-- replace with your email address -->+
 \\ \\
-**Date:** Last modified on <08/01/16>+**Date:** Last modified on 08/01/16
 \\ \\
-**Keywords:** <Arduino, Bluetooth, Serial communication, C++, MM-UAV>+**Keywords:** Arduino, Bluetooth, Serial communication, Cpp, MM-UAV
 \\ \\
- 
-<!-- Add a representative photo of your tutorial below.  Make it centered in the page --> 
  
 {{:bluetooth_operation_2_.jpg?300|}}  {{:bluetooth_operation_2_.jpg?300|}} 
Line 24: Line 18:
   * Know how to write down Arduino sketch, Serial communication   * Know how to write down Arduino sketch, Serial communication
 \\ \\
-  * Perhaps also know how to understand C++ language+  * Perhaps also know how to understand Cpp language
 \\ \\
   * Perhaps additional background needed may include basic electrical engineering knowledge   * Perhaps additional background needed may include basic electrical engineering knowledge
Line 31: Line 25:
 \\ \\
 The rest of this tutorial is presented as follows: The rest of this tutorial is presented as follows:
-  * [[tutorialTemplate#partsListAndSources|Parts List and Sources]] +  * [[mm-uav_arm_bluetooth_operation#partsListAndSources|Parts List and Sources]] 
-  * [[tutorialTemplate#construction|Construction]] +  * [[mm-uav_arm_bluetooth_operation#construction|Construction]]
-  * Programming <!- delete this line if not applicable ->+
   * Final Words   * Final Words
  
Line 40: Line 33:
 US-based vendors to obtain material to complete this tutorial include Amazon.com. US-based vendors to obtain material to complete this tutorial include Amazon.com.
 \\ \\
-To complete this tutorial, you'll need the following items. But I omitted the items from MM-UAV arm assembly because this page is to learn how to manipulate the arm wirelessly. <!-- in table below, replace ??? with relevant information and add additional lines if necessary --> +To complete this tutorial, you'll need the following items. But I omitted the items from MM-UAV arm assembly because this page is to learn how to manipulate the arm wirelessly.
- +
-<!-- Alternatively create: (1) a Google XLS document that's publicly viewable and provide link; and (2) a PDF version of the Google XLS, store the PDF file in your site, and provide link to it --> +
 \\ \\
  
Line 70: Line 60:
 {{:mm-uav_danko_arm.jpg?300|}} {{:mm-uav_danko_arm.jpg?300|}}
 \\ \\
 +Arduino Uno only supplies 6 PWM control pins(3,5,6,9,10,11) and if you connect more than 2 motors, pin 9 and 10 won't work, Since new MM-UAV arm design for current project uses 8 servo motors. and they are arranged in 4 pairs as well as aligned in parallel with each other. I decided to connect one of a pair on Arduino then we can manipulate MM-UAV arm with 4 PWM control pins.  
 \\ \\
 +\\
 +**Step 2. Bluetooth installation**
 +\\
 +\\
 +{{:bluetooth_operation_4_.jpg?300|}} 
 +\\
 +Bluetooth operation is working much, much better in Android enviorment. Please download 'Bluetooth Controller' in Google market.
 +\\
 +\\
 +{{:bluetooth_operation_3_.jpg?300|}} 
 +\\
 +Click 'Set Keys' button and set up the button. 'Data of Key' stands for a data that the app will send Serial communication to Arduino. Make sure you write the same data as in Arduino sketch which is on the next section.
 +\\
 +\\
 +**Step 3. Arduino Sketch**
 +\\
 +\\
 +Please refer the **Programming** section to Sketch Arduino. If you understand Cpp language, you can easily understand the algorithms. When you are done building up Arduino Sketch, Compile the code and upload on Arduino.
  
 +**WARNING** - When you upload the sketch, make sure you take off the VC line(+) of battery for servos. Otherwise, you will encounter lots of operating errors. 
 \\ \\
 \\ \\
-**Step 2**+**Step 4. Bluetooth Settings**
 \\ \\
 \\ \\
-<Additional steps like **Step 3**, **Step 4**, etc>+{{:bluetooth_operation_5_.jpg|}}
 \\ \\
-==== Programming ====+\\ 
 +To set up the bluetooth for yours, you should know how to run AT(Attention) commands. AT commands help you check if bluetooth is connected or not, and help you change name, password, baud rate. The followings are basic AT commands language. 
 +When you type the word at Sent on Serial display, you must check whether you have seen the received word.
  
-A link to the source code can be found <provide URL to your codeprobably saved in this DASL Wiki>.+1. Communications Test : 
 +*Sent : AT 
 +*receive : OK 
 + 
 +2. Change baud rate : 
 +*Sent : AT+BAUD1 
 +*receive : OK1200 
 +  
 +*Sent : AT+BAUD2 
 +*receive : OK2400 
 + 
 +1 : 1200 
 + 
 +2 : 2400 
 + 
 +3 : 4800 
 + 
 +4 : 9600 
 + 
 +5 : 19200 
 + 
 +6 : 38400 
 + 
 +7 : 57600 
 + 
 +8 : 115200 
 + 
 +Baud rate setting can be save even power down. 
 + 
 +3. Change Bluetooth device name: 
 +*Sent : AT+NAMEdevicename 
 +*receive : OKname 
 +(devicename is the name you want the device to be and it will be searched with this name) 
 +Name setting can be save even power down. 
 + 
 +4. Change Pincode: 
 +*Sent : AT+PINxxxx 
 +*receive : OKsetpin 
 +(xxxx is the pin code you set) 
 +Pin code can be save even power down.
 \\ \\
-The goal of the code is <brief explanation> It works in the following way 
 \\ \\
----- +**Step 5. Bluetooth Operation**
-<syntaxhighlight lang="cpp"> +
-#include <iostream> +
-int m2 (int ax, char *p_ax) { +
-  std::cout <<"Hello World!"; +
-  return 0; +
-}</syntaxhighlight> +
-----+
 \\ \\
-The snippet above serves to <fill in the blank>. It does this by <fill in the blank>.+\\ 
 +{{:bluetooth_operation_1_.jpg?300|}} 
 +\\ 
 +Once you are done setting up through AT Commands, Connect the power to Arduino and Motors. Then, click 'Scan' on Bluetooth Controller app, find the server to connectIn my case, the name of bluetooth was 'dbkdasl' 
 +GOOD LUCK! 
 +\\ 
 +\\ 
 +==== Programming ==== 
 + 
 +\\ 
 +The goal of the code is to manipulate MM-UAV with bluetooth.  It works in the following way
 \\ \\
 ---- ----
-<!- Insert another snippet of your code here.  Try to keep to less than 0.5 page long -->+<code c++ mmuavarm.cpp> 
 +#include <SoftwareSerial.h> 
 +#include <Servo.h> 
 + 
 +int tx = 2; //input 
 +int rx = 4; //output 
 +int servopin1 = 5; //motor pin no.1 
 +int servopin2 = 6; //motor pin no.2 
 +int servopin3 = 3; //motor pin no.3 
 +int servopin4 = 11; //motor pin no.4 
 +String myString = ""; 
 +int ini1 = 120; //motor1 starting point 
 +int ini2 = 45; //motor2 starting point 
 +int ini3 = 20; //motor3 starting point 
 +int ini4 = 60; //motor4 starting point 
 +int angle1, angle2, angle3, angle4; 
 +int pos1, pos2, pos3, pos4; 
 +int goal1, goal2, goal3, goal4; 
 +int dly = 120; //motor speed 
 + 
 + 
 +Servo servo1; //definition with header 
 +Servo servo2; 
 +Servo servo3; 
 +Servo servo4; 
 + 
 + 
 +SoftwareSerial bluetooth(tx, rx); 
 + 
 +void setup() 
 +
 +  Serial.begin(9600); 
 +  delay(100); 
 +  bluetooth.begin(9600); 
 +  servo1.attach(servopin1); 
 +  servo2.attach(servopin2); 
 +  servo3.attach(servopin3); 
 +  servo4.attach(servopin4); 
 +  servo1.write(ini1 - 35); // 0 deg to 90 deg on Motor 1 is 120 deg to 30 deg 
 +  servo2.write(ini2 + 35); // deg to 90 deg on Motor 2 is 45 deg to 135 deg 
 +  servo3.write(ini3 + 35); // 0 deg to 90 deg on Motor 3 is 20 deg to 110 deg 
 +  servo4.write(ini4 + 35); // 0 deg to 90 deg on Motor 4 is 60 deg to 150 deg 
 +  //start degree is 35 degree 
 +
 + 
 + 
 +void loop() { 
 +  while (bluetooth.available())  
 +  { 
 +    char myChar = (char)bluetooth.read();  
 +    myString += myChar;  
 +    delay(5);       
 +  } 
 + 
 +  if (!myString.equals(""))  
 +  { 
 +    Serial.println("input value: " + myString); 
 + 
 +    if (myString == "down") //if you click button "down" 
 +    { 
 +      int pos1 = servo1.read(); 
 +      int pos2 = servo2.read(); 
 +      int pos3 = servo3.read(); 
 +      int pos4 = servo4.read(); 
 +      int goal1 = 5; //all motor moves 5 degrees, if you make this number bigger, it moves bigger 
 +      delay(dly); 
 +      for (angle1 = 0; angle1 <= goal1; angle1 += 1) 
 +      { 
 +        servo1.write(pos1 angle1); 
 +        servo2.write(pos2 + angle1); 
 +        servo3.write(pos3 + angle1); 
 +        servo4.write(pos4 + angle1); //all motor moves 5 degrees downward 
 +        delay(dly); 
 +      } 
 +    } else if (myString == "up") { 
 + 
 +      int pos1 = servo1.read(); 
 +      int pos2 = servo2.read(); 
 +      int pos3 = servo3.read(); 
 +      int pos4 = servo4.read(); 
 +      int goal1 = 5; 
 +      delay(dly); 
 +     for (angle1 = 0; angle1 <= goal1; angle1 += 1) 
 +      { 
 +        servo1.write(pos1 + angle1); 
 +        servo2.write(pos2 angle1); 
 +        servo3.write(pos3 - angle1); 
 +        servo4.write(pos4 - angle1); //all motor moves 5 degree upward 
 +        delay(dly); 
 +      } 
 + 
 +    } else if (myString == "go") { 
 + 
 +      int pos1 = servo1.read(); 
 +      int pos2 = servo2.read(); 
 +      int pos3 = servo3.read(); 
 +      int pos4 = servo4.read(); 
 +      int goal1 = 5; 
 +      delay(dly); 
 +     for (angle1 = 0; angle1 <= goal1; angle1 += 1) 
 +      { 
 +        servo1.write(pos1 + angle1); 
 +        servo2.write(pos2 + angle1); 
 +        servo3.write(pos3 + angle1); 
 +        servo4.write(pos4 - angle1); //all motor moves 5 degree forward 
 +        delay(dly); 
 +      } 
 + 
 +    } else if (myString == "back") { 
 + 
 +      int pos1 = servo1.read(); 
 +      int pos2 = servo2.read(); 
 +      int pos3 = servo3.read(); 
 +      int pos4 = servo4.read(); 
 +      int goal1 = 5; 
 +      delay(dly); 
 +     for (angle1 = 0; angle1 <= goal1; angle1 += 1) 
 +      { 
 +        servo1.write(pos1 - angle1); 
 +        servo2.write(pos2 - angle1); 
 +        servo3.write(pos3 - angle1); 
 +        servo4.write(pos4 + angle1); //all motor moves 5 degree backward 
 +        delay(dly); 
 +      } 
 + 
 +    } else if (myString == "left") { 
 + 
 +      int pos1 = servo1.read(); 
 +      int pos2 = servo2.read(); 
 +      int pos3 = servo3.read(); 
 +      int pos4 = servo4.read(); 
 +      int goal1 = 5; 
 +      delay(dly); 
 +     for (angle1 = 0; angle1 <= goal1; angle1 += 1) 
 +      { 
 +        servo1.write(pos1 + angle1); 
 +        servo2.write(pos2 - angle1); 
 +        servo3.write(pos3 + angle1); 
 +        servo4.write(pos4 + angle1); //all motor moves 5 degree left 
 +        delay(dly); 
 +      } 
 + 
 +    } else if (myString == "right") { 
 + 
 +      int pos1 = servo1.read(); 
 +      int pos2 = servo2.read(); 
 +      int pos3 = servo3.read(); 
 +      int pos4 = servo4.read(); 
 +      int goal1 = 5; 
 +      delay(dly); 
 +     for (angle1 = 0; angle1 <= goal1; angle1 += 1) 
 +      { 
 +        servo1.write(pos1 - angle1); 
 +        servo2.write(pos2 + angle1); 
 +        servo3.write(pos3 - angle1); 
 +        servo4.write(pos4 - angle1); //all motor moves 5 degree right 
 +        delay(dly); 
 +      } 
 + 
 +    } else if (myString == "stop") { 
 +      servo1.detach(); 
 +      servo2.detach(); 
 +      servo3.detach(); 
 +      servo4.detach(); //all motor stop moving 
 +    } 
 +    myString = ""; //initialize variable myString 
 +  } 
 +
 + 
 + 
 +</code>
 ---- ----
-Next, the code does <fill in the blank> It does this by <fill in the blank>.   
-<!-- Keep entering snippets of code and descriptions until you've given enough for a reader to understand how it works --> 
 // //
 // //
 ==== Final Words ==== ==== Final Words ====
  
-This tutorial's objective was to <fill in the blank>. Complete <choose: construction details, source code and program descriptions> for <fill in the blank>. Once the concepts were conveyed the reader could <fill in the blank>.+This tutorial's objective was to manipulate MM-UAV arms wirelessly with Bluetooth. Complete sketching Arduino perfectly for active wireless operation. Once the concepts were conveyed the reader could fly drones with the arm to do missions or draw more ideas for further research.
 \\ \\
 \\ \\
-Speculating future work derived from this tutorial, includes <fill in the blank>. In the big picture, the problem of <fill in the blank> can be solved with this tutorial.+Speculating future work derived from this tutorial, includes Hose-Handling, UGV Cargo carry and etc. In the big picture, the problem of obstacles during the flight or being only able to be moved in limited area can be solved with this tutorial.
 \\ \\
 \\ \\
-For questions, clarifications, etc, Email: <paul.oh@unlv.edu+For questions, clarifications, etc, Email: <akdba0207@gmail.com
  
  
mm-uav_arm_bluetooth_operation.1470137868.txt.gz · Last modified: 2016/08/02 04:37 by dongbinkim