View Full Version : microcontroller picking up noise?
sciguy125
29-06-2006, 01:18
I'm having a problem with a microcontroller project that's driving me insane. I've got a PIC18F4455. In an attempt to find the source of the problem, I've stripped it down to a very megar setup. The controller has power, its oscillator, a reset button, and an LED. When it starts up, it turns on the LED and just sits there. Now, if I connect anything that's also connected to the wall socket, it messes up. The LED either dims or turns off completely. I think the dimming is a result of high speed flickering though.
For instance, if I attach my oscilloscope probe (even just ground) to any part of the circuit, the controller flakes out. Also, if I use a wall transformer with a voltage regulator for power, putting my hand close to certain parts of the breadboard makes the LED go out. Touching the metal back plate of my board (which I have verified to be isolated from the circuit) completely puts out the LED. If I touch the back plate and circuit ground, everything is fine. If I run the circuit on a battery only however, it works fine. Just keeping the ground (the negative terminal) from the transformer in makes it flakey again. My multimeter, which runs on batteries, doesn't affect the LED.
At the moment, I'm using a 20MHz crystal and the PLL to get the clock to 48MHz. Bringing down the clock speed (either by internal dividers or using a slower crystal) does very little. I even went as far as trying the internal 8MHz oscillator (but I didn't try it at lower speeds).
I did discover that turning off brown out detection (which will trigger a reset if the power drops below 2.0V) makes it less sensative. With it on, the scope probe causes the LED to go out completely. Without brown out detection, it just dims (presumably flickering). This makes me believe that the controller is in fact resetting for some reason. However, my multimeter claims that the power is fine. The scope, which causes the controller to misbehave, also claims that the power is fine, but there's some noise. Adding capacitors cleans it up though. The caps only make the problem slightly better. After the first cap, additional caps don't make any noticable improvements.
Here's another point. If I can successfully connect the scope without the controller freaking out, the crystal has a nice sine wave. When the LED is out, the crystal is 0V. When the LED is dim, the crystal has some strange almost-square waveform with noise in the latter half of the high period. I haven't figured out if the crystal problems are because the controller is resetting or if the noise in the crystal is forcing the controller to reset. I suspect the former though.
I've narrowed down the problem to having something to do with the power line. I've tried different outlets at home and they all do the same thing. At work, however, the problem doesn't exist. I work in an ESD lab, so they may have some sort of special filtering or grounding that I don't know about. The technicians suggested some sort of noise at my house. I have yet to find the exact problem though. If I can't figure it out in the next few days, I'll make it a point to hunt down one of the engineers and see what they have to say. In the mean time, are there any ideas around here?
I have played with a 18F458 and an LED before. But I have only powered it with batteries(4.5v) and it work fine.
Try:
powering the entire system with only battery power
try striping down the code to bare minimum(take out interupts and such)
I can't help you much more because it you seems that you know a lot more about it than I do.
Al Skierkiewicz
29-06-2006, 07:37
Phil,
Interesting problem...You say you don't have any problems at work just at your house.?! Could be that the ground and neutral are reversed in your house wiring. Easy to check with a simple power checker you can get from Home Depot.
You may have an open neutral. Are you burning out more light bulbs then you think you should? Have you scoped the power supply line on your board? Does it have any ripple or RF running on top of it?
If you see a lot of RF on the power supply (fuzz on the DC on a scope) it is possible you have something in the house that is radiating. Common sources are touch on/off lamps, wireless phones, and believe it or not, aquarium heaters. Another source is X10 lamp controls which use the power line as a bidirectional serial line. They are only designed to transmit during commands but you might have one stuck in transmit. Are your neighbors close? They may have something as well. Finally, a souce of interference you would never think of is your TV. Do you have a plasma display which is a real source of noise. Other TVs also produce power line noise as well as computers. If you suspect one of these, unplug it from the wall to make sure it is not the culprit.
Al
Phill,
I am currently interning at Microchip, my respose would be to try to take out the crystal and just use the internal clock, try that and see what happens, also what do you ahve the reset vecor set to do? and i know you hooked up a multimeter to the input power but have you tryed looking at it thro a scop and seeing how much current it drawing?
BrianBSL
29-06-2006, 12:42
Phill,
I am currently interning at Microchip, my respose would be to try to take out the crystal and just use the internal clock, try that and see what happens, also what do you ahve the reset vecor set to do? and i know you hooked up a multimeter to the input power but have you tryed looking at it thro a scop and seeing how much current it drawing?
The scope isn't going to tell him how much current he is drawing without a special current probe or a low resistance shunt on the input.
However, I do agree with trying the internal RC oscillator, and make sure you have your fuse bits set for the right type and speed of crystal oscillator. Do you have any capacitors to ground on the crystal? The datasheet for the PIC should be able to tell you what size, but I think normal is the 10-20pF range.
FIRST JerseyKid
29-06-2006, 13:59
I've been recently working with pic microprocessor and I was picking up alot of noise from the other pins. I solved the problem by grounding them out. Also make sure that your LED isn't getting to much current, about 20mAmps per a LED is normal. You might not see a light if theres to much current.
When using your oscilloscope add an op amp to reduce the impedience of your testing tool. This will make your testing effect your chip less.
Ken Leedle
29-06-2006, 17:54
If your PIC works fine with batteries and not with a power supply, you probably need to filter your power supply. Just hook up a .1 uF and a 10 uF capacitor between the power leads of the PIC. This solves most noise problems I've had working with PICs. The other thing is make sure that your power supply actually supplies 5V.
sciguy125
29-06-2006, 21:10
Alright, the supply is clean. Well, if I put my scope at 5ns, it doesn't see any noise. I have capacitors right at my voltage regulators and right next to the PIC. Adding more does nothing, removing them increases the problem very little. So, I've ruled out a problem with the voltage supply. However, I have yet to rule out a problem with the power line as it seems to be the main culprit.
Using the internal oscillator in the PIC does nothing to solve the problem. That was one of the first things I checked. Just for kicks, I've even tried 15 different crystals at three different frequencies. I'm using 33pF caps with the crystal. According to the datasheet, I should be using 15pF with the 20MHz. I think that's close enough to the 27pF for the 4MHz crystals. But, again, changing the clock frequency doesn't fix the problem. The only change to the PIC that seems to have any effect is disabling brown out detection.
I've done PIC projects before, but havnen't had this problem. The two differences now are the PIC and my board. I don't have time right now, but this weekend, I'll try to dig up some other PICs and my other board.
Per Al's suggestion, I unplugged everything for the aquarium that's sharing the same socket I'm using. It didn't do anything. I also tried unplugging my wireless router. There's still plenty for my to try, but again, I think I'll have to wait for the weekend.
Al Skierkiewicz
29-06-2006, 21:43
Alright, the supply is clean. Well, if I put my scope at 5ns, it doesn't see any noise.
Phil,
I am more interested in what you see when the scope is at 50-150 ms(full screen). Connect the probe to the output of your regulator. Set the scope to "Line" on the trigger to lock the scope to the power line. Set vertical sensitivity to less than 1 volt and AC couple. Do you see any signal that is not moving on the scope? This is power supply/power line related stuff. It can occur at 60Hz or 120Hz, which is 16ms or 8 ms rep rate. It is not uncommon for three terminal regulators to output 60Hz noise when the input has a lot of ripple. Adding caps on both the input and output will not cure this problem. If you have a low voltage at the wall, then you step down transformer is not capable of giving greater than the 2 volt minimum for correct operation of the regulator. (A 7805 needs more than 7 volts input at all times to produce a clean 5 volt supply. Anytime the input falls below the 7 volt minimum, the output 5 will also fall. If you see any noise at all, it should be in microvolt range. Anything greater than .25 volt peak to peak is likely going to trigger the brownout detector and cause the oscillator to have a lot of FM modulation. When this occurs anything is possible.
One thing we didn't discuss before is grounding. Are you absolutely sure that the power supply and board grounds are firmly attached? Are you using a scratch built power supply? If so are all the power supply filter caps tied together close to the negative terminal on the power supply rectifier. Considerable current exists in this path and if you stretch that out, a large voltage drop is developed at power line frequencies across your grounds. When building power supplies, one needs to think of a single point where all power supplies grounds tie together. Then a single wire from that point out to your board. This way, all the filter current passes through the component leads and not through the circuit being powered. Let me know what you find. I will check CD each day if you need any help.
sciguy125
30-06-2006, 00:13
Ok, this problem is bothering me so much that I've decided to forego tonights other activities to try and figure this thing out.
I'm powering the circuit using an everyday wall transformer. The output is rated for 9V 500mA, but I'm not drawing enough current so it hangs out at about 14V. I'm using a 7805 to power the PIC. There's also a 7806 for some other stuff. Everything downstream of the 7805 is drawing ~20mA. When the PIC freaks out, the current drops to near 0, again supporting the idea that it's resetting or otherwise turning off.
Here's what the scope's giving me: http://ratlab.dyndns.org/scope/1/
There is some noise in the supply with a period of ~17ms, ~60Hz. It's amplitude is slightly different in each of my test cases, but is about 200mV. I guess this is something from the power line.
Recomendations?
Al Skierkiewicz
30-06-2006, 07:34
Phil,
Great pictures, now we are talking. The output waveforms from the wall transformer are normal outputs of a full wave rectifier with very little filtering or too great a load. Not ususally a problem for a 78XX when the lowest part of the waveform is still 2 volts greater than the output. Look close at this waveform and you will a lot of fuzz on the ripple. Since you have a dual trace scope, if you were to put your other probe on the output of the 7805 you would see that the two occur at the exact same time. If you were to delay trigger on the noise you are going to find it is a fairly high frequency, <1MHz. Since it is locked to the line, you have local interference from a line operated device. Most likely a dimmer. If you have a dimmer in your house, try turning it to a different brightness and the period of the noise will change. This could be a fan control, a touch on/off lamp or a wall dimmer. (X10 dimmers are the same.) This could also be caused by a bad switching power supply but that is pretty rare.
The fact that the waveform gets worse when you touch the backplate just indicates that there is a strong field picked up by your body and capacitively coupled to the backplate.
In rare cases, this could be caused by a bad insulator on the power line. Take an AM radio and tune it to a station that is not close to your house. See if you hear hum in the audio and then use the radio to point you to the offending device either inside or out. Am radios use a bar antenna and the greatest sensitivity is along the axis of the bar. By turning the radio you can get an idea of where the culprit actually is. If it turns out to be a bad insulator, you need to contact the power company and tell them you have interference from their equipment. They are required to make the repairs, although not in a timely fashion.
You may be able to make things happy by grounding the back plate to the ground in your house. Run a wire from the chassis of the scope to the backplate and see if that makes things better or worse.
Once you get this part cleared up, we can talk about the what the waveforms on the power transformer are telling you.
sciguy125
07-07-2006, 00:40
Ok, I'm back.
My experiments with the radio didn't turn out so well. I hear a distinct hum on any empty AM frequencies on all the radios that are plugged into the wall. I'm resonably sure that it's from the line because I've heard that same hum from things that I know are produced by the line. My battery powered radio doesn't have the same hum, but there is something there. However, it doesn't show up on all frequencies, just the lower ones, ~<750kHz. The other problem is that everything that runs on electricity produces some kind of noise if I bring the radio close enough. I can hear my computer think. There's also all sorts of cool noises at work.
Back on the oscilloscope, however, things have changed. For some reason, I can't reproduce what I had before. But, while I was in there, I decided to take a look at the line. It's definately a sine, but there's some irregularities on the falling side (going toward 0V) of each peak. It looks symetrical, so whatever is introducing the noise is only happening at a certain voltage (positive and negative).
I added more pictures to the same page: http://ratlab.dyndns.org/scope/1/
Any more insights before I turn off the power room by room to eliminate an internal source?
Al Skierkiewicz
07-07-2006, 07:37
Phil,
The noise you are looking at is likely the same. In the upper photos, you were at 5ms/div in the most recent you are at 20ns/div. The distortion in the line voltage is unusual. How were you attaching the scope to the line? There is a possibility that someone attached to the same transformer as your house has something unusual connected to the power line. The distortion you see can occur when the power transformer is trying to supply more than it was designed for. In my area, residential power line transformers are typically feeding no more than eight individual homes. Design varies for different parts of the country.
The hum in all the radios is indicative of the problem. You need to walk or drive around the neighborhood with your battery op radio and try to loacte the problem. Broadband over power lines (BPL) has been a hot subject in ham radio circles for a couple of years now. I have no personal experience with the issues but the system produces wideband noise sufficient to wipe out communications for ham radio operators. There is a system (Motorola) that uses radio frequecy filters at ham, TV and radio frequencies to prevent interference.
Let me know if you find anything. Whenever I have had local hum, a quick drive around the neighborhood with the car radio on AM will usually locate the insulator. There is no doubt when you drive under the offending pole. If you live near high voltage lines, this will be much harder to find. High voltage lines have insulators that break down all the time. In your case the noise will get worse on rainy days or those days just following a rain.
sciguy125
15-09-2007, 15:44
I hope nobody minds that I revive my own thread.
I've been working on the problem on and off since my last report. To sum it up, I've found nothing. I've gone through the house and tried unplugging anything that might make noise and couldn't find the source. All I figured out is that most of the outlets in the house don't have ground. (That's 50's wiring for you...) However, I managed to try one that is grounded and it has the same noise.
I've given up on trying to track down the source of the noise and fixing it. I've turned to trying to filter it out. Do you think a power line conditioner would work? Something like this or similar:
http://www.apc.com/resource/include/techspec_index.cfm?base_sku=LE1200
I'm guessing that it won't because the UPS I have on my computer doesn't filter out the noise. But can someone point me to a device that would?
I'm about to start my senior project and I would be really nice if I could do some work at home.
JBotAlan
15-09-2007, 18:58
I'm guessing that it won't because the UPS I have on my computer doesn't filter out the noise. But can someone point me to a device that would?
Just a little factoid: none but the really *really* expensive UPSs actually do line filtering. The UPS on your computer probably doesn't filter the line at all, but will look filtered when disconnected from mains power supply. It might be a true sine wave, but I think that they generally use a stepped wave that bears similarity to a sine wave (that's the way most inverters work; and that is all a UPS is--a battery with an inverter and a charger in one box).
So it's not surprising that the UPS isn't filtering the noise. I'd be curious to know if the disconnected UPS (beeping away) would fix the problem with your circuit.
Good luck,
JBot
Kevin Sevcik
15-09-2007, 19:05
Phil,
Most consumer "UPS"s are, in fact, "SPS"s. Standby Power Supplies. So while there's still adequate power available from the mains, the SPS only filters it slightly before passing it along. A true UPS is always running its inverter from the DC supply that's charging the battery. FYI, anything that's going to really filter your power is going to run you around $100. That said, you're looking for a power conditioner or line conditioner. Be suspicious of anything that looks like a standard strip-plug.
With my experience with micro controllers, a steady power supply is definitely required. Even with my Homework Board that I used to run my "Weather Alert" system with, simply flipping a switch on and off would cause the micro controller to freeze and reset. After I added a large capacitor to the input power insulated with diodes and a voltage regulator, the problem seemed to be fixed. I think a 5V voltage regulator, some diodes, and a fairly large capacitor may help you. I'm not familiar with PIC controllers though, so this may not work, but hopefully it does. Also, have you considered that something may be wrong with your oscilloscope? Maybe like it is "shocking" your setup causing your problems. I would listen to Al though, he seems to be a veteran at everything electrical. Good luck.
Al Skierkiewicz
16-09-2007, 16:52
Phil,
Since you had power line related noise when on battery, using a power conditioner is not going to improve anything. The distortion on the power line is an indication of a transformer failure. It can be caused by a variety of things including too much of a load for the transformer size. It can also be caused by the transformer arcing internally. The arcing coincidently can cause generated noise. Remember spark gap transmitters? Everything points to something locally generated. Where is the power line transformer in relation to your house? Have you tried taking your experimenter board to a friend's house a couple of blocks away? The display on the scope indicates a rather strong field.
Just to be sure, many appliances still maintain a power supply even when turned off. I came across a rather nasty TV power supply when I was trying to setup a ham station in a hotel room a few years ago. The only way to cure some things is to unplug them from the wall.
sciguy125
16-09-2007, 17:18
Phil,
Since you had power line related noise when on battery, using a power conditioner is not going to improve anything.
If it's running only on the battery, it's fine. However, when I connect the scope (even only the ground), it starts acting up. I just tried a different board (smaller and without a metal back plate) and found that the problem is much worse. I can't even get the thing to turn on unless I start poking at things with my finger. And, yes, I'm sure it's the noise, not a bad connection.
Anyway, I'm two houses down from the transformer (probably ~100'). If I make one more run and eliminate everything inside the house, what should I do? Should I talk to the power company?
Al Skierkiewicz
17-09-2007, 07:23
Phil,
This is a strange one, that is for sure. It is possible you have a bad ground connection in the house. At the entry point, (usually the power meter or the electrical breaker panel) the neutral must be tied to a good earth ground. Usually this is a green wire tied to water pipe. (It depends on local electrical codes.) Sometimes this wire goes inside the panel and sometimes it just connects to one of the conduits near the panel. Check that all connections outside the box are tight and not corroded. DO not enter the box. This is the realm of a professional. If you still can't find a cure, it might be time to call the power company. You said in an earlier post that line operated AM radios had hum (off station) but battery operated radios inside the house did not. If this is the case, it just adds one more piece that doesn't fit.
I still would like to see what the effects are at a friends house or at school. It sure seems like there is a lot of noise riding on power wiring or ground connections at your house.
Uh... can you try making up your own power supply on board? Maybe as simple as just a low-value resistor and a capacitor to filter out high/low frequency noise... maybe wrap your incomming power wire around a ferrite to cut ultra-high-frequency harmonics.
Strange problem... but i sympathize. I had a motion control board I built this summer that worked ONLY when the scope was connected. So... I feel you.
-q
sciguy125
18-09-2007, 12:15
I emailed the power company, but I haven't gotten a response yet (not that I'm really expecting one). I looked at their power quality info and, from what I can tell, this kind of noise isn't their responsibility. If I were feeling really adventurous, and I could prove that the power lines are radiating, I could probably get the FCC involved...
Anyway, I wanted to run an experiment, but I wanted to make sure that I won't hurt myself. My scope, of course, has a ground screw on the back. If I find a suitable ground for it (maybe a water pipe or the one that the cable guy seems to have installed on the breaker panel), I want to try grounding it directly. Is this a worthy/safe experiment?
Al Skierkiewicz
18-09-2007, 13:35
Phil,
If you cannot find a connection to ground for your breaker panel then you might try a different experiment. If you scope has a three wire power cord, plug it in near where the water enter the house. Then touch the scope probe center pin to the pipe and see what kind of noise you get. If you get no noise, then the electrical system is likely grounded to the water pipe. If the noise is a higher level then at your bench, there may be something wrong with your house. If that is the case and you cannot find a tie in to the water pipe, the cable attachment may have made things worse. I would suspect you have a ground connection but it may be loose or corroded. If you do find the connection, you may want to use an alligator clip to shunt it directly to the pipe and see if things improve.
The power company first response is to say they are not responsible for fixing noise. If it originates in their equipment, it is most definetely their responsibility. I have never had to call the FCC on these matters when I have told them I am looking at their line with a scope. The only way for you to actually look at the line with a scope is through an isolation transformer. Some scopes allow you to display the trigger signal which would give you the same thing. If your scope has a "trigger view" or "view trigger" or "display trigger" function, then select that and then select "line" trigger to see what is coming in the power line.
sciguy125
18-09-2007, 16:18
I figured it out! (mostly...)
It was indeed a ground problem. None of the outlets in the house are grounded. I know that because I personally replaced all of the old 2 prong outlets with GFCI about 2 months ago.
I discovered, using my meter, that the outlets in the garage are properly grounded. (Acutally, I guess it only proves that ground and neutral are connected at some point, not that the system is properly grounded...) My mistake was thinking that the distortion I was seeing in the line was the cause of the problem. So, when I was trying to find what was causing it, I only looked at my scope, not the problemed circuit. After using an outlet in the garage to test my circuit (with a real power supply rather than the transformer...I can't find it right now) it works fine. Not surprisingly, the distortion in the line is still there. So, that distortion isn't the problem, the ground is.
So, I've figured out that to work, all of my equipment needs earth ground. Using a 2 to 3 prong adapter (isolating ground) makes it mess up again. Why is this? I would have thought the opposite would be true.
Al Skierkiewicz
18-09-2007, 22:14
Phil,
You have to look at what is causing the noise to be displayed on the scope. If the scope does not have a ground reference either through the power cord or the ground clip on the probe (or both) then everything that the scope is connected to is now 'raised' above ground. This means that everthing between the scope and a real ground is acting like an antenna and inducing noise in that resistance. Old Ohm's Law comes into play, an induced current through a finite resistance develops a voltage across the resistance. You still have a noise source in your neighborhood and I still suspect it is power related due to a transformer or insulator defect. You have just found out why everything is picking up the noise and one method to minimize it. I think you will continue to be plagued by this and will eventually find it. I am reminded of a broadcast problem where a radio station had lots of noise and it was being picked up by everything in the studio. A search with a scope showed excessive noise on the ground buss of the audio console. A bright engineer noticed that the noise was audio modulation. When they detected the noise they found it was the competitors transmit signal. A quick search showed that the competitor was licensed at an address outside of town so no one thought it would be a problem. However, the studios were located outside of town, but the transmitter and antenna were on the building across the street. Normally radio studios keep the drapes closed but when someone opened them for some light, there was this antenna directly across from the studio window. Keep searching and you will find it.
Good news that annother problem has been solved.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.