visitor counter cum token number display

Thread Starter

laxmi

Joined Jun 19, 2009
14
Hello Sir/Madam,

As im doing this project using pic-16f877a microcontroller.

concept of output: i need to display number of persons enter as well as using sensor and also token number display .

in main program i wrote code of visitor & in interrupt service routine i wrote code of token display.

for visitor -00-99 display
for token display- max_size of array we can store is 25.
main-program:

Note :in this code as im using single controller so i used for 7-segment display PORTA & RE0(g) for token & PORTD for VISITOR.
while(1)
{

/*for up-counter 00-99*/
if(IN_SENSOR)
{

while(IN_SENSOR)
{
continue;
}

DelayMs(50); // Delay for debounce

if(count<=99)
{
count++;
display_number_both_tens_unit(count);
}

}
else
{ /* for Down-counter*/
if(OUT_SENSOR)
{
while(OUT_SENSOR)
{
continue;
}

DelayMs(50); // Delay for Debounce
count--;
display_number_both_tens_unit(count);
}
}
} //End of while


isr:
static void interrupt
isr(void)
{
if(RCIF&& RCIE)
{
if(arr_ptr<max_size)
{
num1=getch();
num2=getch();
read_value=(((num1*10)+num2)-16);
input_arr[arr_ptr]=read_value;
arr_ptr++;

if(arr_ptr==max_size)
{
putch(' ');
putch('A');
putch('F');
putch('F');
}
}
//RCIF=0;
}
else if(INTE&&INTF)
{
int_ptr=0;
tens_place=((input_arr[int_ptr])/10);
unit_place=((input_arr[int_ptr])%10);
putch(' ');
putch('A');
putch(tens_place|0x30);
putch(unit_place|0x30);
if((RB0)==1) // here im gettin problem if i use if statement the result is unit_place is same as tens_place . if use while(RB0) this will be interrupt only means not possible to go main program as visitor counter
{

if(tens_place ==1)
{
g=1;
}
else if(tens_place == 0)
{
g=1;
}
else if(tens_place==7)
{
g=1;
}
else
{
g=0;
}

TOKEN_DISPLAY=Display(tens_place);
DIGIT1_tens_token=0; //Enabling DIGIT1_tens
DelayMs(2); //wait for few milliseconds
DIGIT1_tens_token=1; //Disabling DIGIT1_tens

if(unit_place == 1)
{
g=1;
}
else if(unit_place == 0)
{
g=1;
}
else if(unit_place == 7)
{
g=1;
}
else
{
g=0;
}

TOKEN_DISPLAY=Display(unit_place);
DIGIT2_unit_token=0; //Enabling DIGIT2_unit
DelayMs(2); //wait for few milliseconds
DIGIT2_unit_token=1; //Disabling DIGIT2_unit
}

for(j=0; j<max_size; j++)
{
input_arr[j]=input_arr[j+1];
}
arr_ptr--;
INTF=0;
}

Please Help me out.

Thanks in advance.
 
Top