How do I use this library?

I have a library here and I have no idea on how to use it.

Here is the vfd_vaf1613.h file

#ifndef VFD_H
#define VFD_H

#include <Arduino.h>

#define POSITION_MIN 0
#define POSITION_MAX 15

#define BRIGHTNESS_MIN 0
#define BRIGHTNESS_MAX 31

#define VFD_DUTY_CYCLE 0xe0
#define VFD_POSITION 0xa0
#define VFD_QUESTION_MARK 0x3f

class VFD_VAF1613
{
    /* Lookup table from vaf1613-kv12cs datasheet */
    const uint8_t *LUT = (const uint8_t*) "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'<>*+,-./0123456789:;{=}?";

    uint8_t clock_pin;
    uint8_t data_pin;
    uint8_t reset_pin;

    private:
        uint8_t lookup(uint8_t);
        void init();
        void reset(uint8_t);
    public:
        VFD_VAF1613(uint8_t, uint8_t, uint8_t);
        void write(char *);
        void write_byte(uint8_t);
        void power_off();
        void power_on();
        void long_reset();
        void short_reset();
        void brightness(uint8_t);
        void position(uint8_t);
};

#endif

And here is the vfd_vaf1613.cpp file

#include "vfd_vaf1613.h"

VFD_VAF1613::VFD_VAF1613(uint8_t _clock_pin, uint8_t _data_pin, uint8_t _reset_pin)
{
    clock_pin = _clock_pin;
    data_pin  = _data_pin;
    reset_pin = _reset_pin;

    init();
}

void VFD_VAF1613::init()
{
    pinMode(clock_pin, OUTPUT);
    pinMode(data_pin, OUTPUT);
    pinMode(reset_pin, OUTPUT);

    power_off();
}

void VFD_VAF1613::power_off()
{
    // Holding reset low keeps the module in low power mode. (~19-22mA)
    digitalWrite(reset_pin, LOW);
}

void VFD_VAF1613::power_on()
{
    digitalWrite(reset_pin, HIGH);
    delay(10);
    brightness(BRIGHTNESS_MAX);
    position(POSITION_MIN);
}


void VFD_VAF1613::reset(uint8_t us)
{
    digitalWrite(reset_pin, LOW);
    digitalWrite(data_pin, LOW);
    delayMicroseconds(50);
    digitalWrite(reset_pin, HIGH);
    delayMicroseconds(50);
    digitalWrite(data_pin, HIGH);
}

void VFD_VAF1613::short_reset()
{
    reset(50);
}

void VFD_VAF1613::long_reset()
{
    reset(2000);
}

void VFD_VAF1613::write_byte(uint8_t byte)
{
    for(int8_t index = 7; index >= 0; index--)
    {
        digitalWrite(clock_pin, HIGH);
        digitalWrite(data_pin, (byte >> index) & 1);
        delayMicroseconds(2);
        digitalWrite(clock_pin, LOW); // Bit is read on falling edge.
        delayMicroseconds(2);
    }
    delayMicroseconds(50);
}

void VFD_VAF1613::brightness(uint8_t brightness)
{
    if(brightness > BRIGHTNESS_MAX)
        brightness = BRIGHTNESS_MAX;

    write_byte(VFD_DUTY_CYCLE + brightness);
}

void VFD_VAF1613::position(uint8_t position)
{
    if(position > POSITION_MAX)
        position = POSITION_MAX;

    /*
    * Deal with an unusual off by one configuration that the display
    * addressing seems to use, where 0xaf is the leftmost character,
    * 0xa0 is the second from left, 0xa1 the third from left, etc.
    *
    * For the full 16 position display, the positions and indices are:
    * [F0123456789ABCDE]
    *
    * I have no idea why, but this is how this particular display seems
    * to work.
    */
    position = (position + 15) % 16;

    write_byte(VFD_POSITION + position);
}

void VFD_VAF1613::write(char *message)
{
    for(uint8_t i = 0; i < strlen(message); i++)
        write_byte(lookup(message[i]));
}

uint8_t VFD_VAF1613::lookup(uint8_t chr)
{
    // Get a pointer to where chr appears in LUT.
    uint8_t *chrptr = (uint8_t*) strchr((const char*) LUT, chr);

    if(chrptr == NULL)
        // Not found, return the value for a question mark.
        return VFD_QUESTION_MARK;
    else
        // Use pointer math to get the index of chr in LUT.
        return chrptr - LUT;
}

This didn’t come with any examples or usage instructions at all and I think this might work for my display. Just want to take a shot in the dark. I was looking for something that can run the display driver chip 10937p-50. Thank you in advanced

Please post a link to where you found the library. Please use the chain links icon on the toolbar to make the link clickable.

pert:
Please post a link to where you found the library. Please use the chain links icon on the toolbar to make the link clickable.

Here is the link

OK, that wasn’t very helpful. Sometimes there is some documentation hidden away in a non-obvious place in the repository but in this case there is none. So the source code is all the documentation you get, not even an example sketch to go with it. However, I’m more considerate than the library author so here’s an untested example sketch for you:

#include <vfd_vaf1613.h>

//adjust these according to your wiring:
const byte clockPin = 8;
const byte dataPin = 9;
const byte resetPin = 10;

VFD_VAF1613 vfd(clockPin, dataPin, resetPin);

void setup() {
  vfd.power_on();
  vfd.write("hello world");
}

void loop() {
}

pert:
OK, that wasn’t very helpful. Sometimes there is some documentation hidden away in a non-obvious place in the repository but in this case there is none. So the source code is all the documentation you get, not even an example sketch to go with it. However, I’m more considerate than the library author so here’s an untested example sketch for you:

#include <vfd_vaf1613.h>

//adjust these according to your wiring:
const byte clockPin = 8;
const byte dataPin = 9;
const byte resetPin = 10;

VFD_VAF1613 vfd(clockPin, dataPin, resetPin);

void setup() {
 vfd.power_on();
 vfd.write(“hello world”);
}

void loop() {
}

Success! Yes your code works, however I think there is something wrong with the library it self… I don’t know if you can help me with this or not or how off topic this is but here is what I’m trying to do.

I would like to use LCD Smartie to control this display I have. Here is some information on it:

It is 1x16 VFD “starburst display” that uses 16 segments plus period and tail for each character.
The driver chip on the module is a Micrel 10937p-50 / 10937p-40.
These displays are commonly used in Fruit Machines, amusement machines, and Jukeboxes.

I got mine from an old Rowe Jukebox and have quite a few others that use the same driver chip that I would like to get running. Once I can get one running I can get all the other ones working. I have attached the datasheet for the chip here at the bottom of my post if that will help.

So the problem with the current library is that the letters are all jumbled up for some reason. It lights up the display, which is a good thing, I think lol. No matter what I make the message as in your code it is still all jumbled up :frowning: If you need anymore information on this module please let me know. I am also willing to post some pictures of the device if that would help any.

datasheet.pdf (368 KB)

Is the jumble consistent for a given message? Please upload the following code and then post the resulting output on the display:

#include <vfd_vaf1613.h>

//adjust these according to your wiring:
const byte clockPin = 8;
const byte dataPin = 9;
const byte resetPin = 10;

VFD_VAF1613 vfd(clockPin, dataPin, resetPin);

void setup() {
  vfd.power_on();
  vfd.write("0123456789abcdef");
}

void loop() {
}

I did notice a problem with the library, though I don’t know if it’s the source of the issue you’re having. The library sets the pinMode()s from the constructor, which is a bad idea. The right way to do this is to only use the constructor to configure the pin numbers and then do any hardware initialization from a function called from setup(). The library actually does have such a function, init(), but it’s called from the constructor and is private so you can’t call it from the sketch with the current library code. The fix is simple, you just need to move this line in vfd_vaf1613.h:

void init();

from the private section to the public section, then you can add a call to vfd.init() to your setup():

#include <vfd_vaf1613.h>

//adjust these according to your wiring:
const byte clockPin = 8;
const byte dataPin = 9;
const byte resetPin = 10;

VFD_VAF1613 vfd(clockPin, dataPin, resetPin);

void setup() {
  vfd.init();
  vfd.power_on();
  vfd.write("0123456789abcdef");
}

void loop() {
}

Okay so I did the edit and uploaded and still getting the same results. No the message on the display is not consistent. For instance, if I hit the reset button on my Nano, the display changes to a different set of jumbled letters, symbols, and numbers... I also tried editing the .H file according to the datasheet, and same results if not error sometimes in the middle of the upload. Not sure if I'm doing something wrong or just the library is just that incompatible with this display... I'm still pretty new to this kind of thing. I did supply the datasheet on my last post as well for you to examine and see if this library is even going to work for this display or if we need to come up with something new... I will work with you through this as well because I love learning and am willing to learn all I can about these displays and Arduino because it is a very powerful platform.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

How are yu powering the display?

A picture would help too.

Tom... :slight_smile:

TomGeorge:
Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

How are yu powering the display?

A picture would help too.

Tom… :slight_smile:

The display runs on 8VDC. So it is simple, right now whilst I try to get this one working, I’m using my bench power supply unit as it’s power source. I have the circuit already made for it once we can figure out how to get it to run in LCD Smartie. The circuit is simple I’m using the 7808 voltage regulator with three diodes, and two capacitors. On the input I have a capacitor going across the Positive voltage coming into the regulator, which is 12VDC thru the diode and into the regulator plus a flyback on the input. Also a flyback diode on the output with another capacitor.

Hi,

Are the gnds all connected together, this is why I asked for a circuit, where is your Arduino, your power supplies and component values.

Have you got the supply gnd of the Arduino and the gnd of the display supply connected together?

Thanks.... Tom.. :slight_smile:

TomGeorge:
Hi,

Are the gnds all connected together, this is why I asked for a circuit, where is your Arduino, your power supplies and component values.

Have you got the supply gnd of the Arduino and the gnd of the display supply connected together?

Thanks… Tom… :slight_smile:

Yes the Grounds are hook together. Sorry I didn’t add that in the schematic. Also I added the values to the new schematic for you. Here it is posted at the bottom… However I did forget to common the grounds on the test rig here, and when I did (just now) the jumbled mess is now consistent with what ever i send to the display…

I’ve been messing around with the code a bit, here is what I came up with, it is now consistent because I made a common ground between the bench power supply, the Arduino Nano, and the display. Still jumbled though.

#include <vfd_vaf1613.h>

//adjust these according to your wiring:
const byte clockPin = 7;
const byte dataPin = 5;
const byte resetPin = 6;

VFD_VAF1613 vfd(clockPin, dataPin, resetPin);

void setup() 
{
  vfd.init();
  vfd.power_on();
  vfd.write("F0123456789ABCDE");
  delay(5000);
  vfd.short_reset();
  delay(500);
}

void loop() 
{
  vfd.power_on();
  vfd.write("1234567890ABCDEF");
  delay(1000);
}

Not sure if I helped the situation or not but there is the code. I changed the pin numbers because the project this is going into is already hard wired for those three pins.

I think the unnecessary complexity of the sketch printing two different strings to the display is not going to be helpful in troubleshooting. Start with trying to get one string to print correctly. Getting a consistent jumble is definitely progress.

Please post what the jumbled output on the display looks like.

I changed the code back to the original structure so I could take a picture.

#include <vfd_vaf1613.h>

//adjust these according to your wiring:
const byte clockPin = 7;
const byte dataPin = 5;
const byte resetPin = 6;

VFD_VAF1613 vfd(clockPin, dataPin, resetPin);

void setup() 
{
  vfd.init();
  vfd.power_on();
  vfd.write("F0123456789ABCDE");

}

void loop() 
{
}

Pic posted as attachment

The display was also oscillating so I added a power capacitor to the test rig and some 10nF caps from each of the three data pins to ground. I also added some 10k pullups from the data pins to 5vdc. Now it is solid. Also the display is “artifacting” for some reason. I know this display works because I tested it in one of my Jukeboxes at work and there is no artifacting or nothing on it. It is clear as day when in the original operating environment

@hydrolisk1792’s picture:
64e59a8fa80f8894b880f04d7d669a1ea1bc7807.jpg

That is what it is doing. It is static like that.

pert:
@hydrolisk1792’s picture:
64e59a8fa80f8894b880f04d7d669a1ea1bc7807.jpg

So what do you think could be the cause of this problem? I’m a bit lost at the moment on things to try. Maybe somehow create the character set from the data sheet from scratch? That would have to be changing all lower case letters to capitals for the display to read correctly and ignoring all special characters except the ones that the display can handle.

Hi,
What displays if you write ALL spaces, or all A's, or all B's.

Tom... :slight_smile:

TomGeorge:
Hi,
What displays if you write ALL spaces, or all A's, or all B's.

Tom... :slight_smile:

Mostly the same character but some mixed at the beginning.