Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Autor: El Guajirigallo//
- //Docificador Ver3.0//
- # include <16F877A.h>
- //# include <ios.h>
- # use Delay(clock=4000000)
- # use Fast_io(c)
- # fuses XT,NOWDT
- #USE FAST_IO (A)
- #USE FAST_IO (B)
- //-"direccionamiento de ports-//
- #byte port_A = 0x05
- #byte port_B = 0x06
- #byte port_c = 0x07
- #byte port_d = 0x08
- #byte port_e = 0x09
- #byte PCON = 0x8e
- #define data_pin PIN_b1
- #define clock_pin PIN_b4
- #define latch_pin PIN_b3
- /*-"Declaracion de funciones"-*/
- void write_data(int16 number);
- void write_Nunbers(int16 numbers[]);
- void Retardo_03seg(void);
- void Docis(int MemoryValue,int PinValue ) ;
- # int_ext
- void interrupt()
- {
- int16 const mapaTimer[]={0x631,0x5B31,0x4f31,0x6631,0x6d31,0x7d31,0x0731,0x7f31,0x6f31,0x3F06,0x0606,0x5b06,0x4f06,0x6606,0x6d06,0x7d06};
- int i=0;
- do{
- write_data(mapaTimer[i]);
- delay_ms(500);
- SwitCh(i){
- case(0): //timer1
- //docis0();
- Docis(0,63 );
- Retardo_03seg();
- break;
- case(1): //timer2
- //docis1();
- Docis(1,68 );
- Retardo_03seg();
- break;
- case(2): //timer3
- //docis2();
- Docis(2,64 );
- Retardo_03seg();
- break;
- case(3): //timer4
- //docis3();
- Docis(3,65 );
- Retardo_03seg();
- break;
- case(4): //timer5
- //docis4();
- Docis(4,59 );
- Retardo_03seg();
- break;
- case(5): //timer6
- //docis5();
- Docis(5,58 );
- Retardo_03seg();
- break;
- case(6): //timer7
- //docis6();
- Docis(6,57 );
- Retardo_03seg();
- break;
- case(7): //timer8
- //docis7();
- Docis(7,56 );
- Retardo_03seg();
- break;
- case(8): //timer9
- //docis8();
- Docis(8,67 );
- Retardo_03seg();
- break;
- case(9): //timer10
- //docis9();
- Docis(9,66 );
- Retardo_03seg();
- break;
- case(10): //timer11
- //docis10();
- Docis(10,60 );
- Retardo_03seg();
- break;
- case(11): //timer12
- //docis11();
- Docis(11,61 );
- Retardo_03seg();
- break;
- case(12): //timer13
- //docis12();
- Docis(12,62 );
- Retardo_03seg();
- break;
- case(13): //timer14
- //docis13();
- Docis(13,72 );
- Retardo_03seg();
- break;
- case(14)://timer15
- //docis14();
- Docis(14,73 );
- Retardo_03seg();
- break;
- case(15): //timer16
- //docis15();
- Docis(15,74 );
- Retardo_03seg();
- write_data(0x543f);
- delay_ms(50);
- break;
- }//find del sw
- i++;
- }while(i<=15);//fin del do-while
- delay_ms(500);
- clear_interrupt(int_ext);
- }//fin de la int
- /*-"Declaracion de VARIABLES Globales"-*/
- int16 const digitos[]={0x3f3f,0x063f,0x5B3F,0x4f3f,0x663f,0x6d3f,0x7d3f,0x073f, // Digitos para mostrar por Display del 1 al 99
- 0x7f3f,0x6f3f,0x3F06,0x0606,0x5b06,0x4f06,0x6606,0x6d06,
- 0x7d06,0x0706,0x7f06,0x6f06,0x3f5b, 0x065b,0x5B5b,0x4f5b,
- 0x665b,0x6d5b,0x7d5b,0x075b,0x7f5b,0x6f5b,0x3F4f,0x064f,
- 0x5b4f,0x4f4f,0x664f,0x6d4f,0x7d4f,0x074f,0x7f4f,0x6f4f,
- 0x3f66,0x0666,0x5B66,0x4f66,0x6666,0x6d66,0x7d66,0x0766,
- 0x7f66,0x6f66,0x3F6d,0x066d,0x5b6d,0x4f6d,0x666d,0x6d6d,
- 0x7d6d,0x076d,0x7f6d,0x6f6d,0x3f7d,0x067d,0x5B7d,0x4f7d,
- 0x667d,0x6d7d,0x7d7d,0x077d,0x7f7d,0x6f7d,0x3F07,0x0607,
- 0x5b07,0x4f07,0x6607,0x6d07,0x7d07,0x0707,0x7f07,0x6f07,
- 0x3f7f,0x067f,0x5B7f,0x4f7f,0x667f,0x6d7f,0x7d7f,0x077f,
- 0x7f7f,0x6f7f,0x3F6f,0x066f,0x5b6f,0x4f6f,0x666f,0x6d6f,
- 0x7d6f,0x076f,0x7f6f,0x6f6f
- };
- int const EE_Address[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}; // Registro de la eeprom donde se guarda el tempo de docificacion
- int16 const mapaTimer[]={0x631,0x5B31,0x4f31,0x6631,0x6d31,0x7d31,0x0731,0x7f31,0x6f31};//Numeros del uno al Nueve.
- int16 numeroDies[]={0x00,0x00,0x0600,0x3100,0x0631,0x3F06,0x3F06,0x3F06};
- int16 numeroEleven[]={0x00,0x00,0x0600,0x3100,0x0631,0x0606,0x0606,0x0606};
- int16 numeroTuelve[]={0x00,0x00,0x0600,0x3100,0x0631,0x5b06,0x5b06,0x5b06};
- int16 numero13[]={0x00,0x00,0x0600,0x3100,0x0631,0x4f06,0x4f06,0x4f06};
- int16 numero14[]={0x00,0x00,0x0600,0x3100,0x0631,0x6606,0x6606,0x6606};
- int16 numero15[]={0x00,0x00,0x0600,0x3100,0x0631,0x6d06,0x6d06,0x6d06};
- int16 numero16[]={0x00,0x00,0x0600,0x3100,0x0631,0x7d06,0x7d06,0x7d06};
- // int16 animation[]={0x30,0x06,0x600,0x3000};
- int const animationNun=0b00000000000110;
- //int16 const numbers[]=0x00;
- short i;
- int g=0;
- int z =0;
- int n=0x00;
- int j=0;
- int w=0;
- VOID MAIN() {
- enable_interrupts(global);
- enable_interrupts(int_ext);
- ext_int_edge(h_to_l);
- SET_TRIS_A(0x07);
- SET_TRIS_b(0x01);
- SET_TRIS_c(0x00);
- SET_TRIS_d(0x00);
- SET_TRIS_e(0x00);
- output_b(0xff);
- output_HIGH(pin_B6);
- output_c(0xff);
- output_d(0xff);
- output_e(0xff);
- if(!bit_test(PCON,1)){
- BIT_SET(PCON,1);
- do{
- write_data(0x543f); // Entro por Apagon / Muestro T1 en el dsplay y espero 1 segundo
- delay_ms(100);
- g++;
- }while(G<=10);
- }else if (bit_test(PCON,1)){ // Set 0x00 Para Limpiar los registros de la EEprom Desde 0x00 hasta 0x0f Cuando entro por Reset
- write_data(0x631); // Escrivo en el Display T1
- for(int i=0;i<=15;i++){ //
- write_eeprom(i,0x00); // limpio la eeprom
- }
- }
- //while(true){
- write_data(0x543f); // Write On Again (Muesto On en el display)
- do{
- output_Toggle(pin_B6); //Ago que el led de power blinkin a 250 ms)
- delay_Ms(250); //Aqui Paro El contador del Programa para evitar que no sea llamado desde otro punto que no sea precionando A1
- }while(input(pin_a1)); // preciono la Entrada A1 para selecionar el timer A setiar
- output_high(pin_B6); // encienfo fijo el led de power
- while(true){
- do{
- if(!input(pin_a0) || (!input(pin_a2))){// si pin A0 o Pin_a1 ==0 ir al timer para add o disminuir Tiempo
- //WHILE(1){
- if(input(pin_a2) == 0) { //inc o dec z depen del pin que este precionado A0,A2
- if (z <= 0){
- z = 99;
- }
- z--;
- delay_ms(100);
- }
- if(input(pin_a0) == 0) {
- if (z >= 99){
- z = 0;
- }
- z++;
- delay_ms(100);
- }
- write_eeprom(EE_Address[n],z); // escribo en la EE el valor decimal de Z en direcion N, N puede tomar valores desde 0x00 hasta 0x0f
- // if(!input(pin_a2)) {GOTO T_backward;}
- //if(!input(pin_a1)) {GOTO T_forward;} //llamado desde la rutina que seleciona el numero de timer.
- write_data(digitos[z]); //muetro por display el valor de Z que es el setpoint del timer.
- //delay_ms(250);
- //}// setTimerEnd
- }
- }while(input(pin_a1)); // preciono la Entrada A1 para selecionar el timer a setiar o moverme entre ellos(timer del 1 al 16)
- if(w<=8) write_data(mapaTimer[w]);//Aqui si el registro W toma valor de 0 a 7 y ese valor lo uso para escrivir el valor almacenado en el Array MapaTimer
- switch(w){
- case(9):write_Nunbers(numeroDies);
- break;
- case(10):write_Nunbers(numeroEleven);
- break;
- case(11):write_Nunbers(numeroTuelve);
- break;
- case(12):write_Nunbers(numero13);
- break;
- case(13):write_Nunbers(numero14);
- break;
- case(14):write_Nunbers(numero15);
- break;
- case(15):write_Nunbers(numero16);
- break;
- }
- delay_ms(500);
- //write_data(read_eeprom(0x00));
- write_data(digitos[(read_eeprom(w))]); //Printeo el valor decimal almacenado en la variable Z (timer_1 Valor-actual)
- w++;
- n=w-1;
- z=0;
- if(w>=16){
- w=0;
- }
- }
- }// End del Main
- //FUNCION PARA ESCRBOR LOS DIGITOS EN EL DISPLAY
- void write_data( int16 number){
- for( int16 j = 0x8000; j > 0; j = j >> 1) {
- if(number & j) //and ligico entre j y number para detectar bit a bit 0 o 1 de number
- output_high(data_pin);
- //output_low(data_pin);
- //output_high(clock_pin);
- else
- output_low(data_pin);
- output_high(clock_pin);
- output_low(clock_pin);
- }
- output_high(latch_pin);
- output_low(latch_pin);
- }
- /* Fucion Para La animacion del dispaly Entre Un timer Y otro */
- Void Retardo_03seg(){
- delay_ms(250);
- for(int i=0;i<=1;i++){
- for(long j=0;j<=999;j++){
- //delay_ms(1);
- if(j<=125/2){write_data(animationNun<<3);} //Primera barra
- if(j>125/2 && j<=250/2){write_data(animationNun);}//Segunda Barra
- if(j>250/2 && j<=375/2){write_data(animationNun<<11);}//Tercera Barra
- if(j>375/2 && j<=500/2) {write_data(animationNun<<8);}//Cuarta Barra
- if(j>500/2 && j<=625/2){write_data(0x00);}//
- if(j>625/2 && j<=750/2){write_data(animationNun<<11);}//tersera Barra
- if(j>750/2 && j<=825/2){write_data(animationNun);}//2da barra
- if(j>825/2 && j<=1000/2 ){write_data(animationNun<<3);}//1ra barra
- if(j>500 ){write_data(0x00);}
- delay_ms(1);
- }
- }
- }
- /* Funcion Que Hace el Efecto que Los Numero mayor de 9 se desplacen de Derecha a Isquierda */
- void write_Nunbers(int16 numbers[]){ // funcion que escribe los numeros del 10 al 16.
- for(int j=0;j<=7;j++){
- write_data(numbers[j]);
- delay_ms(200);
- }
- j=0;
- }
- /* Fucion Para Temporizary visualizar en el display el conteo regrecivo */
- void Docis(int MemoryValue,int PinValue ){
- output_low(PinValue);
- int f=read_eeprom(MemoryValue);
- for(int i=0;i<=(read_eeprom(MemoryValue));i++){
- for(long j=0;j<=1000;j++){
- delay_ms(1);
- }
- write_data(digitos[f]);
- f--;
- output_Toggle(pin_B6);
- }
- output_high(PinValue);
- output_high(pin_B6);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement