Skip to content

programming

testing the tubes

First I start with a program code for testing the tube in generally.
Because of easier routing the traces on the pcb, all logic tables from the 74HC595 and the K155iD1 was obsolete.
The biggest challenge was, to find the right HIGH/LOW combination to turn on the correct number.

Here is a code snippet from the header

#include <ShiftRegister74HC595.h>

const int numberOfShiftRegisters = 3; // number of shift registers attached in series
int serialDataPin = 2; // DS
int clockPin = 4;      // SHCP
int latchPin = 3;      // STCP

ShiftRegister74HC595<numberOfShiftRegisters> sr(serialDataPin, clockPin, latchPin);

int dot1 = 5;
int dot2 = 6;
int dot3 = 7;
int dot4 = 8;


int wait = 150;

and the loop

    // Turn on all Dots
  digitalWrite(dot1, HIGH);
  digitalWrite(dot2, HIGH);
  digitalWrite(dot3, HIGH);
  digitalWrite(dot4, HIGH);

delay(wait*2);

    // Turn off all Dots
  digitalWrite(dot1, LOW);
  digitalWrite(dot2, LOW);
  digitalWrite(dot3, LOW);
  digitalWrite(dot4, LOW);

delay(wait);

// HOUER LEFT

    //case 1:
  sr.set(3, HIGH);
  sr.set(2, HIGH); 
  sr.set(1, LOW); 
  sr.set(0, LOW); 

delay(wait);

    //case 2:
  sr.set(3, LOW);
  sr.set(2, LOW); 
  sr.set(1, HIGH); 
  sr.set(0, LOW); 

delay(wait);

It tooks it’s time, but in the end, everything works flawless.

HERE is the complete sketch available for download.

building the clock sketch

The code for the complete clock is partially based on Cledfo11 instructable of the Arduino Nixie Clock for Absolute Beginners.
But I did lots of changes in the code:
- removed the button things and also the ‘antipoison’ feature
- the way I use the shift register is different
- my pin mapping is complete different
- I used another DS1307 library which is available in arduino IDEs Library Manager - because of the other library the code for RTC module is different
- I’ve implemented a debug output for the RTC Clock and the Tubes
- added the dot animation

I’ve describe how to add the DS1307 library HERE

So here is snippet from the beginning of my loop routine

void loop() {

// removed Cathode prevention and buttonstate stuff

  tmElements_t tm;   // different RTC implementation because of other DS1307 library

  if (RTC.read(tm)) {

      // added optional debug output and adapted it to the now used DS1307 library
  if (debug == 1) {
    Serial.print("RTC Time: ");
    Serial.print(tmYearToCalendar(tm.Year));
    Serial.print('/');
    Serial.print(tm.Month);
    Serial.print('/');
    Serial.print(tm.Day);
    Serial.print(" (");
    Serial.print(tm.Hour);
    Serial.print(":");
    Serial.print(tm.Minute);
    Serial.print(":");
    Serial.print(tm.Second);
    Serial.print(")");
    Serial.print(" | ");
  }

and another example from my dot animation

// added dot animation

    if (dotcount == 1){
      digitalWrite(dot1,LOW);
      digitalWrite(dot2,LOW);
      digitalWrite(dot3,LOW);
      digitalWrite(dot4,LOW);

    } else if (dotcount == 2){
      digitalWrite(dot1,HIGH);
      digitalWrite(dot2,LOW);
      digitalWrite(dot3,LOW);
      digitalWrite(dot4,LOW);

    } else if (dotcount == 3){
      digitalWrite(dot1,LOW);
      digitalWrite(dot2,HIGH);
      digitalWrite(dot3,LOW);
      digitalWrite(dot4,LOW);

    } else if (dotcount == 4){
      digitalWrite(dot1,LOW);
      digitalWrite(dot2,LOW);
      digitalWrite(dot3,HIGH);
      digitalWrite(dot4,LOW);

    } else if (dotcount == 5){
      digitalWrite(dot1,LOW);
      digitalWrite(dot2,LOW);
      digitalWrite(dot3,LOW);
      digitalWrite(dot4,HIGH);

    } else if (dotcount == 6){
      digitalWrite(dot1,HIGH);
      digitalWrite(dot2,HIGH);
      digitalWrite(dot3,HIGH);
      digitalWrite(dot4,HIGH);
     dotcount = 0;
   }
    dotcount++;

With my debug output, I can compare the RTC time and the numbers which should be displayed

RTC Time: 2021/6/9 (20:25:38) | NIXIE: HL:2 HR:0 ML:2 MR:5 SL:3 SR:8 
RTC Time: 2021/6/9 (20:25:39) | NIXIE: HL:2 HR:0 ML:2 MR:5 SL:3 SR:9 
RTC Time: 2021/6/9 (20:25:40) | NIXIE: HL:2 HR:0 ML:2 MR:5 SL:4 SR:0 
RTC Time: 2021/6/9 (20:25:41) | NIXIE: HL:2 HR:0 ML:2 MR:5 SL:4 SR:1 
RTC Time: 2021/6/9 (20:25:42) | NIXIE: HL:2 HR:0 ML:2 MR:5 SL:4 SR:2 
RTC Time: 2021/6/9 (20:25:43) | NIXIE: HL:2 HR:0 ML:2 MR:5 SL:4 SR:3 
RTC Time: 2021/6/9 (20:25:44) | NIXIE: HL:2 HR:0 ML:2 MR:5 SL:4 SR:4 
RTC Time: 2021/6/9 (20:25:45) | NIXIE: HL:2 HR:0 ML:2 MR:5 SL:4 SR:5 

The complete code is available HERE