cancel
Showing results for 
Search instead for 
Did you mean: 

Weird I2C problem stm32f4 switch 230V coil

kenny__84
Associate II
Posted on July 22, 2013 at 14:02

Hello everybody

I have the weirdest problem on my i2c....

I have some pcf8574's connected on my stm32f4Discovery and the work like a charm

(thanks Clive1.....)

But now i have connected some 5V relays which also work fine and they have to switch on some 24V relays and everything there works perfectly untill i let the 24v relays switch a 230VAC coil. Then my PCF will just switch all outputs high and when i switch a few times than the I2C hangs on EV6 flag...

This also happens when i switch the coil by pressing the relay so it's some kind of inductance :s

Any ideas?

#i2c-stm32f4
15 REPLIES 15
crt2
Associate II
Posted on July 22, 2013 at 14:38

Make Farady cage around all elements (tin foil around them - just watch that you dont touch the elements) which can be influenced by electrical or magnetic interference  - that includes i2c wires. If you can plug in some oscilloscope you will probably observe some funny behaviour caused by interference. Also all this might be dependant on good grounding of everything and how you have connected everything together (circuit design)

kenny__84
Associate II
Posted on July 22, 2013 at 15:49

Okay thank you for your quick response!

I tried some foil here and there and it didn't work. (This was all that was possible)

I can't redesign now so i have to drop I2C from my project.

In this prototype I need an absolute stable solution and I2C has not proven to be just that for now.

Although i don't want to i will go in another direction.

Thank you for your time!

dthedens23
Associate II
Posted on July 22, 2013 at 16:52

you are looking at an ESD nightmare.  You need all sorts of traps, filters, suppressors, opto isolated in/outputs, and isolated supplies.  If the 230V coil is anywhere near the other parts, then the EMI in the air alone, will be enough to cause problems.

good luck

kenny__84
Associate II
Posted on July 22, 2013 at 17:24

Thank you, i appreciate your input on this!

Do you guys think that in a future project RS or TTL will be an option to expand IO ?

I am a prototyper so noise is something i just have :s

I use the GPIO now and that works like a charm (but you'd expected that i guess)

dthedens23
Associate II
Posted on July 22, 2013 at 20:04

It is generally cheaper to spec a micro controller with more pins than it is to do some port expander.  I suppose one reason to use an expander would be isolation as well as distance.  I much prefer SPI over I2C.

kenny__84
Associate II
Posted on July 23, 2013 at 07:26

okay thanks!

In the future i will not be using i2c in 230vac applications

crt2
Associate II
Posted on July 23, 2013 at 11:11

As much as you're describing it is not I2C problem really - any serial (or parallel for this matter) connection has possibility to corrupt in such ESD environment. Tin foil here and there will not solve anything (distortion can hit anywhere really). You need Faraday insulation all around to make this workable. It is not really such big problem to make this happen if you have small elements up to relays - for example you can buy ESD wires (or just wrap wires into foil), you can then wrap rest of components into foil and that will surely solve your current i2c problems.

Mostly the longer wires are a problem with all connections.

kenny__84
Associate II
Posted on July 24, 2013 at 18:54

Thank you, it's difficult to change everything now to shielded wires and such, because time is 

running low.

In the future i will create everything shielded from the ground up!

Is it only the bus that needs to be shielded?

Or would it be better to shield from supply to relay for this?

crt2
Associate II
Posted on July 25, 2013 at 09:15

Dont get this explicitly since I'm guessing but you probably dont have 100m i2c cable, so you can make this shield very very fast. I would primary shield bus wires and you can shield them together (like suggested tin foil wrap around can be done in few minutes even if cable is somehow long). Then run a test. After that shielding the circuit nearest to coil is next. etc., you get the idea. You dont need to ''ground'' the foil for start, but you need to keep it connected so that it all is on same potential. Inside you'll create an ''OK'' EM field... But that's just prototype thinking 😉

Since I suspect this are not room-sized elements (not the coil and relays), you can wrap everything in foil much faster than to develop a new software (especially since you claim you already tested this-one and it works)