EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / IR based Vehicle over speed detector using 89c51 microcontroller

IR based Vehicle over speed detector using 89c51 microcontroller

|

Microcontroller › 8051 › IR based Vehicle over speed detector using 89c51 microcontroller

  • This topic has 1 reply, 2 voices, and was last updated 5 years, 3 months ago by Ashutosh Bhatt.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • April 10, 2017 at 10:23 pm #4641
    banda
    Participant

    am trying to make an automatic speed checker for final year project using IR sensor and a microcontroller interfaced with RF TxRX module for remote reporting. however, my code in which am using interrupts is only able to detect the first car then it fails to reset. how can i go about it?

    below is the code.help

    /// almost done///

    #include<reg51.h>

    #include<string.h>

    sfr LCD=0x80;

    sbit RS=P2^7;

    sbit EN=P2^6;

    sbit led=P2^5;

    unsigned int a=0, i=0, v;

    unsigned int flag=0,d;

    void tm();

    void delay(unsigned char time)

    {

    unsigned int a,b;

    for(a=0;a<time;a++)

    for(b=0;b<1275;b++);

    }

    void lcdcmd(unsigned char value)

    {

    LCD=value;

    RS=0;

    EN=1;

    delay(10);

    EN=0;

    }

    void lcddata(unsigned char value)

    {

    LCD=value;

    RS=1;

    EN=1;

    delay(10);

    EN=0;

    }

    void lcd_init()

    {lcdcmd(0x38);

    delay(20);

    lcdcmd(0x0c);

    delay(20);

    lcdcmd(0x01);

    delay(20);

    lcdcmd(0x06);

    delay(20);

    }

    void writestr(unsigned char*s)

    {

    unsigned char l,i;

    l=strlen(s);

    for(i=0; i<l;i++)

    {

    lcddata(*s);

    s++;

    }

    }

    void ISR_ex0(void) interrupt 0

    {

    while(P3^3!=0)

    { led=0;

    tm();

    a++;

    }

    led=1;

    a=0;

    }

     

     void display()

     { unsigned char m,n,temp,o;

     while(IE1==0)

     {

    v=100/a;

    m=v/100;

    temp=v%100;

    n=temp/10;

    o=temp%10;

    if (v>=60)

    {lcdcmd(0x3C);

    lcdcmd(0x0E);

    lcdcmd(0x01);

    lcdcmd(0x80);

     

    writestr("OVERSPEED DETECTED");

    lcdcmd(0xc6);

    lcdcmd(0x84);

    lcdcmd(0xc0);

    lcddata(m+48);

    lcddata(n+48);

    lcddata(o+48);

    lcddata('K');

    lcddata('M');

    lcddata('/');

    lcddata('H');

    lcddata(' ');

    lcddata(' ');

    delay(1500);}

    else if(v<=50)

    {

     lcdcmd(0x01);

    writestr("SPEED:");

    lcdcmd(0xc6);

    lcddata(m+48);

    lcddata(n+48);

    lcddata(o+48);

    lcddata('K');

    lcddata('M');

    lcddata('/');

    lcddata('H');

    lcddata(' ');

    lcddata(' ');

    EX0=0;

     }

     }

     }

     void ISR_ex1(void) interrupt 2

    {

    delay(1500);

     display();

    v=100/a;

     

    EX0=0;

    led=1;

     

    }

     

    void main()

    {

    IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2)

    EX0 = 1; // Enable EX0 Interrupt

    IT1 = 1; // Configure interrupt 1 for falling edge on /INT0 (P3.2)

    EX1 = 1; // Enable EX1 Interrupt

    EA=1; // Enable Global Interrupt Flag

    PX1=1; // Priority of ex1 high

    led=0;

    led=1;

    lcd_init();

    lcdcmd(0x84);

    lcdcmd(0xc0);

    writestr("SPEED DETECTOR");

    delay(1500);

    while(i);

    }

     

    void tm()

    {

    int y=0;

    for(y=0;y<15;y++)

    {

    TMOD=0x01;

    TL0=0xFD;

    TH0=0x4B;

    TR0=1;

    while(TF0==0);

    TR0=0;

    TF0=0;

    }

    }

    April 20, 2017 at 12:01 pm #14573
    Ashutosh Bhatt
    Participant

    have you disabled interrupt?

    have you enabled interrupts again?

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Washing Machine motor August 14, 2022
  • arduino help needed August 14, 2022
  • Looking for amplifier ic August 14, 2022
  • Light Automation via mqtt August 14, 2022
  • Right channel distortion on vintage fisher rs-2010 August 14, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools