Nixie tube display from RTC

Hi,
I am have a bit of a problem with getting my Nixie Tubes to display the time from my rtc.
I know my RTC code works,because I am re purposing this piece of code from my working LCD display.

The problem I am having is trying to get the RTC to be displayed on the Nixie tubes. I know that you will have to display each number individually on the nixie tubes. I know that you can do this with using the %10, but when I do that I still can not get it to work.

If anyone could help me out I would so much appreciate it.

Thank you

CODE****************
is attached

2020-03-17_Nixie_Clock_version_3.ino (12.5 KB)

If you post your code as described in the how to use this forum sticky more members will be able to see it. A schematic of your wiring would likely be helpful, too.

From the coding, it appears to be a 6 digit nixie tube display which you are driving directly with 6 chips similar to KM155ID1 BCD to decimal converters, and from the number of pins it appears you are using an Arduino Mega.

Your code is too long for inline inclusion in a post, but, as mentioned, a schematic would be good.

Does anything work? For example, if you put this at the end of setup() :

writenumber( 2 , 9 ) ;

do you see a '9' displayed on tube 3 (assuming the first tube is numbered 0) ?

If so, you might try this in the loop:

writenumber( 0 ,   Hours / 10   ) ;
writenumber( 1 ,   Hours % 10  ) ;
// etc

To run my Nixie tubes I am using the K155ID1 data chip, along with the DS1307 RTC that is controlled by a Arduino Mega.

I can run a test code that will cycle through 1-9 and my nixie tubes will display all of the correct numbers.

#include <Wire.h>

#define RTC 0x68                                
#define Hours 0x23                              
#define Minutes 0x59                            
#define Seconds 0x45                           
#define Day 0x5                                 
#define Date 0x31                               
#define Month 0x12                             
#define Year 0x99

//hours
#define A1 23
#define B1 25
#define C1 27
#define D1 29

//hours
#define A2 31
#define B2 33
#define C2 35
#define D2 37

//minutes second part
#define A3 39
#define B3 41
#define C3 43
#define D3 45

//minute first part
#define A4 22
#define B4 24
#define C4 26
#define D4 28

//seconds
#define A5 30
#define B5 32
#define C5 34
#define D5 36

//seconds
#define A6 38
#define B6 40
#define C6 42
#define D6 44

char *LINE2Day[8] = {"       Not A Day", "Sunday  ", "Monday ", "Tuesday ", "Wednesday", "Thursday", "Friday  ", "Saturday"};
int ClockArray[8];
int OldClockArray[8];

char A[6] = {A1, A2, A3, A4, A5, A6};
char B[6] = {B1, B2, B3, B4, B5, B6};
char C[6] = {C1, C2, C3, C4, C5, C6};
char D[6] = {D1, D2, D3, D4, D5, D6};

//Golbal
byte iHours = 0;                              
byte iMinutes = 0;                             
byte iSeconds = 0;                            
byte iDay = 0;                                 
byte iDate = 0;                                
byte iMonth = 0;                               
byte iYear = 0;                                

byte zero = 0;
byte one = 0;
byte two = 0;
byte three = 0;
byte four = 0;
byte five = 0;

void setup()
{
  pinMode(A1, OUTPUT);
  pinMode(B1, OUTPUT);
  pinMode(C1, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(B2, OUTPUT);
  pinMode(C2, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(A3, OUTPUT);
  pinMode(B3, OUTPUT);
  pinMode(C3, OUTPUT);
  pinMode(D3, OUTPUT);
  pinMode(A4, OUTPUT);
  pinMode(B4, OUTPUT);
  pinMode(C4, OUTPUT);
  pinMode(D4, OUTPUT);
  pinMode(A5, OUTPUT);
  pinMode(B5, OUTPUT);
  pinMode(C5, OUTPUT);
  pinMode(D5, OUTPUT);
  pinMode(A6, OUTPUT);
  pinMode(B6, OUTPUT);
  pinMode(C6, OUTPUT);
  pinMode(D6, OUTPUT);


  for (char i = 0; i < 6; i++) {
    digitalWrite(A[i], HIGH);
    digitalWrite(B[i], HIGH);
    digitalWrite(C[i], HIGH);
    digitalWrite(D[i], HIGH);
  }
  //  if (!RTC.isRunning())
  //    RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);



  //I2C setup
  Wire.begin();    

void writenumber(int a, int b)
{
  switch (b) {
    case 0:
      digitalWrite(A[a], LOW);
      digitalWrite(B[a], LOW);
      digitalWrite(C[a], LOW);
      digitalWrite(D[a], LOW);
      break;
    case 9:
      digitalWrite(A[a], HIGH);
      digitalWrite(B[a], LOW);
      digitalWrite(C[a], LOW);
      digitalWrite(D[a], LOW);
      break;
    case 8:
      digitalWrite(A[a], LOW);
      digitalWrite(B[a], HIGH);
      digitalWrite(C[a], LOW);
      digitalWrite(D[a], LOW);
      break;
    case 7:
      digitalWrite(A[a], HIGH);
      digitalWrite(B[a], HIGH);
      digitalWrite(C[a], LOW);
      digitalWrite(D[a], LOW);
      break;
    case 6:
      digitalWrite(A[a], LOW);
      digitalWrite(B[a], LOW);
      digitalWrite(C[a], HIGH);
      digitalWrite(D[a], LOW);
      break;
    case 5:
      digitalWrite(A[a], HIGH);
      digitalWrite(B[a], LOW);
      digitalWrite(C[a], HIGH);
      digitalWrite(D[a], LOW);
      break;
    case 4:
      digitalWrite(A[a], LOW);
      digitalWrite(B[a], HIGH);
      digitalWrite(C[a], HIGH);
      digitalWrite(D[a], LOW);
      break;
    case 3:
      digitalWrite(A[a], HIGH);
      digitalWrite(B[a], HIGH);
      digitalWrite(C[a], HIGH);
      digitalWrite(D[a], LOW);
      break;
    case 2:
      digitalWrite(A[a], LOW);
      digitalWrite(B[a], LOW);
      digitalWrite(C[a], LOW);
      digitalWrite(D[a], HIGH);
      break;
    case 1:
      digitalWrite(A[a], HIGH);
      digitalWrite(B[a], LOW);
      digitalWrite(C[a], LOW);
      digitalWrite(D[a], HIGH);
      break;
  }
}

  void off(int a) {
  digitalWrite(A[a], HIGH);
  digitalWrite(B[a], HIGH);
  digitalWrite(C[a], HIGH);
  digitalWrite(D[a], HIGH);
}
  // LCD Software Initialization
  _lcdinit();                           // Call _lcdinit() function (User difine function)


void RTC_int()
{
  Wire.beginTransmission(RTC);          //opens commucation with RTC
  Wire.write(0x00);                     //Set RTC address to be accessed can only set one byte at a time
  Wire.write(Seconds);
  Wire.write(Minutes);
  Wire.write(Hours);
  Wire.write(Day);
  Wire.write(Date);
  Wire.write(Month);
  Wire.write(Year);
  //DS1307 output frequency for 8.192 Khz
  Wire.write(0x12);

  Wire.endTransmission();
}

void _lcdinit()
{
  for (int i = 0; i < 10; i++) {
    for (int m = 0; m < 6; m++) {
      writenumber(m, i);
    }
    delay(500);
  }
}

void RTC_read()
{
  OldClockArray[0] = iMonth;               // Old Array postion for the sotred value for the Month
  OldClockArray[1] = iDate;                // Old Array postion for the sotred value for the Date
  OldClockArray[2] = iYear;                // Old Array postion for the sotred value for the Year
  OldClockArray[3] = iHours;               // Old Array postion for the sotred value for the hour
  OldClockArray[4] = iMinutes;             // Old Array postion for the sotred value for the Minute
  OldClockArray[5] = iSeconds;             // Old Array postion for the sotred value for the Second
  OldClockArray[6] = iDay;                 // Old Array postion for the sotred value for the Day

  Wire.beginTransmission(RTC);             //opens commucation with RTC
  Wire.write(0x00);                        // this tells the program where to start reading from
  Wire.endTransmission();                  // Close I2C commucation with RTC

  // need to request the other bite from the RTCby requestion 3 bytes(you can add more if needed)
  Wire.requestFrom(RTC, 7);                // You want it to read everything except the square wave

  iSeconds = Wire.read() & 0x7f;           //Store Seconds
  iMinutes = Wire.read() & 0x7f;           //Store minutes
  iHours = Wire.read() & 0x3f;             //Store Hours
  iDay = Wire.read() & 0x07;               //Store days
  iDate = Wire.read() & 0x3f;              //Store date
  iMonth = Wire.read() & 0x1f;             //Store Month
  iYear = Wire.read() & 0xff;              //Store year

  ClockArray[0] = iMonth;                  // Array postion for the sotred value for the Month
  ClockArray[1] = iDate;                   // Array postion for the sotred value for the Date
  ClockArray[2] = iYear;                   // Array postion for the sotred value for the Year
  ClockArray[3] = iHours;                  // Array postion for the sotred value for the hour
  ClockArray[4] = iMinutes;                // Array postion for the sotred value for the Minute
  ClockArray[5] = iSeconds;                // Array postion for the sotred value for the Second
  ClockArray[6] = iDay;                    // Array postion for the sotred value for the Day
}

void Console_Read()
{
  if  ((ClockArray[5] & 0x0F) == 0x00)
  {
    if (ClockArray[5] != OldClockArray[5])
    {
      for (int i = 0; i < 6; i++)
      {
        if (ClockArray[i] < 10)
        {
          Serial.print('0');    // padding for the 0
        }
        Serial.print(ClockArray[i]);
      }
      Serial.print('\n');
    }
  }
}
void loop()
{
  /**************************************** The main run loop **********************************
      Notes:
    runs through a data packet that containing the configuration setting reqired for the 8 programmed registers of
    the DS1307 RTC used in this programm. That will use the RTC to count the time.
   ******************************************************************************************/
  RTC_read();
  Console_Read();
  Nixie_Tube();


  //  zero = (iHours / 10) % 10;
  //  one = iHours % 10;
  //  two =  (iMinute / 10) % 10;
  //  three = iMinute % 10;
  //  four =  (iSeconds / 10) % 10;
  //  five = iSeconds % 10;

  //  Serial.println(zero);
  //  Serial.println(one);
  //  Serial.println(two);
  //  Serial.println(three);



  //delay(1000);

}

[code]

Nixie_ schematic.pdf (404 KB)