ana_cont
Junior Member level 2
hi inee some one to help me to add rpm to my counter how please....
}
}
Code:
int a;
int b ;
int pulse=0;
int pulse2=0 ;
unsigned long rpm_value;
char text[15];
void main() {
TRISD.F0 = 1;
TRISD.F1= 1;
TRISA=0X00;
PORTA=0;
TRISC=0X00;
PORTC=0;
#define SW PORTD.RD0 // RD7 pin is pulse input pin
#define SW2 PORTD.RD1 //RD1PIN IS PULSE
while(1){
if(SW==1){
while(SW==1);
pulse++;
}
if(pulse>=721) pulse = 0;
if(RD0_bit==1) pulse ++;
if(pulse== pulse <=128){
portc.f5=0;
}
if (pulse>= 129 && pulse <=180){
porta.f2=1;
}
if (pulse>=181&& pulse <=308){
porta.f2=0;
portc.f3=0;
portc.f4=0 ;
}
if (pulse>=309 && pulse <=360){
porta.f2=0;
portc.f3=1 ;
portc.f4=0;
portc.f5=0;
}if (pulse>=361 && pulse <=488){
porta.f2=0;
portc.f3=0 ;
portc.f4=0;
portc.f5=0;
}
if (pulse>=489 && pulse <=540){
porta.f2=0;
portc.f3=0 ;
portc.f4=1;
portc.f5=0;
}
if (pulse>=541 && pulse <=668){
porta.f2=0;
portc.f3=0 ;
portc.f4=0;
portc.f5=0;
}
if (pulse>=669 && pulse <=720){
porta.f2=0;
portc.f3=0;
portc.f4=0;
portc.f5=1;
}
if(SW2==1){
while(SW2==1);
pulse2++;
}
if(RD1_bit==1) pulse2 ++;
if(pulse2>=60) pulse2=1*60; {
rpm=pulse2;
}
}
}
Last edited by a moderator: