bianchi77
Advanced Member level 4
- Joined
- Jun 11, 2009
- Messages
- 1,313
- Helped
- 21
- Reputation
- 44
- Reaction score
- 20
- Trophy points
- 1,318
- Location
- California
- Activity points
- 9,442
//init timer 0 as a counter for a pulse from op amp
sbit counter_input=P3^4; //input pulse from op-amp
void init_timer()
{
counter_input = 1; //set it as input to read a pulse from op-amp
TCON = 0x10;
TMOD = 0x0F;
}
void init_timer()
{
counter_input = 1; //set it as input to read a pulse from op-amp
counter_input = 0x00; //clear the counter
TCON = 0x10;
TMOD = 0x0F;
}
main()
{
counter = TL0;
lcd_data(counter);
}
\\ *Program for convert binary to decimal*\\
unsigned char binary,d1,d2,d3;
binary=TL0;
x=binary/0A;
d1=binary%0A;
d2=x%0A;
d3=x/0A;
hai,
to display the TL0 value you have to convert that as decimal then u can display...Code:\\ *Program for convert binary to decimal*\\ unsigned char binary,d1,d2,d3; binary=TL0; x=binary/0A; d1=binary%0A; d2=x%0A; d3=x/0A;
send the values d1+48,d2+48,d3+48 values to the LCD port... you can get the exact value of the TL0.
i think its may be use full for u..
thanks
how can I use d1+48,d2+48,d3+48, is it dy=d1+48+d2+48+d3+48
lcd_data(dy); ?
how can I count it frequency per minute ?
thanks
any code examples for this idea ?For counting per minute u can use the one minute delay with timer.. after getting overflow with timer u can capture the value from TL0.
unsigned int counter,d1,d2,d3,dx,dy,dz,x;
counter=TL0;
x=counter/0A;
d1=counter%0A;
d2=x%0A;
d3=x/0A;
dx=d1+48;
dy=d2+48;
dz=d3+48;
INIT_LCD.C(483): error C251: illegal octal digit
INIT_LCD.C(484): error C251: illegal octal digit
INIT_LCD.C(485): error C251: illegal octal digit
INIT_LCD.C(486): error C251: illegal octal digit
can u post full code??I did :
Code:unsigned int counter,d1,d2,d3,dx,dy,dz,x; counter=TL0; x=counter/0A; d1=counter%0A; d2=x%0A; d3=x/0A; dx=d1+48; dy=d2+48; dz=d3+48;
I got :
sbit counter_input=P3^4; //input pulse from op-amp
//init timer 0 as a counter from op amp
void init_timer()
{
counter_input = 1; //set it as input to read a pulse from op-amp
counter_input = 0x00; //clear the counter
TCON = 0x10;
TMOD = 0x07;
}
void main() //main program
{
unsigned char serial_char;
unsigned int counter,d1,d2,d3,dx,dy,dz,x;
counter=TL0;
x=counter/0A;
d1=counter%0A;
d2=x%0A;
d3=x/0A;
dx=d1+48;
dy=d2+48;
dz=d3+48;
lcd_ini(); //init LCD
init_timer();//init timer0
while (1)
{
message3();
lcd_data(dx); lcd_data(dy); lcd_data(dz);
delay(100);
}
}
x=counter/10;
d1=counter%10;
d2=x%10;
d3=x/10;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?