Strange behaviour in two different part of the world (Nepal and Netherlands)

Thread Starter

supermankid

Joined May 26, 2013
54
Hello everyone,
I made a small hobby project few years ago and recently I have send one to my parents in Nepal.
I have a very very strange situation where the same circuits are behaving differently in two different continents (Netherlands and Nepal).
I have a simple circuit as shown in figure below.
Basically it is a clock that gets time from the RTC and displays on the 8 segment display.
Few things to note:
There are two buttons SW1 and SW2 that increase or decrease the time.
Now, lets talk about the issue.
I have this setup here in Netherlands for almost 2 years and the clock is running with accurate timing but the clock in Nepal seems to change itself intermittently which causes
the failure in time(sometimes there is delay and sometimes it is ahead by 10-15 minutes).

Few things I did.
1. Crystals??
My first suspect was the crystals I bought on e-bay.
To solve this, I re-formulated code to get the time from only from RTC. Internal clock did not have any influence on time. This improved my code but did not solve the issue.

2. Buttons circuit
As shown on the circuit, the buttons are normally open, when pressed shorts the pin to GND.
I do not have debounce proof hardware as shown on the figure, so I implemented it on software. This also did not solve the issue.

Additional info: Internal pullup is enabled.
I plan to add hardware debounce on future circuits.

3. Wooden frame.
The whole electronics is enclosed on the wooden frame.
Besides the display, all the electronics and wires are isolated using ESD plastics.
The buttons attached are also in the plastic housing, so isolated from the wood.
The isolation also did not solve the issue.

Conclusion and Problem:
I asked my father in Nepal to send the failing unit to Netherlands to investigate.
I have tested that failing unit for two weeks here without any issue.
I have 1 unit in Netherlands working without any issue and 2 more running for about 2 months also without any issue.

May be some experieced person can help me to understand / improvise the situation.
What could be the cause the time changes automatically sometimes in Nepal and not in the Netherlands. My main suspect is the grounding of the house which is triggering button (since the wooden frame where the clock is hung in wall and I remember in the past getting slight shock in house in Nepal). (But the ciruit is isolated from the wood, so should not have impact in my opinion).

Have nay experienced engineers/ enthusiasts have experienced similar situation?
Cold you please provide any recommendations?

Time Change analysis.png
 

Thread Starter

supermankid

Joined May 26, 2013
54
Supply voltage transients getting through the power supply??
Increase decoupling on supply input and output?
Hi Albert, thanks for the reply. You might be right because I remember few years ago when I was back home in Nepal, I measured the AC voltage and was below 200V (expected 230). What is the best way to simulate transients to reproduce the error. I am far away from Nepal to actually measure the transients there. In Netherlands I have not seen the issue, hence the AC input should be stable here. But I would like to reproduce the error by creating transients on input of AC/DC converter, then I can estimate input/output capcitors required. Any suggestions?
 

jpanhalt

Joined Jan 18, 2008
10,277
For short term transients, put a switched load on the same outlet and flip the switch a few times.

If you have a Variac (autotransformer), you could use that to test for low or high voltage effects over longer periods.
 

BobaMosfet

Joined Jul 1, 2009
1,209
@supermankid
Ahhh... nothing more frustrating than sending your electronic child out and having it do something unexpected. What RTC are you using? Does it have a way to tell if it thinks time is corrupted? If so, watch for that and that could be your first clue that it's likely power-related.

We need more details- what power-supply are you using, what RTC, how is your power-circuit schematic done to provide power to your ATMEGA328?

I'm nearing completion of my own clock around an ATMEGA32 with a PCF8563 RTC:
1583861143111.png
24-hour time shown, but it will in the end have 6 digits and be able to do 12/24-time as a user-adjustable setting.
 

Thread Starter

supermankid

Joined May 26, 2013
54
For short term transients, put a switched load on the same outlet and flip the switch a few times.

If you have a Variac (autotransformer), you could use that to test for low or high voltage effects over longer periods.
Nice tip. I will try it this weekend. However, my suspicion now is on the line transient than load transient.
 

Thread Starter

supermankid

Joined May 26, 2013
54
@supermankid
Ahhh... nothing more frustrating than sending your electronic child out and having it do something unexpected. What RTC are you using? Does it have a way to tell if it thinks time is corrupted? If so, watch for that and that could be your first clue that it's likely power-related.

We need more details- what power-supply are you using, what RTC, how is your power-circuit schematic done to provide power to your ATMEGA328?

I'm nearing completion of my own clock around an ATMEGA32 with a PCF8563 RTC:
View attachment 201150
24-hour time shown, but it will in the end have 6 digits and be able to do 12/24-time as a user-adjustable setting.
I was using ds3231 on the boards I see the problems. I sent two replacement PCB that worked here in Netherlands for almost two years and suddenly when they land in Nepal, they seem to go wrong (either delay or forward) withing few days...I have a simple linear regulator...I do not want to change input and output decouplings/(or make improvement on PSU circuit) before I reproduce the error here in the Netherlands though.

And by the way cool project that you are working on.
 

ebeowulf17

Joined Aug 12, 2014
3,274
If the issue is stray noise being picked up on the button inputs, you could try adding stronger, external pull-up resistors so that it would take a larger transient to cause a phantom button press. Adding a small cap (maybe 0.1uF) from input to ground seems like a good idea too (actually, probably more helpful than the added pull-up.)

You could test whether or not it's a button noise issue, and perhaps even fix said issue, with a code-only fix as follows. Instead of allowing each button press to edit the current time, create a time setting mode, which is harder to accidentally enter, and only accept time edits there. For example require the user to press and hold both buttons simultaneously for two full seconds, then enter time set mode. Require the same to exit. During normal operation, transient noise will never equal two-second-long presses, so transients won't enter time set mode.

I do think it's worth finding the actual root cause and addressing it, but locking out time edits might be a useful stopgap fix and/or diagnostic tool.
 

BobTPH

Joined Jun 5, 2013
2,546
Have you ruled out the possibility that a mischievous person is messing with it? Any ‘tween age children, aka poltergeists, around?

Bob
 

Thread Starter

supermankid

Joined May 26, 2013
54
If the issue is stray noise being picked up on the button inputs, you could try adding stronger, external pull-up resistors so that it would take a larger transient to cause a phantom button press. Adding a small cap (maybe 0.1uF) from input to ground seems like a good idea too (actually, probably more helpful than the added pull-up.)

You could test whether or not it's a button noise issue, and perhaps even fix said issue, with a code-only fix as follows. Instead of allowing each button press to edit the current time, create a time setting mode, which is harder to accidentally enter, and only accept time edits there. For example require the user to press and hold both buttons simultaneously for two full seconds, then enter time set mode. Require the same to exit. During normal operation, transient noise will never equal two-second-long presses, so transients won't enter time set mode.

I do think it's worth finding the actual root cause and addressing it, but locking out time edits might be a useful stopgap fix and/or diagnostic tool.
This sound promising....I will try and adapt and experiment with the code and then test in Nepal... Thanks a lot for your input...
 

Thread Starter

supermankid

Joined May 26, 2013
54
@supermankid
What altitude and temperature... are you using any parts that have altitude or temperature limitations? Any issues with solder joints?
The altitune is around 1500 meters. I have already received one PCB back from Nepal that was having issue and is working perfectly here in Netherlands. So, definitely no hardware issues...
 

Thread Starter

supermankid

Joined May 26, 2013
54
Is there a significant humidity difference between the two locations?
Generally I am not sure about this but when I looked at accuweather.
Humidity in Nepal => 25%
Netherlands => 77%

Netherlands has a lot of rainfall and is mostly humid through out the year...
I am not sure if this has any relation since it is less humid there...
 

Thread Starter

supermankid

Joined May 26, 2013
54
Have you ruled out the possibility that a mischievous person is messing with it? Any ‘tween age children, aka poltergeists, around?

Bob
In the beginning we had similar suspicion because I myself have damaged some electronics because of bad ESD practices. But I have sent one PCB and that was carefully handled and assembled...the same result....works here and not in Nepal....
I am thinking to make improvement on few things
1. Add hardware pullup (now I am using internal pullup on the chip)
2. POssibly improve the button by going to set time mode after long press or something like that (as suggested by some experts here)
3. I already have two input and output capacitor 10µF and 100 nF in parallel....May be I should add more decoupling on the linear regulator....
4. If none of this works....I WILL GO THERE AND HUNT DOWN THAT GHOST. :)
 

Willen

Joined Nov 13, 2015
294
Can the lower humidity in Nepal cause greater ESD problems?
Sure,
During winter (Fagun, Chait), humidity is extremely low and we get cracks in lips and skins. I get high volts ESD sparks while stripping clothes. I can glow a neon bulb by rubbing some plastic material. All of these are not possible during the summer (Asaar, Saaun).
 

BobTPH

Joined Jun 5, 2013
2,546
In the beginning we had similar suspicion because I myself have damaged some electronics because of bad ESD practices. But I have sent one PCB and that was carefully handled and assembled...the same result....works here and not in Nepal....
I am thinking to make improvement on few things
1. Add hardware pullup (now I am using internal pullup on the chip)
2. POssibly improve the button by going to set time mode after long press or something like that (as suggested by some experts here)
3. I already have two input and output capacitor 10µF and 100 nF in parallel....May be I should add more decoupling on the linear regulator....
4. If none of this works....I WILL GO THERE AND HUNT DOWN THAT GHOST. :)
You misunderstand me. I meant someone purposely changing the time as a prank. If there are any youngsters around, I would consider this one of the most likely possibilities.

Bob
 
Interesting! I would guess the RTC but it looks fine. Then it also comes down to coding... Assume 'fine' so what then? What's different between the two countries... Power Distribution. I know here in USA that the frequency is updated (according to people) its once a day early in the morning. Looked at Nepal and found this interesting paper about their power system - and mentions something about 'system charging' which means there is no power?!? Graph says 20 hours... Without power it switches to RTC backup... Opps! System would stop running but RTC would 'run'... Hmmm! https://escholarship.org/uc/item/66b658ws
 
I have no idea if you ever fixed it, but I would put a switching power supply in there.

To avoid problems with kids, I'd create some sort of "trick" that's necessary to set the time. Magnet. Some "code" using the existing buttons that might enable setting for a certain amount of time.

make sure bypass caps are used.
 
Top