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);
}





Week 6







After finish to solder my circuit, I’m having problem in connecting the circuit with the input and all the outputs.  So, I ask my sister to help me in doing that because I need to done this circuit before the end of my semester break.  To be frank, without my sister and her friend help’s I will face the difficulty in accomplish all of this including the hardware and software process.  Just so you know miss because I’m not doing this project 100% on my own. There’s the picture of my circuit’s connection with all the input and outputs.

Connection of the circuit with all the outputs (GSM, LCD and buzzer)


week 7 (phase test week)





Saturday 17 March 2012

Week 5: Etching PRoCeSS




Actually I’ve got some help in etching my project because that time was my semester break.  I’ve asked my sister who is studying at UTHM to help me etching my PCB Board.  There’s some picture of the etching process.  Eventhough my etching process was doing by my sister, I’m also learning how to etching with my several friend just to know how the process it is.  Well, I’ve also already been exposed on how to do myself the etching when I’m was doing my diploma’s final project. There’s the flow of etching process:-

a) Build the PCB layout
PCB Fabrication
1. PCB Drawing: PCB drawing is designed using Protel DXP 2005, this software can automatically convert schematic file to PCB automatically.
2.    Film Printing: After PCB file is generated, use laser printer to print it on transparency.
3.    PCB Cutting: Cut photo PCB size according to the film size.
4.    PCB Photo Etching: Expose the photo PCB in photo etching kit for 8-10minutes.
5.    PCB Developing: Wash the PCB using PCB developer (white powder) for 2 min.
6.    Acid Etching: After PCB is developed, put it in Ferric Chloride liquid. Add in hot water (80C) and shake the water until you see unused part is ‘washed’ and left only the tracks. The etching process takes around 30 min.
7.    Alcohol Washing: Wash the PCB with alcohol to get rid off the green coating.
8.    Drilling: Drill PCB after alcohol washing, use drill bit 0.8mm, 1.0mm and 1.2mm.
9.    Soldering: Place all components on the PCB, use tape to stick all components tightly on the PCB and then solder the components using soldering iron and lead.


b) complete the PCB board.











After the drilling, I’ve continued the process to complete my circuit.  Honestly, I’ve got too many helps from my sister and her friend in accomplish this circuit. Now its turn to connect this circuit with the all the output.

To be continued.....