Sunday 12 August 2018

MY FYP2 (WPB49906)


Development of Smart Recycle Bin using Microcontroller
by NOR HABSAH OTHMAN
Supervisor: Madam Azliza Binti Mohamad Arshad

Synopsis of the project: Smart recycling bin serves to sort three types of waste ie metal, paper and plastic. It uses a microcontroller and sensor to detect the type of trash and the main circuit is powered by power supply.

Week 1
Activity: draft poster
Objective: to make poster for final presentation
Content/procedure: using microsoft publisher to make it.
Result and analysis:  
Conclusion:  result, analysis and conclusion are not available yet.
Verification:
Supervisor's sign:
Date: 16/7/2018 – 20/7/2018
_________________________________________________________________________________
Week 2
Activity: design circuit using proteus 8 software and Keil : Interfacing DC Motor with 8051 using L298
Objective: to test source code
Content/procedure: 1st coding is basic code for dc motor, its refer to Mazidi book.
#include <reg51.h>// ok, no error
sbit Mp=P2^0;
sbit Mn=P2^1;
sbit sw1 = P1^0; //define switch
sbit sw2 = P1^1; //define switch
sbit sw3 = P1^2; //define switch
void MSDelay(unsigned int value);
void main()
{
unsigned char z;
z = P1;
z = z & 0x03;
Mp=0;
Mn=0;
while(1)
{
switch (z)
{
case (0):
{
Mp = 1;
MSDelay(25);
Mn = 0;
MSDelay(75);
break;
}
case (1):
{
Mp = 1;
MSDelay(55);
Mn = 0;
MSDelay(50);
break;
}
case (2):
{
Mp = 1;
MSDelay(75);
Mn = 0;
MSDelay(25);
break;
}
default:
Mp=1;
Mn=1;
}
}

}
Result and analysis:
  • coding case.
  • motor continue rotate clockwise when switch is pressed. when switch 1 is pressed, motor rotate 25% slower, while switch 2 is 50% and switch 3 is 75%.
  • CIRCUIT
Conclusion: 
Verification:
Supervisor's sign:
Date: 23/7/2018 – 27/7/2018
_________________________________________________________________________________
Week 3
Activity: TRY ANOTHER CODE & fyp briefing for fyp 2
Objective: to test source code
Content/procedure: just refer to previous coding, change it a bit.
#include <reg51.h>
sbit sw1 = P1^0; //define switch
sbit sw2 = P1^1; //define switch
sbit sw3 = P1^2; //define switch
sbit Mp=P2^0;
sbit Mn=P2^1;

void main(void);

void MSDelay(unsigned int value);
void main()
{
while(1)
{
if(sw1 == 0) //when switch 1 pressed
{
Mp = 1;
MSDelay(55);
Mn = 0;
MSDelay(50);
Mp = 1;
Mn = 1; //Stops Motor
MSDelay();
break;
}

if(sw2 == 0) //when switch 2 pressed

{
Mp = 1;
MSDelay(50);
Mn = 0;
MSDelay(50);
Mp = 1;
Mn = 1; //Stops Motor
MSDelay();
break;
}
if(sw3 == 0) //when switch 3 pressed
{
Mp = 1;
MSDelay(55);
Mn = 0;
MSDelay(50);
Mp = 1;
Mn = 1; //Stops Motor
MSDelay();
break;
}
}
}
void MSDelay(unsigned char value)
{
 unsigned int x,y;
 for(x = 0; x < 100; x++)
 for(y=0; y<value; y++);
 return;

}

// motor gerak 25% setiap suis ditekan
Result and analysis:
  • if, if else, else
  • motor rotate clockwise when switch is pressed. every switch is pressed, motor rotate 25% slower and stop.
  • circuit refer as previous.
Conclusion: 
this week are having some  1st briefing regarding fyp 2 this semester. below is the details of the schedule for fyp 2.so this is our guide for fyp 2


Verification:
Supervisor's sign:
Date: 30/7/2018 – 03/8/2018
_________________________________________________________________________________
Week 4
Activity: ANOTHER CODE
Objective: to test source code
Result and analysis:
#include <reg51.h>
sbit Mp=P2^0;
sbit Mn=P2^1;
sbit sw1 = P1^0; //define switch
sbit sw2 = P1^1; //define switch
sbit sw3 = P1^2; //define switch
void MSDelay(unsigned int value);
void main()
 {
 unsigned char z;
 P1 = 0XFF;
 z = P1;
 z = z & 0x07;
 Mp=0;
 Mn=0;
 while(1)
  {
  switch (z)
   {
   case (0):
    {
    Mp = 0;
    MSDelay(25);
    Mn = 1;
    MSDelay(75);
    break;
    }
   case (1):
    {
    Mp = 1;
    MSDelay(55);
    Mn = 0;
    MSDelay(50);
    break;    
    }
   case (2):
    {
    Mp = 1;
    MSDelay(75);
    Mn = 0;
    MSDelay(25);
    break;
    }
   default:
    Mp=1;
    Mn=1;
   }
  }


 }
// MOTOR X FUNGSI LANGSUNG
Conclusion:
Verification:
Supervisor's sign:
Date: 06/8/2018 – 10/8/2018
_________________________________________________________________________________
Week 5
Activity: studies the coding from website & workshop for result and discussion for chapter 4 and conclusion for chapter 5
Objective: To understand about dc motor coding. To learn about thesis writing in detail
Result and analysis:
#include <reg51.h>
#include <string.h>
sbit rs = P3^2; // declare P2.7 as rs pin
sbit en = P3^3; // declare p2.5 as enable pin
sbit op1 = P3^6;
sbit op2 = P3^7;
sbit led1 = P3^0;
sbit led2 = P3^1;
sbit led3 = P3^4;
sbit led4 = P3^5;
void delay(void);
void rot_dely() // 1 sec delay
  {
  int k;
TL1 = 0xBF; // load value 15535=3CAF
TH1 = 0x3C;
TR1 = 1;
for(k=0;k<120;k++)
 {
while(TF1==0);
TF1 = 0;
TL1 = 0xBF;
TH1 = 0x3C;
 }
TR1 = 0;
  }
void keydelay()
  {
    int z,y;
for(z=0;z<50;z++)
 for(y=0;y<1000;y++);
  }
void busy()
{
int o;
for(o=0;o<2000;o++);
}
void writecmd(unsigned char a)
{
busy(); // check for LCD is busy or not
rs = 0; // clear rs pin for command    
P2 = a; // send command character
en = 1; // strob LCD
en = 0;
}
void writedat(unsigned char b)
{
busy(); // check for LCD is busy or not
rs = 1; // set rs pin for data
P2 = b; // send data character
en = 1; // strob LCD
en = 0;
}
void writestr(unsigned char *s)
{
unsigned char l,i;
l = strlen(s); // get the length of string
for(i=0;i<l;i++)
{
writedat(*s); // write every char one by one
s++;
}
 }
void display(unsigned int z) // to display digits 0-9 on LCD
  {
  int z1,ASCII[2];     
z1=z%10;
ASCII[1]=z1+0x30;
z=z/10;
ASCII[0]=z+0x30;
writedat(ASCII[0]);
writedat(ASCII[1]);
  }
void main()
  {
    unsigned int i,r1=1,r2=1,r3=1,r4=1,s=0,c=0;
P3=0x00;
P2=0x00;
TMOD = 0x10;
writecmd(0x3C); // initilize LCD
writecmd(0x0E); 
writecmd(0x01);
writestr(" DC gear Motor");
writecmd(0xC0);
writestr("rotation control");
loop:P1=0xFF;
while(P1==0xFF); 
led1=1;
 switch(P1)
   {
case 0xFE:
   writecmd(0x01);
writestr("Button 1");
writecmd(0xC0);
writestr("Rotations: ");
display(r1);
op1=1;
op2=0;
led1=0;
led2=1;
for(i=0;i<r1;i++) rot_dely();
op1=0;
led2=0;
break;
case 0xFD:
   writecmd(0x01);
writestr("Button 2");
writecmd(0xC0);
writestr("Rotation: ");
display(r2);
op1=1;
op2=0;
led1=0;
led2=1;
for(i=0;i<r2;i++) rot_dely();
op1=0;
led2=0;
break;
case 0xFB:
   writecmd(0x01);
writestr("Button 3");
writecmd(0xC0);
writestr("Rotation: ");
display(r3);
op1=1;
op2=0;
led1=0;
led2=1;
for(i=0;i<r3;i++) rot_dely();
op1=0;
led2=0;
break;
case 0xF7:
   writecmd(0x01);
writestr("Button 4");
writecmd(0xC0);
writestr("Rotation: ");
display(r4);
op1=1;
op2=0;
led1=0;
led2=1;
for(i=0;i<r4;i++) rot_dely();
op1=0;
led2=0;
break;
case 0xEF:
if(c==0)
{
s=1;
writecmd(0x80);
writestr("Enter Rotation");
writecmd(0xC0);
writestr("for Button 1: ");
display(r1);
led1=0;
led3=1;
 }
else led4=1;
break;
case 0xDF:
if(s==1) 
 {
  if(c==0){r1++;writecmd(0xCE);display(r1);}
else if(c==1){r2++;writecmd(0xCE);display(r2);}
else if(c==2){r3++;writecmd(0xCE);display(r3);}
else if(c==3){r4++;writecmd(0xCE);display(r4);}
 }
break;
case 0xBF:
if(s==1) 
 {
  if(c==0){r1--;writecmd(0xCE);display(r1);}
else if(c==1){r2--;writecmd(0xCE);display(r2);}
else if(c==2){r3--;writecmd(0xCE);display(r3);}
else if(c==3){r4--;writecmd(0xCE);display(r4);}
 }
break;
case 0x7F:
c++;
writecmd(0xCB);
if(c==1) {writestr("2: ");display(r2);}
else if(c==2) {writestr("3: ");display(r3);}
else if(c==3) {writestr("4: ");display(r4);}
else if (c==4) 
 {
   writecmd(0x01);
 writestr("set process over");
 writecmd(0xC0);
 writestr("Press button 1-4");
 c=0;s=0;
 led3=0;led4=0;
 }  
break;
}
keydelay();  
led1=0;
goto loop;


  }
Conclusion:  The detail are as link below.
https://www.engineersgarage.com/contribution/ambhatt/gear-motor-rotation-control

  • this week we had attended  workshop that discuss about result data and discussion

    Explaining the finding to the reader. There are elements of the discussion  and analysis that should be included and other things that should be avoided. Always write the discussion for the reader; remember that the focus should be to help the reader understand the result.

 

Verification:
Supervisor's sign:

Date: 13/8/2018 – 17/8/2018
_________________________________________________________________________________
Week 6
Activity: test coding
Objective: to test source code
Result and analysis:
#include <reg51.h>

sbit sw1 = P1^0; //define switch
sbit sw2 = P1^1; //define switch
sbit sw3 = P1^2; //define switch
sbit Mp=P2^0;
sbit Mn=P2^1;

void main(void);
void MSDelay(unsigned int value);
void main()

 {
 while(1)
  {
  if(sw1 == 0 && sw2 == 1 && sw3 == 1) //when switch 1 pressed
   {
   Mp = 1;
   MSDelay(55);
   Mn = 0;
   MSDelay(50);
   Mp = 1;
   Mn = 1; //Stops Motor
   MSDelay();
   break;
   }
  else if(sw1 == 1 && sw2 == 0 && sw3 == 1 ) //when switch 2 pressed
   {
   Mp = 1;
   MSDelay(50);
   Mn = 0;
   MSDelay(50);
   Mp = 1;
   Mn = 1; //Stops Motor
   MSDelay();
   break;    
   }
  else//(sw3 == 0) //when switch 3 pressed
   {
   Mp = 1;
   MSDelay(55);
   Mn = 0;
   MSDelay(50);
   Mp = 1;
   Mn = 1; //Stops Motor
   MSDelay();
   break;
   }
  }
 }

void MSDelay(unsigned char value)
{
 unsigned int x,y;
 for(x = 0; x < 100; x++)
 for(y=0; y<value; y++);
 return;
}
// motor terus berpusing tanpa tekan suis
Conclusion:  Motor is not function as needed.
Verification:
Supervisor's sign:

Date: 20/8/2018 – 24/8/2018
_________________________________________________________________________________
Week 7
Activity: Coding for servo motor
Objective:  To interface the servo motor with microcontroller and the functioning.
Result and analysis:
#include<reg52.h> // servo motor = ok...
#include<stdio.h>
#include <intrins.h>

sbit motor_pin = P2^0;
void Delay(unsigned int);
void Delay_servo(unsigned int);
void main()
{
  motor_pin = 0;

 do
 {
//Turn to 180 degree
   motor_pin=1;
   Delay_servo(110);
   motor_pin=0;
 
   Delay(1000);
 
  //Turn to 90 degree
    motor_pin=1;
  Delay_servo(82);
    motor_pin=0;
 
   Delay(1000);
 
//Turn to 0 degree
motor_pin = 1;
   Delay_servo(50);
   motor_pin = 0;
 
   Delay(1000);

 
// //Turn to 180 degree
//    motor_pin=1;
//    Delay_servo(110);
//    motor_pin=0;
//  
//    Delay(1000);
 }while(1);
}

void Delay(unsigned int ms)
{
  unsigned long int us = ms*1000;
while(us--)
{
    _nop_();
  }
}

void Delay_servo(unsigned int us)
{
while(us--)
{
    _nop_();
  }

}
Conclusion: servo is working well. when microcontroller is on, servo motor turn to 180 degree then 90 degree and next 0 degree.
Verification:
Supervisor's sign:


Date: 27/8/2018 – 31/8/2018
_________________________________________________________________________________
Week 8
Activity: Finalize the component are need to use.
Objective:  to complete the component needed and test with source code
Result and analysis: related component and testing
Conclusion:  still error while interface sensor and dc motor white microcontroller
Verification:
Supervisor's sign:

Date: 10/9/2018 – 14/9/2018
_________________________________________________________________________________
Week 9
Activity:  continue with previous activity & workshop regarding abstract and presentation poster
Objective:  to test the component with source code
Result and analysis:  still not working 
Conclusion:  

  • need to alter the coding, understand the working principle of sensor.
  • presentation poster need to have :

    - title , name, and program
    - objective
    - finding
    - methodology
    - flow chart
    - result and discussion
    - conclusion
    - reference
Verification:
Supervisor's sign:


Date: 17/9/2018 – 21/9/2018
_________________________________________________________________________________
Week 10
Activity: combination servo and dc motor
Objective: to combine and test functioning the circuit
Result and analysis:
when switch is pressed, dc motor rotate clockwise and stop then servo should turn to 90 degree then return to 0 degree. but the servo is not return.
Conclusion:
#include<reg52.h>
#include<stdio.h>
#include <intrins.h>

sbit motor1_pin = P2^0;// motor rotate disk
sbit motor2_pin = P2^1; //motor put trash to bin
sbit sw1 = P1^0; //define switch
sbit sw2 = P1^1; //define switch
sbit sw3 = P1^2; //define switch

void Delay(unsigned int);
void Delay_servo(unsigned int);
void main()
{
motor1_pin = 0;
  do
  {

  if(sw1 == 0 && sw2 == 1 && sw3 == 1) //when switch 1 pressed  
 
{//Turn to 180 degree
   motor1_pin=1;
   Delay_servo(110);
   motor1_pin=0;
   Delay(1000);

// motor2_pin=1;
//    Delay_servo(82);
//    motor2_pin=0;
//    Delay(1000);
// motor2_pin=1;
//    Delay_servo(50);
//    motor2_pin=0;
//    Delay(1000);}
}
else if(sw1 == 1 && sw2 == 0  && sw3 == 1) //when switch 2 pressed 
{//Turn to 90 degree
   motor1_pin=1;
Delay_servo(82);
   motor1_pin=0;
   Delay(1000);

// motor2_pin=1;
//    Delay_servo(82);
//    motor2_pin=0;
//    Delay(1000);
}
 
else if (sw1 == 1 && sw2 ==1  && sw3 == 0)
{//Turn to 0 degree
   motor1_pin=1;
   Delay_servo(50);
   motor1_pin=0;
   Delay(1000);
 
// motor2_pin=1;
//    Delay_servo(82);
//    motor2_pin=0;
//    Delay(1000);
   }
 
 }while(1);
}

void Delay(unsigned int ms)
{
  unsigned long int us = ms*1000;
while(us--)
{
    _nop_();
  }
}

void Delay_servo(unsigned int us)
{
while(us--)
{
    _nop_();
  }

}
Verification:
Supervisor's sign:


Date: 24/9/2018 – 28/9/2018
_________________________________________________________________________________
Week 11
Activity: troubleshoot the circuit and hardware making.
Objective: To check either circuit or coding is problem.
Result and analysis: problem with code arrangement of servo
Conclusion:  make it another code
Verification:
Supervisor's sign:


Date: 01/10/2018 – 05/10/2018
_________________________________________________________________________________
Week 12
Activity: continue with previous activity, 
Objective:
Result and analysis:  all related making process are in link: fyp making
Conclusion:  all simulation is working well.
Verification:
Supervisor's sign:


Date: 08/10/2018 – 12/10/2018
_________________________________________________________________________________
Week 13
Activity: troubleshoot the circuit and hardware making.
Objective:  combine software and hardware
Result and analysis:

#include <reg51.h>
#include <stdio.h>
#include <intrins.h>

sbit sw1 = P1^0; //define switch
sbit sw2 = P1^1; //define switch
sbit sw3 = P1^2; //define switch
sbit Mp=P2^0;
sbit Mn=P2^1;
sbit motor1_pin=P2^2;

void Delay(unsigned int);
void main(void);
void Delay_servo(unsigned int us);
void main()
{

while (1)
{
if (sw1 == 0 && sw2 == 1&& sw3 == 1)
{
Mp=1;
Mn=0;

motor1_pin=1;
   Delay_servo(124);
   motor1_pin=0;


}
   else if(sw1 == 0 && sw2 == 0 && sw3 == 1) //when switch 1 pressed
   {
   Mp = 1;
   Mn = 1; //Stops Motor
   motor1_pin=1;
   Delay_servo(185);
   motor1_pin=0;
   Delay(1000);  
   }
else if (sw1 == 0 && sw2 == 1 && sw3 == 0) //when switch 1 pressed
{
   Mp = 1;
   Mn = 1; //Stops Motor
   motor1_pin=1;
   Delay_servo(185);
   motor1_pin=0;
   Delay(1000);

   }

else
{
Mp=1;
       Mn=1;

// motor1_pin=1;
//    Delay_servo(124);
//    motor1_pin=0;
    }
}
}


void Delay(unsigned int ms)
{
  unsigned long int us = ms*1000;
 while(us--)
 {
    _nop_();
  }  
}

void Delay_servo(unsigned int us)
{
 while(us--)
 {
    _nop_();
  }  


}

// latest: when ir detect trash, motor dc rotate then when next sensor detect trash then servo on. 
//when test to hardware, sensor is not working. when troubleshoot is doing, 5v regulator is not regulate ( at this time, using 12v adaptor).
Conclusion:  change the adaptor by using 12v rechargeable battery
Verification:
Supervisor's sign:


Date: 15/10/2018 – 19/10/2018
_________________________________________________________________________________
Week 14
Activity: industrial day
Objective: present final prototype product
Result and analysis: the circuit is not working well, the microcontroller is burn due to previous problem.



the poster
project prototype
Verification:
Supervisor's sign:



Date: 22/10/2018 – 26/10/2018
_________________________________________________________________________________
Week 15
Activity: report writing
Objective:  report writing on chapter 4  & 5.
Result and analysis:
Conclusion:
Verification:
Supervisor's sign:



Date: 29/10/2018 – 02/11/2018
_________________________________________________________________________________
Week 16
Activity: continuous with previous activity in week 15 and finalize all chapter
Objective:  to combine and checking plagiarism
Result and analysis:
Conclusion:
Verification:
Supervisor's sign:



Date: 05/11/2018 – 09/11/2018
_________________________________________________________________________________
Week 17
Activity: final report 
Objective: checking plagiarism
Result and analysis: 6% 
Conclusion: proceed with hard cover copy
Verification:
Supervisor's sign:



Date: 12/11/2018 – 16/11/2018