Designing Your Own VFD Clock II: The Functional Circuit
While our last focus was on the IV-11 VFD tube - since we had to design a circuit that make the tubes glow and display the stuff we want it to, now the microcontroller is in the spotlight for adding fundamental features, such as a real time clock to the circuit.
The second part of the article is meant to be read in a flow since every step would require its own testing code.
At the end however, you can put it all together on breadboard or any real PCB.
And we're ready to upload the latest OpenVFD firmware to our completed circuit and enjoy how far we've come!
STEP 1: MEET THE MICROCONTROLLER
OpenVFD could've been powered by this hipster microcontroller on the left picture. What you see is an old school Intel® MCS-51 (8051)microcontroller in a nobel golden ceramic DIP package.
The choice fell on the Atmel® ATmega328P though, because Arduino® Uno shares exactly the same powerful processor. We begin by designing a fundamental circuit that makes developing on OpenVFD feel like working with the regular Uno environment. Just like reverse-engineering you first analyze the Uno schematics and take it apart. Then it's time to remove all the stuff that's not necessary for basic functionality and put it back together again with its essentials. Let's go!
Do you know what we will need for basic functionality?
We need a supply voltage of 5V. This is done by connecting the VCC pin to 5V and GND pins to ground. Also, AVCC gets the same 5V connection
Like every processor, we need a clock frequency. While the AVR® has a built in, internal oscillator, we - just like the Uno - use an external one for maximum performance. The corresponding circuit is connected to pin 9 and 10 of the processor
Everything can be solved by a reboot. Right? Exactly, so we could also use some emergency circuitry which helps to reset the µC. That's everything connected to pin 1. Don't mind that capacitor to DTR (C10). We'll talk about that later.
STEP 2: COMPLETING THE UNO
We complete the Uno compatible circuit by adding the status LEDs on serial transfer pins RxD, TxD and pin 13. One more LED indicates, that our circuit is powered on.
Like the original Uno, the serial LEDs RxD and TxD turn on when the pin is LOW. Conversely, pin 13 will turn on when the output is 5V.
Thinking about makes developing on the Arduino® platform super convenient I found and believe it's the simplicity of uploading code to the microcontroller using just a USB cable! Developing on OpenVFD should be as intuitive it is on an Arduino® Uno.
So we found the Chinese WCH CH340G as a reliable and easy to use communicator between the computer and OpenVFD. DTR will make OpenVFD reboot automatically when being connected to a computer.
STEP 3: THE REAL TIME CLOCK - DS1307 VS DS3231
What else do we need for the VFD clock? Oh right... it's the clock. So finally we're adding a circuit that provides clock functionality. Our so called RTC (real time clock) is backed up with a battery so that the clock can tick on even if OpenVFD is turned off itself. That makes sense, right? Since we wouldn't want to set the time everytime we power on. We choose between a DS1307 and a DS3231 module:
The DS1307 is an affordable RTC solution, simple to control but with trade-off in accuracy depending on the crystal used - which is in general pretty inaccurate due to temperature change. I had situations where the DS1307 was a minute or more off after a day. That wouldn't work in a commercial product at all
Luckily, the DS1307 module can easily be drop-in replaced by a DS3231 module. The DS3231 is a RTC with a TCXO (temperature compensated crystal oscillator) ensuring jaw-dropping accuracy of less than a minute error per year
After all it depends on your expectation of accuracy, which module you want to use for your VFD clock. Both are tested to be both pin and source code compatible to the OpenVFD schematics and firmware (software).
STEP 4: LIGHT UP THE CLOCK
Now let's add the most memorable characteristic of the OpenVFD clock: The LEDs that light up the tubes to create the effects and moods that we all love. It begins by finding the right RGB LED that is reliable and bright. Why RGB? Here's how beautiful colors work: We combine the three colors of RGB (red, green and blue) to get new colors. So for instance purple is just blue and red mixed together.
Meet the WS2812B digital LED. This LED acts like a shift register and is controlled by shuttling data through one single data pin.
What makes the WS2812B really lovely is that the exact same LED is found in NeoPixel by Adafruit®. Even though the OpenVFD firmware does not rely on any Adafruit® libraries, Adafruit® still provide brilliant documentation on this LED that help when working with them. Take a look at the connection diagram. OpenVFD chained up six WS2812Bs to light up the six tubes individually.
STEP 5: EVERYTHING ELSE
For the time OpenVFD is not connected to a PC, four push buttons are used to set time, play with colors and do much more. The firmware OpenVFD makes them reacting to short and long presses.
A microphone module (MAX9812) makes your VFD clock dance to the tunes you enjoy. It measures sound as variations in air pressure and sends corresponding electric signals that are then evaluated by the microcontroller. Temperature measurement is done by a LM35 sensor that converts temperature into voltage levels. Our microcontroller translates this back to a temperature value that we all understand.
STEP 7: PUTTING IT ALL TOGETHER
And we're done with the complete VFD clock circuit design. You can download the complete prototyping circuit diagram on the right. If you got it on breadboard or prototype board by now, we're totally ready to upload the OpenVFD firmware to your microcontroller.
Prototyping Circuit Diagram
File Format: PNG Graphic, 223 KB
Here's the OpenVFD Firmware in its latest version. When compiling on your own, make sure the libraries RTClib, Wire and digitalWriteFast are ready. These are the only dependencies of OpenVFD. In the present circuit configuration, you can also upload the firmware using myOpenVFD (the PC tool that can control OpenVFD). The only requirement is the Arduino® Uno bootloader installed on the AVR microcontroller. Otherwise, use the Firmware .HEX file to upload the latest firmware to the AVR® microcontroller directly using SPI or HV programming.
Latest OpenVFD: 6-Digit IV-11 VFD Clock Firmware C/C++ Code: