Pull-up interference from DCC system?

Hi

I have put together several proto-boards incorporatingarduino nanos. Each board controls one 3 aspect model railway signal on my uncle's layout. The arduino basically reads values from light sensors when a train passes over to control the signal aspect and also reads the position of the nearest turnout (point) to ascertain whether a red light should be on. This then runs a bit of code that fades down the green led and fades up the red. This is simply a switch built into the turnout control motor that connects a digi pin on the arduino to ground in order to trigger the action. This pin uses the arduino's internal pull-up resistor.

All works perfectly as expected on the bench before installation. I connect the relevent pin to ground and the red led is lit. Releasing the connection turns off red led and back to green. No problems there, then.

The issue I have is when I fit the board to the underside of the layout and run 2-3 foot wires from the ground and trigger pins to reach the nearest point motor switch. Before connecting, touching these wires together (sending earth to my trigger pin) triggers my red LED reliably and stays there, but when I release them my green led lights up as expected but then behaves like my trigger pin is floating, so it's flicking sporadically between red and green. Connecting these wires together again results in a solid red.

Back at home on the bench, I tried connected a long-ish wire to the same pins, thinking it may be that, or the need for a stronger pull-up, but the board works as expected.

My work around is to use the SPDT switches on the point motors to send 5v to the pin or earth to the pin, rather than earth or nothing (or earth and pull-up). This workaround, although working fine, uses more switch contacts that need to be used for other things later on.

My only idea about what may be causing my problem is electromagnetic interference from the railway's DCC power bus lines that run round under the layout. I know the system causes audio interference if listening to MW radio or if you place speakers near the wiring, but I would have thought it'd be difficult for it to interfere with a simple 5v-gnd connection?? All other functions including the photoresistors seem to work fine.

Any ideas on how to overcome this would be much appreciated!

My first thought is to add external pullup. The internal pullups are not that strong and a 2.2K external pullup might help.

And a 0.1 uF cap.

Pelle

Thank you both for your input.

I'll try a 2.2k external pull-up & disable the internals. I'm not entirely sure what the internal values are for the nano - the website just says in the region of 20-50k ohms...

Pelle, please excuse my ignorance... Would I add the cap Between the 2.2k pull-up & 5v or across the pin and ground? I'm guessing the purpose of the cap is to smooth out any interference, have I got that right?

Edit: Another thought... Would I benefit from using shielded wire like that from an audio cable or LAN cable? At the moment I'm just using single multi strand wire.

Shielded wire can't hurt. Connect only one end of the shield to a good ground. I think cap would go to ground. The cap will filter higher frequency noise.

Many thanks - I'll give both methods a go

You've created a magnetic loop antenna without meaning to. Probably very strongly coupled to the currents in the track that carry lots of noise from the motors...

Try twisted pair for the connection, its always a good idea to use twisted pair or shielded cables for every signal path.

Ok thanks for that. Looking on the net, it seems cat5 cables are a lot easier to get hold of than simple twisted pair wires so I might try them.

Although I suppose if I twisted the two single cables I've already got it would do the same job...? If they're long enough.

EDIT:

When you say I've created a magnetic loop, do you mean in the DCC bus cables around the layout, or in the extended wires to the pull-up pin?

I will finally be getting round to attempting a fix for this soon.

I'll be twisting the wire pairs together, adding external pull ups (2.2k) and disabling the internal ones.

I didn't however get to the bottom of the use of the coupling cap that was advised earlier in this thread. Do I connect it:

A) between the pull-up pin and ground? B) between pull-up pin and 5v? C) across the arduino's main 5v and ground? D) across the arduino's Vin (12v) and ground?

If A or B, do I connect capacitor at the switch on the end of the long cable, or on the arduino itself?

Material online suggests C but I'm not sure if that's something more to do with power supplies?

Help would be greatly appreciated!

danielmc1: Ok thanks for that. Looking on the net, it seems cat5 cables are a lot easier to get hold of than simple twisted pair wires so I might try them.

Although I suppose if I twisted the two single cables I've already got it would do the same job...? If they're long enough.

You can easily make twisted pair using a hand-drill and a bench-vice.

EDIT:

When you say I've created a magnetic loop, do you mean in the DCC bus cables around the layout, or in the extended wires to the pull-up pin?

All loops are magnetic antennas by virtue of being a loop. The larger the area the worse the interference (the better the antenna). Twisted pair keeps the area very small and the alternating bits of loop sign-cancel so the level of interference is very low.

The train track is itself a very strong emitter of interference and you should keep your as much of your sensor wiring as far away from it as you can - run the wires away from the track, before turning parallel to it. Parallel is the worst configuration for cross-talk.

MarkT: You can easily make twisted pair using a hand-drill and a bench-vice.

My first vacation job was working in a small electronics assembly plant. I spent some of that time making twisted cables (2 to 5 strands) by tying one end of the cables to some fixed point at one end of the factory and spooling about 50 foot out to the other end. I then placed the ends in the chuck of an electric drill and turned it on until the cable was twisted enough. The trick, to prevent the cable from untwisting, was to take it out of the chuck and pull hard, to stretch it slightly. That was the fun bit. I then spent the rest of the day cutting it up into 6" lengths. :sleeping: :sleeping:

Or you can run the drill backwards a little bit to lose the torsion. With short lengths a hand-drill gives much more tactile feedback.

I hope you didn't have to strip and solder them too! (Or make litz wire!)

MarkT:
Or you can run the drill backwards a little bit to lose the torsion.

Then you have to remember to twist it more than you need before turning backwards. But stretching sets the twist tighter.

With short lengths a hand-drill gives much more tactile feedback.

I wouldn’t like to use a hand drill on 50’ lengths. :roll_eyes:

I hope you didn’t have to strip and solder them too! (Or make litz wire!)

I wasn’t trusted with a soldering iron then! No Litz wire either, thank goodness. I hear it was nasty stuff to work with and the soldering technique was a severe fire hazard. Plunging hot wire into methylated spirits [Sterno?] isn’t a good idea!

They mainly made speaker enclosures with crossovers. The demand was so slow that the testing bods found time to turn their green screen circular oscilloscope into a TV, but no sound. That was in the days of single channel monochrome 405 lines TV (early 60s).

@danielmc1. I'd keep all the electronics as far away as possible from the point motors, especially if you're using the solenoid type. Those give one heck of a magnetic kick when they're activated. I'd also suggest keeping all your electronics away from the track too, near to the edge of the baseboard (or, my preferred option, on the floor in a grounded metal enclosure). Then run your twisted pair or shielded cables to the points and signals at right angles to the track, as already suggested. Remember that your rails are acting like a very long aerial.

That's all really helpful, thanks very much! I'll defiantly be doing some twisting with the drill - there's already slack in most of those wires so hopefully twisting won't cause to much if an issue in terms if length. Re routing away from the power bus & track will be another matter though, but I'll see how I get on with the stronger pull-ups & twisting first.

As for the capacitors... What do you reckon?

I thought someone just recommended 100nF on the input pin to ground to soak up interference spikes?

Input pin to ground - thanks, I'll do that