29 Replies Latest reply on Apr 25, 2019 11:34 AM by gurnaldo

    16*2 LCD getting weird characters

    jrcs

      Hi all.

       

      This is my first post so I hope it is at the right place.

       

      I'm working on a project whose objective is to control two ac loads (one ac fan, controlled by phase angle control and one ac motor controlled by a 5V relay) and output to an LCD the room temperature and the % of fan speed.

       

       

      The code I wrote seem to work fine without the AC loads connected. I tested it for long periods of time (+12 hours) and everything is ok.

       

      The problem is when I connect both (or just one) AC loads, I always end up with my LCD info corrupted like this:

       

      WP_20160627_005.jpg

       

      https://1drv.ms/i/s!Ah12lhUG5VG8g9FOhR9Y0ccFTsq2Rg

       

      Sometimes past 2 minutes, sometimes past 10 minutes... It's random but it always end up like this.

       

       

      I'm guessing it's noise problems due to the loads switching TRIAC/Relay. The TRIAC its connected trough a optocoupler but the relay it's directly connected to the arduino.

       

       

      First, I put the lcd.clear() function in my code to "rebuild" the info from time to time but it doesen't work 100% and it's not a "clean" solution for the pourpose.

       

       

      The AC loads are connected to the grid but the arduino is powered from my computer's usb port. Already put an EMI filter into AC main input of my loads but no solution.

       

      Is there a solution to this problem? Any help?

      Sorry for my poor english but I'm a little bit rusty.

       

      Regards

        • Re: 16*2 LCD getting weird characters
          WarrenW

          How are you driving the relay from the arduino? Direct off the micro or via a transistor? Does the relay have a snubber cap across the coil and a back emf diode? Does the arduino have a filter capacitor near the supply rails?

          All things to look for to prevent the back emf.

           

          Also you may be getting induced noise in your supply from the triac switching, again check for supply noise with a scope perhaps?

           

          HTH

          Warren.

            • Re: 16*2 LCD getting weird characters
              jrcs

              Hi sir,

               

              I don't have a scope (and that's a problem, I know).

               

              The relay is a module (SRD-05VDC) and yes, it's being driven directly from the arduino.

              No filter near the supply rails. You mean a cap through vcc and gnd supply right?

               

              I'll try to get my hands on a scope in the next few days.

               

               

              Regards.

            • Re: 16*2 LCD getting weird characters
              peteroakes

              Can you please provide a schematic of your setup and also a full picture (Cant see all your connections in the one provided. You can upload them right into this community post.

               

              I have done what your describing on several occasions and not run into mains based issues so this is why I am interested to se how everything is wired

               

              You should not need a scope to fix this and if the LCD is connected as I think it is, then the scope will not help a lot.

              Thanks

              • Re: 16*2 LCD getting weird characters
                lui_gough

                What is your setup? It appears maybe you have some inducted noise interfering with communications from the board. Maybe you have long LCD bus lines which are more prone to picking up interference from the AC mains, which you should re-route, shorten, or maybe even use shielded cable. Perhaps try isolating the relay power supply lines from the LCD lines by having separate ground wires (in the case you've commoned them up on a breadboard in a "bus" fashion). I would also suggest increasing the separation between a phase control device and the arduino, as many of those devices have high in-rush currents when "cutting in", and this can result in significant EMF generation. Another possibility is that you might have short voltage dips when switching your phase-control dimmer (information might be necessary), so perhaps try thicker Vcc/GND leads to the display and bypassing the supply with a sizeable ceramic/MKT polyester + electrolytic capacitor at the display itself could help.

                 

                - Gough

                • Re: 16*2 LCD getting weird characters
                  dougw

                  It sounds like your arduino is not crashing, just the display is getting corrupted data.

                  You can try checking the clocking signals to the display - make sure they are low impedance connections not running close to high voltage AC wires.

                  Try disconnecting the clocking signals and grounding the display clocks at the display to confirm everything else is running properly and no random characters get clocked into the display. If random characters still show up, then the power supply to the display becomes the next most likely issue - put a large capacitor across the display power supply. Try moving the AC parts of your circuit further away from the digital parts.

                  • Re: 16*2 LCD getting weird characters
                    clem57

                    I would go so far as having the breadboard for the LCD diferent from the one for the higher voltage.

                    clem

                    • Re: 16*2 LCD getting weird characters
                      jrcs

                      Hi all,

                       

                      Thank you all for your time.

                       

                      I took a picture today of the system today. It's not very "clean" but I was really short on time to test it. You can see it here: https://1drv.ms/i/s!Ah12lhUG5VG8g9FU0eNo8CpDdW1WYQ  I'll try to post the schematic later today when I arrive home.

                       

                      I have done some measurements with a scope with a borrowed scope. The 5V supply is getting lots of spikes when I open or close the relay (more when I close it so I only took pictures of closing).

                       

                      This is what I measure: https://1drv.ms/i/s!Ah12lhUG5VG8g9FRBvXyADPi7U7WZQ

                       

                      Then I add 2x470uF capacitores to 5V: https://1drv.ms/i/s!Ah12lhUG5VG8g9FS6mhCWvuhGU6JZw

                       

                      Not very helpfull. So I was reading around and added a snubber in paralel with the motor to see if it gets any better: https://1drv.ms/i/s!Ah12lhUG5VG8g9FTdvyVX-heJbancA

                       

                      So, basically I think the problem is the coil on the relay that is giving me all this spikes.

                       

                       

                      I measured the system with the phase angle control and I get some noise at low firing angles but it doesn't seem to be enough for the problem... the noise is very low.

                       

                       

                      Thank you all in advance.

                      • Re: 16*2 LCD getting weird characters
                        jrcs

                        The schematic it's this but with arduino Mega.

                        • Re: 16*2 LCD getting weird characters
                          jrcs

                          Hi neilk

                           

                          I'm sorry I haven't made myself clear. The relay is a module driven by a transistor. A module like this: http://www.elecfreaks.com/store/images/BK_SRD.jpg

                          You can see it in the photo of the system itself.

                           

                          The arduino is not directly driving the relay coil. I'm using the module. I'm sorry for my mistake.

                           

                          Regards

                            • Re: 16*2 LCD getting weird characters
                              neilk

                              Understood. However, is the module being powered from the same supply as the Arduino?

                                • Re: 16*2 LCD getting weird characters
                                  jrcs

                                  Yes. The module's VCC and GND are the same as the Arduino (laptop usb port or usb charger. I have tried with both solutions)

                                    • Re: 16*2 LCD getting weird characters
                                      mcb1

                                      The simpliest way to verify which part is causing it is to eliminate one item at a time.

                                       

                                      You can remove the lamp, then the ventilator.

                                      I suspect that the mains side is not the issue, so move to the control side.

                                       

                                      I'd suggest removing the 5v power feed to the relay first as this is likely to cause a spike, which drops the volts and upsets the LCD.

                                      As you have said it's quite likely this is the cause.

                                       

                                      In order to provide isolation you could try feeding the power to the relay via a diode.

                                      Add a 470uF (preferably bigger) on the relay side of the diode.

                                      This will help keep the spikes away from the Arduino supply.

                                       

                                      The rule of thumb for filter caps is 1000uF per amp.

                                      Because these are spikes something around 10,000uF is going to help along with a 0.1uF cap as well.

                                       

                                      Mark

                                      1 of 1 people found this helpful
                                        • Re: 16*2 LCD getting weird characters
                                          mcb1

                                          Just a thought.

                                          You appear to have a zero crossing detector.

                                          The purpose is to switch the load when it is at zero, which is fine.

                                           

                                          I don't suppose the relay output is being switched ON/OFF as it goes past the zero cross point.??

                                          In theory it should just switch ON when the zero point is detected and stay ON.

                                           

                                          The easist way to prove it is to short the pin to ground and recheck for switching noise.

                                           

                                           

                                          Mark

                                        • Re: 16*2 LCD getting weird characters
                                          dougw

                                          That relay module has a built-in snubber diode. It takes about 80 mA at 5V so be sure your supply is okay with that.

                                          The noise you show is definitely switching noise, not just ac coupling. You can isolate the display and MCU (separately) by placing a small resistor or inductor in the power supply wire and low ESR capacitor on the digital side. It may be useful to feed the digital side through a Schottky diode and also the relay power through a separate diode. You could add an LDO regulator if all else fails.

                                          1 of 1 people found this helpful
                                    • Re: 16*2 LCD getting weird characters
                                      jrcs

                                      Hi all.

                                      Thanks in advance for your help. I'll try to answer to all of you clearly but I know my english it's not very good (nor technical).

                                       

                                      mcb1 When I disconnect just the ac motor from the relay (and keep the relay coil connected and controlled by the Arduino) the noise disappears. Could it be the AC motor producing the spikes?? I added a snubber circuit just to be sure but didn't help.

                                       

                                      The lamp (is actually a AC Fan) is not the problem. It is controlled by phase angle control and being connected or not doesn't change the spikes.

                                       

                                      If I remove the 5v power to the relay coil I have no spikes... but the motor obviously doesn't turn on so...

                                       

                                      I've put a flyback diode directly into the relay coil aswell but didn't help.

                                       

                                       

                                      The zero crossing detector is just to trigger the triac and power the AC Fan (Ventilador).

                                      The AC motor connected to the relay is turned on for a few seconds (3 to 10 seconds) and off for 40 seconds regardless of zerocross detected or not... but I can try to change the program to only switch the relay when zerocross is detected.

                                       

                                       

                                      dougw the supply on the laptop's usb port can give 500mA and the usb charger can give 2A. I tried both ways and got the same result.

                                       

                                      A small resistor/inductor and a capacitor in the power supply wire ? In the whole system supply wire or just the relay supply wire?

                                      I'll try to learn how to feed the digital with the Schottky diode.

                                       

                                       

                                      Thank you all for your time.

                                      Regards.

                                        • Re: 16*2 LCD getting weird characters
                                          mcb1

                                          Cheers for checking.

                                          You could try using a 230/240 lamp instead of the motor as a test.

                                          A lamp is resistive (rather than inductive like a motor) and it will help prove it.

                                           

                                          Rather than change software, if you short the output of the zero cross, it will always think its at zero.

                                          You could then put the power onto the 5v relay when it suits and see if the LCD corrupts.

                                           

                                           

                                          The picture you provided shows a lot of wires.

                                          The mains is fed back onto the board for the zero cross and the Triac.

                                           

                                          My concern is that you may have the neutral and the ground connected somehow.

                                          It could be via the power supply

                                           

                                          You could connect a switch across relay contacts and see if pressing it (which will make the motor run) also corrupts the LCD.

                                           

                                           

                                          Two other minor observations.

                                          1. The filter caps you have are close to the LCD, but they are quite a way from the Arduino. One across the 5v and ground plugged on top of the proto board wouldn't hurt.

                                          2. The schematic shows the base of the zero cross output transistor floating. I've found that a 47k between the base and emitter stops any issues.

                                           

                                           

                                          Your english and explanations are fine ... much better than mine in your language ...

                                          Mark

                                          • Re: 16*2 LCD getting weird characters
                                            dougw

                                            Just filter the power to the low power circuit being affected by the noise (the LCD and arduino)

                                            1 of 1 people found this helpful
                                          • Re: 16*2 LCD getting weird characters
                                            jrcs

                                            Hi mcb1

                                             

                                            I don't have any lamp available so I didn't test it with a lamp.

                                             

                                            I've been reading around and I found that adding a capacitor in the relay's output connections would help. The thing is when the relay latches and delatches creates an electric arch strong enough to mess up with the coil and the 5V supplying it!

                                             

                                            I add a 0.33uF capacitor and I get better. I didn't have any LCD problem for 20 minutes (way more time than before!) and this is what I've got on the scope with the capacitor plugged in:

                                             

                                            WP_20160706_002.jpg

                                            Now, I don't know if this is an "acceptable" spike. I don't think so but I'm not and expert. It obviously isn't a perfect solution though.

                                             

                                            Another thing, when I turn on/off the system's 230V connection, I get some noise too. (Just by turn the 230V switch on). Is there any easy way to get rid of this "switch on noise"?

                                             

                                            Thanks in advance

                                            Regards

                                            1 of 1 people found this helpful
                                              • Re: 16*2 LCD getting weird characters
                                                dougw

                                                Some fancy systems use a triac to turn on AC - where the triac circuit is designed to only turn on when the voltage is crossing zero - this minimizes turn-on noise.

                                                Can you use a solid state relay? It should have less spark noise.

                                                • Re: 16*2 LCD getting weird characters
                                                  mcb1

                                                  Joao

                                                  when the relay latches and delatches creates an electric arch

                                                  You're quite correct ... this will happen and does so with capacitive and inductive loads much more than resistive loads.

                                                  This is why relays are de-rated for inductive loads.

                                                   

                                                  If the 0.33 gets you past the problem, then its acceptable.

                                                  Did you have LCD problems 20 mins later or was that how long you ran it for.?

                                                   

                                                  I think dougw is right about using the MOC3041 and triac to drive it.

                                                  This will remove all problems, and if you require a much higher current then use the triac to turn on a 230v relay coil which switches the fan.

                                                  It will switch at zero so the noise should not be present.

                                                   

                                                  Mark

                                                • Re: 16*2 LCD getting weird characters
                                                  niko.vicencio

                                                  Hi

                                                   

                                                  I had the same problem, the lcd showed random characters when the electromechanical relay commutated. I solved this problem, changing the relay by a ssr (Solid state relay). I hope that my answer help you.

                                                   

                                                  Nicolás

                                                  2 of 2 people found this helpful
                                                  • Re: 16*2 LCD getting weird characters
                                                    D_Hersey

                                                    For a pure inductive load, switching at the zero crossing is stressful on the switch

                                                    2 of 2 people found this helpful
                                                    • Re: 16*2 LCD getting weird characters
                                                      gurnaldo

                                                      Hi,

                                                      I was facing same problem.

                                                      But I solved it by switching AC inductive loads through 24v relay and also having different power supplies for Arduino and relay and no common ground between them.

                                                      And do use optocoupler to operate the relay.

                                                      Thanks and regards,

                                                      Gurpreet

                                                      1 of 1 people found this helpful