Autor Tema: Reloj binario portable HH:MM  (Leído 8251 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Reloj binario portable HH:MM
« en: 18 de Marzo de 2016, 19:14:41 »
Hola amigos,buen día!

Decidí realizar mi propio reloj binario después de ver algunos muy interesantes.

Les comparto mis avances :

Si se presiona rapidamente el botón y se suelta solo muestra HH:MM por 2.5s aproximadamente,después de apaga el display y entra en modo bajo consumo

Al encender marca 00:00:00 , si se presiona RB0 y se mantiene asi, se ingresa al menu en el cual puedes ajustar los minutos/segundos etc... si esta en ajuste de minutos estos comienzan a titilar,si esta en editar horas estas titilaran.

Una vez en la opción seleccionada se presiona RB1 para incrementar HH:MM.

Se debe presionar RB0 para salir del Menu

Los LEDs que indican las horas sirven también para notificar la opción seleccionada.


Materiales :

pic18f26k20 ( de estos tengo varios a la mano,seria facil portar el código)
cristal de 32.768KHz , es el corazón del reloj
10 LEDs (horas  4/ minutos 6)
2 botones switch
capacitores de 1uF/0.1uF
transistor mosfet N
y algunas resistencias.

XC8 v1.34 optimizacion-free
(probe con la optimizacion PRO y el codigo se reduce casi en un 40% esto afecta la entrada y operaciones realizadas en las interrupciones porque trabajo con el cristal de 32.768KHz,se resolvió cambiando de oscilador entre LP de 32.768KHz al interno de 1MHz)

Intente utilizar el mínimo de componentes, así que realice una pequeña matriz de LEDs.

** Más tarde subo vídeo,estoy trabajando en el pcb.


Código: C
  1. /*
  2.  * File:   main_v2.c
  3.  * Author: Fabrizio Barragan
  4.  *
  5.  * https://twitter.com/IObrizio
  6.  * http://amedialab.com/
  7.  * https://www.youtube.com/user/AutomationMediaLab
  8.  *
  9.  *
  10.  * Created on 17 de Marzo de 2016, 02:41 PM
  11.  *
  12.  * RTC reloj binario / Horas:Minutos
  13.  *
  14.  * Cambio de oscilador entre LP@32.768KHz<->Internal@1MHz
  15.  * Entrada a Menu por Ext Int0 RB0 / RB1 incrementa valor
  16.  * horas:minutos:segundos
  17.  *  11:59:59
  18.  *
  19.  * Solo muestra HH:MM
  20.  */
  21.  
  22. // 'C' source line config statements
  23. #define _XTAL_FREQ 32768    // 32.768KHz Crystal frecuency
  24. #include <xc.h>
  25.  
  26. #include <stdint.h>
  27.  
  28. // #pragma config statements should precede project file includes.
  29. // Use project enums instead of #define for ON and OFF.
  30.  
  31. // CONFIG1H
  32. #pragma config FOSC = INTIO67   // Oscillator Selection bits (Internal oscillator block, port function on RA6 and RA7)
  33. #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
  34. #pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
  35.  
  36. // CONFIG2L
  37. #pragma config PWRT = ON        // Power-up Timer Enable bit (PWRT enabled)
  38. #pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
  39. #pragma config BORV = 18        // Brown Out Reset Voltage bits (VBOR set to 1.8 V nominal)
  40.  
  41. // CONFIG2H
  42. #pragma config WDTEN = OFF      // Watchdog Timer Enable bit (WDT is controlled by SWDTEN bit of the WDTCON register)
  43. #pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)
  44.  
  45. // CONFIG3H
  46. #pragma config CCP2MX = PORTBE  // CCP2 MUX bit (CCP2 input/output is multiplexed with RB3)
  47. #pragma config PBADEN = ON      // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
  48. #pragma config LPT1OSC = ON     // Low-Power Timer1 Oscillator Enable bit (Timer1 configured for low-power operation)
  49. #pragma config HFOFST = OFF     // HFINTOSC Fast Start-up (The system clock is held off until the HFINTOSC is stable.)
  50. #pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
  51.  
  52. // CONFIG4L
  53. #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
  54. #pragma config LVP = OFF        // Single-Supply ICSP Enable bit (Single-Supply ICSP disabled)
  55. #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
  56.  
  57. // CONFIG5L
  58. #pragma config CP0 = OFF        // Code Protection Block 0 (Block 0 (000800-003FFFh) not code-protected)
  59. #pragma config CP1 = OFF        // Code Protection Block 1 (Block 1 (004000-007FFFh) not code-protected)
  60. #pragma config CP2 = OFF        // Code Protection Block 2 (Block 2 (008000-00BFFFh) not code-protected)
  61. #pragma config CP3 = OFF        // Code Protection Block 3 (Block 3 (00C000-00FFFFh) not code-protected)
  62.  
  63. // CONFIG5H
  64. #pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) not code-protected)
  65. #pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM not code-protected)
  66.  
  67. // CONFIG6L
  68. #pragma config WRT0 = OFF       // Write Protection Block 0 (Block 0 (000800-003FFFh) not write-protected)
  69. #pragma config WRT1 = OFF       // Write Protection Block 1 (Block 1 (004000-007FFFh) not write-protected)
  70. #pragma config WRT2 = OFF       // Write Protection Block 2 (Block 2 (008000-00BFFFh) not write-protected)
  71. #pragma config WRT3 = OFF       // Write Protection Block 3 (Block 3 (00C000h-00FFFFh) not write-protected)
  72.  
  73. // CONFIG6H
  74. #pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write-protected)
  75. #pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
  76. #pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
  77.  
  78. // CONFIG7L
  79. #pragma config EBTR0 = OFF      // Table Read Protection Block 0 (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks)
  80. #pragma config EBTR1 = OFF      // Table Read Protection Block 1 (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks)
  81. #pragma config EBTR2 = OFF      // Table Read Protection Block 2 (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks)
  82. #pragma config EBTR3 = OFF      // Table Read Protection Block 3 (Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks)
  83.  
  84. // CONFIG7H
  85. #pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot Block (000000-0007FFh) not protected from table reads executed in other blocks)
  86. //--------------------------------------------------------
  87.  
  88. #define menu_option    5           // numero de opciones del menu
  89.  
  90. #define led_row_0 LATAbits.LATA6    // habilita fila 0
  91. #define led_row_1 LATAbits.LATA7    // habilita fila 1
  92.  
  93. #define led_stat LATBbits.LATB5    //
  94.  
  95. #define button_swicth_0    PORTBbits.RB0   // Boton sin presionar = 1
  96. #define button_swicth_1    PORTBbits.RB1   // Boton presionado = 0
  97.  
  98. void config_OSC(void);      //configuracion e reloj
  99. void config_EUSART(void);   // Configuracion puerto serial
  100. void config_TMR0(void);     // configurarion Timer0
  101. void config_TMR1(void);     // configurarion Timer1
  102. void config_PORT(void);     // configuracion puertos
  103. void show_data(uint8_t data_to_display_hi,uint8_t data_to_display_lo,uint16_t time_active);
  104.                              // Actualiza los datos a visualizar
  105. //------------------------------------------------------------
  106.  
  107. uint8_t segundos = 0;       // Contador segundos
  108. uint8_t minutos = 0;        // contador minutos
  109. uint8_t horas = 0;          // contador horas
  110.  
  111. uint8_t data_disp_hi;       // 4 LEDS datos a dibujar parte alta
  112. uint8_t data_disp_lo;       // 6 LEDS datos a dibujar parte baja
  113. uint16_t display_active_time;   // Duración de encendido display
  114.                                 // Maximo 65536 // 100 aprox = 500ms
  115.  
  116. uint8_t display_en = 0;     // bandera refresco display
  117. uint8_t led_row_index = 0;  // indicador parte alta o baja
  118. uint16_t tmr0_retries = 0;  // contador desbordes Tmr0
  119.  
  120. uint8_t menu_index = 0;     // indica tarea a ejecutar
  121. uint8_t button_flag = 0;    // bandera boton interrupción Externa
  122.                             // 0 esperando interrupción
  123.                             // 1 button_switch_0 presionado
  124.  
  125. int main(void) {
  126.  
  127.     config_OSC();           // Configuracion Oscilador
  128.     config_TMR0();          // Configurarion Timer0    
  129.     config_TMR1();          // Configuracion Tmr1
  130.     config_PORT();          // Configuracion de Pines    
  131.    
  132.     INTCONbits.PEIE = 1;
  133.                         //When IPEN = 0:
  134.                         //1 = Enables all unmasked peripheral interrupts
  135.                         //0 = Disables all peripheral interrupts    
  136.    
  137.     PIE1bits.TMR1IE = 1;
  138.                         //TMR1IE: TMR1 Overflow Interrupt Enable bit
  139.                         //1 = Enables the TMR1 overflow interrupt
  140.                         //0 = Disables the TMR1 overflow interrupt  
  141.    
  142.     INTCON2bits.INTEDG0 = 0;
  143.                         //INTEDG0: External Interrupt 0 Edge Select bit
  144.                         //1 = Interrupt on rising edge
  145.                         //0 = Interrupt on falling edge      
  146.    
  147.     INTCONbits.INT0IF = 0;  // Limpiar bandera Ext Int0
  148.     INTCONbits.INT0IE = 1;  // Initerrupción Externa Int0 ON
  149.    
  150.     INTCONbits.GIE = 1;     // Interrupción Global ON
  151.                         //When IPEN = 0:
  152.                         //1 = Enables all unmasked interrupts
  153.                         //0 = Disables all interrupts including peripherals
  154.  
  155.     while(1){           // Programa Principal
  156.  
  157.  
  158.         if(button_flag){    // Se presiono button_switch_0 ?
  159.                             // Desperto uC
  160.                            
  161.             __delay_ms(100);    // retardo antirebotes
  162.            
  163.             if(button_swicth_0){    // Interruptor Abierto ?
  164.  
  165.                 show_data(horas,minutos,500);   // Activar display X tiempo
  166.                 while(display_en);              // Esperar a que termine de
  167.             }// if button_0                     // dibujar display
  168.            
  169.             else{                   // El Interruptor se mantiene Cerrado
  170.            
  171.                 while(button_swicth_0 == 0){    // Mientras interruptor
  172.                                                 // Cerrado
  173.                    
  174.                     menu_index++;               // Incrementa variable Menu
  175.                    
  176.                     if(menu_index > menu_option){
  177.                         menu_index = 0;         // Menu solo de 0 a menu_option
  178.                     }//if menu index
  179.                    
  180.                     show_data(menu_index,0,100);    // Indice Menu mostrado en
  181.                     while(display_en);              // display parte Alta
  182.  
  183.                 }// while button_0
  184.                
  185.                 while(menu_index == 1 && button_swicth_0 == 1){
  186.                                         // Mientras Indice Menu 1 y no se
  187.                                         // presiones button_0
  188.                
  189.                     show_data(0,minutos,30);    // parpadea minutos
  190.                     while(display_en);          // editables
  191.                    
  192.                     if(button_swicth_1 == 0)    // Incrementa minutos
  193.                         minutos++;              // si se presiona button_1
  194.                    
  195.                     show_data(0,0,10);
  196.                     while(display_en);                    
  197.          
  198.                 }// while menu_index 1
  199.  
  200.                 while(menu_index == 2 && button_swicth_0 == 1){
  201.                                         // Mientras Indice Menu 1 y no se
  202.                                         // presiones button_0
  203.                    
  204.                     show_data(horas,0,30);      // parpadea horas
  205.                     while(display_en);          // editables
  206.                    
  207.                     if(button_swicth_1 == 0)    // Incrementa horas
  208.                         horas++;                // si se presiona button_1
  209.                    
  210.                     show_data(0,0,10);
  211.                     while(display_en);                    
  212.          
  213.                 }// while menu_index 2
  214.                
  215.                 // Agregar Opciones siguiendo la sintaxis previa.
  216.                 // while(menu_index == #opcion && button_swicth_0 == 1)...
  217.                
  218.             }// else button_0
  219.            
  220.             INTCONbits.INT0IF = 0;      // Limpiar bandera Ext Int0
  221.             INTCONbits.INT0IE = 1;      // Initerrupción Externa Int0 ON
  222.             button_flag = 0;            // Limpiar bandera button
  223.            
  224.             menu_index = 0;                   // Reinicia opciones menu_index
  225.         }
  226.        
  227.         Sleep();        // Consumo Minimo,A despertar por Ext Int0/TMR1
  228.        
  229.     }   //loop Programa Principal
  230.    
  231. }   //main loop
  232. //------------------------------------------
  233. void show_data(uint8_t data_to_display_hi,uint8_t data_to_display_lo,uint16_t time_active){
  234.    
  235.     data_disp_hi = data_to_display_hi;
  236.     data_disp_lo = data_to_display_lo;
  237.     display_active_time = time_active;  // indica tiempo de display encendido
  238.  
  239. //    led_stat = 1;           // LED de estado
  240.    
  241.     OSCCONbits.SCS = 0b10;   // Cambio de Oscilador LP a
  242.                             //  OScilador Inter 1MHz
  243.    
  244.     TMR0 = 100;             // Recarga Tmr0 para desborde
  245.    
  246.     INTCONbits.TMR0IF = 0;  // Limpiar bandera Tmr0
  247.     INTCONbits.TMR0IE = 1;  // Interrupcion Tmr0 ON    
  248.  
  249.     T0CONbits.TMR0ON = 1;   // Tmr0 ON
  250.  
  251.     display_en = 1;         // Habilita refresco display
  252.    
  253. }// show_data- datos parte alta/datos parte baja/tiempo de encendido
  254.  
  255. //------------------------------------------
  256. void config_TMR0(void){      // configurarión Timer0
  257.    
  258.     T0CON = 0b01000010;
  259.  
  260.             //bit 7 TMR0ON: Timer0 On/Off Control bit
  261. //1 = Enables Timer0
  262. //0 = Stops Timer0
  263.  
  264.             //bit 6 T08BIT: Timer0 8-bit/16-bit Control bit
  265. //1 = Timer0 is configured as an 8-bit timer/counter
  266. //0 = Timer0 is configured as a 16-bit timer/counter
  267.  
  268.             //bit 5 T0CS: Timer0 Clock Source Select bit
  269. //1 = Transition on T0CKI pin
  270. //0 = Internal instruction cycle clock (CLKOUT)
  271.  
  272.             //bit 4 T0SE: Timer0 Source Edge Select bit
  273. //1 = Increment on high-to-low transition on T0CKI pin
  274. //0 = Increment on low-to-high transition on T0CKI pin
  275.  
  276.             //bit 3 PSA: Timer0 Prescaler Assignment bit
  277. //1 = TImer0 prescaler is NOT assigned. Timer0 clock input bypasses prescaler.
  278. //0 = Timer0 prescaler is assigned. Timer0 clock input comes from prescaler output.
  279.  
  280.             //bit 2-0 T0PS<2:0>: Timer0 Prescaler Select bits
  281. //111 = 1:256 prescale value
  282. //110 = 1:128 prescale value
  283. //101 = 1:64 prescale value
  284. //100 = 1:32 prescale value
  285. //011 = 1:16 prescale value
  286. //010 = 1:8 prescale value
  287. //001 = 1:4 prescale value
  288. //000 = 1:2 prescale value    
  289. }
  290. //------------------------------------------
  291. void config_TMR1(void){      // configurarión Timer1
  292.  
  293.     T1CON = 0b00001111;
  294.  
  295.     //bit 7 RD16: 16-bit Read/Write Mode Enable bit
  296. //1 = Enables register read/write of TImer1 in one 16-bit operation
  297. //0 = Enables register read/write of Timer1 in two 8-bit operations
  298.  
  299.     //bit 6 T1RUN: Timer1 System Clock Status bit
  300. //1 = Main system clock is derived from Timer1 oscillator
  301. //0 = Main system clock is derived from another source
  302.  
  303.     //bit 5-4 T1CKPS<1:0>: Timer1 Input Clock Prescale Select bits
  304. //11 = 1:8 Prescale value
  305. //10 = 1:4 Prescale value
  306. //01 = 1:2 Prescale value
  307. //00 = 1:1 Prescale value
  308.  
  309.     //bit 3 T1OSCEN: Timer1 Oscillator Enable bit
  310. //1 = Timer1 oscillator is enabled
  311. //0 = Timer1 oscillator is shut off
  312. //The oscillator inverter and feedback resistor are turned off to eliminate power drain.
  313.  
  314.     //bit 2 T1SYNC: Timer1 External Clock Input Synchronization Select bit
  315. //When TMR1CS = 1:
  316. //1 = Do not synchronize external clock input
  317. //0 = Synchronize external clock input
  318. //When TMR1CS = 0:
  319. //This bit is ignored. Timer1 uses the internal clock when TMR1CS = 0.
  320.  
  321.     //bit 1 TMR1CS: Timer1 Clock Source Select bit
  322. //1 = External clock from pin RC0/T1OSO/T13CKI (on the rising edge)
  323. //0 = Internal clock (FOSC/4)
  324.  
  325.     //bit 0 TMR1ON: Timer1 On bit
  326. //1 = Enables Timer1  
  327.    
  328. }
  329.  
  330. //------------------------------------------
  331. void config_PORT(VOID){
  332.  
  333.     ANSEL   = 0;    // NO ANALOG
  334.     ANSELH  = 0;
  335.    
  336.     LATA    = 0;
  337.     TRISA   = 0;
  338.             // General I/O pins LED MAtrix
  339.  
  340.             // RA7 -> Out LED horas mosfet enable
  341.             // RA6 -> Out LED minutos  mosfet enable
  342.    
  343.             // RA5 -> MSB   LED
  344.             // RA4 ->    
  345.             // RA3 ->
  346.             // RA2 ->
  347.             // RA1 ->
  348.             // RA0 -> LSB   LED
  349.  
  350.     INTCON2bits.RBPU = 0;
  351.                         //RBPU: PORTB Pull-up Enable bit
  352.                         //1 = All PORTB pull-ups are disabled
  353.                         //0 = PORTB pull-ups are enabled provided that the pin is an input and the corresponding WPUB bit is
  354.                         //set.    
  355.     WPUB = 0b00000011;
  356.                         // RB0-RB1 pull up enables
  357.    
  358.     LATB    = 0;
  359.     TRISB   = 0b00000011;
  360.             // RB7
  361.             // RB6
  362.             // RB5
  363.             // RB4
  364.             // RB3
  365.             // RB2
  366.             // RB1 <- Input Button 1
  367.             // RB0 <- Input Button 2
  368.  
  369.     LATC    = 0;
  370.     TRISC   = 0;
  371.             // RC7 <- Input SERIAL_RX
  372.             // RC6 -> Out   SERIAL_TX
  373.             // RC5 ->
  374.             // RC4 ->
  375.             // RC3 // not used
  376.             // RC2 ->
  377.             // RC1 ->
  378.             // RC0 <->    
  379.     }
  380. //------------------------------------------    
  381. void config_OSC(void){
  382.    
  383.     OSCCONbits.SCS = 0b01;
  384.                     //    SCS<1:0>: System Clock Select bits
  385.                     //1x = Internal oscillator block
  386.                     //01 = Secondary (Timer1) oscillator
  387.                     //00 = Primary clock (determined by CONFIG1H[FOSC<3:0>]).    
  388.    
  389.     OSCCONbits.IRCF = 0b011;    // 1MHz
  390.             //    IRCF<2:0>: Internal Oscillator Frequency Select bits
  391.             //111 = 16 MHz (HFINTOSC drives clock directly)
  392.             //110 = 8 MHz
  393.             //101 = 4 MHz
  394.             //100 = 2 MHz
  395.             //011 = 1 MHz(3)
  396.             //010 = 500 kHz
  397.             //001 = 250 kHz
  398.             //000 = 31 kHz (from either HFINTOSC/512 or LFINTOSC directly)
  399.     //OSCTUNEbits.PLLEN = 1;
  400.     }  
  401. //------------------------------------------
  402. /***       INTERRUPT SERVICE ROUTINE           ***/
  403. void interrupt isr(void){
  404. //----------------- INT0  --------------------------------
  405. if(INTCONbits.INT0IE == 1 && INTCONbits.INT0IF == 1){
  406.                         // Interruptcion Externa Int0
  407.    
  408.     button_flag = 1;    // Establece bandera button
  409.  
  410.     INTCONbits.INT0IE = 0;  // Interrupcion Externa OFF
  411.     INTCONbits.INT0IF = 0;  // limpiar bandera Ext Int0
  412.    
  413. }
  414. //----------------- TIMER0 --------------------------------
  415.     if(INTCONbits.TMR0IE == 1 && INTCONbits.TMR0IF ==1){
  416.  
  417. //----------------- Rutina encendido LED ----------------        
  418.         if(display_en){             // ¿habilitar display ?
  419.  
  420.             if(led_row_index){
  421.  
  422.                 LATA = data_disp_lo;    // Datos LEDs parte baja            
  423.                 led_row_1 = 0;
  424.                 led_row_0 = 1;          // Activa fila baja
  425.  
  426.                 led_row_index = 0;      //parte baja
  427.             }// if led row
  428.  
  429.             else{
  430.  
  431.                 LATA = data_disp_hi;    // Datos LEDs parte alta
  432.                 led_row_0 = 0;          // fila apagada
  433.                 led_row_1 = 1;          // Activa fila Alta
  434.  
  435.                 led_row_index = 1;      // parte Alta
  436.  
  437.             }// else if led row
  438.  
  439.             tmr0_retries++;             // Incrementar contador de
  440.                                         // desbordes
  441.  
  442.             if(tmr0_retries > display_active_time){
  443.  
  444.                                         // Tiempo Activo alcanzado?
  445.  
  446.                 display_en = 0;         // Limpiar bander display  
  447.                 tmr0_retries = 0;       // Contador de desborde a 0
  448.  
  449.                 LATA = 0;               // Puerto Apagado
  450.  
  451.                 OSCCONbits.SCS = 0b01;  // LP oscillator
  452.                                         //SCS<1:0>: System Clock Select bits
  453.                                         //1x = Internal oscillator block
  454.                                         //01 = Secondary (Timer1) oscillator
  455.  
  456.                 INTCONbits.TMR0IF = 0;  // Limpiar bandera Tmr0
  457.                 INTCONbits.TMR0IE = 0;  // Interrupcion Tmr0 OFF
  458.  
  459.                 T0CONbits.TMR0ON = 0;   // Tmr0 OFF
  460.  
  461.     //            led_stat = 0;           // LED indicador OFF
  462.             }// if / tiempo de encendido alcanzado
  463.  
  464.         TMR0=100;                       // Precarga Tmr0/desborde en 5ms aprox
  465.                                         // refresco @ 100Hz
  466.  
  467.         }// if- display   Refresco @ 100Hz      
  468. //---------------------------------------------------------        
  469.     INTCONbits.TMR0IF = 0;        // Limpiar bandera Tmr0
  470.        
  471.     }// TRM0 interrupt
  472.  
  473. //----------------- TIMER1 --------------------------------
  474.     if(PIE1bits.TMR1IE == 1 && PIR1bits.TMR1IF == 1){
  475.  
  476.         TMR1H |= 1 << 7;        // Precarga TMR1 =32768
  477.                                 // desborde cada 1segundo
  478.        
  479.         PIR1bits.TMR1IF = 0;    // limpiar bandera Tmr1
  480.        
  481.         segundos++;             // incrementa segundos
  482.        
  483.         if(segundos > 59){      // 60 segundos?
  484.        
  485.             minutos++;          // aumenta minutos
  486.             segundos = 0;       // reinicia regundos
  487.          
  488.             if(minutos > 59){   // 60 minutos?
  489.        
  490.                 horas++;        // aumenta horas
  491.                 minutos = 0;    // reinicia minutos
  492.                
  493.                 if(horas > 11){ // 12 horas ?
  494.                    
  495.                     horas = 0;  // reinicia horas
  496.        
  497.                 }// horas
  498.             }// minutos
  499.         }// segundos
  500.        
  501.     }//TRM1 interrupt
  502.  
  503. //------------------------------------------------------------
  504. }// ISR
« Última modificación: 18 de Marzo de 2016, 19:31:39 por AKENAFAB »

Desconectado KILLERJC

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8242
Re:Reloj binario portable HH:MM
« Respuesta #1 en: 28 de Marzo de 2016, 00:11:48 »
Te quedo bueno AKENAFAB. Aunque te quedo grande el PIC18 jeje.

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Re:Reloj binario portable HH:MM
« Respuesta #2 en: 28 de Marzo de 2016, 13:54:13 »
Gracias!

Si,es un cañón para una mosquita  :D , son los micros que tenia disponibles.
Estoy trabajando en el pcb. 8)

Saludos!

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Re:Reloj binario portable HH:MM
« Respuesta #3 en: 30 de Marzo de 2016, 07:06:02 »
Hola amigos!

Buscando entre los micros disponibles encontré unos pic16f1828 , migre el código sin tanto problema.

Realice un pcb prototipo antes de pasar a empaquetado qfn.

-Me falta incorporar una rutina antirebotes para los botones,la que tengo es caca.

-Medí un consumo de 11mA máximos ,esto cuando los 6 LEDs estan encendidos y se trabaja a una Fosc de 1MHz

-No recuerdo el consumo en reposo,creo que eran 60uA@32.768KHz 26uA@32.768KHz, son las 4am asi que xD más tarde no olvidare anotar ese dato.

Saludos!
« Última modificación: 05 de Abril de 2016, 03:25:59 por AKENAFAB »

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Re:Reloj binario portable HH:MM
« Respuesta #4 en: 08 de Mayo de 2016, 17:18:39 »
Hola amigos!

Les comparto algunas fotos del reloj funcionando,me falta mucha programación tiempo para terminar el reloj.

Saludos!
« Última modificación: 08 de Mayo de 2016, 17:23:15 por AKENAFAB »

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Re:Reloj binario portable HH:MM
« Respuesta #5 en: 14 de Mayo de 2016, 00:40:26 »
Hola amigos!

De momento asi va el asunto del reloj, les coparto un video.

Estoy probando unas funciones de lectura del boton, botonazo corto o botón presionado.

https://twitter.com/AutoMaLab/status/730972613065891840

Saludos!

Desconectado Fulguitron

  • PIC16
  • ***
  • Mensajes: 122
    • Disfruta de mi blog, hobbies y gadgets diferentes y poco comunes.
Re:Reloj binario portable HH:MM
« Respuesta #6 en: 20 de Mayo de 2016, 01:25:56 »
Que bueno si señor, yo también estoy haciendo uno, pero con seis Leds, una correa chula y ya lo tienes.
Disfruta de mi blog, hobbies y gadgets diferentes y poco comunes.

http://hobbiesygadgets.blogspot.com.es/

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Re:Reloj binario portable HH:MM
« Respuesta #7 en: 20 de Mayo de 2016, 13:46:11 »
gracias,todavia falta algo  programación, no he tenido mucho tiempo de avanzar y aparte se daño la tarjeta de vídeo,estoy trabajando en una laptop donde  tengo nada de nada :P.

Comparte las fotos de proyecto  ((:-)) esperemos verlo por aca.

Saludos!

Desconectado Fulguitron

  • PIC16
  • ***
  • Mensajes: 122
    • Disfruta de mi blog, hobbies y gadgets diferentes y poco comunes.
Re:Reloj binario portable HH:MM
« Respuesta #8 en: 07 de Junio de 2016, 02:25:18 »
Pues en breve colgaré fotos, pero lo mio es muuuucho más cutre, con cables y soldado, ya me molaría a mi, hacer las placas así de chulas.
Disfruta de mi blog, hobbies y gadgets diferentes y poco comunes.

http://hobbiesygadgets.blogspot.com.es/

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Re:Reloj binario portable HH:MM
« Respuesta #9 en: 31 de Enero de 2017, 22:01:59 »
Les comparto un video probando el mini buzzer.
Me falta bastante con los sonidos :P

Saludos!


Desconectado KILLERJC

  • Colaborador
  • DsPIC33
  • *****
  • Mensajes: 8242
Re:Reloj binario portable HH:MM
« Respuesta #10 en: 31 de Enero de 2017, 22:41:58 »
Va quedando genial, una pregunta el PIC lo soldaste con horno o a mano?

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Re:Reloj binario portable HH:MM
« Respuesta #11 en: 31 de Enero de 2017, 23:47:14 »
Va quedando genial, una pregunta el PIC lo soldaste con horno o a mano?

Lo soldé a mano con pistola de aire.

Desconectado informatica

  • PIC10
  • *
  • Mensajes: 1
Re:Reloj binario portable HH:MM
« Respuesta #12 en: 03 de Febrero de 2017, 13:11:19 »
Muy buen trabajo, voy a intentarlo

Desconectado Fulguitron

  • PIC16
  • ***
  • Mensajes: 122
    • Disfruta de mi blog, hobbies y gadgets diferentes y poco comunes.
Re:Reloj binario portable HH:MM
« Respuesta #13 en: 06 de Mayo de 2018, 07:19:07 »
Una pregunta, cuanto te dura la pila???
Disfruta de mi blog, hobbies y gadgets diferentes y poco comunes.

http://hobbiesygadgets.blogspot.com.es/

Desconectado AKENAFAB

  • Colaborador
  • DsPIC30
  • *****
  • Mensajes: 3227
Re:Reloj binario portable HH:MM
« Respuesta #14 en: 09 de Mayo de 2018, 00:26:25 »
Una pregunta, cuanto te dura la pila???
No lo he medido,lo dejé en pausa por ahora en lo que terminó otras cosas.

No he avanzado más con el proyecto.

Saludos