Possible noise on digital pin?

Hi,

I have Arduino MEGA based solution that has one quite annoying problem:
Three digital pins are used to adjust current date/time settings (day of week, hours, minutes), however
I have noticed that sometimes clock 'adjusts' itself, currently I think that it might be due to electrical
noise when other pins are used. Any ideas how to avoid this?

This problem is kinda hard to track as it appears only once per few weeks meaning that it does not
always happen (if it would be some programming bug it would happen every week or more often)

Thanks in advance,
Jurz

How are the pins connected up?

Sounds like a lick of pull up resistors or too high pull down. Read this:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Depending on programming and hardware hookup - a 1K resistor either to ground or +5V. Call them Pull Downs or Pull Ups depending on which voltage they are connected to. How long are the wires connecting things together?

If you are already using the internal pull-ups remember they are rather weak (20k to 50k according to the datasheet). Any significant crosstalk due to long wires/PCB traces and they could be overwhelmed. Add something like 4k7 pull-up resistor close to the Arduino chip.

I don't understand what is "Cross Talking" to what and interfering... the Arduino is a single thread device... it doesn't talk to one sensor and do something else at the same time... But I do understand poor bypassing that will not keep digital noise quiet enough to not interfere and poor wiring technique. I would think that a properly terminated wire of modest length between 30 Cm to a meter or more in length would NOT be susceptible to noise generated elsewhere. to flip a digital input a "Crosstalk" signal must impress on the wire being "Crosstalked" a voltage of 60% min Vcc. When I was designing processor based analog equipment, I regularly used sensors with millivolt level outputs to A/D ports on other processors with NO issues whatsoever and these things were done with 25 watt 450 Mhz radios operating at the same time all in a multiprocessor environment and all in the same aluminium case with switchers and solenoid drivers and other noisy components. If there is any Cross talking it comes from poor layout conditions, even poorer unbypassed power supplies and improperly terminated connections to the processor/sensor...

Doc

Cross talk is the inadvertent coupling of signals due to capacitave coupling of adjacent conductors.
It can happen at aly level. Its effects are worst at high impedances so one way to reduce its effect is to haver lower pull resistors.

I regularly used sensors with millivolt level outputs to A/D ports on other processors with NO issues whatsoever and these things were done with 25 watt 450 Mhz radios operating at the same time all in a multiprocessor environment and all in the same aluminium case with switchers and solenoid drivers and other noisy components.

Impressive to the point of almost incredulity.

All this is wild speculation at the moment. We are all flailing around in the dark throwing in ideas that may or may not have a bearing on the problem.

We cannot make any reasonable suggestions without more information from the OP.

We NEED to see the circuit before we can have a clue what is going on.

Yes, it sounds like this, and it sounds like that, but it could he absolutely anything, even a mouse making a nest in it.

Very true but in the absence of any real information from the OP all we can do is speculate.

No Mike not impossible at all... separate power supplies and voltage followers. All of any external or internal for that matter devices had a separate regulated 5V supply and ALL of the Analog sensors had voltage followers on them so as to provide a very low impedance input to the processor. So this cross talk thing is clock data getting into the data line/s? or data getting into the clock lines? I have that problem from time to time... usually I'm either lazy or in a real hurry and I forget to use the right value of pulldown or up... When you tie a 1K resistor from Vcc to a digital input pin the input impedance is now 1K instead of several megohms or 20 - 50K ohm if you enable the Weak pull-ups and if that doesn't work I will go to 470R or even 330R thus lowering the input impedance to a point where external noise Has to have a GREAT deal of power to be able to "interfere" with the data or control and when pull-ups were not suitable for loading reasons I used bus transmitters and bus receivers I remember a 75494 or 5 that worked well for a couple of lines and for bus wide things there were the 74HC244 - 544 devices as bus terminators/transmitters, actually very handy with the bus enable you could connect as many devices inputs together as you liked and just enable the output of the one you needed to use. Nasty things though if you left that /OE pin floating or any of the unused inputs. I once made a 2 watt 60 mhz ring oscillator with one package... 3 sections for the oscillator and 3 in parallel for the output. My neighbor at home liked to use his tv late at night at a high enough volume to keep me awake at night... this Thing made enough power locally to take out his tv tuner... Pretty completely on channels 2 and 4/5 all for about $.50 and the hour it took to build it and put it into a box.

Doc

Hi,

my bad. Quite stupid from my part not to include schematic (attached).

Have you enabled the internal pull up resistors, you need to.
Remove that common resistor in the -ve line of the switches and connect them all directly to ground.

Before I added common resistor this problem occured even more often.

If I'm getting you right then your suggestion is to turn in INPUTS for the buttons to HIGH and turn them LOW to switch hours/mins/sec?

Before I added common resistor this problem occured even more often.

I don't care, it is wrong remove it and lets get to the real problem. Make sure that common line is connected to ground.

then your suggestion is to turn in INPUTS for the buttons to HIGH and turn them LOW to switch hours/mins/sec?

No, use pinMode on all the three pins to make them into inputs. The do a digitalWrite(pin, HIGH) on each one to enable the pull up resistors.
Then you will see HIGH when you read an input with the button not pressed and a low with it pressed.

Will do, thanks

Just looked at my source, internal pull-ups where enabled. So there must be other problem.

So there must be other problem.

Yes got rid of that resistor yet?

Yes

OK, I would try and connect the common ground in a more direct path to the ground.
I would also add some decoupling caps to the power supply of the LCD.

Are the buttons working but sometimes you get false signals?
If so then You might need a stronger pull up resistor than the internal ones as those are quite weak. Try a 4k7 from each input to +5V. Also try a 0.1uF from each of the inputs to ground.

Grumpy_Mike:
No, use pinMode on all the three pins to make them into inputs. The do a digitalWrite(pin, HIGH) on each one to enable the pull up resistors.
Then you will see HIGH when you read an input with the button not pressed and a low with it pressed.

I'm not an arduino expert or anything but isn't the syntax pinMode(pin, INPUT_PULLUP); ? At least maybe in IDE v1.0.1? I really could be wrong, just putting that out there lol