Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reducing noise in circuit...ideas?

Status
Not open for further replies.

MacGyverS2000

Electrical
Dec 22, 2003
8,504
Some background...I have a PIC chip on a 1.5" x 3" board, several switches (with RC networks for debouncing), and multiple PWM outputs. PIC chip is smack dab in the middle, crystal is directly above (top of board, middle), and voltage regulator is in the top left. Vdd for the chip is brought down the left side of the board, along the bottom, then back up towards the PIC once it hits the middle (a sizable length track, about 3" long). This supply also powers the keypad.

I just finished transferring the code, which worked reasonably well on a different chip and board layout, to this new setup. Once in a blue moon the old setup would lock up after a keypress, but it happened so infrequently as to let me ignore it. The new setup, however, exhibits the symptom more readily if I stress it (repeatedly press the buttons quickly), so I needed to track it down.

Contamination from the PWM lines has been ruled out as I shut them off for the time being. Contamination from contact bounce has been ruled out as the signals look quite clean (10kohm resistor, 1uF cap for a 10ms debounce time, along with the chip inputs being Schmitt triggers). If there is any contamination from the clock, it's so small as to be lost in the surrounding noise.

Last thing to check was the Vdd line. At the regulator output, ripple is minimal (10mV?), but it definitely increases as I get further from the regulator...at the point where it powers the PIC, static noise levels (no buttons) are much closer to 200mV+ :(

But I wanted to know if those buttons were doing anything to that line, over and above what the background noise was at that point. As I set my trigger level lower and lower, I began to think something was wrong with my scope...I was able to trigger a wave capture at voltage drops as low as +4.0V!!! A couple of good hits to the button made the Vdd line drop an entire volt, which no doubt is wreaking havoc with the PIC itself and sending it into La-La Land.

-----

Soooo, my question is how do I mitigate some of this noise? Some possibilities I'm thinking of (and I'd like your feedback on):
1) A decoupling cap near the Vdd and Vss line of the PIC (scary, but I JUST now thought of this...have NO Earthly idea why I never put one on before). A 0.1uF should do it.
2) Shorten the distance between the regulator and PIC (seems like a no-brainer, and I've done so already on the production board gerbers).
3) Increase the cap value on the regulator's output. I currently have a 0.1uF per datasheet suggestion, but it seemed a bit low to me (it's a 100mA max part).
4) This one is for those knowledgable in PIC design. Evidently the MCLR pin is quite touchy to noise on some chips (from what I read). I currently have a 10kohm resistor from Vdd to MCLR and use the internal Power-On Reset option...should I add a low value cap for an RC network? I chose to leave it out so my In-Circuit Serial Programmer would work without the need for a diode (space is tight).


Your thoughts/opinions welcome...
 
Replies continue below

Recommended for you

MacGyver,

The solution came to you while writing. Didn't it? Vdd decoupling and a good ground plane almost certainly will remove the problem. Internal reset is OK in all chips that I have used so far. MCLR and 10 k to Vdd is rock solid, but if you have any doubts about it you can add 10 - 100 nF temporarily to Vss to keep it real steady.

But I think that the 100 nF decoupling is the crucial point. Keep it reasonable close to the Vd/Vss pins.
 
Obviously your decoupling needs improving and you are doing that. What interests me is why the power rail is dipping when you push the button. Is it the button debounce or some action that the PIC takes as a result? 1µF is a rather excessive debounce capacitor and it is not clear from your posting how you have go it wired up. Is it, for example, a 10K pull-up to the power rail connected to the 1µF capacitor, the other end of which is grounded? Is the switch shorting the 1µF capacitor directly to ground? If so you are generating a rather nasty (unlimited) transient current in the ground path which may be messing with your system.
 
I agree with LOGBOOK, if pressing a button droops our supply voltage that much, then something is fishy. Do you really need the 1uF? Could you get away with a smaller cap and larger series resistor (to prevent large surge currents)?
 
While the lock-up problem has been resolved, I'm still interested in continuing the discussion and getting more feedback as other issues have recently been raised. I've posted some significant info on the MicroChip forums, but I'll repeat the necessary stuff here.

Before I forget, a decoupling cap is exactly what was needed on the power line...I went from 350mV ripple this morning to less than 20mV, even with massive beatings on the switches.

The switches are debounced in the typical fashion...Schmitt trigger I/O pin attaches to a 10k resistor (to Vdd), a 1uF cap (to ground), and a switch that connects directly to ground. I originally had it as a 100k and 0.1uF, but then was informed (possibly incorrectly) that to have such a low current was pushing it. Now the leakage current for the I/O pin is 1 uA, and a 100k resistor allows 50uA, so I'm leery of the info, but figured it couldn't hurt to go with 10k.

A second issue that has been raised is the necessity of the caps on the switch debouncing at all. I chose the hardware debounce route as I did not know how tight software timing might be, so software debounce was too dicey. It was suggested that a 4.7k pullup resistor was enough, but I'm not sure why it was suggested since it does not allow for any debouncing...even with a Schmitt trigger input, a good switch bounce is going to give me several pulses. A 0.1uF cap is significantly cheaper than a 1uF, and no cap at all is quite a bit cheaper still ;)
 
Firstly, let me say that I am glad that you fixed the decoupling problem.

Now it seems to me your are living on hearsay and rumour. That is not a good state of mind for a designer. You really want to get some facts to work on so that you can be sure of what you are doing. Do you have access to a digital storage oscilloscope (DSO)? If so use a 10:1 scope probe and look at the waveform on the switch. This will tell you if the de-bounce circuit is working correctly in terms of its time-constant. A real time scope really wouldn’t be able to see this sort of waveform but any old DSO will do this job easily.

Now let’s look at the specifics of your existing de-bounce circuit. I assume you are using a solid dielectric 1µF capacitor. Let’s assume the switch resistance when on is 1 milliohm and the capacitor ESR is less than 10 milliohms. How much current flows through the switch when you close it? 5/0.011= 454A. Oops! This gives a circulating transient current from the capacitor, through the switch and back to the other end of the capacitor, right through you system ground. You are now apparently able to withstand this transient, but with what margin?

It is frankly a bad design to have such a large and relatively uncontrolled transient in your system. All it takes is one extra resistor to define the current and make the system clean. Put the resistor in series with either the switch or the capacitor, it really doesn’t make a great deal of difference.

Suppose you put the resistor in series with the switch and the value is 100 ohms. The low level is now not quite zero. With a 10K pullup the low level is then 50mV, which will not compromise your noise margins. However, the transient current is limited to 50mA, a much more sensible figure. Personally I would put the resistor in series with the capacitor as the optimal position. The low level is then still zero. The transient current is still 50mA.

I would still want to put a scope on this circuit to check-out the resulting signal. This will tell you if you can reduce the RC time-constant.
 
I didn't really spell it out in my first post, but I hinted to the fact that I've checked the lines. What would I do without my DSO :)

The switch looks ultra clean. Immediate drop to ground with no ringing, smooth logarithmic curve up to 5V upon release...ripple is practically nonexistent/invisible on the trace at 1V/division.

As far as living on hearsay/rumor...I continually re-evaluate what I think I know based upon what I'm told and/or read. For example, I saw no immediate harm in decreasing the resistance from 100k to 10k under the assumption that I would chase down more of the facts at some point in the future. It sounded as if it had a grain of truth, so better to be safe than sorry...resolve the absolute truth later.

I agree, the heavy transient poses potential problems. I suppose the lack of energy storage capability in the tiny cap lulled me into a false sense of security. I generally use Multilayer Ceramic Chip (MLCC) caps (particularly those by Panasonic) because the wide selection uses has the value/spec I need, and I get the benefit of a low ESR similar to (and many times better than) a tantalum.

So what's your take on the other guy's suggestion of removing the cap altogether? It sounds like a bad idea for all of the reaosns I mentioned above, but again, maybe I'm missing something.
 
Glad to see we agree on the philosophy and I apologise for any unintentional slight.

You could certainly try 100nF and see if that still gives a monotonic edge. I would still prefer to see the 100 ohm series resistor as well for a general purpose solution.

Having said that, for a cost sensitive project, or just for simplicity, it is certainly possible to omit all the de-bounce circuitry and just use the simple pull-up resistor. If you are clocking a flip-flop with the switch then two clock edges may be produced for one action of the switch. Likewise a falling edge from the switch may produce a rising edge due to bouncing. (A rising edge would likewise also produce a falling edge.)

In this project the switch drives a schmitt input on a PIC. Neglect the schmitt if you are not using the capacitor. If you get two edges within a space of 1ms, will it make any difference to the system? The usual trick is to read the input then read it again (and possible again and again) until you are confident that the reading is valid and not a bounce.

PIC chips are slow anyway. I used a PIC chip as a function generator to produce triangle or square waves according to an input line. In this application de-bounce is irrelevant and I didn’t even read the input twice.
 
You can get away from the external switch debouncing if you use your micro. Read the switch mulitple times. This is not uncommon. In systems where space is at a premium, handheld devices, switch debouncing via software has been successfully implemented.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor