I purchased a IV-18 VFD tube driver module, which came with some example code for an ESP32 board. The driver module has a 20 output MAX6921 serial chip to drive the vacuum tube. I want to use this driver module with an Arduino Uno and then eventually a Raspberry Pi.
I think I have a very rough understanding of the electronics and demo code, but cannot seem to get my SPI calls to work. Rather than trying to translate the demo code in its entirety, my first goal is to just get one segment to light up.
Quick background
The IV18 tube has 9 grids. The first grid has only a dot and a dash, but the remaining 8 grid have 7 segments and a decimal point.
To light a segment, you provide power to the segment pins / decimal point and to the grid for that segment. To display several numbers, you have to quickly cycle through lighting each of the grid positions and the relevant segments for that position. If you cycle through this fast enough, the human eye sees the whole grid with numbers (persistence of vision).
What I have tried
So far, I have made the connections from the Arduino Uno to the driver board
Driver GND - Uno GND
Driver 5V - Uno +5V
Driver Din - Uno digital pin 11 / MOSI
Driver CLK - Uno digital pin 13 / SCK
Driver LOAD - Uno digital pin 2
Driver BLANK - Uno digital pin 3
Driver Dout - Not connected
The example code has hex codes which I believe are then translated to a 24 bit buffer (although only 17 bits are required) to send via SPI to set the MAX6921 outputs HIGH or LOW.
I think the bits required are as follows:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
G7 | G6 | G5 | G4 | G3 | G2 | G1 | G0 | SEG_G | SEG_F | SEG_E | SEG_D | SEG_C | SEG_B | SEG_A | SIGN | DP |
So to light the number 8 in the righthand most grid, I assumed I'd need the 8th bit high (grid) and bits 9,10,11,12,13,14 and 15 for the 7 semens for the "8".
In my setup function, I call SPI.begin
and then SPI.transfer
with what I assumed was the matching binary data (from right to left, I think because of the bit order LSB/MSB?):
SPI.transfer(0b000000000111111110000000);
This lights the first grid (the one after the degree and minus sign) but not what I want - I see some segments in the leftmost grid (the full grid, not the grid with the dot and minus) but these light in a different pattern each time (varies each time I reset or re-upload which I think is to be expected as I'm pushing data to the MAX6921 each time).
This is my code so far
#include "SPI.h"
#define DISP_CLK 13 // White - SPI SCK
#define DISP_DATA 11 // Yellow - SPI MOSI
#define DISP_LOAD 2 // Blue
#define DISP_BLANK 3 // Green
void setup() {
Serial.begin(9600);
Serial.println("IV18 Test");
SPI.begin();
pinMode(DISP_BLANK, OUTPUT);
digitalWrite(DISP_BLANK, LOW);
pinMode(DISP_LOAD, OUTPUT);
digitalWrite(DISP_LOAD, HIGH);
SPI.transfer(0b000000000111111110000000);
}
void loop() {
}
I'm pretty sure the two fundamental things I have wrong here are the bits of data to send and then the correct use of the SPI.
Can someone please help me to understand the ESP32 code properly, and ideally help me get the correct data to send via SPI so that I can light up the segments & grid positions that I expect to.
SPI.transfer()
does only serve the clock and write/read MOSI/MISO. It does not bring the CS low to select the SPI slave.