Function not being called after code has been running for few days

Good evening all,

I’m having tremendous problems finding the error in a current project.
The project is a public clock that plays music, rotates a large motor and triggers a light show every hour on the hour. The entire project is currently in operation, just no hour bong.

The error I am having is the chiming of the number of the hour (IE four “bongs” for 4 pm) stops after a few days of the code running.
I have a duplicate of the arduino and shield here with me, but I can not replicate the error that is happening on site.
The entire program is triggered by a third party commercial outdoor clock, IE, it receives a button push and sets the whole program in motion. No variables, or data is passed at all.

I recently checked the operation on site. When I tested the system with an attached hard button, it did not chime the hour. But, as soon as I attached my laptop and opened a serial monitor, the board reset and bonged the hour. After a few hours on site of testing, the bonging stopped. Again as soon as I connected a laptop, the bonging resumed.

I have the active code attached below.

When it is malfunctioning and not bonging the hour, it will still run the seasonal programs, the code breaks and the “chime()” or “signal()” function, but continues to the “motor off” command.

I am stumped. If it isn’t the code, or some memory sloughing issue, I’ll need to tear into possible electronic malfunction, I fail to see how a single trigger input would solicit two different results from the same code.

'Tany rate. If anyone can see anything, I will be unendingly grateful.

Many many thanks in Advance.

FYI, all outputs have physical 10kOhm pullup resistors and .1 uF capacitors wired.

CLOCK_REV23_ACTIVE.ino (9.84 KB)

Ah, it seems that I have heard tell of this clock ... :D

How exactly is the HN-50 output wired to the Arduino and what are its characteristics? Is it a relay? You say all outputs have 10K pullups and 0.1µF caps, but is this also true of inputs? If it is a relay, it will need to be debounced like any other switch.

I'm unclear on the part about

the code breaks and the "chime()" or "signal()" function

I would try putting in print statements at the top of each function and maybe also at other critical points so it's clear where control is being passed to. Or maybe you have a clear view of this already.

Hello Again!

Oops, I meant “the code breaks AT the…”

the code breaks and the “chime()” or “signal()” function

The HN-50 is a relay. It has a 10kOhm resistor as well, but no cap.
I initially thought of debouncing, and have that in a revised version of the code, but this is the active code in the clock, so I figured I’d include this.

I have a few of the print line statements in there. That’s how I can see it is still calling the “chime()” function here on my desk. It repeatedly prints “Chime” each time the function plays a chime. I’m putting a bunch more in right now.

I’ve also added the MemoryFree library and testing code from the forum, and memory usage doesn’t change at all over time. I have it staying at a static 1277.

FWIW, your timezone library is rock solid!

I downloaded the HN-50 manual, the connection is to the "CH1" terminals? And they are connected to just ground the MCU pin? I also gather that some programming in the HN-50 is needed. I assume there is no reason to question that it is operating correctly.

Normally I'd say definitely debounce a relay input, but given the nature of the code and the relatively long delays, I assume it's effectively self-debouncing.

So in the season function, spring() or summer() now I guess, you would see the prints for "Motor On", "Audio On", and "Lights On" but then it was as if signal() was never called?

SturdySound: FWIW, your timezone library is rock solid!

Thanks, good to hear!

Exactly. The CH1 on the HN-50 is a low voltage relay closure that s programmed to close for 1 sec each hour on the hour. That functions as the trigger for the program.

The Summer() function is the currently active one, and the code will run all parts except the chime() or signal() functions (depending on the time of day). But it still runs the motor off commands.

The most confusing part is, I can't duplicate the error here. It all works fine. Granted, I have the laptop connected all the time thus far. Perhaps tomorrow, I'll do a full electrical mock up and see if I can make it stop working properly.

I've never wanted an error so much!

It doesn't always happen at noon, does it?

This code will set hr_12 to zero at noon:

  if (hr_24 == 0) hr_12 = 12;
  else hr_12 = hr_24 % 12;

This would be better:

  hr_12 = hr_24 % 12;
  if (hr_12 == 0 ) hr_12 = 12;

It sounds like the rest of your program keeps working - the only problem is the chime. If that is the case I would suspect a code problem rather than a hardware problem.

From looking at your code one possible reason for the chime stopping is because it thinks it is night-time when the chime is suppressed. Perhaps it gets its am/pm mixed up? There are an awful lot of long delay()s in the code. Is it possible there is a cumulative missing of something?

…R