Want your
own Fotopage?






 
Arao's FotoPage
Eletrônica na bancada
By: Arao Hayashida Filho

[Recommend this Fotopage] | [Share this Fotopage] | [Track this Fotopage]
View complete fotopage

Friday, 6-Nov-2009 02:50 Email | Share | Bookmark
Projetinho de fim de semana: Reloginho VFD

 
 
 
 
 
Comprei no ebay uns displays VFD IV-8, resolvi fazer um reloginho com eles, eles foram escolhidos porque trabalhar.

Daí foi começar a desenhar a placa e esquema enquanto a encomenda não chegava da Rússia..

O resultado do esquema e placas está nas fotos 1 e 2.

A idéia era usar um AT89s52 e depois de umas horinhas de trabalho o negócio funcionou muito bem!

O programa ocupa só 1kB da Flash e foi compilado no SDCC, deixo o código para quem quiser fazer o seu próprio reloginho!

Poutz e não é que essa nhaca de fotopage detonou a minha identação!



/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <at89x52.h>

#define Desabilita_INT IE=0x0

#define Habilita_INT IE=0x1



// Prototipos

void inicializa_timer2(void) ;
void enviacharvfd (unsigned char disp1,unsigned char disp2, unsigned char disp3, unsigned char disp4);

void delay_ms(unsigned char ms);



// Variaveis globais

unsigned char ms100=0;



//ISR's

void Timer2_ISR(void) interrupt 5

{

ms100++;

TF2 = 0; // Apago o flag de interrupcao

}





void main(void)

{

unsigned char segundos, min1, min2, hor1, hor2;

segundos=0;

ms100=0;

min1=0;

min2=0;

hor1=0;

hor2=0;

enviacharvfd(hor2, hor1, min2, min1);

inicializa_timer2();





while (1)

{

P2_7=1;

if (P2_7==0)

{

min1++;

enviacharvfd(hor2, hor1, min2, min1);

delay_ms(30);

}



//ms100++;

if (ms100>9)

{

ms100=0;

segundos++;

enviacharvfd(hor2, hor1, min2, min1);

}

if (segundos>59)

{

segundos=0;

min1++;

}



if (min1>9)

{

min1=0;

min2++;

}

if (min2>5)

{

hor1++;

min2=0;

}

if (hor1>9)

{

hor2++;

hor1=0;

}

if (hor2==2 && hor1>3)

{

hor1=0;

hor2=0;

}

}

}



// Modo 0 com auto reload

void inicializa_timer2(void)

{

T2MOD &= 0xFC; // T2OE=0;DCEN=1;

T2MOD |= 0x01;

EXF2=0; //apago o flag

TCLK=0;RCLK=0; // desabilita o BRG

EXEN2=0; //ignora T2ex

TH2=0x7D; //Valores de inicializacao: 100ms (4MHz) - descontos das intrucoes executadas no ISR

TL2=0xC8;

RCAP2H=0x7D; // Valores do reload

RCAP2L=0xC8;

C_T2=0; // Modo timer

CP_RL2=0; // Reload

EA=1;

ET2=1; // Habilita int do timer 2

TR2=1; // Habilito contagem do timer 2

}











// Disp1,2=horas Disp2,3=minutos

void enviacharvfd (unsigned char disp1,unsigned char disp2, unsigned char disp3, unsigned char disp4)

{

// Horas 2

//if (disp1==0x00) P0=0xA0;

if (disp1==0x00) P0=0xFF; // Não mostra nada no primeiro dígito se 0, ex 02:59 -> 2:59

if (disp1==0x01) P0=0xF3;

if (disp1==0x02) P0=0xC4;

if (disp1==0x03) P0=0xC0;

if (disp1==0x04) P0=0x93;

if (disp1==0x05) P0=0x81;

if (disp1==0x06) P0=0x88;

if (disp1==0x07) P0=0xE3;

if (disp1==0x08) P0=0x80;

if (disp1==0x09) P0=0x83;

// Horas 1

if (disp2==0x00) P1=0x82;

if (disp2==0x01) P1=0xE7;

if (disp2==0x02) P1=0x91;

if (disp2==0x03) P1=0xC1;

if (disp2==0x04) P1=0xE4;

if (disp2==0x05) P1=0xC8;

if (disp2==0x06) P1=0x88;

if (disp2==0x07) P1=0xE3;

if (disp2==0x08) P1=0x80;

if (disp2==0x09) P1=0xE0;

// Minutos 2

if (disp3==0x00) P3=0x82;

if (disp3==0x01) P3=0xE7;

if (disp3==0x02) P3=0x91;

if (disp3==0x03) P3=0xC1;

if (disp3==0x04) P3=0xE4;

if (disp3==0x05) P3=0xC8;

if (disp3==0x06) P3=0x88;

if (disp3==0x07) P3=0xE3;

if (disp3==0x08) P3=0x80;

if (disp3==0x09) P3=0xE0;

// Minutos 1

if (disp4==0x00) P2=0x82;

if (disp4==0x01) P2=0xE7;

if (disp4==0x02) P2=0x91;

if (disp4==0x03) P2=0xC1;

if (disp4==0x04) P2=0xE4;

if (disp4==0x05) P2=0xC8;

if (disp4==0x06) P2=0x88;

if (disp4==0x07) P2=0xE3;

if (disp4==0x08) P2=0x80;

if (disp4==0x09) P2=0xE0;



}


void delay_ms(unsigned char ms) // delay pra lá de aproximado!

{

unsigned char i;

while (ms> 1)

{

ms--;

for (i=0; i < 200; i++)//era 200

{

_asm

nop // o DJNZ é 2 Machine Cycles (12x4 clocks) ,NOP é 1 Machine Cycle

nop // conferir as contas e adicionar/reduzir a enrolacao da rotina ao se fazer a mudanca de cristal!

nop

_endasm; // cada machine cycle é 12 clocks!!! (que lerdeza) .. 12 MHz



}

}

}


Add your comment
Name
Email (optional)
Register for updates Register for this Fotopage update (requires email)
Register for entry comments update (requires email)

More...
Link URL (optional)
verification Code
fill in the below number in the box





View complete fotopage


© Pidgin Technologies Ltd. 2008.