Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/29/11 13:24
Read: times


 
#183936 - Modified program
Responding to: ???'s previous message
Hi to all,
After few days of work on VFD I clear all the problems.The modified program is I am putting for your reference.Hopefully this will help you in developing the VFD driving code.

#include <c:c51incstdio.h>
#include <c:c51increg52.h>
#include <c:c51incintrins.h>

#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long int

#define CS      P24
#define CLK     P25
#define DATA    P26
#define FILAMENT        P20

uchar   ms100,
        displaydigit[9],
        datareg,
        data_buffer1,
        vfdcounter;

int     init_vfd(),        
        write_vfd1(),
        data2vfd();        

code unsigned char dis_tab[]
                =   {
                    0xc0,  //code for 0         add 0x00
                    0xf9,  //code for 1         add 0x01
                    0xa4,  //code for 2         add 0x02
                    0xb0,  //code for 3         add 0x03
                    0x99,  //code for 4         add 0x04
                    0x92,  //code for 5         add 0x05
                    0x82,  //code for 6         add 0x06
                    0xf8,  //code for 7         add 0x07
                    0x80,  //code for 8         add 0x08
                    0x90,  //code for 9         add 0x09
                    0xff,  //code for blank     add 0x0a
                    0x86,  //code for E         add 0x0b
                    0x87,  //code for t         add 0x0c
                    0xa1,  //code for d         add 0x0d
                    0x88,  //code for A         add 0x0e
                    0xc7,  //code for L         add 0x0f
                    0x87,  //code for T         add 0x10
                    0xc1,  //code for U         add 0x11
                    0x8c,  //code for P         add 0x12
                    };




init_vfd()
{
CS = 0;

data_buffer1 = 0x05;    //9 digit & 13 segment selection
data2vfd();

CS = 1;

_nop_();
_nop_();

CS = 0;

data_buffer1 = 0x40;    //auto increment address mode
data2vfd();

CS = 1;

_nop_();
_nop_();

CS = 0;

data_buffer1 = 0x8f;    //display on & pulsewidth = 14/16
data2vfd();             

CS = 1;
}

write_vfd1()
{
CS = 0;

data_buffer1 = 0xc0;
data2vfd();

data_buffer1 = dis_tab[displaydigit[0]];            //0
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = dis_tab[displaydigit[1]];            //1
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = dis_tab[displaydigit[2]];            //2
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = dis_tab[displaydigit[3]];            //3
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = dis_tab[displaydigit[4]];            //4
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = dis_tab[displaydigit[5]];            //5
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = dis_tab[displaydigit[6]];            //6
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = dis_tab[displaydigit[7]];            //7
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = 0xff;            //dummy
data_buffer1 = ~data_buffer1;
data2vfd();

data_buffer1 = dis_tab[displaydigit[7]];            //8
data_buffer1 = ~data_buffer1;
data2vfd();


CS = 1;
}

data2vfd()
{
for(vfdcounter = 0;vfdcounter != 8;vfdcounter++)
        {
        CLK = 0;
        DATA = data_buffer1 & 0x01;
        CLK = 1;
        data_buffer1 = data_buffer1 >> 1;
        }
}

void main(void)
{
SP = 0xa0;

P0 = 0xff;
P1 = 0xff;
P2 = 0xff;
P3 = 0xff;

init_vfd();

P37 = 0;                        //Not the part of VFD program

displaydigit[0] = 0;
displaydigit[1] = 1;
displaydigit[2] = 2;
displaydigit[3] = 3;
displaydigit[4] = 4;
displaydigit[5] = 5;
displaydigit[6] = 6;
displaydigit[7] = 7;
displaydigit[8] = 8;

write_vfd1();

for(;;)
        {
        FILAMENT = 1;
        ++ms100;
        if(ms100 == 15)
                {
                FILAMENT = 0;
                ms100 = 0;
                }
        }
}



List of 25 messages in thread
TopicAuthorDate
How to control Grid voltage of VFD            01/01/70 00:00      
   what You mean?            01/01/70 00:00      
   bought as module or built by you?            01/01/70 00:00      
      voltage is steady            01/01/70 00:00      
         RE: "I purchase it from market"            01/01/70 00:00      
   I have            01/01/70 00:00      
   how            01/01/70 00:00      
   code            01/01/70 00:00      
      GO OUT FROM INTERRUPT            01/01/70 00:00      
   filament power ?            01/01/70 00:00      
      ISR changed, FILAMENT IS...            01/01/70 00:00      
   Link about VFD            01/01/70 00:00      
      what i should read there?            01/01/70 00:00      
         Same problem with modified code            01/01/70 00:00      
   Work on hardware            01/01/70 00:00      
      show pictures            01/01/70 00:00      
      DC connection            01/01/70 00:00      
         Near to solution            01/01/70 00:00      
            just a thought            01/01/70 00:00      
               Thanks            01/01/70 00:00      
                  Modified program            01/01/70 00:00      
                     make report            01/01/70 00:00      
                        about Filament            01/01/70 00:00      
                           RE:about filament            01/01/70 00:00      
                              PWM            01/01/70 00:00      

Back to Subject List