Problem setting time in DS3231 RTC for Nixie Clock

Hi all,

Bit of background.

I have designs a universal Nixie tube driver board based around a NANO and using a DS3231RTC, the initial idea was loosely based around the Arduinix idea arduinix.com. The circuit has been much improved and now incorporates a DS3231RTC.
I have a friend in Belgium who has help with the coding but we have now run into problems trying to set the correct date on the RTC, setting the time seems no issue but when trying to set the date the year and months can be setup using the i/p switches but when selecting the day set mode there is nothing being displayed on the nixie tube.

We had a earlier version of the code that took the time/date from the local PC, but at that point we had not implemented the setting option.

Now with the latest build we thought we had sorted out how to set the time/date/alarm, setting the time and alarm function work fine it's just the date in particular setting the day that is not working correctly.

I wonder if anybody out there has an idea as to why its not working. My friend is unfortunately unable to take a look at the code due to Uni work.

I have attached both codes;

sixtube35_alm (gets time/date from PC but only alarm time can be set)
sixtube40_alm (setting of time/date/alarm added, but with date setting issue)

If someone out there can help, it would be very much appreciated.

Regards

Robin

RLB Designs

my webpage

sixtube35_alm.zip (9.17 KB)

sixtube40_alm.zip (10.3 KB)

Hello,

I've looked in sixtube40, I can't see anywhere that you are setting the date or the time, only if the rtc wasn't running you set it to the date and time of the compiling. So you have to call "adjust" somewhere else no?

Hi,

we use 5 analog i/p to set the clock up,

A1 for mode selection i.e. time/date/alm
A0 for entering set mode (hold down for >3sec)
A2 increases the time/date/alm
A3 decreases the time/date/alm
A4 Alm on/off toggle

What happens is that when you push the 'mode' button it switches between displaying time/date/alm, so you select what you want to set from the 3 option, then you hold down the set button (A0) and you enter the set mode, the will flash the middle pair of displays and using A2/A3 you change the number, then you push the mode select the next pair. once you have set either time/date/alm correct you push and hold the set button >3 the exit.

So you can by using A1 select either time/date of alm and using A0 enter set mode to set the select option.

We are not saving the setting to the RTC but too the Nano, the issue seems only that you cant set the 'Day' of the date for some reason, it would be nice to again pick up the current date/time from the PC and the make fine adjustments using the onboard switches.

You can eventually set the day but only after pressing A2 or A3 several hundred times.

That's were we are currently, I have been selling the product on eBay and have persevered with the date setting issue, but now is a problem that needs resolving.

If you need any more info let me know.

Regards

Robin.

If you look at the link to my friends website this will explain more on how the whole thing hangs together and what it looks like.

Link to design page

Regards

Robin

Can anyone help please.. I would like to market this retro clock but need help sorting out the issue with setting the date.

Now very urgent as launching product for Xmas......

Can you be a bit more specific about what is going wrong? Also, have you tried printing your code out on continuous paper and seeing if it makes sense?

I found this:

 if(ModeInput==0)  ModeButtonPressed = true;
  
  if (Mode==1 && ModeButtonPressed==true && ModeInput==1)
  {
    Mode = 2;    //Switching from Time to Date mode
    ModeButtonPressed = false;
    SETMODE=false;
  }

The second if statement doesn't make sense after the first, as the first sets ModeButtonPressed to be true only if ModeInput is 0. So the second statement can be read as:

If Mode = 1 AND ModeInput is both 0 AND 1 at the same time.....

Which may be why you can't set the date. I have not read much more of the code because you are not clear about exactly what the problem is.

Hi,

There is no issue in the MODE selection, as I can set the time/Alarm with no problem. I can also set the Year / Month it's just to setting of the Day portion of the date that is the issue.

In the previous incarnation of the code (which I have uploaded), we took the time/date from the PC at time of compillilng, but had not implemented how to adjust the time/date only the setting of the Alarm time.

In the Ver4 code my friend Chris then tried to introduce the setting of the time/date. The Mode switch would cycle through Time/Date/Alarm on each button press, once you have decided which one of the three modes you wanted to set, you held down the Set button for more than 5secs thus entering the set mode, a pair of digits would flash and by pushing either of the + or - buttons increase or decrease the number, pushing the set button quickly would then select the next pair to set, once you have set it to the correct number, you could either exit the set mode or press the mode button to select another option to set. Pushing the set button for more than 5sec exited the set mode. You would do this for Time/Date/Alarm.

So the current issue is only with being able to set the DAY part of the DATE, either the number displayed is very high and takes 10-20mins to set correctly or it is blank.

What I have found is by changing line 403 (int Day = days;)

Original Code
// DATE CALCULATION /////////////////////////////////

/////////////////////////////////////////////////////

int Day = days;
int Month = ClockMonthSet;
int Year = abs(ClockYearSet%100);
//Defining years incrementation.
if(Month>=13){
Year++;
Month=Month-12;
}

To this;
Modified code

// DATE CALCULATION /////////////////////////////////

/////////////////////////////////////////////////////

int Day = ClockDaySet;
int Month = ClockMonthSet;
int Year = abs(ClockYearSet%100);
//Defining years incrementation.
if(Month>=13){
Year++;
Month=Month-12;
}

Seems to work and I can set the date correctly, but with a new problem the date does not roll over at 00.00.00 to the next day.

If I then re-upload the unmodified code again I can set the date and the date rolls over at midnight, so this is only a temporary fix.

What i would like is to be able to get the time from the PC again, and still be able to fine tune it using the switches, bare in mind the PCB's have already been produced so I'm stuck with this design.

Regards

Robin

Well, as it is not working as you would like, put serial.begin(9600); in your setup and then you can out put some serial debug messages to tell you where you are in bits of code.

That way you can check where the problem is.

This might be an option also.

http://www.crossroadsfencing.com/BobuinoRev17/

rlb-designs:
...
sixtube40_alm (setting of time/date/alarm added, but with date setting issue)
...

I've just briefly experimented with the DS3231, and I also had difficulty with adjusting the set time. I had much better luck using this library:

fwiw i took delivery of the same rtc module yesterday and had fun n games with libs that woudnt compile till i found this oneds3231 lib

the example to set n display time worked out of the box, i modded it a bit to add 0 in front of single digit month date and time values when displaying and shifting to proper date format dd mm yyyy :wink:

edit whoops same as pantaz.. :wink:

Putting on your circuit, the anode 4 Why is the lamp?