Reading a switch - Ground loop problems?


Apologies but (as most posts seem to start) I'm a electronics newbie.

I trying to use a Arduino Nano to read a simple switch. I've followed the debounce example and it works fine when testing.

When I move to my live environment I run into problems. The solution needs to read from a medical video device and capture a trigger press.

Video is delivered as composite over coax to a USB based frame grabber. The trigger signal is also over a separate coax. Both USB devices are connected to the same laptop.

If I use a trigger other than from the medical device i.e. a foot pedal, it works fine. If I don't connect the USB frame grabber it works fine but if I connect both the trigger isn't detected.

I did some Googling and guessed that my problem was a ground loop issue? I got a ground loop isolator and put it in the path of the video feed and that fixed the problem so that seems to confirm it's a ground loop issue. However if I plug anything else into my laptop i.e. an external monitor, the problem recurs.

I'm not going to be able to isolate every device that will ever connect to my system from ground :o

I'm in the process of trying to get up to speed on ground loops and how to address them but I'm fairly time constrained hence the cry for help.

Can anyone suggest 1. Any method of reading the switch state that wouldn't be susceptible to the ground loop issue i.e. using analogue pins to read the state rather than digital? 2. Any way to address ground loop at a PCB level (I don't want a half-dozen box solution)? 3. Or does anyone think I'm barking up the wrong tree altogether with the ground loop thing? 4. Is sending the v+ down the shield of the coax to the switch in order to get it back when switched good (or at least acceptable) practice?

Many thanks


As was suggested the optocoupler is a good idea.

Sending a voltage down the shield of a co-ax is usually a very bad idea since a lot of systems may expect the shield to be earth ground or power supply return. I have seen triax cables where the outer shield was earth ground and the inner shield has a voltage. Triax is difficult to work with and expensive. You could use a shielded twisted-pair. The shield would be ground and the signals would be on the pair. Excellent noise immunity.

I usually do a hardware debounce. The circuit I use is in the datasheet for the prototyping board I make (see A hardware solution won't help is your problem is due to isolation or grounding.

(* jcl *)

www: twitter: blog:

Thanks for the suggestions, both good. I'd never heard of an optocoupler before.

I've grabbed one and have it working in the test rig (I don't have access to the production environment to test until the end of next week).

The one thing that springs to mind is that my solution has no active circuitry on the switch side. Although it's a powered unit (hence the ground loop) the trigger simply closes a circuit rather than sending a pulse.

This means I have to power both sides of the optocoupler from my Arduino, which surely defeats the purpose?

Is this a case of fixing the environment I'm trying to plug into rather than something I can fix with a solution on my side?

Powering directly from the Arduino does defeat the purpose but you can power from an isolated dc-dc converter that is connected to the Arduino.

(* jcl *)

I’m a bit thick, but could you sketch out the circuit? I’m surprised that you have an issue simply reading a switch contact tbh.

If you have to use co-ax for the switching, how is it wired up? Could you not use it to pull an input down to ground, i.e. screen of the co-ax grounded (same ground as the Arduino) and connect the centre conductor to the digital input with a pull-up resistor to 5V (with the switch connecting the centre and screen together).

Or is this what you’re doing already? Is the connection at the equipment (switch) end totally floating, or is there some connection on the co-ax socket to ground at that end?

I wouldn't disagree that someone is being a bit thick, but I would suggest you're pointing at the wrong person :)

I'm doing pretty much as you've described. As far as I'm aware the far end of the cable is totally floating, no connection to ground (although the facts would seem to indicate this isn't the case).

I'll sketch up the solution but won't get a chance today. I completely agree that it shouldn't be this difficult. The use of co-ax for the switch signal is simply to maintain wiring compatibility with the existing solution, I'm not making any use of the shielding functionallity, it's simply a two core cable to me.

A large part of the problem is that I don't have access to a test stack so I have to do my final testing on the actual stacks in the operating theatres.

Getting access to these is fairly difficult, it's a sterile environment and they have to do a deep clean after I've been in with my box of tricks for testing. Therefore I can only get in fairly infrequently.

I'm now armed with a lot better understanding of the issues and the next time I can get in I can get measuring with the multi-meter and hopefully get a better understanding of what's actually happening. I hadn't a clue about a fraction of the stuff the last time I was in so didn't know what to measure.

I believe the pointers here have me well on the way to a working solution, many thanks to all. I'll keep asking questions as I come up with them but it's to make the most of my next access for testing, not because I don't understand the answers so far or think they're not going to work.

Thanks again