27.11.2012 Views

Diseño y construcción de tricicleta solar - GEA - Universidad ...

Diseño y construcción de tricicleta solar - GEA - Universidad ...

Diseño y construcción de tricicleta solar - GEA - Universidad ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SIGNAL(TIMER2_COMP_vect){ ){<br />

//Contador <strong>de</strong> vueltas, calculo <strong>de</strong> la velocidad y envío <strong>de</strong> mensaje a la pantalla LCD<br />

cont1++; ++;<br />

if(cont1 == == 100){ ){<br />

cont1=0;<br />

enco<strong>de</strong>rVel = enco<strong>de</strong>rCount;<br />

enco<strong>de</strong>rCount = 0;<br />

//Velocidad<br />

velocidad = Kvel * enco<strong>de</strong>rVel;<br />

}<br />

Thum=75/( /( /(Krad /( * enco<strong>de</strong>rVel); ); );//T=P/W<br />

);<br />

if(Pmotor > 250)//si la potencia <strong>de</strong>l motor es superior a 250W<br />

{<br />

if( Tmax < (Thum/cambio3)) ))<br />

{<br />

printf("C"); ); );//escribe );<br />

en LCD: "Pedalear en Vel.3"<br />

}else{<br />

}<br />

if(Tmax < (Thum/cambio2)){ )){<br />

printf("B"); ); );//escribe );<br />

en LCD: "Pedalear en Vel.2"<br />

}else{<br />

}else{<br />

printf("D"); ); );//escribe );<br />

en LCD: No pedalear!!<br />

}<br />

printf("A"); ); );//escribe );<br />

en LCD: "Pedalear en Vel.1"<br />

}<br />

//*** Mira el estado <strong>de</strong>l interruptor <strong>de</strong>l freno, acelerador y velocidad y selecciona el<br />

estado <strong>de</strong> los conversores DC/DC<br />

freno=( =( =(PINB =( & 0x80); );<br />

if(frenoh!= != !=freno){<br />

!= ){ //<strong>de</strong>tecta canto<br />

//resguardo anti-rebote<br />

//_<strong>de</strong>lay_ms(1);//tiempo resguardo para verificacion<br />

frenoh=freno; //actualiza valor anterior<br />

if(! (! (!freno (! && && && readChannel(5) > 20) // verifica estado interruptor y<br />

que acelerador sea mayor al 20/1024 x 100 = 2%<br />

{<br />

pwmSelect=1;//chooper motor<br />

}<br />

else<br />

{<br />

if(velocidad > 0){ ){<br />

pwmSelect=2;//frenado regenerativo<br />

}<br />

}<br />

}<br />

if(velocidad == == == 0 && && && readChannel(5) < 20){ ){<br />

pwmSelect=3;//<strong>de</strong>tenido y en carga <strong>de</strong> banco <strong>de</strong> baterías y<br />

ultracapacitores<br />

}<br />

//actualiza estado <strong>de</strong>l led si esta activado/<strong>de</strong>sactivado PWM0 - con umbral <strong>de</strong><br />

encendido al 2%<br />

if(PWM0 > 5){ ){<br />

led(1); );<br />

}else{<br />

led(2); );<br />

}<br />

//*** pwmSelect=1: operación como motor<br />

if( pwmSelect == == 1 )

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!