Slow rising/falling input signals and TTL inputs

tiscando

Senior Member
I'm using an 18M2+ in a circuit that controls a 600W water pump (via a relay). For its inputs, float switches in a rainwater tank outside are connected to the 18M2 via long wires. The problem was, every time the pump turns on or off (even by an external switch downstream) it creates a lot of electrical noise that resets the 18M2. Disconnecting the float switches solved the problem (the PICAXE already had caps on the power rails and the relay had a freewheel diode), so I reconnected them with the noise suppression circuit below:

Code:
                             +5V
                               |
                               \
                               / 10k
                               \
       /                       |
  .___/   _____________________|______/\/\/\____________. 18M2 input
 0V            long wire               10k       |
                                                 |
                                              ___|___
                                              _______ 22nF
                                                 |
                                                0V
This circuit is effective in preventing noise from resetting the PICAXE. It is an RC filter between the switch and the input pin and, as well as filtering out spikes, it slows down the transitions in the switch's voltage level, which I think could damage the PICAXE's input circuitry if it is TTL type. The 18M2 only has TTL inputs.

I read that schmitt trigger inputs on PIC microcontrollers work like the 74HC14 for example, in that they can tolerate slow signals better than TTL, but have a larger hysteresis (1 to 4V), although a thread here on ST inputs disputed this.

The control circuit is powered 24/7 and needs to be reliable - it has been working fine for 7 days with this noise suppressor on each input so far. All the inputs are fully debounced in software with transition acceptance times of at least 20ms.

Does anyone think the above noise suppression circuit is safe for TTL inputs, or should it only be used on ST inputs?

Thanks. T
 

Goeytex

Senior Member
How Long is the Wire?

A long open ended wire is like an antenna and will pick up all kind of noise. This is why in the instrumentation world a current loop is very common. That's what all of the 4-20ma stuff is all about. For long runs and reliability an active circuit is normally used.

That being said, with your circuit in place you have added enough resistance for the Picaxe internal ESD diodes to work. It should be ok.

A slow moving signal will not necessarily damage a TTL input. The problem with slow moving signals can be oscillation or ringing at the trigger point. Like a comparator with no hysteresis. More of an annoyance and functional problem than a concern for blowing a Picaxe.

If your circuit has worked for a week with no problems then I wouldn't worry too much about it. But if you want to do it more properly then consider an active control circuit.
 

rossko57

Senior Member
Commercial burglar alarms etc. routinely sense from switches over 100's of metres of unscreened wire. It's just a case of having pullups and debouncing as you have done. The lower the value you make the pullup (or pulldown) resistors, the better the immunity to external influence. Personally I'd go for 4k7 as a pullup here, and keep the 10k as series protection for the Picaxe input.

Often you'd add a diode from PIC pin to + rail to limit possible overvoltage input; Picaxe has a small diode built in which is not really intended for this purpose - but ought to do.
 

westaust55

Moderator
Another way to help resolve the electrical noise pick-up is to use twisted wires for the level switch to PICAXE input signal.

Instrumentation uses twisted pairs (usually with screens) as does some other fields including model railways particularly where DCC is invoked.
 

tiscando

Senior Member
Thanks for your info. The cable to the float switches is not that long, about 3 to 4 metres. It's a flat 4-core telephone cable, so not twisted pair. I will consider an active circuit for much longer runs if I ever come across them.

For safety reasons, the ground of the low-voltage circuit is connected to Earth. Before fitting the input noise suppressors, disconnecting the Earth connection reduced but didn't solve the resetting problem.
 

Goeytex

Senior Member
Twisted pairs are really only effective at canceling noise in a balanced pair transmission line. Yours is a normally open circuit so a twisted pair cable would only help if it were shielded and then only because of the shielding. IF you do ever use shielded cable, remember that the shield wire only connects to ground at one end of the cable, otherwise there could be ground looping problems.

Rosko mentioned commercial alarm circuits and long cable runs. But these are never open ended. Any decent alarm circuit will have a termination resistor to close the loop. You could do the same. Close the loop at the switch end with a say 4K7 resistor. Then use ADC to read the switch state. You keep the series and pullup resistors you already have. An ADC of 2.5 volt means the switch is closed. 5 volts means open or broken wire. 0v means a shorted cable. This would require that the switch be normally closed. There are are lots of ways to do stuff .....
 

fernando_g

Senior Member
Goeytex approach is an excellent one, as it provides a warning if the wiring becomes faulty....this is similar to an open thermocouple sensor, the last thing you want is a furnace running open loop!!

Having said this, the only thing I would add if using an ADC method, is to take multiple readings and average them. Use ADC10 and a word variable, and if you have the computing time available, take 64 readings which you accumulate into the word variable. Any noise during one of those readings is significantly reduced.
Even if you cannot perform the full 64 readings, at least perform 4.
 
Top