Sunday, February 14, 2016

FINAL BLOG POST

                                       


About Our Product

GyroThermo.90° is a water surveyor which measures water surface temperature constantly in a lawn mower pattern.

Prominent Features

GyroThermo.90° can be controlled automatically or manually with bluetooth. Under auto mode, GyroThermo.90° will move in a lawn mower pattern. Under manual mode, we can control GyroThermo.90° to go to any specific location.



Calculation

2 x Extrusion Bars                                                    =0.223kg
2 x Acrylic Base                                                       =0.210kg
2 x Motor                                                                  = 0.298kg
Electrical Casing (Tupperware)                                =0.157kg
Infrared Sensor                                                         =0.011kg
Infrared Sensor Cap                                                  =0.012kg
2 x Motor Bracket                                                     =0.090 kg
45 degree Pipe                                                           =0.021kg
Electronic Components                                             =0.412kg
TOTAL WEIGHT = 1.434kg

Using Formula:











V= 1.434/1000
   =0.001434 m^3
VOLUME NEEDED= 0.1434 cm^3

Giving 20% extra tolerance:

Volume x 120%
=1.434 x 1.2
VOLUME NEEDED =1720.8 cm^3

Pipe Radius Needed:
Πr2h=  1720.8
Πr2(23)=  1720.8
RADIUS OF PIPE NEEDED= 4.88cm



Hence, we choose the pipe with radius 4cm which is diameter 80 mm.



Our code is available here:
 http://monedgroup8.blogspot.sg/2016/02/our-code.html

Here is the latest design:
http://monedgroup8.blogspot.sg/2016/02/final-design-of-our-water-surveyor-old.html
http://monedgroup8.blogspot.sg/2016/02/infrared-sensor-throughout-lots-of.html

Here is the older design:
http://monedgroup8.blogspot.sg/2016/01/e-project-update.html
http://monedgroup8.blogspot.sg/2015/12/concept-report-after-rounds-of.html

Our Electrical Circuit and Code

Circuit diagram:


Arduino Code:

//---Tempreature Sensor---
#include <OneWire.h>
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
OneWire ds(DS18S20_Pin); // on digital pin 2

//---cmps---
#include "Wire.h"
#include "CMPS03.h"
CMPS03 cmps03;
volatile float cmpsValue;   //compass reading
volatile float cmpsTurn;    //the turning degree

//----infra---
const int InfraredSensorPin = 8;
volatile int countTurns = 0;

//---Motors---
int E1 = 5;
int M1 = 4;
int E2 = 6;
int M2 = 7;

//---LED---
int rightLed= 13;
int leftLed= 12;
int infraLed=11;

void setup() {
 pinMode(M1, OUTPUT);
 pinMode(M2, OUTPUT);
 pinMode(E1, OUTPUT);
 pinMode(E2, OUTPUT);
 pinMode(rightLed,OUTPUT);
 pinMode(leftLed,OUTPUT);
 pinMode(infraLed,OUTPUT);
 Serial.begin(9600);
 pinMode(InfraredSensorPin,INPUT);
 Wire.begin();
 volatile char c;
 volatile int a = 0;
 while(Serial.available()){
     c = Serial.read();
  }
  while(a !=1){
    stopBoat();
    c = Serial.read();
    if(c == 'r'){
      a=1;
    }
    if(c=='l'){
      a=1;
    }
  }
  if(c=='r'){
    while(digitalRead(InfraredSensorPin) == HIGH){
    forward();
  }
  Serial.println("wall");
  digitalWrite(infraLed,HIGH);
  reverseRight();
  turnRight();
  digitalWrite(infraLed,LOW);
  digitalWrite(rightLed,LOW);
  shortForward();
  turnRight();
  digitalWrite(rightLed,LOW);
  countTurns++;
  forward();
}
if(c=='l'){
  while(digitalRead(InfraredSensorPin) == HIGH){
    forward();
  }
  Serial.println("wall");
  digitalWrite(infraLed,HIGH);
  reverseLeft();
  turnLeft();
  digitalWrite(infraLed,LOW);
  digitalWrite(leftLed,LOW);
  shortForward();
  turnLeft();
  digitalWrite(leftLed,LOW);
  forward();
}
}


void loop() {
  volatile char c;   // incoming data from phone
  int toggle =0;     // Keep track of whether its in auto or manual
    while(Serial.available()){
     c = Serial.read();
  }
  if(c == 'm'){
    toggle =1;
    while( toggle == 1){
    switch(c){
   
      case'a':manForward();
      c= Serial.read();
      break;
   
   
      case'c':manRight();
      c= Serial.read();
      break;
   
      case'd':manLeft();
      c= Serial.read();
      break;

      case'u':toggle = 0;
      //Serial.println("Now going to automatic mode");
      break;

      default: stopBoat();
      c= Serial.read();
      break;
    }
  }
  }
 else{
  c = Serial.read();
  if(c == 'm'){
    toggle = 1;
  }
  /*if(digitalRead(InfraredSensorPin) == HIGH){
    forward();
  }
  else{
    if(countTurns%2 == 0){
    reverseLeft();
    digitalWrite(infraLed,HIGH);
    turnRight();
    digitalWrite(rightLed,LOW);
    digitalWrite(infraLed,LOW);
    shortForward();
    turnRight();
    digitalWrite(rightLed,LOW);
    forward();
    }
    else{
      reverseRight();
      digitalWrite(infraLed,HIGH);
      turnLeft();
      digitalWrite(leftLed,LOW);
      digitalWrite(infraLed,LOW);
      shortForward();
      turnLeft();
      digitalWrite(leftLed,LOW);
      forward();
    }
  }*/
}
}




void forward(){
  volatile char c;
  int stopcount = 0;
  c = Serial.read();
    if(c == 'r'){
      stopcount = 1;
    }
  while(stopcount==1){
    stopBoat();
    c = Serial.read();
    if(c=='l'){
      stopcount=0;
    }
  }
  digitalWrite(M1,LOW);
  digitalWrite(M2, LOW);
  analogWrite(E1, 88);
  analogWrite(E2, 120);
  digitalWrite(leftLed,LOW);
  digitalWrite(rightLed,LOW);
  /*float temperature = getTemp();
  Serial.print("The Water is ");
  Serial.print(temperature);
  Serial.println("°C");*/
  Serial.println("forward");
  delay(1000);
}

void shortForward(){
  digitalWrite(M1,LOW);
  digitalWrite(M2, LOW);
  analogWrite(E1, 88);
  analogWrite(E2, 120);
  float temperature = getTemp();
  /*Serial.print("The Water is ");
  Serial.print(temperature);
  Serial.println("°C");*/
  Serial.println("shortforward");
  delay(5000);
}

void turnRight() {
  for(int turnTimer=0; turnTimer <6; turnTimer++){
    digitalWrite(rightLed,HIGH);
    digitalWrite(M1,LOW);
    digitalWrite(M2, HIGH);
    analogWrite(E1, 88);
    analogWrite(E2, 120);
    /*float temperature = getTemp();
    Serial.print("The Water is ");
    Serial.print(temperature);
    Serial.println("°C");*/
    Serial.println("right");
    delay(500);
  }
  countTurns++;
  }

void turnLeft() {
  for(int turnTimer=0;turnTimer<6;turnTimer++){
    digitalWrite(M1,HIGH);
    digitalWrite(M2, LOW);
    analogWrite(E1, 88);
    analogWrite(E2, 120);
    digitalWrite(leftLed,HIGH);
    /*float temperature = getTemp();
    Serial.print("The Water is ");
    Serial.print(temperature);
    Serial.println("°C");*/
    Serial.println("Left");
    delay(500);
  }
  countTurns++;
  }

void reverseLeft(){
  digitalWrite(M1,HIGH);
  digitalWrite(M2, LOW);
  analogWrite(E1, 150);
  digitalWrite(E2, LOW);
  Serial.println("reverse left");
  delay(10000);

}

void reverseRight(){
  digitalWrite(M1,LOW);
  digitalWrite(M2, HIGH);
  digitalWrite(E1, LOW);
  analogWrite(E2, 150);
  Serial.println("reverse right");
  delay(10000);
}

void manForward(){
  digitalWrite(M1,LOW);
  digitalWrite(M2, LOW);
  analogWrite(E1, 88);
  analogWrite(E2, 110);
  float temperature = getTemp();
  Serial.print("The Water is ");
  Serial.print(temperature);
  Serial.println("°C");
  delay(3000);
}

void manRight(){
  digitalWrite(M1,LOW);
  digitalWrite(M2, HIGH);
  analogWrite(E1, 120);
  analogWrite(E2, 80);
  digitalWrite(rightLed,HIGH);
  float temperature = getTemp();
  Serial.print("The Water is ");
  Serial.print(temperature);
  Serial.println("°C");
  delay(3000);
  digitalWrite(rightLed,LOW);
  }

void manLeft(){
  digitalWrite(M1,HIGH);
  digitalWrite(M2, LOW);
  analogWrite(E1, 120);
  analogWrite(E2, 87);
  digitalWrite(leftLed,HIGH);
  float temperature = getTemp();
  Serial.print("The Water is ");
  Serial.print(temperature);
  Serial.println("°C");
  delay(3000);
  digitalWrite(leftLed,LOW);
  }

void stopBoat(){
  digitalWrite(M1,HIGH);
  digitalWrite(M2, HIGH);
  digitalWrite(E1, LOW);
  digitalWrite(E2, LOW);
  float temperature = getTemp();
  Serial.print("The Water is ");
  Serial.print(temperature);
  Serial.println("°C");
  delay(1000);
  }

float getTemp(){
 //returns the temperature from one DS18S20 in DEG Celsius

 byte data[12];
 byte addr[8];

 if ( !ds.search(addr)) {
   //no more sensors on chain, reset search
   ds.reset_search();
   return -1000;
 }

 if ( OneWire::crc8( addr, 7) != addr[7]) {
   Serial.println("CRC is not valid!");
   return -1000;
 }

 if ( addr[0] != 0x10 && addr[0] != 0x28) {
   Serial.print("Device is not recognized");
   return -1000;
 }

 ds.reset();
 ds.select(addr);
 ds.write(0x44,1); // start conversion, with parasite power on at the end

 byte present = ds.reset();
 ds.select(addr);
 ds.write(0xBE); // Read Scratchpad


 for (int i = 0; i < 9; i++) { // we need 9 bytes
  data[i] = ds.read();
 }

 ds.reset_search();

 byte MSB = data[1];
 byte LSB = data[0];

 float tempRead = ((MSB << 8) | LSB); //using two's compliment
 float TemperatureSum = tempRead / 16;

 return TemperatureSum;

}

Saturday, February 13, 2016

INFRARED SENSOR

Throughout lots of discussions and testings, we have make a serious decision, changing the ultrasonic sensor to an infrared sensor.



So, what is an infrared sensor? An Infrared sensor is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view.



We plan to use the sensor to detect the wall or banks of our water body. This allows our boat to know when to turn. Using this knowledge combined with our compass the boat is able to achieve a 90° turn for both left and right hence completing the lawn mower pattern.


On the other side, we had figured out how to mount the infrared sensor onto our boat. Firstly we purchased some pipes, we got an one-side threaded connector and 45° connector.Then, we cut the pipe into 2 pieces, one is 20mm long and another is 10mm. We drilled a hole on one end of the 20mm long of pipe.


We also designed and 3D printed a bracket to hold the pipe.


The bracket is mounted on top of the cover of the tupperware and secured with screws and nuts.


Besides that we designed and 3D printed a shelter for the infrared sensor to prevent the excess infrared light from the sun which may affect the reading. The infrared sensor is inserted into the one-side threaded connector and sealed with transparent silicon sealant.


After that, we assemble the pipes and connectors as shown in the photo where the pipe with hole attached to the bracket and secured with a screw and nut while the other pipe connect both the pipe connectors.

Saturday, February 6, 2016

Motor Stalling, Jerkng or Skipping Solution



                Hello everyone welcome back to our blog. A lot of groups have been affected by this problem and our group is no exception. But what is this problem I am talking about? The problem is motors suddenly not turning or suddenly jerking or skipping. Now this is a huge problem as almost all of our projects are relying on motors to turn propellers to provide thrust for movement. Originally we set our motors PWM to 255 ( The maximum pulse width modulation) this means we are supplying our motors with the maximum amount of voltage our power supply can provide, in our case we are using a 12v LiPO battery. This provided much speed in air but when we put it in to the water our motors started stalling and skipping. We asked around and found out that alot of other groups were facing the same problem and were stumped. We researched online and found out that propellers for airplanes are able to turn very fast as air resistance is quite small compared to water resistance hence the propellers in water needs to turn slower. However this does not mean that the motors become less powerful. They actually become more powerful as the lesser the speed the greater the torque. We then set our PWM to 100 and voila our motors started to turn without Stalling Jerking or Skipping. PWM is a tool by Arduino to change the output voltage. PWM or pulse width modulation means controlling the pulse width to achieve a lower voltage. The formula is (Max Voltage) x (The time the wave is HIGH / The Period of a wave). The image below shows a example of pulse width modulation in action.




Thank you for reading and we hoped that this blog post have helped you solve your problem.


Tuesday, February 2, 2016

FINAL DESIGN



Final Design of our Water SurveyorFINAL Design.png

Old Design of our Water Surveyor


We have made several changes to our design. Firstly, we have excluded the keel as after a few experiments conducted, it does not really ensure our boat move in a straight line on water. On the contrary, the keel affects the turning of our boat when our boat is trying to achieve a lawn mower pattern on water.


Secondly, we have replaced the acrylic body structure with a tupperware. This is because we found out that the acrylic structure is not necessary and hard to be waterproof. Not to mention that it is time consuming to make, we decided to replace it with a tupperware which is waterproof and big enough to hold our circuits and electronic devices.


Thirdly, we have modified our body structure which is entirely made of acrylic by adding 2 pieces of aluminium extrusion bars below our downsized acrylic plates. Our previous design which is shown below has the problem of withstanding the weight acting on it and it will bend in middle. Hence, we have created a skeleton for it by supporting it with aluminium extrusion bars.  





To mount the motors, we have designed special motor brackets using Autodesk Inventor and 3D printed them out. Then, we laser cut 2 pieces of acrylic board and the motor brackets are attached to the acrylic base.

After a few of experiments, we noticed that the boat still tilted backward due to the weight of the powerbank in the tupperware. Thus, we add a float on the back part of our boat. It is to provide buoyancy force to our boat to stabilise our boat. The addition of the float has significantly increased the stability of our boat and ensure it balance when moving on water.

`


Ta daaaaa!!! This is how the water surveyor will look like: