Hi guys!
For the last couple of months I have been working on a clock made of four Russian IV-6 tubes, an Arduino Nano and a readily available Neo6m GPS module.
The concept is fairly simple: the GPS module receives an NMEA sentence, the Nano distills the time from the NMEA sentence, converts it in 4 separate digits, outputs it to a decoder (CD4511) which is then multiplexed to a set of VFD tubes. Each of the tubes is turned on or off by it's grid.
I have had a crude concept running for some time now, but so far I have only been able to get one digit working properly. With just a hand full of knowledge on coding and a lot of reading, working out the code led me to insanity. That is why I am reaching out to the community for some guidance.
What I have been trying to achieve with my code is that I would like the multiplexing to go on and on until the Nano receives a 'new' time from the GPS moldule and updates the time that is being outputted to the decoder (and the VFD tubes). The code as it is compiles, but behaves rather erratically when uploaded. The code is the best I have s far. It is a mix of parts of code that have worked in the past.
My question is if I am in the right direction with what I have written so far and if you would have suggestions for me on how to modify my code in order to get it working accordingly.
/*********************
3 naar GPS Module TX VOORHEEN 3, NU 0
2 naar GPS Module RX VOORHEEN 2, NU 1
4511 constructor:
cijfer 1 t/m 4 (7,8,11,12) is A, B, C en D
cijfer 5 (1) is de hoeveelheid IC's die je gebruikt
cijfer 6 (9,10) is latch pins maar die gebruiken we niet
MICREL (2981) driver
Digit 1 = pin D5 (T1)
Digit 2 = pin D4 (T2)
Digit 3 = pin D3 (T3)
Digit 4 = pin D2 (T4)
*********************/
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <SegmentDisplay_CD4511B.h>
#include <TimeLib.h>
// Choose two Arduino pins to use for software //serial
int RXPin = 1;
int TXPin = 0;
int GPSBaud = 9600;
int T1 = 5;
int T2 = 4;
int T3 = 3;
int T4 = 2;
// Create a TinyGPS++ object
TinyGPSPlus gps;
// Create a software serial port called "gpsserial"
SoftwareSerial gpsserial(RXPin, TXPin);
SegmentDisplay_CD4511B displayDriver(7, 8, 11, 12, 1);
//-----------------------------------------------
byte last_minute, Minute, Hour;
void setup() {
// Start the software serial port at the GPS's default baud
gpsserial.begin(GPSBaud);
// MICREL 2981 grid driver als output
pinMode(T1, OUTPUT);
pinMode(T2, OUTPUT);
pinMode(T3, OUTPUT);
pinMode(T4, OUTPUT);
}
void loop() {
while (gpsserial.available() > 0)
if (gps.encode(gpsserial.read()))
{
// get time from GPS module
if (gps.time.isValid())
{
Minute = gps.time.minute();
Hour = gps.time.hour();
}
if (last_minute != gps.time.minute()) // if time has changed
{
last_minute = gps.time.minute();
int uurTientallen = ((Hour + 1) / 10 % 10);
int uurEenheden = ((Hour + 1) % 10);
int minuutTientallen = (Minute / 10 % 10);
int minuutEenheden = (Minute % 10);
digitalWrite(T1, HIGH);
displayDriver.showNumber(uurTientallen);
digitalWrite(T1, LOW);
digitalWrite(T2, HIGH);
displayDriver.showNumber(uurEenheden);
digitalWrite(T2, LOW);
digitalWrite(T3, HIGH);
displayDriver.showNumber(minuutTientallen);
digitalWrite(T3, LOW);
digitalWrite(T4, HIGH);
displayDriver.showNumber(minuutEenheden);
digitalWrite(T4, LOW);
}
}
}
Desired cycle:
My schematic:
Finished clock. You've got to love the tubes!
And yes, for those wondering: I am running the filaments on 1v alternating current.