Overactive interrupt triggering using internal pullups

Post here first, or if you can't find a relevant section!
User avatar
RogerClark
Posts: 6910
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Overactive interrupt triggering using internal pullups

Post by RogerClark » Sat Dec 17, 2016 10:18 pm

I've just built a small project that uses a Maple mini with a Nokia 5110 monochrome LCD display , and a rotary encoder, and a external switch input (reed switch to detect a magnet), and also a high current put 1A using a FET driver.

I'm using the internal 22k pullup on the input from the rotary encoder and also from the reed switch input, but I've noticed I appear to get false triggers on the reed switch input and more recently on the rotary encoder input.

I was using the internal 22k pullup, e.g.

pinMode(PUSH_BUTTON, INPUT_PULLUP);

But it now looks like this is too weak for real world usage.

I suppose I could solder on external pullups e.g. 4.7k or perhaps even 1k, to prevent false triggers, but it seems odd that STM would have 22k as the internal pullup, if its value was too high to be usable.

It could also be that a lot of the miss-triggers are caused by supply noise.

Note. I'm debouncing the rotary switch extrnally using 100nF cap across the switch, so I would have thought this would also act to decouple the pin and stop miss triggering as well as debouncing, but at the moment it doesnt seem to be working as well as I'd like ?

BTW. I'm powering the Maple Mini on Vin, via a 9V external supply, because the switched high current output - which drives a solenoid, is designed to run from 12V, but 9V seems to be plenty (but 5V is not quite enough)

Any thoughts about what I am doing wrong.

User avatar
ahull
Posts: 1597
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: Overactive interrupt triggering using internal pullups

Post by ahull » Sat Dec 17, 2016 10:44 pm

What does the 'scope show?
- Andy Hull -

User avatar
mrburnette
Posts: 1803
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Overactive interrupt triggering using internal pullups

Post by mrburnette » Sat Dec 17, 2016 10:57 pm

Sounds like you have a radio receiver on your hands. My guess is 50Hz noise.

Ray

User avatar
ahull
Posts: 1597
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: Overactive interrupt triggering using internal pullups

Post by ahull » Sat Dec 17, 2016 10:58 pm

mrburnette wrote:Sounds like you have a radio receiver on your hands. My guess is 50Hz noise.

Ray
Good thinking. Try shorter wires, screened cables...
- Andy Hull -

User avatar
RogerClark
Posts: 6910
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Overactive interrupt triggering using internal pullups

Post by RogerClark » Sun Dec 18, 2016 2:32 am

I've not looked on the scope, as I built 2 of these and the units and the one that is exhibiting the fault is the one I build for my dad.

I agree it sounds like the input wires are too long, but I modified the code to disable the external reed switch detector, (which is on a 10ft long pair of wires), and its still going wrong, so I think its miss triggering on the rotary encoder, and the rotary encoder connections are only about 2 inches long, inside a box.

To be honest, I cut some corners, to save having to solder loads external components, I use the internall 22k pullups on all inputs, which are the 2 rotary encoder signals, as well as the push button that is on my rotary encoder, and also use the 22k pullups on the reed switch sensor.

To debounce, I just have a 100nF capacitors to gnd on all these inputs.

But initially I had a problem, where if I pushed the Press button on the rotary encoder, I"d get a miss trigger on the rotary encoder its self.
And to stop that happening, I had to change my wiring, so that it didnt have a common ground wire from the system GND to the button gnd and the rotary encoder ground.

I presumed the problem was that when the button was pushed, it shorts the 100nF to GND, (across the push button).

Somehow this was causing current to flow up the common GND, and caused the GND on the rotary encoder to rise, hence somehow applying noise / spike to the rotary encoder trigger input.

Basically, I'm doing the same as Nick Gammon describes here

http://www.gammon.com.au/forum/?id=11130

Image

But the push button on the rotary encoder is debounced in the same way, and shares a common GND wire

User avatar
RogerClark
Posts: 6910
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Overactive interrupt triggering using internal pullups

Post by RogerClark » Sun Dec 18, 2016 3:00 am

OK.

I learnt something new.

For some reason I thought the internal pullups were 22k. But they are not !

On page 62 of the datasheet

http://www.st.com/content/ccc/resource/ ... 161566.pdf

It says

RPU

Weak pull-up equivalent resistor min 30k, typical 40k, max 50k

Mine are appear to be around 42k.

So really I need a much lower external resistor, as these "weak" pullups are far to high to be usable in my application, (at least for the interrupt lines)

User avatar
Pito
Posts: 1528
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Overactive interrupt triggering using internal pullups

Post by Pito » Sun Dec 18, 2016 10:05 am

Also use an R=1k-2k2 in series with switches contacts, see the schematics in the previous rot enc topic.
You may try to pass 3 turns (all wires incl gnd) via a ferrite bead with longer cables too.. when living close to a radio station :)
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 6910
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Overactive interrupt triggering using internal pullups

Post by RogerClark » Sun Dec 18, 2016 11:17 am

Pito wrote:Also use an R=1k-2k2 in series with switches contacts, see the schematics in the previous rot enc topic.
You may try to pass 3 turns (all wires incl gnd) via a ferrite bead with longer cables too.. when living close to a radio station :)
Thanks.

I need to change all the inputs, not just the rotary encoder, and a much stronger pullup is needed.

Pickup / flase triggering seems to be caused internally,rather than from an external source like a radio transmitter.
However I don't quite understand how shorting a 100nF cap, could put signicant noise back into the supply (or gnd) or the system

I'll try modelling it in ltspice to see what it looks like.

User avatar
Pito
Posts: 1528
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Overactive interrupt triggering using internal pullups

Post by Pito » Sun Dec 18, 2016 11:34 am

Without a simulation a 100nF capacitor @3V shorted via 0.010Ohm switch resistance can cause Amps of currents :)
Pukao Hats Cleaning Services Ltd.

User avatar
ahull
Posts: 1597
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: Overactive interrupt triggering using internal pullups

Post by ahull » Sun Dec 18, 2016 2:21 pm

Pito wrote:Without a simulation a 100nF capacitor @3V shorted via 0.010Ohm switch resistance can cause Amps of currents :)
Indeed with a perfect cap, in theory at the moment the contacts close you could be talking tens or even hundreds of Amps. Obviously this drops rapidly as the charge is dumped. Caps are not perfect of course and have an ESR so in reality this current is much less.

Hence my question what does all this look like on the scope.

I suspect shorting out those caps directly through the switch is not a very clean design. I imagine it might produce some interesting spikes even a few tens of ohms in line with the switch would probably clean it up. Dumping the cap charge directly through the switch may also cause the switch contacts to pit over time. We are not talking huge amounts of energy, but even so, as the contacts close, there will be some local heating, and some ringing in the circuit as the energy gets dissipated presumably as heat and even some RF. Stick your AM radio next to it and spin the encoder, see if you get a nice crackle. :D

BTW a small AM/FM radio is quite a good debug tool when working with mixed signal circuits if you don't have a 'scope to hand. You can hear all sorts of interesting beeps, clicks and squeaks as your code runs. :o

Try a small resistor (1k or less) between C and GND and see if it makes matters better or worse.
- Andy Hull -

Post Reply