1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

guys help pls in conveyor object counting

Discussion in 'Microcontrollers' started by cyanpraveen, Jun 7, 2011.

  1. cyanpraveen

    cyanpraveen New Member

    Likes Received:
    0
    Trophy Points:
    0
    Guys i m trying to count the no of objects passing in a conveyor belt. for that purpose i am using IR sensor. When sensor goes low it have increase the count by 1.
    Now the problem is in the debugger mode it increments the count properly. but while displaying in LCD it increment the count twice...
    And i want to know whether i had followed correct procedure.. since i am new to this programming field. i had include my code below

    Code (Text):
    1. P3   = 0x00;
    2.     LED1 = 1;
    3. /* LCD initialization */   
    4.     InitializeLCD();
    5.  
    6.     /* Display project titles */
    7.     DisplayProjectTitle();
    8.    
    9.     *ArrayBasePtr=&UserMessageStorage;
    10.    
    11.     EA   = 1;
    12.     EX0  = 1;
    13.     IT0  = 1;
    14.          
    15.     while(True)
    16.     {
    17.  
    18. /* Serial bit transmissions */
    19.         SerTx(TotalCount[0]);
    20.         SerTx(TotalCount[1]);
    21.         SerTx(TotalCount[2]);
    22.        
    23.                 ArrayBasePtr="  TOTAL OBJECTS  ";
    24.         DisplayLCD(1,0,ArrayBasePtr);
    25.         ArrayBasePtr=&TotalCount[0];
    26.         DisplayLCD(2,5,ArrayBasePtr);
    27.         TimeDelay(850);
    28.         LCD_CLEAR();
    29. void Extint0 (void) interrupt 0
    30. {
    31. //  IE0=0;
    32.   value++;
    33.   Count = value;
    34.  
    35.         UserMessageStorage[4]= Count/100;
    36.         Count=(Count-(UserMessageStorage[4]*100));
    37.         UserMessageStorage[4]+=0x30;
    38.        
    39.         UserMessageStorage[5]= Count/10;
    40.         Count=(Count-(UserMessageStorage[5]*10));
    41.         UserMessageStorage[5]+=0x30;
    42.        
    43.         UserMessageStorage[6]= Count%10;
    44.         UserMessageStorage[6]+=0x30;
    45.        
    46.         TotalCount[0] =  UserMessageStorage[4];
    47.         TotalCount[1] =  UserMessageStorage[5];
    48.         TotalCount[2] =  UserMessageStorage[6];
    49.  
    50.         ArrayBasePtr="  TOTAL OBJECTS  ";
    51.         DisplayLCD(1,0,ArrayBasePtr);
    52.         ArrayBasePtr=&TotalCount[0];
    53.         DisplayLCD(2,5,ArrayBasePtr);
    54.  
    55.         TimeDelay(850);
    56.         LCD_CLEAR();
    57.  }
    thanks for you help
    Tags:
  2. Binu

    Binu Administrator

    Likes Received:
    138
    Trophy Points:
    63
    Increase the time delay after the interrupt code and try.
Loading...

Share This Page

Loading...