Digital output directly applied to a digital input for a test condition

I will be using an Arduino Mega 2560 to monitor 38 float switches as a flood monitor system on a historic ship. Wire runs could be as long as 200 feet and groups of 7 floats will be connected with a 8 conductor cable (a common ground and 7 signal lines from the floats.) Each float is a NC switch and I am using 10k pull ups for the digital inputs to the Arduino. Also, some of the floats signals will be using the analog ports as digital inputs. Please see the included sketch.

So, the problem is that I would like to be able provide an easy test that would periodically verify the port functionality and associated reporting logic.

Instead of a direct connection to ground for the floats, I would supply the ground for a group of 7 floats from a digital port acting as an OUTPUT with a LOW == ground for normal operation. In the "test" mode, I would OUTPUT a HIGH which would then be applying 5v directly to the corresponding 7 digital inputs. This appears to work with a small trial but would it damage or compromise the ports of the Arduino by temporarily applying 5v directly to the digital port?

Thanks for your help.

No, it will not harm the inputs by applying 5V to them. EDIT see reply #5 If you are worried at all, include a 10K resistor in series between the output and input. The 10K resistor is so much smaller than the input impedance of a digital input that it is insignificant, but will protect the input.

I think that you may need stronger (lower resistance) pull ups on the longer lines (as low as 1K minimum).

Looks like a clever way to test to me.

saylur:
would it damage or compromise the ports of the Arduino by temporarily applying 5v directly to the digital port?

No it wouldn't. It really isn't any different than connecting a pushbutton or switch a pull-down resistor.

Thanks for the quick responses. I certainly couldn't see that it would be a problem but given it's not just a home project I was looking for reassurance about possible damage to the Mega.

I too am concerned that the 10k may be too high and will be looking for a test in the real environment. The multi-cable is 18 AWG and shielded. Also, these will not be a one shot look at the floats but multiple counts of an "open" condition over time before sounding the alarm. I'll hold my breath on the 10k since I already have them installed.

Thanks again.

Also, some of the floats signals will be using the analog ports as digital inputs.

Analog pins configured as digital pins are no different than other digital pins.

Physically the only difference is there is a switch between the digital hardware path and the analog path. When used as an analog pin, the switch is changed to the analog path. (Which itself then goes to an analog MUX.)

If you are worried at all, include a 10K resistor in series between the output and input. The 10K resistor is so much smaller than the input impedance of a digital input that it is insignificant, but will protect the input.

Now that I think about it and the way you are testing, the series resistor is not really necessary and may not be a good idea.

I too am concerned that the 10k may be too high

Yes that jumped out at me as well. I would use at least a 1K for the pull up resistor if not lower. That is a lot of wire to pick up interference. I might even be tempted to go down to 330R.

A 0.1uf cap across each of the switches at its digital input, might help shunt some of the higher frequency noise to ground, too.

Keep an eye on the total current you're sinking into your "gnd" pin. Using your 7 bit groups, if you used a dedicated "gnd" i/o pin per group, that's 35mA with 1k. (I suppose less from cable losses). But that's still very close to the 40mA maximum limit.

And then there is a 200mA limit (combining all I/O) on ATmega2560's VCC/GND pins.

I will post an update on the pull up outcome when this all gets wired up but that may be a couple of months away.

Thanks again for all the comments.

You could wire three or four float switches in series, with resistors across the switches.
And connect those groups to the analogue inputs of the Mega.
Then only one pull up resistor per analogue input is needed.
With the right resistors, you can detect which float switch is open or closed.
With an extra series resistor at the far end of the wire you can detect an open circuit or shorted wire pair.
Cuts down on the number of wires too.
Add a 100n-1uF cap from each analogue input to ground to reduce noise.
Leo..

Wawa, very interesting and actually I use that technique on a panel with 4 pushbuttons that I have on my home security/monitor system.

I will consider that approach for the longest runs which I believe will be only 6 floats. Also, I will need to find out how close together that 6 floats will be since that would add to the total length. There will be a junction panel somewhere in the area of the floats so the resistors and series wiring could be done there before a final run to the controller. The series wiring with resistors directly on the floats will also be considered without using the junction.

Thanks