gulliverrr
Posts: 38
Joined: Wed Jan 02, 2013 1:38 pm

I2C strange interference by mains

Thu Mar 28, 2013 11:45 pm

Hello Pi'ers,

I have a wheezy setup with a java application talking to an LCD screen (2x16 LED) over I2C.
The applications monitors 2 buttons (GPIO 17 & 24 - normally HIGH) and controls 2 LEDs (from GPIO 14 & 15 straight to GND without -incorrectly- a resistor).
I have noticed that sometimes after leaving the setup on for about a day, during which time the buttons won't be pressed but the LEDs will turn ON and OFF from the java app, the screen shows garbled text instead of the information (time and temperature among the various info). I thought it was a java error that I would debug later but yesterday I noticed something I would never imagine.

As the RasPi was happily displaying its stuff on the screen I removed a (switched off beforehand!) desk lamp from the same mains multisocket the RasPi's power supply is and then magically the display went into gibberish mode! I restarted the RasPi, retried the same unplugging scenario and the problem was very easily reproduced! For the record, the power supply is an original Samsung 2A mains from a Galaxy Tab which I assume it is reliable. Maybe Ill try with my digital lab psu to rule out the chance of being a somehow faulty psu that causes this effect some levels further down from the power supply. Something even stranger is that after a few attempts (re-plugging and unplugging) the gibberish switched back to normal. Carrying on (re-plugging and unplugging) after a attempts again the gibberish was on.
The fact that the lamp was off before unplugging really confuses me. The lamp has no transformer either. Just the standard electrical switch. So practically only passive components were added. Can these cause EMFs and even so, what part of RasPi can be affected so much from such interference? My 20ish short jump wires on my RasPi and LCD?

Obviously I can avoid playing with my lamp while I use my RasPi but I am wondering what could cause this and if I can protect my design from it.

Your help will be very much appreciated as I have seen I2C and garbled text issues on google but none are related to my problem

User avatar
Jim JKla
Posts: 2218
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: I2C strange interference by mains

Thu Mar 28, 2013 11:51 pm

First step check your lamp wiring. ;)
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

gulliverrr
Posts: 38
Joined: Wed Jan 02, 2013 1:38 pm

Re: I2C strange interference by mains

Fri Mar 29, 2013 12:40 am

Check for what? What "symptom" of the cable could give anyone a hint towards any assumption?

gulliverrr
Posts: 38
Joined: Wed Jan 02, 2013 1:38 pm

Re: I2C strange interference by mains

Fri Mar 29, 2013 1:31 am

I just want to confirm that I tried the lab power supply and the bug is still reproducible, so its not the power supply causing it :(
Is there any I2C initialisation function I could be safely calling often enough without clearing the text so that I could recover in the unfortunate event if I dont find a solution?

Thanks!

User avatar
elektrknight
Posts: 140
Joined: Sat Mar 02, 2013 1:25 pm

Re: I2C strange interference by mains

Fri Mar 29, 2013 3:22 am

From the description you have provided looks like you might have a wiring problem in your
mains multisocket. Your PSU test seems to confirm this, but you can still try plug/unplug
test with something other then the desk lamp. If the problem persist then you will know that
this is the source of the problem.

The other possibility is the problem with 5V you are using to power the LCD. I am assuming your
LCD is the 1602 smart type, if this is the case then it could be picking up some EMF noise when
you plug, unplug desk lamp. This would be especially likely if the 5V is not quite the 5V or it is a noisy
5V. You can easily test the first case by measuring the voltage with the volt meter, the second case
would require an oscilloscope to see what happens when plug/unplug the desk lamp.
Placek Malinowy to jest to!

User avatar
Jim JKla
Posts: 2218
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: I2C strange interference by mains

Fri Mar 29, 2013 1:00 pm

Check the wiring on your desk lamp unplugging and plugging to find fault elswhere is a shure method to get yourself electrocuted if theres some fault in the lamp wiring. The next port of call is the mains socket.

It's unlikely it is the RPi causing this it is just the effect in the cause effect loop.
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

gulliverrr
Posts: 38
Joined: Wed Jan 02, 2013 1:38 pm

Re: I2C strange interference by mains

Sun Mar 31, 2013 12:02 am

Here's my update:
1. Tried an adafruit python script to display a clock on the LCD. Tried my plugging test and gibberish appeared. So my code is ruled out
2. Tried another (Rev2 - my original error was on a Rev1) RasPi board. Error reproducible. So my board is ruled out
3. Tried another USB psu. Error reproducible. So my psu is again ruled out
4. Cut precise length wires to replace the long jumper leads on the breadboard and I feel error is appearing less often. Unfortunately I cannot measure this as it was not happening after x unplug-replug attempts. Either way, error is still there, even less frequent, so I still need to find a way programmaticaly to cleanup and init the 4-bit parallel mode bus to the LCD.

will update soon

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: I2C strange interference by mains

Sun Mar 31, 2013 1:14 am

Try short neat wiring, if wires are via a ribbon cable to something like a cobbler connect all the GND pins at the cobbler end together to reduce number of aerials.

Add 100nF or larger cap by the LCD for its 5V supply to decouple noise

Try 100nF capacitors across your switches to see if that reduces pick up

EMI/RFI/EMC problems are always difficult and just the way the cables run can cause problems.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

gulliverrr
Posts: 38
Joined: Wed Jan 02, 2013 1:38 pm

Re: I2C strange interference by mains

Sun Mar 31, 2013 4:08 am

Thanks techpaul!
Will try the caps and grounding the spare GNDs too. Didn't try that. Although Im not sure if RasPi Rev1 boards (mine) have spare GNDs on the unused pins as the Rev2 does.
The wiring is as neat as possible. Yes it is something like a cobbler I made myself with a ribbon to get all pins on the breadboard.

As a plan B solution, if I dont fix this properly, is that I call the init function of the LCD before every 20th write (1 every second), so you see an instant flick every 20 seconds. I find this acceptable but it is only hiding the problem, not solving it.
Will update after I try your suggestions too!

Sun is out... time to go to bed :)
Thanks again!

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: I2C strange interference by mains

Sun Mar 31, 2013 8:51 am

Can you give more details and perhaps a picture of the lamp?
If it's switched off, it's kind of strange it gives such behavour.
Have you tried to ground your Pi minus? Usually it's floating with most power supplies.
Is your power block one with a buildin filter ans surge protector, or is it just passing the wires?

gulliverrr
Posts: 38
Joined: Wed Jan 02, 2013 1:38 pm

Re: I2C strange interference by mains

Sun Mar 31, 2013 10:40 am

The magic a little ceramic 100n cap can do! thechpaul it worked! Thank you so much ;)

For the record obcd I could reproduce the error with a simple C8 cable like this one:
Image
with nothing on the other end! Weird huh!? Also the power usb cable has no filter inline. Im not sure about the power supply though. Its from a (expensive) Samsung tablet. I would assume it has some sort of protection but then again I tried a proper lab psu on 5V and the problem was there...
* Grounding the spare GNDs did not change the problem.
* Adding the cap on LCD's power did not change the problem. I had the buttons removed trying to simplify the setup.
* Doing both did the trick!

Im so releaved! It was a bugger!
Thanks again Paul!

User avatar
Jim JKla
Posts: 2218
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: I2C strange interference by mains

Sun Mar 31, 2013 11:18 am

Given that it happened with the simple C8 cable as described I would suspect there is some sort of issue with your home wiring.

Especialy given the number of RPi users out there who have never seen this problem. ;)
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

User avatar
cyrano
Posts: 714
Joined: Wed Dec 05, 2012 11:48 pm
Location: Belgium

Re: I2C strange interference by mains

Sun Mar 31, 2013 12:48 pm

From what I read, I'd replace the wall socket. It smells as if you can trigger sparks by plugging in a cable with no load. A problem with a mechanical origine, in other words.

Sparks will produce a short but very strong RFI burst. Enough to interfere with most gear nearby, but sparks might just cause fire too. And it's the kind of problem that will get worse...

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12212
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: I2C strange interference by mains

Sun Mar 31, 2013 12:53 pm

either that or there is RF noise on your mains, maybe a sparking electro-motor (refrigerator maybe) induces RF on the mains, and you wire simply acts like an extra antenna.

User avatar
Jim JKla
Posts: 2218
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: I2C strange interference by mains

Sun Mar 31, 2013 2:25 pm

Either way something needs looking into. ;)
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

User avatar
bgreat
Posts: 235
Joined: Mon Jan 23, 2012 2:09 pm

Re: I2C strange interference by mains

Sun Mar 31, 2013 3:59 pm

I do not know how the I2C display is wired, but I have seen similar issues when separate power supplies are used for the controller and display when the grounds are not connected common. If the display is not connected to the Raspberry Pi power supply, the display power supply ground must be connected to the Raspberry Pi ground for a common signal reference.

Enjoy!
Bill

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: I2C strange interference by mains

Sun Mar 31, 2013 5:16 pm

If two power supplies are being used one for Pi and one for other hardware check the GND connection.

Sometimes adding wire will do strange things, it could be a home wiring problem but I suspect pickup a C8 lead coiled or straight, with no load is still acting as a transmitting aerial. Probably too close to your kit.

Consider a screened box for your Pi etc connected to mains earth. Check to see if the power supply has a connection between mains earth and its negative lead (GND).
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

gulliverrr
Posts: 38
Joined: Wed Jan 02, 2013 1:38 pm

Re: I2C strange interference by mains

Mon Apr 01, 2013 9:24 pm

I dont have 2 PSUs. The LCD is powered by the RasPis power via the GPIO header. I believe it is the multisocket although it is a fairly proper one by Legrand. I suspect this as I tried in another room in my house with a different multisocket and the error is gone. The suspicious one also holds my desktop tower, my speakers (hmmm...) and my 2 LCD PC monitors.

Eitherway it may be something that will never happen again but I feel more relaxed having this rare scenario covered as random people may use this device Im making.

By the way Paul, how did you come up with this 100n value or do you know this purely out of experience?

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: I2C strange interference by mains

Mon Apr 01, 2013 11:16 pm

Mostly experience, been designing and fixing circuits and micros for too many years
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

Return to “Troubleshooting”