33 Replies Latest reply on Nov 24, 2014 10:52 PM by nilay007

    mcp23017 resets and relays stop working!

    nilay007

      Hello,


      I have attached AC fan as load to my SainSmart 8 Channel DC 5V Relay Module.

      The relay board is supplied with external power supply(5V,1Amp).The relay board is controlled by MCP23017(gpio expander ic connected to my raspberry pi).

      The fan is with Regulator.Sometimes when i change speed from regulator the ic is reset and relays stop working.

        • Re: mcp23017 resets and relays stop working!
          jw0752

          Hi Nilay,

          Could you clarify your explanation of the circuit setup. You mention an AC fan but how are you powering the AC Fan. I guess the most likely cause of the problem is a voltage spike or voltage dip is pulsing your power feed to the logic circuitry. This in turn causes the logic circuitry to reset. Usually you can protect yourself from this by using decoupling capacitors on the power rails or by isolating the power supply to the logic circuitry from the power management circuitry.

          John

          1 of 1 people found this helpful
            • Re: mcp23017 resets and relays stop working!
              Problemchild

              Sounds very much like it John, I assume it's some kind of speed controller rather than a regulator as such. If so and it switches at any old time rather than say at zero crossing the spikes could indeed be quite large however it's amazing it does this considering those relay modules also have opto isolation and he's using a different power supply.

               

              Nilay can you lay out your circuit diagram so we can see it ...cheers

              1 of 1 people found this helpful
            • Re: mcp23017 resets and relays stop working!
              jw0752

              Hi Nilay, I see nothing intrinsically wrong with your layout. The fan may be creating enough of a spike when the speed changes to affect the house mains. Depending on the sophistication of your 5 volt supplies this spike may be getting through. Try putting 100 uF caps across the Vdd - Vss on the Pi and MCP23017. The only other possible situation is if the Pi and MCP boards are very close to the 240 volt power feed to the AC we might be getting some inductive coupling.

              John

                • Re: mcp23017 resets and relays stop working!
                  nilay007

                  Thanks alot  sir,

                  il surely try with the capacitor and let you know the results soon.

                  just a doubt, the spikes that i observe are bcoz of the speed regulator from relays reseting the ic .so why to set up the capacitor between pi and ic and not between relays and ic ?

                    • Re: mcp23017 resets and relays stop working!
                      jw0752

                      Hi Nilay, The capacitors should go between the power rails, as close to the boards as possible. Watch the polarity. I sugested one capacitor between the power rails for the Pi and one capacitor between the rails of the MCP as they are the most susceptible to spikes. You did indicate that it was the MCP that was resetting. Give it a try and if it doesn't solve the problem let us know. John Alexander is following this thread too and he is actually a lot more knowledgeable than me and he will let us know if there are better options to try.

                      John

                        • Re: mcp23017 resets and relays stop working!
                          michaelkellett

                          It's hard to be sure but another possibility to look for is that the regulator is opening and closing the mains circuit causing large very high frequency transients. If you set up the fan and regulator not connected to your relays but with the wires physically close does it still affect the rest of the circuit ? If it does then you will need to do something about the regulator but I'm not quite sure what (without knowing what is inside it.) If the problem only occurs with everything connected you could try winding the two wires GND and GPA0 from the MCP32017 to the relay board several times round a ferrite lump (like Farnell 2364660).

                           

                          MK

                            • Re: mcp23017 resets and relays stop working!
                              nilay007

                              Hello Michael,

                              I dont think its just the regulator thats creating the problem. As even when i switch fan relay on off in succession there is the same effect as of regulator that is resetting of mcp. Also i would like to mention its only the fan that resets the mcp and not other appliances connected to relays like lights or switch sockets .

                                • Re: mcp23017 resets and relays stop working!
                                  michaelkellett

                                  The fan may be a much more difficult load than the lights - but if switching the relay makes it go wrong only if it's the fan that is switched then it is probably something to do with the characteristics of the fan/regulator combination.

                                  I should mention that you need to be very very careful using the Sainsmart board to switch mains voltages - you must be very careful with your wiring and make sure things are in a box and firmly screwed down. You could try putting  a transient suppressor across the relay contacts for the fan - something like this:

                                   

                                   

                                     

                                   

                                  Manufacturer: EPCOS

                                   

                                   

                                   

                                   

                                  TAKE CARE WITH MAINS !!

                                   

                                  MK

                                    • Re: mcp23017 resets and relays stop working!
                                      Problemchild

                                      Good idea since the Fan is an  inductive load and as Michael says make sure that all the equipment especially the mains equipment is bolted down to some board to keep it neat and safe.

                                       

                                      Out of interest does this problem occur if you use a normal light bulb (incandescent not florescent) if it's ok then most likely the inductive nature of the fan is most likely your problem.

                                      • Re: mcp23017 resets and relays stop working!
                                        mcb1

                                        I'm not seeing a pullup resistor between the SCL and SDA lines to 3v3 (which is what the Pi GPIO is).

                                        If there is no 4k7 resistor the lines will be floating and very susceptible to any spikes.

                                         

                                        The capacitors across the supply lines are very worthwhile, but spikes are best dealt with by adding a 0.1uF (100nF) capacitor in parallel to the 100uF capacitor.

                                        The mains inrush/switching should not be enough to do any resetting.

                                         

                                         

                                        The relays can be controlled with the Pi, but you may need to reduce the series resistor (usually 1000 ohms) in series with the opto and run it from 3v3 while powering the relays from 5v.  It means you don't need the MCP23017.

                                         

                                        Mark

                                          • Re: mcp23017 resets and relays stop working!
                                            michaelkellett

                                            It won't be the mains inrush current that is the problem (that would be worse with incandescent lights) but more likely the inductive spike when the relay controlling the fan is opened. I did mean to suggest that Nilay should try to find out if the errors are triggered by turning the fan on or off.

                                             

                                            MK

                                              • Re: mcp23017 resets and relays stop working!
                                                mcb1
                                                Sometimes when i change speed from regulator the ic is reset and relays stop working.

                                                 

                                                This was mentioned at the start, and could be triggering the SCL and SDA lines, which makes the MCP23017 reset the relay.

                                                 

                                                First thing is add the pull-ups and the capacitors and then see.

                                                 

                                                 

                                                Mark

                                                • Re: mcp23017 resets and relays stop working!
                                                  nilay007

                                                  Sir, mov is not making any differnece to the cirkuit (i.e. the spikes still reset the ic).i have connected it across the relay contacts .i have used v14k 275v mov since my mains is 250v.is it the right value? i also tried 1 across the load (fan) still no use. please help.!

                                                    • Re: mcp23017 resets and relays stop working!
                                                      mcb1

                                                      Nilay

                                                      Have you added pullup resistors on the SCL and SDA lines to 3v3 as I mentioned earlier.?

                                                       

                                                      A 275v MOV is primary designed to conduct when the voltage exceeds 275v AC and IMO won't fix spikes when the contact opens.

                                                      I doubt that an induction motor fan will generate enough energy to be causing it, it will be the 5v relays.

                                                      The question is does it happen when you don't have the fan connected.?

                                                      What happens if you switch the mains off, but leave the fan connected.?

                                                       

                                                      If you could mark the capacitors on your drawing and repost, we might be able to see if there is something overlooked.

                                                      You have shown a ground connection running from the RPi ground and the power supply. Is this actually connected to anything or is just a symbol.?

                                                       

                                                      Mark

                                                        • Re: mcp23017 resets and relays stop working!
                                                          michaelkellett

                                                          The MOV shouldn't be connected across the relay contacts but across the load.

                                                           

                                                          Definitely do the experiment with the fan removed (but I think we have established that the problem only happens with the fan and that lamps are OK).

                                                           

                                                          And you must add those pull up resistors.

                                                           

                                                          How about a full circuit and some pictures - it's often hard to fix this kind of issue when the device is on the bench in front of you - it's really hard to pin it down at long distance.

                                                           

                                                          MK

                                            • Re: mcp23017 resets and relays stop working!
                                              nilay007

                                              oh yes definitely sir its my privilege that my thread got noticed and guided by experts like John Alexander. i do share the same concern what john sir mentioned earlier that inspite of such a stable circuitry of sain smart relays (opto isolation) voltage spikes is affecting my MCP.Anyways ill try out the capacitors and get back here with the results in a while. 

                                        • Re: mcp23017 resets and relays stop working!
                                          nilay007

                                          I would like to inform you all that a capacitor across vdd and vss has helped .. slight voltage spike upto 2-3v is observed but its not resetting the mcp anyways. thanks to everyone who contributed ,specially John Wiltrout sir as you suggested the capacitor.

                                          further i would like to ask is there any effect of the voltage spike on relays in future?. I read it somewhere that this spike eventually damage the relay .

                                            • Re: mcp23017 resets and relays stop working!
                                              jw0752

                                              Hi Nilay, Every time that a relay opens and closes under load there is some wear to the contacts. This is particularly true of large loads and inductive loads. Micael Kellert suggested a good part to put accross the relay contacts that will minimize the wear. The other thing that is important is to make sure the contacts are rated for the voltage and current that is demanded by your load. Solid state relays do have a softer contact and release but they have their own set of side effects. If you want to power heavier loads with the small relays just use the small relay to power a larger relay. The other thing that can damage a relay quickly is if it is chattering (turning on and off rapidly) under load. For this reason make sure you are incorporating hysteresis into your design.
                                              John

                                            • Re: mcp23017 resets and relays stop working!
                                              nilay007

                                              1st image is the circuit with capacitor across vdd and vss which is succesfull in protecting the spikes ( reducing enough to not reset the mcp).

                                              2nd image is when i tried the mov across the load as well as across the relay contacts later. both places mov failed to protect from spikes and eventually reset.20141124_153746.jpg20141124_154119.jpg

                                              .

                                              • Re: mcp23017 resets and relays stop working!
                                                nilay007

                                                but stil can there be any spike suppression on the AC main line before relays? and what can be the reason for mov failure?!