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.  

No comments:

Post a Comment