ana_cont
Junior Member level 2
Code:
const wh_length=11;
const pulse=36;
const meter_pulse=(100/wh_length)*pulse;
int meter=0;
char speedshow[30];
char RPMshow[30];
char distanceshow[30];
int count_puls=0;
int speed ;
int rpm=0;
void TMR0_init (void);
T1SE;
TF00;
E11;
GIE1;
unsigned int_option_reg;
unsigned int_T1CKI;
void Interruption()
{
if (TF00==1)
{
rpm = (1000/count_puls) * 60;
speed = meter/count_puls;
}
TF00=0;
if (TMR0IF_bit){
TMR0IF_bit = 0;
TMR0 = 6;
count_puls++;
}
}
void InitTimer0(){
OPTION_REG = 0x81;
TMR0 = 6;
INTCON = 0xA0;
}
void main()
{
UART1_Init(115200);
trisb.b0=1;
trisd=0;
InitTimer0();
t1con=0;
while(1)
{
if (count_puls>=meter_pulse){
meter++;
count_puls=0;
}
sprinti(speedshow,"n0.val=%d",speed);
UART1_Write_Text(speedshow);
UART1_Write(0XFF);
UART1_Write(0XFF);
UART1_Write(0XFF);
sprinti(RPMshow,"n1.val=%d",RPM);
UART1_Write_Text(RPMshow);
UART1_Write(0XFF);
UART1_Write(0XFF);
UART1_Write(0XFF);
sprinti(distanceshow,"n2.val=%d",meter);
UART1_Write_Text(distanceshow);
UART1_Write(0XFF);
UART1_Write(0XFF);
UART1_Write(0XFF);
}
}
--- Updated ---
rpm compiled but not displaied
--- Updated ---
rpm compiled but not displaied
--- Updated ---
hi Ihave code compiled but not displaied.
const wh_length=11;
const pulse=36;
const meter_pulse=(100/wh_length)*pulse;
int meter=0;
char speedshow[30];
char RPMshow[30];
char distanceshow[30];
int count_puls=0;
int speed ;
int rpm=0;
void TMR0_init (void);
T1SE;
TF00;
E11;
GIE1;
unsigned int_option_reg;
unsigned int_T1CKI;
void Interruption()
{
if (TF00==1)
{
rpm = (1000/count_puls) * 60;
speed = meter/count_puls;
}
TF00=0;
if (TMR0IF_bit){
TMR0IF_bit = 0;
TMR0 = 6;
count_puls++;
}
}
void InitTimer0(){
OPTION_REG = 0x81;
TMR0 = 6;
INTCON = 0xA0;
}
void main()
{
UART1_Init(115200);
trisb.b0=1;
trisd=0;
InitTimer0();
t1con=0;
while(1)
{
if (count_puls>=meter_pulse){
meter++;
count_puls=0;
}
sprinti(speedshow,"n0.val=%d",speed);
UART1_Write_Text(speedshow);
UART1_Write(0XFF);
UART1_Write(0XFF);
UART1_Write(0XFF);
sprinti(RPMshow,"n1.val=%d",RPM);
UART1_Write_Text(RPMshow);
UART1_Write(0XFF);
UART1_Write(0XFF);
UART1_Write(0XFF);
sprinti(distanceshow,"n2.val=%d",meter);
UART1_Write_Text(distanceshow);
UART1_Write(0XFF);
UART1_Write(0XFF);
UART1_Write(0XFF);
}
Last edited: