We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
the problem i ask yesterday hv solved, the now i'm facing another prob. which is the velocity value cant display in LCD once i reach "START==0 AND STOP==0" it will display 255 for the velocity value, could anyone help me with that, thanks alot
#include <AT898252.H> #include <stdio.h> #include "LCD.c" unsigned char pulse_low=0,pulse_high=0; unsigned int overflow_count=0,int_count=1,pulse=0,time=0; unsigned int velocity=0; unsigned long int pulse_width=0; unsigned char b; sbit START=P1^0; sbit STOP=P1^1; char buf[16]; void main(){ lcd_init(); lcd_puts("The Speed Is"); msdelay(1000); TMOD=0x90; TF1=0; IT1=1; IE=0x8c; while(1){ unsigned char a; // unsigned char x; if(START==0&&STOP==1){ a=0; } else if(START==1&&STOP==0){ a=2; } else if(START==1&&STOP==1){ a=3; } else if (START==0&&STOP==0){ a=1; } switch(a){ case 0:{ TR1=1; break; } case 1:{ pulse_low=TL1; pulse_high=TH1; pulse=(TH1<<8)+TL1; pulse_width=(overflow_count)*65536+pulse; time=pulse_width/13921583; velocity=(180/time); lcd_gotoxy(0,1); lcd_putchar(' '); sprintf(buf,"%u",v); lcd_puts(buf); break; } case 2:{ TR1=0; TH1=0x00; TL1=0x00; overflow_count=0; break; } default:{ break; } } } } void timer1_int()interrupt 3 { overflow_count++; }
actually the v is the velocity and it is wrongly written in this post, the actual code is written as velocity...sorry for the wrong info...