Translate

MEMBUAT ALAT DENGAN KENDALI RFID READER ID-12 dan ACCELEROMETER ( CV AVR ) CODE VISION AVR

MEMBUAT ALAT DENGAN KENDALI RFID READER ID-12 dan ACCELEROMETER ( CV AVR ) CODE VISION AVR


              Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat yang digunakan untuk mengendalikan sepeda motor dengan menggunakan kartu atau tag card RFID. reader yang digunakan pada alat ini yaitu ID-12 atau bisa juga dengan RDM630 / 6300 sama saja. output pada alat ini seharusnya adalah relay namun simulasi kali ini hanya menggunakan led. sensor accelerometer yang digunakan adalah GY 61 sebagai detektor maling, jadi jika motor berubah kemiringannya, maka buzzer akan ON otomatis. untuk lebih jelasnya berikut adalah skema dan programnya.



 a. Minimum System





b. RFID Reader ID-12





c. Sensor ACCELEROMETER GY-61 








d. Program CV AVR (Code Vision AVR)

/*****************************************************
This program was produced by the
CodeWizardAVR V2.04.4a Advanced
Automatic Program Generator
© Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project :
Version :
Date    : 6/23/2016
Author  : NeVaDa
Company : HP InfoTech s.r.l.
Comments:


Chip type               : ATmega16
Program type            : Application
AVR Core Clock frequency: 12.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 256
*****************************************************/

#include <mega16.h>

#include <delay.h>
#include <string.h>
#include <stdlib.h>

// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd.h>

// Standard Input/Output functions
#include <stdio.h>

#define ADC_VREF_TYPE 0x40

// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}

// Declare your global variables here

unsigned char pass[13] = "6F0085C0173";
unsigned char passx[13] = "780027BA5FB";

unsigned char code[13];
int val = 0;
int bytesread;
int count = 0;
int Dataadcx;
char tampungx[100];
int Dataadcy;
char tampungy[100];


void tampil(){

          PORTB.2 = 0;
          PORTB.3 = 0;
          PORTB.4 = 0;
          PORTB.5 = 0; 
       
         Dataadcx = read_adc(0);
    
         itoa(Dataadcx,tampungx);    
         lcd_gotoxy (0,1);
         lcd_puts(tampungx);
        
     if ((Dataadcx > 350 )||( Dataadcx < 300)){
       PORTB.6 = 1;
      }
      else{
       PORTB.6 = 0;
      }
 
         Dataadcy = read_adc(1);
    
         itoa(Dataadcy,tampungy);    
         lcd_gotoxy (5,1);
         lcd_puts(tampungy);
        
         delay_ms(1000);
     
       
      if (PIND.2 == 0){     
      tampil();     
      }
     

     
     
}


void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;

// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0xFF;

// Port C initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTC=0x00;
DDRC=0xFF;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: Off
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x10;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x4D;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC Clock frequency: 750.000 kHz
// ADC Voltage Reference: AVCC pin
// ADC Auto Trigger Source: Free Running
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0xA4;
SFIOR&=0x1F;

PORTD.2 = 1;

// LCD module initialization
lcd_init(16);

while (1)
      {
     
      if (PIND.2 == 0){     
      lcd_clear();
      tampil();     
      }
     
     
     Dataadcx = read_adc(0);
     Dataadcy = read_adc(1);
    
           
    // Place your code here
    if((val=getchar()) == 2) {
    bytesread = 0;
    while(bytesread<11) {
      val = getchar();
      if((val==3)) {
        break;
      }
  
      code[bytesread] = val;
      bytesread++;
    }
   
    if(bytesread == 11) {
      lcd_clear();
      lcd_puts(code);
                    
    }        
   
          if( strcmp(code,pass) == 0 )
          {
          count++;
         
          if(count > 5 ){
          count = 1;
          }
         
         
          if(count == 1){
        
         Dataadcx = read_adc(0);
    
         itoa(Dataadcx,tampungx);    
         lcd_gotoxy (0,1);
         lcd_puts(tampungx);
 
         Dataadcy = read_adc(1);
    
         itoa(Dataadcy,tampungy);    
         lcd_gotoxy (5,1);
         lcd_puts(tampungy);
        
         delay_ms(1000);
 
          tampil();
         
         }
         
          if(count == 2){
          lcd_gotoxy(0,1); 
          lcd_puts("RELAY 1 ON");
         
          PORTB.2 = 1;
          PORTB.3 = 0;
          PORTB.4 = 0;
          PORTB.5 = 0;
         
          }
          if(count == 3){
          lcd_gotoxy(0,1); 
          lcd_puts("RELAY 2 ON");
         
          PORTB.2 = 0;
          PORTB.3 = 1;
          PORTB.4 = 0;
          PORTB.5 = 0;
         
          }
          if(count == 4){
          lcd_gotoxy(0,1); 
          lcd_puts("RELAY 3 ON");
         
          PORTB.2 = 0;
          PORTB.3 = 0;
          PORTB.4 = 1;
          PORTB.5 = 0;
          }          
         
          if(count == 5){
          lcd_gotoxy(0,1); 
          lcd_puts("RELAY 4 ON");
         
          PORTB.2 = 0;
          PORTB.3 = 0;
          PORTB.4 = 0;
          PORTB.5 = 1;
         
          }
         
         
          } 
          else {
            lcd_gotoxy(0,1); 
            lcd_puts("salah");        
          }
          
         
         
           if( strcmp(code,passx) == 0 )
          {
          count++;
         
          
          if(count > 5 ){
          count = 1;
          }
         
         
          if(count == 1){
        
         Dataadcx = read_adc(0);
    
         itoa(Dataadcx,tampungx);    
         lcd_gotoxy (0,1);
         lcd_puts(tampungx);
 
         Dataadcy = read_adc(1);
    
         itoa(Dataadcy,tampungy);    
         lcd_gotoxy (5,1);
         lcd_puts(tampungy);
        
         delay_ms(1000);
 
          tampil();
         
         }
         
          if(count == 2){
          lcd_gotoxy(0,1); 
          lcd_puts("RELAY 1 ON");
         
          PORTB.2 = 1;
          PORTB.3 = 0;
          PORTB.4 = 0;
          PORTB.5 = 0;
         
          }
          if(count == 3){
          lcd_gotoxy(0,1); 
          lcd_puts("RELAY 2 ON");
         
          PORTB.2 = 0;
          PORTB.3 = 1;
          PORTB.4 = 0;
          PORTB.5 = 0;
         
          }
          if(count == 4){
          lcd_gotoxy(0,1); 
          lcd_puts("RELAY 3 ON");
         
          PORTB.2 = 0;
          PORTB.3 = 0;
          PORTB.4 = 1;
          PORTB.5 = 0;
          }          
         
          if(count == 5){
          lcd_gotoxy(0,1); 
          lcd_puts("RELAY 4 ON");
         
          PORTB.2 = 0;
          PORTB.3 = 0;
          PORTB.4 = 0;
          PORTB.5 = 1;
         
          }
         
         
          } 
          else {
            lcd_gotoxy(0,1); 
            lcd_puts("salah");        
          }
            
    bytesread = 0;
  }
             
      };
}





e. VIDEO HASILNYA









 

No comments:

Post a Comment