Monday, 9 March 2015

WEEK 5- Arduino Ethernet, Simulation of a helicopter control system

Location: 3rd floor, EEE building, University of Liverpool
Date: 4th March, 2015
This is the final week of our project. Firstly, I need to say thank you for following us during the last five weeks.  The whole aim has been achieved. We successfully simulate the flying process and control module of the aircraft.

The whole system is shown on the next figures. In the last week, we combine all the components together to ensure the system like a real helicopter. We test each part of the system and still some tiny problems happened in our system. In the future we need more time to improve the system.
Thank you again for reading this week blog. We will post the latest news if we change and improve the system.

Saturday, 7 March 2015

WEEK 4- Arduino Ethernet, Simulation of a helicopter control system

Location: 3rd floor, EEE building, University of Liverpool
Date: 27th February, 2015

Time flows so fast. This is the fourth week of our whole project. After three week group work, we have already finished the control part and the Bluetooth part of the codes. Instructions such as UP, STABLE, FORWARD, RECOVER, BACKWARD and DOWN are achieved by typing commands in phone. However, how to give feedback to show the result to the audience is still a problem.
In the fourth week, we try to use the IR Infrared Sensor to measure the speed of the motor. The figure shows how the sensor looks like.


This sensor can receive the signal from the reflects from the wings. Each time the wing rotated above the emitter, the sensor will output high signal. The numbers of the high signal in one minute can be viewed as the speed of the motor. However, many factors like angles, distance can influence the accuracy the result.
Another arduino is used to measure the speed of the two motors and give feedback to the computer to show the result.
The measuring rotation speed system code are as following:
#include <MsTimer2.h>               
 int w=2;
int z=3;
int m=0;
int n=0;
 int x=0;
int y=0;
void flash()                        //break function

    
  Serial.println(x*6);
  Serial.println(y*6);
  x=0;
  y=0;
}

void setup() 
{
  

  MsTimer2::set(5000, flash);       // set function,break function operates every 500ns
  MsTimer2::start();                //starts counting
  pinMode(w,INPUT);
  pinMode(z,INPUT);
  Serial.begin(9600);
}

void loop()
{

  int i; 
  i=digitalRead(w);
 if(i==0)
  {
    m+=1;
   
  }
  
  if(m>=1&&i==1)
  {
    x+=1;
    m=0;
    
  }
  
  int j; 
  j=digitalRead(z);
 if(j==0)
  {
    n+=1;
   
  }
  
  if(n>=1&&j==1)
  {
    y+=1;
    n=0;
    
  }
  

}

After the fourth week, we almost finish the whole project. In the fifth week, we are trying to combine all the components together and preparing the bench inspection.
Thank you for reading our fourth wee blog and waiting for our final achievement in the fifth week.  

WEEK 3- Arduino Ethernet, Simulation of a helicopter control system

Location: 3rd floor, EEE building, University of Liverpool
Date: 20th February, 2015
Thank you for waiting for a long time. This is the third week of our group project. After three week’s group work, we almost achieve our goal. In last week, we finished the code for control part. In third week, we finish the code for Bluetooth part, which were added to the control part.
Initially, we define five commands: up, stable, forward, backward, recover and down. We use a APP named “Bluno” to control the flying system. At first, it is a problem to connect the Arduino to the mobile. Finally we fixed the problem by changing some settings. After adding the Bluetooth, the whole system is almost finished.
The issue we facing now is how to show the feedback of the system. Two methods are raised, one is to show the voltage directly, another is to measure the speed of the motors. However, the problem is how to measure the speed.

Thank you for reading and waiting our next wee post.

WEEK 2- Arduino Ethernet, Simulation of a helicopter control system

Location: 3rd floor, EEE building, University of Liverpool
Date: 13th February, 2015
Thank you for waiting for a long time. This is the second blog for what we achieved in week 2.
After the discussion in week 1, our group began to write the codes which control the two DC motors. By changing the voltage of the motor, for states which are up, down, forward and backward can be achieved. Figure 1 is the screen shot of our codes.

int motorPin1=3,motorPin2=4;
char getstr;
String f="";
String b="";
String u="";
String d="";
String s="";
String r="";
String comdata = "";
int flag;
void setup()
{
    
    pinMode(motorPin1, OUTPUT);
    pinMode(motorPin2, OUTPUT);
    Serial.begin(9600);
    f="f";
    b="b";
    u="u";
    d="d";
    s="s";
    r="r";
    flag=0;
}

void loop()
{
  
    while (Serial.available() > 0)  
    {
        comdata += char(Serial.read());
        delay(2);
    }
    if (comdata.length() > 0)
    {
        
          if(comdata==u&&(flag==0||flag==1))  //flag=0 initial condition, flag=1 stable condition
        {
           motorUp();
           flag=2;
           Serial.println(flag);
         }
         else
         if(comdata==d&&(flag==1||flag==2))  //flag=2 up condition
         {
           if(flag==2)
         {
           motorStable();
         }
           motorDown();
           motorOff();
           
           Serial.println(flag);
           flag=0;
         }
         else
         if(comdata==f&&flag==1) //flag=3 forward condition
         {
           motorForwardPrepare();
           motorStable();
           flag=3;
           Serial.println("s");
         }
         else 
         if(comdata==b&&flag==1) //flag=4 backward condition
         {
           motorBackwardPrepare();
           motorStable();
           flag=4;
         }
         else
         if(comdata==s&&flag==2)
         {
           motorStable();
           flag=1;
         }
         else
         if(comdata==r&&(flag==3||flag==4))
         {
           if(flag==3)
           {
            motorFordwardRecover();
            flag=1;
           }
           else
           {
            motorBackwardRecover();
            flag= 1;
           }
           
         }
         else
         { 
          Serial.println("input wrong!")
         }
         comdata="";
    }
}
  
  
  void motorUp()
{
int onTime0=200;
analogWrite(motorPin1,255);
analogWrite(motorPin2,255);
delay(onTime0);
}



void motorStable()
{
int delayTime1=5;
int onTime1=100;
for (int i=255; i>=200;i--)
{
analogWrite(motorPin2,i);
analogWrite(motorPin1,i);
delay(delayTime1);
}
analogWrite(motorPin2,200);
analogWrite(motorPin1,200);
delay(onTime1);
}



void motorDown()
{
int delayTime2=50;
int onTime2=100;
for(int j=200;j>100;j--)
{
analogWrite(motorPin1, j);
analogWrite(motorPin2, j);
delay(delayTime2);
}
analogWrite(motorPin1,200);
analogWrite(motorPin2,200)                                                                                                                                   ;
delay(onTime2);
}



void motorOff()
{
int delayTime3=50;

int delayTime4=20000;
for (int k=100; k>=0;k--)
{
analogWrite(motorPin1,k);
analogWrite(motorPin2,k);
delay(delayTime3);

}

analogWrite(motorPin1,0);

analogWrite(motorPin2,0);

delay(delayTime4);
 Serial.println(flag);
}


void motorForwardPrepare()

{
int delayTime5=50;
for(int m=200;m>=170;m--)

{

analogWrite(motorPin1,200);

analogWrite(motorPin2,m);

delay(delayTime5);

}

analogWrite(motorPin2,200);
}


void motorForwardRecover()
{
delayTime5=50;
for(n=200;n<=255;n++)
{
analogWrite(motorPin1,n);
analogWrite(motorPin2,200);
delay(dealyTime50);
}
analogWrite(motorPin1,200);
analogwrite(motorPin2,200);
}





void motorBackwardPrepare()
{
int delayTime6=50;
for(int n=200;n>=170;n--)
{
analogWrite(motorPin2,200);
analogWrite(motorPin1,n);
delay(delayTime6);
}
analogWrite(motorPin1,200);
}


void motorBackwardRecover()
{
delayTime5=50;
for(n=200;n<=255;n++)
{
analogWrite(motorPin2,n);
analogWrite(motorPin1,200);
delay(dealyTime50);
}
analogWrite(motorPin1,200);
analogWrite(motorPin2,200);
}


In the design, the whole process is divided into 5 parts: up, stable, forward, backward and down. STABLE must follow the states UP, FORWARD and BACKWARD. When conducting the up, the two motors running at high speed. When conducting forward, the second motor accelerates. When conducting backward, the first motor accelerates.

Thank you for reading the second week blog. In the third week, we prepare to finish the code for Bluetooth control and debug the Bluetooth.

Sunday, 15 February 2015

WEEK 1- Arduino Ethernet, Simulation of a helicopter control system Location: 3rd floor, EEE building, University of Liverpool Date: 6th February, 2015

WEEK 1- Arduino Ethernet, Simulation of a helicopter control system

Location: 3rd floor, EEE building, University of Liverpool
Date: 6th February, 2015

Hello, everyone. This is the first week of our Year 2 project. Thank you for watching and hope you can follow us in the next five weeks to search the Arduino with our group.

Everything works well before the experiment day. We discussed what we will achieve and what components we need.On Friday, we collect the components from the lab technician’s  office: one Arduino Ethernet which is a micro-controller board based on the ATmega328 and two DC motors. Besides these, two other propellers are bought from AMAZON. 











Arduino Ethernet Board











DC Motor
Firstly, we discussed how the systems should be designed and we separated the project into five parts which will be finished in the next five weeks. Figure 1 shows the designed basic system. We planned to control the Arduino by Bluetooth then the two motors will operate separately in different situations. Finally, the two motors will give feed back to the Arduino which will be displayed in computer. 
   
The operation of the system will be shown by observing the changes of the voltage waveform.
The next step was to begin to write the code to control the motors which will be complete perfectly in the second week.
Overall, we finished the first week successfully. Thank you for reading and waiting for our next post.