Saturday, April 5, 2014

Initialize VFD display using Arduino

In this article I will describe how to initialize display from a faulty DVD player. DVD player, VCR and other consumer electronics use vacuum fluorescent display (VFD) for displaying different information and we can can control it using Arduino or any other microcontroller. Most of us electronics technician in our workshops have a faulty device from which we can make use of valid parts for new projects and devices.
From a faulty DVD player I took VFD display and a power source. I used the power source to power the VFD display and Arduino.

Picture of VFD and the power source

VFD display module which I took from a faulty DVD player uses PT6312 controller, for which I found on the internet datasheet. According the datasheet PT6312 is a controller for a vacuum fluorescent display (VFD) packaged in a 44 pin plastic housing. PT6312 is functionally compatible with the μPD16312. To communicate with the Arduino I used DAT, CLK and STB lines from module and connect on Arduino digital pins 2, 3 and 4.

Sketch for initialize VFD module
// *********************************************************
// Program:  VFD display control (PT6312)
// Version:  1.0
// Author:  Elvis Baketa
// Description: 
// *********************************************************

#define DAT 2
#define CLK 3
#define STB 4

#define displayMode 0x01         // 5 digits, 16 segments
#define dataSettings 0x40        // Data write & read mode settings
#define incrementAddress 0x40    // Increment address after data has been written
#define fixedAddress 0x44        // Fixed address
#define addressSettings 0xC0     // Address settings command
#define startAddress 0x00        // start address of ram memory
#define endAddress 0x09          // end address of ram memory
#define displayControl 0x8F      // Display settings ON/OFF

// standard Arduino setup routine
void setup()
{
  // initialize vfd display
  initDisplay();
  // send some data to display
  updateFixedAddress(startAddress, 0b01110111);
}

// standard Arduino loop routine
void loop()
{
}

// routines for sending commands
void sendCommand(unsigned int command, boolean data)
{
  digitalWrite(CLK, HIGH);
  digitalWrite(STB, LOW);
  
  for(int i = 0; i < 8; i++)
  {
    if(bitRead(command, i) & 0x01)
    {
      digitalWrite(DAT, HIGH);
    }else{
      digitalWrite(DAT, LOW);
    }
    digitalWrite(CLK, LOW);
    digitalWrite(CLK, HIGH);
  }
  
  if(data) digitalWrite(STB, HIGH);
}

// routines for sending data
void sendData(unsigned int data, boolean last)
{ 
  for(int i = 0; i < 8; i++)
  {
    if(bitRead(data, i) & 0x01)
    {
      digitalWrite(DAT, HIGH);
    }else{
      digitalWrite(DAT, LOW);
    }
    digitalWrite(CLK, LOW);
    digitalWrite(CLK, HIGH);
  }
  
  if(last) digitalWrite(STB, HIGH);
}

// routines for set ram address
void setAddress(unsigned int address, boolean data)
{
  sendCommand(addressSettings | (address & 0x1F), data);
}

// routine cleaning of display memory
void clearDisplay()
{
  sendCommand(incrementAddress, true);
  setAddress(startAddress, false);
  for(int i = 0; i <= endAddress; i++)
  {
    sendData(0x00, false);
  }
  digitalWrite(STB, HIGH);
}

// routines for initialize display
void initDisplay()
{
  delay (200);
  
  // define communication pins
  pinMode(DAT, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(STB, OUTPUT);
  
  // clear display ram memory
  clearDisplay();
  
  // set display mode to 5 digits, 16 segments
  sendCommand(displayMode, true);
  // set display on and maximum dimming
  sendCommand(displayControl, true);
}

// routine to update fixed memory addresses
void updateFixedAddress(int address, int data)
{
  sendCommand(fixedAddress, true);
  setAddress(address, false);
  sendData(data, true);
}

10 comments:

  1. Thanks for sharing your code.There're mistakes on updateFixedAddres(startAddres, 0b01110111)

    Address not addres and there's miss a <;>at last

    ReplyDelete
    Replies
    1. can you send me the correct code please?

      Delete
    2. Code is now corrected and should compile in arduino ide

      Delete
  2. Que buen trabajo amigo tengo una pantalla similar con su controlador hare algo similar a tu proyecto 😃😃😃

    ReplyDelete
  3. Hello Friend!
    I have a VFD Display like yours and a PT6312 controller but, it is off the board; please, i would like to know how to connect the pins of the controller to the VFD and Arduino. Thank you

    ReplyDelete
  4. Hello, I believe pins on PT6312 for communication are DAT is pin 6, CLK is pin 8 and STB is pin 9. That was a long time ago, but you can search for data sheet uPD16312 and there is all info for controler and how it works!

    ReplyDelete
  5. Hi Elvis, do these "defines" in the Arduino code depend on each VFD or is it fixed? Or does it depend on PT6312?

    #define displayMode 0x01 // 5 digits, 16 segments
    #define dataSettings 0x40 // Data write & read mode settings
    #define incrementAddress 0x40 // Increment address after data has been written
    #define fixedAddress 0x44 // Fixed address
    #define addressSettings 0xC0 // Address settings command
    #define startAddress 0x00 // start address of ram memory
    #define endAddress 0x09 // end address of ram memory
    #define displayControl 0x8F // Display settings ON / OFF

    And if it depends on each VFD, how do I know?
    Thank you

    ReplyDelete
    Replies
    1. Defines are for this display that i have, i dont know how it is wired on your display. It was long time ago that i write this program.
      It is configured for 5 digit and it write zero to first blue digit. If you change fixedAddress form 0x44 to 0x66 you are gonna write zero to secodn blue digit. That was only experiment to try reverse engineering somthing and learn how it work.
      Did you try load sketch?

      Delete
    2. Greetings Elvis
      1) My VFD is exactly the same as yours, but I need to know how to connect the VFD wires to PT6312 because the chip is out of the board.
      2) What does your code do? I would like to make a clock with the CD / DVD symbol circling!

      Delete
    3. For that you have to search data sheet. I don't have schematic.
      My code write zero to first blue digit.

      Delete