Tuesday 15 May 2012

project development & presentation day



Programming Development

The circuit had been draw and simulated by using PCB Wizard software. While the coding used in the PIC16F877A is in C Programming which had been compile and run by using C-Compiler software. Then, the programs are loaded into the PIC microchip. After that, the PIC is attached to the circuit to run the project.  The circuit connections for Smart Mailbox are as shown in Figure below.

The Circuit Connection

The sensor detects incoming mail and number of mail based on the calculation in the methodology. The data from the sensor are send to the PIC and converted from analog to digital signal. According to the data signal from the circuit that had been build, the data are send to the receiver.
After each program file was loaded into each microcontroller using PIC KIT programmer, IR Sensor and GSM Module was installed into the mailbox. Then all circuit board was switched on as Figure below.
The Circuit installed into the Mailbox

Before the letter inserted into the mailbox, the LED is turn GREEN to show the empty of mailbox. After the letter has been inserted into the mailbox, the LED turned on to the RED to inform the letter is inside the mailbox. The buzzer produces sound after few moments or GSM will send message to the user to inform the incoming mail.

 Overall Result Analysis of The Project

List of Connected Sensor/Actuator to the PIC

PIC I/O Pin
Connected To
Sensor / Actuator
Function
RA0
IR sensor
To detect mail
RB0
Pin E LCD
Display message on LCD
RB1
Pin RS LCD
Display message on LCD
RB2
Pin R/W LCD
Display message on LCD
RB4
Pin DB4 LCD
Display message on LCD
RB5
Pin DB5 LCD
Display message on LCD
RB6
Pin DB6 LCD
Display message on LCD
RB7
Pin DB7 LCD
Display message on LCD
RC0
Red LED
Turn on red LED
RC1
Green LED
Turn on green LED
RC4
Push button 1

RC6
Pin 11 max232
Send data to GSM
RC7
Pin 12 max232
Receive data from GSM
RD2
Push button 2

RD3
Push button 3

RE0
Buzzer
Turn on buzzer



Result And Analysis - Part 3 -




4.2.4        PIC16F877A Microcontroller Programming

This project use PIC 16F877A as a controller. A 5V voltage supplied to the circuit. Figure 4.7 shows the circuit with normal condition when tested from oscilloscope. Voltage peak-peak is 5.20V. Figure below shows the voltage of the supply 12VDC.


Normal Condition of Power Supply

The wave of the supply is taking it from oscilloscope as shown as below.


Voltage for Supply

Result And Analysis - Part 2-




Buzzer as Output (First Method)


Buzzer 5V is the output for the input IR sensor. The toggle switch pressed and LCD display will be turn to SMS = 0, the buzzer mode will active. When the IR Sensor detects the mail, the buzzer will be sound according to the set point that had been set. The display of the buzzer mode shows in Figure 4.2.




Display mode for Buzzer active

SMS as Output (Second Method)


GSM technology 7.5V is using to send Short Messaging System (SMS) to the user. GSM frequency range is 900-1800 MHz’s. When the mode is active for notification of SMS (SMS=1) the GSM module will be active. Once the input IR Sensor detects the mail, GSM will send the SMS to the user. Message setting coding are loaded into the PIC microchip. This coding are designed to simplify the user and they are easily can set the message character and phone number. The Figure below shows the SMS receiving from the GSM for the first notification when the project ON. 
GSM active for sending SMS

The Figure below has shown the display in LCD of the GSM mode. GSM mode is SMS=1.


Display for GSM active mode

The Figure below is shown the wave of the GSM frequency and the result is 904.8MHz. This frequency is in the range of the GSM frequency (900-1800MHZ).



The Frequency of GSM

This Figure below shows the receiving of SMS which is sending via GSM to inform the number of the mail when the mail inserted in to the mailbox.



SMS receive to notice the mail


Result And Analysis - Part 1-
















GP2D12 Sensor (IR Sensor) as input for PIC Microcontroller

One I/O pin is needed for one IR Sensor as input for PIC microcontroller. The connection of the IR Sensor to the I/O pin is 5V. This sensor can measure object in the range 10cm-80cm. Figure 4.1 shows Input IR sensor interface with PIC microcontroller and Table 2 approximately voltage for distance object (letter).


                                       Voltage Calculation for distance object



DISTANCE OBJECT (LETTER)
APPROXIMATELY VOLTAGE
10cm
2.4V
20cm
1.93V
30cm
1.66V
40cm
1.47V
50cm
1V
60cm
0.52V
70cm
0.3V
80cm
0.16V


Sunday 1 April 2012

Week 10: short summary of the project




The circuit had been draw and simulated by using PCB Wizard software. While the coding used in the PIC16F877A is in C Programming which had been compile and run by using C-Compiler software. Then, the programs are loaded into the PIC microchip. After that, the PIC is attached to the circuit to run the project. 



The Circuit Connection
When the project completely done, the sensor detects incoming mail and number of mail. The data from the sensor are send to the PIC and was converted from analog to digital signal. According to the data signal from the circuit that had been build, the data are send to the receiver.After I loaded each program file into  microcontroller, I installed  IR Sensor and GSM Module into the mailbox. Then all circuit board was switched on as shown below:-

The Circuit installed into the Mailbox
Before the letter inserted into the mailbox, the LED is turn GREEN to show that the mailbox is empty. After the letter has been inserted into the mailbox, the LED turned on to the RED to inform the letter is inside the mailbox. The buzzer produces sound after few moments or GSM will send message to the user to inform the incoming mail.




week 9:get ready for presentation to advisor



On Thursday, 22th March 2012 I had my project presentation in front of my advisor.  But unfortunately, I only presented 80% of my project because I'm having a problem in PIC microcontroller programs.  Being so grateful because having a very understanding advisor that  giving me no pressure to complete the other 20% of the project. The problem occurred from the program that can't be send SMS to the phone which was being the second output methods of my project.  One day before my presentation day, I had solved the problem but unfortunately I didn't have the time to burn the program into the PIC.  There's the picture of my completed prototype of the project.






Saturday 31 March 2012

WEEK 8:PIC PROGRAM FOR GSM SMART MAILBOX


Complete program which was develop by my sister's friend.

#include <16f877a.h> //use pic16f877a pic
#device adc=8     //use 8 bit adc
#use delay(clock=20000000) //speed 20mhz
#fuses hs, noprotect, nowdt, nolvp  //default setting
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,PARITY=N)//gsm setting
#define use_portb_lcd TRUE //use portb for lcd
#include <lcd.c>  //call lcd.c library

//pic port address
#byte porta=5
#byte portb=6
#byte portc=7
#byte portd=8
#byte porte=9

void main()
{
   int ir_in;
   int sms_mod=1;
   int ir_en=1;
   long int sp=3;
   long int count=0;
   int c0_sta=1;
   int c1_sta=1;
   int c2_sta=1;

   //set i/o pin for pic
   set_tris_a(0b00000001);
   set_tris_b(0b00000000);
   set_tris_c(0b10000111);
   set_tris_d(0b00000000); 
   set_tris_e(0b00000000); 
   setup_port_a(RA0_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(0);

   //initialize lcd
   lcd_init();
   lcd_putc("\fAutomatic");
   lcd_putc("\nMailbox");

   output_high(pin_d6); //on buzzer
   output_high(pin_a1); //on red led
   output_high(pin_a2); //on green led
   delay_ms(1000); 
   output_low(pin_d6); //off buzzer
   delay_ms(20000);

   //send sms out to annouce system started
   printf("AT+CMGF=1\r");
   delay_ms(1000);   
   printf("AT+CMGD=1\r");   
   delay_ms(1000);   
   printf("AT+CMGF=1\r");
   delay_ms(1000);   
   printf("AT+CMGD=1\r");   
   delay_ms(1000);   

   printf("AT+CMGS=");
   putc(0x22);
   printf("+60179272562");
   putc(0x22);
   putc(0x0D);           
   delay_ms(500);
   printf("Automatic Mailbox Started");
   putc(0x1A);
   delay_ms(2000);          
   printf("AT+CMGD=1\r");   
   delay_ms(1000);

   output_low(pin_a1); //off red led
   output_high(pin_a2); //on green led     

   do
   {
      //read ir sensor
      ir_in=read_adc();

      if(ir_in>=90 && ir_en==1) //if letter detected
      {
         count=count+1; //up count counter         

         if(count>=sp) //if letter full
         {
            if(sms_mod==1) //if sms mode activated
            {
               //send sms out to annouce system started
               printf("AT+CMGS=");
               putc(0x22);
               printf("+60179272562");
               putc(0x22);
               putc(0x0D);           
               delay_ms(500);
               printf("Total letter:%03lu",count);
               putc(0x1A);
               delay_ms(2000);          
               printf("AT+CMGD=1\r");   
               delay_ms(1000);            
            }
         }
         else
         {
            output_low(pin_d6); //off buzzer         
         }

         ir_en=0;
      }
      else if(ir_in<100)
      {
         ir_en=1;
      }

      if(input(pin_c0)==0 && c0_sta==1)   //if upcount button pressed
      {
         if(sp<1000) //up count sp
         {
            sp=sp+1;
         }
         else
         {
            sp=0; 
         }
         c0_sta=0;
      }
      else if(input(pin_c0)==1) //if upcount button released
      {
         c0_sta=1;
      }

      if(input(pin_c1)==0 && c1_sta==1)   //if down count button pressed
      {
         if(sp>0) //down count sp
         {
            sp=sp-1;
         }
         else
         {
            sp=0; 
         }
         c1_sta=0;
      }
      else if(input(pin_c1)==1) //if down button released
      {
         c1_sta=1;
      }

      if(input(pin_c2)==0 && c2_sta==1)   //if change mode button pressed
      {
         if(sms_mod==0) //toggle mode
         {
            sms_mod=1;
         }
         else
         {
            sms_mod=0; 
         }
         c2_sta=0;
      }
      else if(input(pin_c2)==1) //if down button released
      {
         c2_sta=1;
      }

      if(sms_mod==1) //if sms mode activated
      {
         output_low(pin_d6); //off buzzer
      }
      else //if sms mode not activated
      {
         if(count<sp) //if not reached set point
         {                
            output_low(pin_d6); //off buzzer
         }                 
         else
         {
            output_high(pin_d6); //on buzzer         
         }
      }

      if(count>=sp)//if  set point reached
      {
         output_high(pin_a1); //on red led
         output_low(pin_a2); //off green led                    
      }
      else
      {
         output_low(pin_a1); //off red led
         output_high(pin_a2); //on green led           
      }

      printf(lcd_putc,"\fTot Letter:%03lu",count);
      printf(lcd_putc,"\nSP:%03lu SMS:%u",sp, sms_mod);
      delay_ms(250);

   }while(1);
}