Documentos de Académico
Documentos de Profesional
Documentos de Cultura
// Cursores
char cursor10;
// opciones
char opcion10;
//menu
char submenu;
// ciclo trabajo
float ciclo1, ciclo2,ciclo3;
// valor de voltaje
float voltaje;
// valor de Apertura
float apertura;
// valor rpm
float rpm,rntc;
char txt[20];
int temp;
float frecuenciaabs;
float frecuenciamaf;
int timer0;
int velocidad;
float T;
char contador;
// FUNCION INTERRUPCION
void Interrupt(){
// interrupcion timer0 para ckp hall 40-1 (700 rpm min 5000 rpm max)
if ((TMR0IF_bit)&&(opcion9==1)) {
TMR0IF_bit = 0;
TMR0H = (timer0)>> 8;
TMR0L = (timer0);
contador++;
LATD.F2=~LATD.F2;
if (contador==79){
LATD.F2=0X00; }
if (contador==80){
LATD.F2=0X00;
contador=0;
// interrupcion timer0 para ckp hall 36-1 800 RPM MIN MAX 5000 RPM
if ((TMR0IF_bit)&&(opcion9==2) ) {
TMR0IF_bit = 0;
TMR0H = (timer0)>> 8;
TMR0L = (timer0);
contador++;
LATD.F2=~LATD.F2;
if (contador==71){
LATD.F2=0X00; }
if (contador==72){
LATD.F2=0X00;
contador=0;
if ((TMR0IF_bit)&&(opcion9==3 ) ) {
TMR0IF_bit = 0;
TMR0H = (timer0)>> 8;
TMR0L = (timer0);
contador++;
LATD.F2=~LATD.F2;
if (contador==117){
LATD.F2=0X00; }
if (contador==118){
LATD.F2=0X00;
if (contador==119){
LATD.F2=0X00; }
if (contador==120){
LATD.F2=0X00;
contador=0;
if ((TMR0IF_bit)&&(opcion10==1)){
TMR0IF_bit = 0;
TMR0H = (timer0)>> 8;
TMR0L = (timer0);
contador++;
LATD.F3=~LATD.F3;
if (contador==79){
LATD.F3=0X00; }
if (contador==80){
LATD.F3=0X00;
contador=0;
if ((TMR0IF_bit)&&(opcion10==2)) {
TMR0IF_bit = 0;
TMR0H = (timer0)>> 8;
TMR0L = (timer0);
contador++;
LATD.F3=~LATD.F3;
if (contador==71){
LATD.F3=0X00; }
if (contador==72){
LATD.F3=0X00;
contador=0;
if ((TMR0IF_bit)&&(opcion10==3) ) {
TMR0IF_bit = 0;
TMR0H = (timer0)>> 8;
TMR0L = (timer0);
contador++;
LATD.F3=~LATD.F3;
if (contador==117){
LATD.F3=0X00; }
if (contador==118){
LATD.F3=0X00;
}
if (contador==119){
LATD.F3=0X00; }
if (contador==120){
LATD.F3=0X00;
contador=0;
if ((TMR0IF_bit)&&(opcion7==1)){
TMR0IF_bit = 0;
TMR0H = (timer0)>> 8;
TMR0L = (timer0);
LATD.F2=~LATD.F2;
TMR0IF_bit = 0;
TMR0H = (timer0)>> 8;
TMR0L = (timer0);
LATD.F2=~LATD.F2;
if ((TMR0IF_bit)&&(opcion6==1)){
TMR0IF_bit = 0;
TMR0H = (62533)>> 8;
TMR0L = (62533);
LATC.F1=~LATC.F1;
}
}
void main()
// CONFIGURACION PUERTOS
TRISC=0b11111001;
LATC=0b00000000;
LATD.F2=0X00;
// DECLARACION DE VARIABLES
cursor = 1;
submenu = 0;
cursor2 = 1;
cursor3=1;
cursor4=1;
opcion=0;
opcion2=0;
opcion3=0;
opcion4=0;
opcion5=0;
opcion7=0;
cursor5=1;
cursor6=1;
cursor7=1;
cursor8=1;
cursor9=1;
cursor10=1;
opcion6=0;
opcion7=0;
opcion8=0;
opcion9=0;
opcion10=0;
ciclo1=0;
ciclo2=180;
ciclo3=0;
contador=0;
// PANTALLA PRINCIPAL
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"SIMULADOR-PRUEBA DE");
Lcd_Out(2,1,"SENSORES AUTOMOTRIZ");
Lcd_Out(3,3,"OPCION SIMULACION");
// CICLO WHILE
while (1)
switch(cursor)
case 1:
Lcd_Chr(3,1,'>');
Lcd_Chr(4,1,' ');
cursor = 2;
opcion = 1;
break;
case 2:
Lcd_Chr(3,1,' ');
cursor = 1;
opcion = 2;
Lcd_Chr(4,1,'>');
break;
if (Button(&PORTC,6,50,1))
case 1:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 2,"TPS");
Lcd_Out(2,2,"ECT");
Lcd_Out(3,2,"ABS");
Lcd_Out(1,7,"MAF");
Lcd_Out(2,7,"CKP");
Lcd_Out(3,7,"OXI");
Lcd_Out(1,12,"MAP");
Lcd_Out(2,12,"CMP");
Lcd_Out(3,12,"KS");
Lcd_Out(1,17,"IAT");
Lcd_Out(2,17,"VSS");
submenu = 1;
break;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2,"TPS");
Lcd_Out(2,2,"MAP");
Lcd_Out(3,2,"MAF");
Lcd_Out(4,11,"SIGUIENTE");
Lcd_Out(1,7,"IAT");
Lcd_Out(2,7,"ECT");
Lcd_Out(3,7,"CKP");
Lcd_Out(1,12,"CMP");
Lcd_Out(2,12,"ABS");
Lcd_Out(3,12,"EGR");
Lcd_Out(1,17,"APP");
Lcd_Out(2,17,"KNOC");
Lcd_Out(3,17,"VSS");
submenu = 2;
break;
}
// SI PULSO RC5 MUEVO CURSOR EN SUB MENU =1 ( SUBMENU SIMULACION)
switch(cursor2)
case 1: //TPS
Lcd_Chr(1,1,'>');
cursor2=2;
opcion2=1;
break;
case 2:
Lcd_Chr(2,1,'>');
cursor2=3;
opcion2=2;
break;
case 3:
Lcd_Chr(3,1,'>');
cursor2=4;
opcion2=3;
break;
case 4:
Lcd_Chr(4,1,'>');
opcion2=4;
cursor2=5;
break;
case 5:
Lcd_Chr(1,6,'>');
opcion2=5;
cursor2=6;
break;
case 6:
Lcd_Chr(2,6,'>');
opcion2=6;
cursor2=7;
break;
case 7:
Lcd_Chr(3,6,'>');
cursor2 = 8;
opcion2=7;
break;
case 8:
Lcd_Chr(3,6,' '); // MAP
Lcd_Chr(1,11,'>');
opcion2=8;
cursor2=9;
break;
case 9:
Lcd_Chr(2,11,'>');
opcion2=9;
cursor2=10;
break;
case 10:
Lcd_Chr(2,11,' '); // KS
Lcd_Chr(3,11,'>');
opcion2=10;
cursor2=11;
break;
case 11:
Lcd_Chr(1,16,'>');
opcion2=11;
cursor2=12;
break;
case 12:
opcion2=12;
cursor2=1;
break;
if (Button(&PORTC,6,50,1))
switch (opcion2)
case 1:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,"% APERTURA");
Lcd_Out(3,6,"V VOLTAJE");
Lcd_Out(4,6,"RPM APROX");
PWM1_init(4000);
PWM1_Start();
PWM1_Set_Duty(ciclo1);
while(1) {
if(Button(&PORTC,7,50,1)){
break; }
if(Button(&PORTC,4,10,1)&& (opcion2==1)){
ciclo1=ciclo1+1;
if (ciclo1==255){
ciclo1=255;}
if(Button(&PORTC,0,50,1)&& (opcion2==1)){
ciclo1=ciclo1-1;
if (ciclo1<0){
ciclo1=0;}
PWM1_Set_Duty(ciclo1);
delay_ms(10);
// voltaje
voltaje= (ciclo1)*0.0196;
FloatToStr_FixLen(voltaje,txt,4);
Lcd_out(3,1,Txt);
// apertura
apertura=(ciclo1)*100 / 255;
FloatToStr_FixLen(apertura,txt,4);
Lcd_out(2,1,Txt);
// RPM
rpm=23.5294*(ciclo1);
FloatToStr_FixLen(rpm,txt,4);
Lcd_out(4,1,Txt);
break;
case 2:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,6,"V VOLTAJE");
PWM1_init(4000);
PWM1_Start();
PWM1_Set_Duty(ciclo2);
while(1) {
if(Button(&PORTC,7,50,1)){
break; }
if(Button(&PORTC,4,50,1)&& (opcion2==2)){
ciclo2=ciclo2+1;
if (ciclo2>180){
ciclo2=180;}
if(Button(&PORTC,0,50,1)&& (opcion2==2)){
ciclo2=ciclo2-1;
if (ciclo2<30){
ciclo2=30;}
PWM1_Set_Duty(ciclo2);
delay_ms(10);
// voltaje
// 255*0.0196=5 voltios
voltaje= ((ciclo2)*0.0196);
FloatToStr_FixLen(voltaje,txt,4);
Lcd_out(3,1,Txt);
// calculo de rnt
rntc=(31300/(5/voltaje)-1);
// TEMPERATURA
temp= ((3795.5*293.15)/(3795.5+293.15*log(rntc/39200)));
temp=temp-273.15;
FloatToStr_FixLen(temp,txt,4);
Lcd_out(4,1,Txt);
}
break;
case 3:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,"");
Lcd_Out(3,7,"K/M VELOCIDAD");
Lcd_Out(4,7,"HZ FRECUENCIA");
T0CON = 0x85;
TMR0H = (56100)>> 8;
TMR0L = 56100;
GIE_bit = 1;
TMR0IE_bit = 1;
timer0=56100;
while(1) {
if (Button(&PORTC,7,50,1)) {
break; }
if (Button(&PORTC,4,50,1)&&(opcion2==3)){
timer0+=100;
delay_ms(1);
if (timer0>64700){
timer0=64700;}
delay_ms(1);
if(Button(&PORTC,0,50,1)&& ( opcion2==3)){
timer0-=100;
delay_ms(1);
if (timer0<56100){
timer0=56100;
delay_ms(1);
T=(((65535-timer0)*5.331)/1000000);
// T=T/1000000;
frecuenciaabs=(1/(T*2));
// frecuencia
ByteToStr(frecuenciaabs, txt);
Lcd_out(4,1,Txt);
// velocidad
ByteToStr(frecuenciaabs, txt);
Lcd_out(3,1,Txt);
break;
case 4:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(4,3,"CKP INDUCTIVO");
submenu=3;
break;
case 5:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,3,"MAF DIGITAL");
Lcd_Out(4,3,"MAF ANALOGICO");
submenu=7;
break;
case 6 :
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,3,"EFECTO HALL");
Lcd_Out(4,3,"INDUCTIVO");
submenu=4;
break;
case 7 :
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,3,"SEÑAL DIGITAL");
Lcd_Out(4,3,"SEÑAL ANALOGA");
submenu=5;
break;
case 8:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,"V VOLTAJE");
Lcd_Out(3,6,"RPM");
Lcd_Out(4,6,"Kpa");
break;
case 9:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,"V VOLTAJE");
Lcd_Out(3,6,"RPM");
Lcd_Out(4,6,"HZ FRECUENCIA");
break;
case 10:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,"V VOLTAJE");
Lcd_Out(3,6,"RPM");
Lcd_Out(4,6,"HZ FRECUENCIA");
break;
case 11:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,"C TEMPERATURA");
Lcd_Out(3,6,"V VOLTAJE");
break;
case 12:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,"K/H VELOCIDAD");
Lcd_Out(3,6,"HZ FRECUENCIA");
break;
}
}
if (Button(&PORTC,5,50,1)&& ( submenu==2))
switch (cursor3){
case 1:
Lcd_Chr(1,1,'>'); //TPS
Lcd_Chr(3,16,' ');
opcion3=1;
cursor3=2;
break;
case 2:
Lcd_Chr(2,1,'>');
opcion3=2;
cursor3=3;
break;
case 3:
Lcd_Chr(3,1,'>');
opcion3=3;
cursor3=4;
break;
case 4:
Lcd_Chr(4,10,'>');
opcion3=4;
cursor3=5;
submenu=6;
break;
case 5:
Lcd_Chr(1,6,'>');
cursor3=6;
opcion3=5;
break;
case 6:
Lcd_Chr(2,6,'>');
opcion3=6;
cursor3=7;
break;
case 7:
Lcd_Chr(3,6,'>');
opcion3=7;
cursor3=8;
break;
case 8:
Lcd_Chr(1,11,'>');
cursor3=9;
opcion3=8;
break;
case 9:
Lcd_Chr(2,11,'>');
opcion3=9;
cursor3=10;
break;
case 10:
Lcd_Chr(3,11,'>');
opcion3=10;
cursor3=11;
break;
case 11:
Lcd_Chr(1,16,'>');
opcion3=11;
cursor3=12;
break;
case 12:
Lcd_Chr(2,16,'>');
opcion3=12;
cursor3=13;
break;
case 13:
Lcd_Chr(3,16,'>');
opcion3=13;
cursor3=1;
break;
switch ( cursor4){
case 1:
opcion4=1;
cursor4=2;
break;
case 2:
Lcd_Chr(3,2,' ');
opcion4=2;
cursor4=1;
break;
if (Button(&PORTC,5,50,1)&&(submenu==4))
switch ( cursor8){
case 1:
Lcd_Chr(4,2,' ');
opcion8=1;
cursor8=2;
break;
case 2:
Lcd_Chr(3,2,' '); // EFECTO INDUCTIVO
Lcd_Chr(4,2,'>');
opcion8=2;
cursor8=1;
break;
if (Button(&PORTC,5,50,1)&& (submenu==5))
switch ( cursor6){
case 1:
Lcd_Chr(4,2,' ');
opcion6=1;
cursor6=2;
break;
case 2:
Lcd_Chr(4,2,'>');
opcion6=2;
cursor6=1;
break;
}
if (Button(&PORTC,5,50,1)&& (submenu==7))
switch ( cursor7){
case 1:
Lcd_Chr(4,2,' ');
opcion7=1;
cursor7=2;
break;
case 2:
Lcd_Chr(4,2,'>');
opcion7=2;
cursor7=1;
break;
switch ( cursor10){
case 1:
Lcd_Chr(2,1,'>'); // 40-1
Lcd_Chr(4,1,' ');
opcion10=1;
cursor10=2;
break;
case 2:
Lcd_Chr(3,1,'>'); // 36-1
Lcd_Chr(2,1,' ');
opcion10=2;
cursor10=3;
break;
case 3:
Lcd_Chr(4,1,'>');
opcion10=3;
cursor10=1;
break;
}
}
if (Button(&PORTC,5,50,1)&& (submenu==8))
switch ( cursor9){
case 1:
Lcd_Chr(2,1,'>'); // 40-1
Lcd_Chr(4,1,' ');
opcion9=1;
cursor9=2;
break;
case 2:
Lcd_Chr(3,1,'>'); // 36-1
Lcd_Chr(2,1,' ');
opcion9=2;
cursor9=3;
break;
case 3:
Lcd_Chr(4,1,'>');
opcion9=3;
cursor9=1;
break;
}
if (Button(&PORTC,6,50,1))
switch (opcion6)
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,7,"0-1 V VOLTAJE");
T0CON = 0x80;
TMR0H = (62533)>> 8;
TMR0L = 62533;
GIE_bit = 1;
TMR0IE_bit = 1;
break;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,1," ");
Lcd_Out(4,6," ");
PWM1_init(2000);
PWM1_Start();
PWM1_Set_Duty(ciclo3);
while(1) {
if(Button(&PORTC,7,50,1)){
break; }
if(Button(&PORTC,4,50,1)&& (opcion6==2)){
ciclo3=ciclo3+1;
if (ciclo3>51){
ciclo3=51;}
}
if(Button(&PORTC,0,50,1)&& (opcion6==2)){
ciclo3=ciclo3-1;
if (ciclo3<0){
ciclo3=0;}
PWM1_Set_Duty(ciclo3);
delay_ms(10);
// voltaje
// 255*0.0196=5 voltios
voltaje= ((ciclo3)*0.0196);
//ByteToStr(voltaje, txt);
//Lcd_out(4,1,Txt);
FloatToStr_FixLen(voltaje,txt,4);
Lcd_out(2,2,Txt);
break;
switch (opcion7)
case 1:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,7,"HZ FRECUENCIA");
Lcd_Out(3,1," ");
Lcd_Out(4,6," ");
T0CON = 0x83;
TMR0H = (28019)>> 8;
TMR0L = 28019;
GIE_bit = 1;
TMR0IE_bit = 1;
timer0=28020;
while(1) {
// temporizacion = Temporización = Ciclo de instrucción * (65535-TMR0) * Divisor de
Frecuencia
if (Button(&PORTC,7,50,1)) {
break; }
if (Button(&PORTC,4,1,1)&&(opcion7==1)){
timer0+=10;
if (timer0>65460){
timer0=65460;}
if(Button(&PORTC,0,1,1)&& ( opcion7==1)){
timer0-=10;
if (timer0<28020){
timer0=28020;
}
T=(((65535-timer0)*1.328)/1000000);
// T=T/1000000;
frecuenciamaf=(1/(T*2));
// frecuencia
IntToStr(frecuenciamaf, txt);
Lcd_out(2,1,Txt);
break;
case 2:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,1," ");
Lcd_Out(4,6," ");
// CODIGO EJECUCION MAF ANALOGICO
PWM1_init(4000);
PWM1_Start();
PWM1_Set_Duty(ciclo3);
while(1) {
if(Button(&PORTC,7,50,1)){
break; }
if(Button(&PORTC,4,50,1)&& (opcion7==2)){
ciclo3=ciclo3+1;
if (ciclo3>230){
ciclo3=230;}
if(Button(&PORTC,0,50,1)&& (opcion7==2)){
ciclo3=ciclo3-1;
if (ciclo3<0){
ciclo3=0;}
PWM1_Set_Duty(ciclo3);
delay_ms(10);
// voltaje
// 255*0.0196=5 voltios
voltaje= ((ciclo3)*0.0196);
//ByteToStr(voltaje, txt);
//Lcd_out(4,1,Txt);
FloatToStr_FixLen(voltaje,txt,4);
Lcd_out(2,2,Txt);
break;
if (Button(&PORTC,6,50,1))
switch (opcion8)
case 1:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,2,"40-1");
Lcd_Out(3,2,"36-1");
Lcd_Out(4,2,"60-2");
submenu=8;
break;
case 2:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,2,"40-1");
Lcd_Out(3,2,"36-1");
Lcd_Out(4,2,"60-2");
submenu=9;
break;
if (Button(&PORTC,6,50,1))
switch (opcion9)
case 1:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(3,8,"HZ FRECUENCIA");
opcion9=1;
T0CON = 0x80;
TMR0H = (61783)>> 8;
TMR0L = 61783;
GIE_bit = 1;
TMR0IE_bit = 1;
contador=0;
LATD.F2=0X00;
timer0=61783;
while(1) {
if (Button(&PORTC,7,50,1)) {
break; }
if (Button(&PORTC,4,1,1)&&(opcion9==1)){
timer0++;
delay_ms(1);
if (timer0>64934){
timer0=64934;}
delay_ms(1);
if(Button(&PORTC,0,1,1)&& ( opcion9==1)){
timer0--;
delay_ms(1);
if (timer0<61783){
timer0=61783;
delay_ms(1);
T=(((65535-timer0)*0.166)/1000000);
// T=T/1000000;
frecuenciamaf=(1/(T*2));
// frecuencia
IntToStr(frecuenciamaf, txt);
Lcd_out(2,1,Txt);
lcd_out(3,1,txt);
break;
case 2:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,8,"RPM");
Lcd_Out(3,8,"HZ FRECUENCIA");
T0CON = 0x80;
TMR0H = (61783)>> 8;
TMR0L = 61783;
GIE_bit = 1;
TMR0IE_bit = 1;
contador=0;
LATD.F2=0X00;
timer0=61783;
while(1) {
if (Button(&PORTC,7,50,1)) {
break; }
if (Button(&PORTC,4,1,1)&&(opcion9==2)){
timer0++;
delay_ms(1);
if (timer0>64934){
timer0=64934;}
delay_ms(1);
if(Button(&PORTC,0,1,1)&& ( opcion9==2)){
timer0--;
delay_ms(1);
if (timer0<61783){
timer0=61783;
delay_ms(1);
}
}
T=(((65535-timer0)*0.166)/1000000);
// T=T/1000000;
frecuenciamaf=(1/(T*2));
// frecuencia
IntToStr(frecuenciamaf, txt);
Lcd_out(2,1,Txt);
lcd_out(3,1,txt);
break;
case 3:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,8,"RPM");
Lcd_Out(3,8,"HZ FRECUENCIA");
TMR0H = (61783)>> 8;
TMR0L = 61783;
GIE_bit = 1;
TMR0IE_bit = 1;
contador=0;
LATD.F2=0X00;
timer0=61783;
while(1) {
if (Button(&PORTC,7,50,1)) {
break; }
if (Button(&PORTC,4,1,1)&&(opcion9==3)){
timer0++;
delay_ms(1);
if (timer0>64934){
timer0=64934;}
delay_ms(1);
if(Button(&PORTC,0,1,1)&& ( opcion9==3)){
timer0--;
delay_ms(1);
if (timer0<61783){
timer0=61783;
delay_ms(1);
T=(((65535-timer0)*0.166)/1000000);
// T=T/1000000;
frecuenciamaf=(1/(T*2));
// frecuencia
IntToStr(frecuenciamaf, txt);
Lcd_out(2,1,Txt);
lcd_out(3,1,txt);
break;
switch (opcion10)
case 1:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,8,"RPM");
Lcd_Out(3,8,"HZ FRECUENCIA");
T0CON = 0x80;
TMR0H = (61783)>> 8;
TMR0L = 61783;
GIE_bit = 1;
TMR0IE_bit = 1;
contador=0;
LATD.F3=0X00;
timer0=61783;
while(1) {
// temporizacion = Temporización = Ciclo de instrucción * (65535-TMR0) * Divisor de
Frecuencia
if (Button(&PORTC,7,50,1)) {
break; }
if (Button(&PORTC,4,1,1)&&(opcion10==1)){
timer0++;
delay_ms(1);
if (timer0>64934){
timer0=64934;}
delay_ms(1);
if(Button(&PORTC,0,1,1)&& ( opcion10==1)){
timer0--;
delay_ms(1);
if (timer0<61783){
timer0=61783;
delay_ms(1);
}
T=(((65535-timer0)*0.166)/1000000);
// T=T/1000000;
frecuenciamaf=(1/(T*2));
// frecuencia
IntToStr(frecuenciamaf, txt);
Lcd_out(2,1,Txt);
lcd_out(3,1,txt);
break;
case 2:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,8,"RPM");
Lcd_Out(3,8,"HZ FRECUENCIA");
T0CON = 0x80;
TMR0H = (61783)>> 8;
TMR0L = 61783;
GIE_bit = 1;
TMR0IE_bit = 1;
contador=0;
LATD.F3=0X00;
timer0=61783;
while(1) {
if (Button(&PORTC,7,50,1)) {
break; }
if (Button(&PORTC,4,1,1)&&(opcion10==2)){
timer0++;
delay_ms(1);
if (timer0>64934){
timer0=64934;}
delay_ms(1);
}
if(Button(&PORTC,0,1,1)&& ( opcion10==2)){
timer0--;
delay_ms(1);
if (timer0<61783){
timer0=61783;
delay_ms(1);
T=(((65535-timer0)*0.166)/1000000);
// T=T/1000000;
frecuenciamaf=(1/(T*2));
// frecuencia
IntToStr(frecuenciamaf, txt);
Lcd_out(2,1,Txt);
lcd_out(3,1,txt);
break;
case 3:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,8,"RPM");
Lcd_Out(3,8,"HZ FRECUENCIA");
T0CON = 0x80;
TMR0H = (61783)>> 8;
TMR0L = 61783;
GIE_bit = 1;
TMR0IE_bit = 1;
contador=0;
LATD.F3=0X00;
timer0=61783;
while(1) {
if (Button(&PORTC,7,50,1)) {
break; }
if (Button(&PORTC,4,1,1)&&(opcion10==3)){
timer0++;
delay_ms(1);
if (timer0>64934){
timer0=64934;}
delay_ms(1);
if(Button(&PORTC,0,1,1)&& ( opcion10==3)){
timer0--;
delay_ms(1);
if (timer0<61783){
timer0=61783;
delay_ms(1);
T=(((65535-timer0)*0.166)/1000000);
// T=T/1000000;
frecuenciamaf=(1/(T*2));
// frecuencia
IntToStr(frecuenciamaf, txt);
Lcd_out(2,1,Txt);
lcd_out(3,1,txt);
}
break;
if (Button(&PORTC,7,50,1)) {
Lcd_Out(1,1,"SIMULADOR-PRUEBA DE");
Lcd_Out(2,1,"SENSORES AUTOMOTRIZ");
Lcd_Out(3,3,"OPCION SIMULACION");
Lcd_Out(4,3,"OPCION TEST PRUEBA");
submenu = 0;
cursor = 1;
cursor2 = 1;
cursor3=1;
cursor4=1;
cursor5=1;
opcion=0;
opcion2=0;
opcion3=0;
opcion4=0;
opcion5=0;
opcion6=0;
cursor6=1;
cursor7=1;
cursor8=1;
cursor9=1;
cursor10=1;
opcion7=0;
opcion8=0;
opcion9=0;
opcion10=0;
ciclo1=0;
ciclo2=180;
ciclo3=0;
T0CON.TMR0ON=0;
CCP1CON.CCP1M3=0;
CCP1CON.CCP1M2=0;
CCP1CON.CCP1M1=0;
CCP1CON.CCP1M0=0;
LATC.F2=0X00;
LATD.F2=0X00;
timer0=0;
contador=0;