Monday, 27 August 2012

Week 5 (Final Semester)

Title : Buying the component

Objective:


  • To buy the components for the project
  • To discover the suitable place to buy the components

Content:

This project mainly have two parts, which is the transmitter circuit parts and the receiver circuit parts. After write down all the components that need to be bought for the project, the Bizchip company has been chose as a components dealer because of the price and transportation. These are the components that has been bought from the dealer

For transmitter circuit



For receiver circuit


and the additional of remote control car and the lock mechanism that not including on the list.

Analysis:

There are discount that has been given from the dealer because of buying huge numbers of components. And the PIC and the RF sensor has two month warranty if there is some dysfunctional on these components

Conclusion:

All the component has been bought, the next step is to testing the component to make sure the component function.

Monday, 20 August 2012

Week 4 (Final Semester)

Title: Program designing

Objective:


  • To design a program proportional with the flow chart of the project
  • To master C compiler software
  • To master C language

Content:

PCWH C-Compiler Software

PCWH powerful C-Compiler that developed by CCS Co. USA. The software is designed mainly for 8 bit chip microcontroller embedded system. It supports a wide range of PIC micro-controllers, including PIC10, PIC12, PIC14, PIC16, and PIC18. The software also has broad library functions at which programmer can access.
In general, the PCWH C-Compiler allows user:
  • Write the C code using advanced code editor.
  • By using "include" function, accessing or processing of code become even faster.
  • Control the execution of the program at which the "error" will be reported when bugs are detected.
  • Samples of program also provided in the helps file.


            To used the software creating a project, make sure a copy of PCWH available in the computer. User can download a 30 days trial copy from http://ccsinfo.com/ccsfreedemo.php. Follow steps by steps on the instruction during installation process and finally user will see an icon of PCWH appears on the desktop of the computer.

Steps to use PCWH C-Compiler

1.    Open PCW C-Compiler Start->All Programs->PIC-C->PIC C Compiler.
2.    ‘File’ -> ‘New’ to start a new file.
3.    Save the file as .c file, it is advisable to put the main file name within 8 chars length, extended file name must be .c, e.g. myprog1.c.
4.    Type / Edit your program.
5.    Save program before compile.
6.    Compile your program using F9.
7.    If any error occurs, please check your program and compile again. Otherwise you won’t get your .hex file.

    
For the project, by using this software, there are two program need to be design which is for the transmitter and the receiver. These two programs are necessary to make sure the project function smoothly. After countless trial and compiling, finally the programs works and ready to use.

Program for transmitter (PIC 16F876A)

#include <16f876A.h>       //use pic16f876a library
#use delay(clock=20000000) //set pic clock speed as 20mhz
#use rs232(baud=4800,xmit=PIN_C6,rcv=PIN_C7,PARITY=N) //set serial interfacing
#fuses hs,protect,nowdt,nolvp //default setting

#byte PORTA=5 //define PORT A address
#byte PORTB=6 //define PORT B address
#byte PORTC=7 //define PORT C address

void main()
{
   int i=0;

   //set i/o for each pin
   set_tris_a(0b00000000); 
   set_tris_b(0b00000000); 
   set_tris_c(0b10000000); 

   output_high(pin_c2); //on led
   delay_ms(1000);
   output_low(pin_c2);  //off led
   delay_ms(1000);

   do
   {
      output_high(pin_c2); //on led

      //send data out
      for(i=0;i<10;i++)
      {
         putc('(');
         putc('1');
         putc(')');
         delay_ms(10);
      }

      output_low(pin_c2);  //off led
      delay_ms(3000);

   }while(1);
}

Program for receiver (PIC 16F877A)

#include <16f877A.h> //use pic16f877a
#use delay(clock=20000000) //set pic speed 20mhz
#fuses hs,noprotect,nowdt,nolvp  //default setting
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7, parity=N) //set serial interfacing

#byte PORTA=5 
#byte PORTB=6 
#byte PORTC=7 
#byte PORTD=8 
#byte PORTE=9 

int rx_temp1=0;
int rx_temp3=0;
int rcvdata;
int mystat=0;

//receive data from transmitter
#int_rda
void serial_isr()
{
   rx_temp1=getch();
   if(rx_temp1=='(')
   {
      rcvdata=getc();
      rx_temp3=getch();
      if(rx_temp3==')')
      {
         mystat=1;
      }
   }

   rx_temp1=0;
   rx_temp3=0;

}

void main()
{
   int id1sta=0;
   int id1count=0;

   set_tris_a(0b00000000);    //set i/o pin for port a
   set_tris_b(0b00000000);    //set i/o pin for port b
   set_tris_c(0b10011000);    //set i/o pin for port c
   set_tris_d(0b00000110);    //set i/o pin for port d
   set_tris_e(0b00000000);    //set i/o pin for port e

   //initialize interrupt
   enable_interrupts(int_rda);
   enable_interrupts(GLOBAL);

   output_low(pin_d5);  //stop motor1
   output_low(pin_d4);  //stop motor2
   output_low(pin_c5);  //lock door
   output_high(pin_c0);  //on blue led
   output_high(pin_c1);  //on white led1
   output_high(pin_c2);  //on white led2
   delay_ms(1000);
   output_low(pin_c0);  //off blue led
   output_low(pin_c1);  //off white led1
   output_low(pin_c2);  //off white led2
   delay_ms(1000);

   do
   {
      //if RF receiver received valid data
      if(mystat==1)
      {
         mystat=0;
         if(rcvdata=='1')  //if '1' received
         {
            id1sta=1;
            id1count=0;            
         }
      }
      else
      {
         if(id1count<6)    //if transmitter lost less than 3sec
         {
            id1count=id1count+1; //increase timer
         }
         else  //if 3sec reached
         {
            id1sta=0;            
         }
      }

      if(id1sta==1)  //if transmitter in range
      {
         output_high(pin_c5);  //unlock door

         output_high(pin_c0);  //on blue led
         delay_ms(250);
         output_low(pin_c0);   //off blue led
         delay_ms(250);

         if(input(pin_d1)==0) //if on white led button pressed
         {
            output_high(pin_c1);  //on white led1
            output_high(pin_c2);  //on white led2         
         }
         if(input(pin_d3)==0) //if off white led button pressed
         {
            output_low(pin_c1);  //off white led1
            output_low(pin_c2);  //off white led2               
         }

         if(input(pin_d2)==0) //if on motor button pressed
         {
            output_high(pin_d5);  //run motor1
            output_high(pin_d4);  //run motor2
         }
         if(input(pin_c4)==0) //if off motor button pressed
         {
            output_low(pin_d5);  //stop motor1
            output_low(pin_d4);  //stop motor2
         }
      }
      else  //if transmitter out of range
      {
         output_low(pin_c1);  //off white led1
         output_low(pin_c2);  //off white led2                     
         output_low(pin_c5);  //lock door
         output_low(pin_d5);  //stop motor1
         output_low(pin_d4);  //stop motor2
      }     

      delay_ms(500);
      
   }while(1);
}


Analysis:

The program on receiver circuit are longer than the program on the transmitter circuit because the transmitter job is only send a signal to the receiver when the transmitter is on the range, while the receiver  circuit do all the works such as running the motor, switch, led's.

Conclusion:

There are numbers of the software that can be use to design a program. C compiler has been use is because this software is quite simple and easy to use. And with program and circuit is already design, purchasing the component will be the next step of the project






Monday, 13 August 2012

Week 3 (Final Semester)

Title: Circuit design

Objective:

  • To master the PROTEL DXP software
  • To design circuit for the project
  • Testing the circuit by simulation


Content:

After several error had been corrected, finally the final circuit for the Automatic Car Lock/Unlock system has been ready to fabric. Because of the RF sensor has two main part, which is the transmitter and the receiver, so the circuit also split to two. This is the two circuit before it convert for PCB fabrication

Transmitter circuit

Normal circuit



Convert for fabrication

-Components
 -Pins

-components and pins



Receiver ciruit

-Normal circuit


-Components


-Pins


-Components and Pins



Analysis:

While design this circuit, the lay out must be as simpler as it can and the lay out must must below 90 degrees at the corner. If not the circuit will have some error when operate. The name and the ID number on the lay out is to keep the originality as a designer.


Conclusion:

With the circuit lay out is finish, next week will begin purchasing the components and the hardware of the project 

Monday, 6 August 2012

Week 2 (Final Semester)

Title: New flow chart and block diagram


Objective:


  • To notify the change had made on the flow chart and the block diagram
  • To show the new system flow
  • To identified the scope of the project

Content:

The new flow chart of the Automatic Car Lock/Unlock System


there are slightly change from the previous flow chart where there are no timer, means after the receiver get the signal from the transmitter, the car will unlock and the engine will not start automatically. The push button are added to turn on or off the engine and the light of the car.


Block Diagram of the project



The block diagram contain two parts which is the Transmitter and Receiver as the RF sensor has those two parts.


Analysis:

The RF sensor is contain two main part which is the transmitter and the receiver. With those two parts, the system need two different PIC to make sure this project work smoothly without any problem. Those PIC is 16F876A for the transmitter and 16F877A for the receiver. The PIC on the transmitter is simpler and smaller for portable usage.

Conclusion:

This block diagram and flow chart is more accurate than the previous one. With this block diagram and flow chart ready, the project will start in no time.