Announcement

Collapse
No announcement yet.

Digital Input On GPIO Pins Fluctuates Quickly From Off - On - Off - On

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Digital Input On GPIO Pins Fluctuates Quickly From Off - On - Off - On

    As I am about to install the Water valve with the feedback connections to confirm fully open or fully closed (it does this with micro switches at the endpoints of the travel on either open or closed) I see the RaspberryIO register Off - On - Off - On intermittently. Things I did to troubleshoot this:
    • First had Pullup resistor setting in plugin wired to GPIO pin and Ground
    • Then tried switching to pull down resistor wired to GPIO pin and 3.3V
    I also noticed on boot-up with nothing connected to the GPIO inputs, it sometime registered ON until I manually closed circuit and then opened it again, then the status would be correct.
    1. Is there a reliability issue to using the internal pullup or pulldown resistors on the Pi for accurate readings on the Input status?
    2. Should I used an external Pull-up or Pull-down resistor instead for reliable readings?
    3. It seems like the voltage at the Input GPIO pins is floating and hits a threshold every so often and that triggers a state change in RaspberryIO even though nothing has changed on the real input at all.
    4. What could I do to make this very reliable and accurate?

    Here is a debug log with NO CHANGES being made to the actual input at all... just leaving it alone over time... As you can see if goes off then on in the same second...

    Code:
    Dec-14 7:50:20 PM         RaspberryIO    DEBUG Pin17 value changed to On
    Dec-14 7:50:19 PM         RaspberryIO    DEBUG Pin17 value changed to Off
    Dec-14 7:39:37 PM         RaspberryIO    DEBUG Pin17 value changed to On
    Dec-14 7:39:37 PM         RaspberryIO    DEBUG Pin17 value changed to Off
    Dec-14 7:32:43 PM         RaspberryIO    DEBUG Pin4 value changed to Off
    Dec-14 7:32:43 PM         RaspberryIO    DEBUG Pin4 value changed to On
    Dec-14 7:31:49 PM         RaspberryIO    DEBUG Pin4 value changed to Off
    Dec-14 7:31:49 PM         RaspberryIO    DEBUG Pin4 value changed to On
    Dec-14 7:31:41 PM         RaspberryIO    DEBUG Pin4 value changed to Off
    Dec-14 7:31:41 PM         RaspberryIO    DEBUG Pin4 value changed to On
    Dec-14 7:31:29 PM         RaspberryIO    DEBUG Pin4 value changed to Off
    Dec-14 7:31:29 PM         RaspberryIO    DEBUG Pin4 value changed to On
    Dec-14 7:31:28 PM         RaspberryIO    DEBUG Pin4 value changed to Off
    Dec-14 7:31:28 PM         RaspberryIO    DEBUG Pin4 value changed to On
    Dec-14 7:31:18 PM         RaspberryIO    DEBUG Pin17 value changed to On
    Dec-14 7:31:18 PM         RaspberryIO    DEBUG Pin17 value changed to Off
    ---------------------------------------------------
    Jean-Marie G. Vaneskahian
    jean@vaneskahian.com
    ---------------------------------------------------

    #2
    So I disabled the on-board pull-down resistors and built a breadboard with the physical pull-down resistors and connected them to the water valve on GPIO#25 and GPIO#27... Same exact problem!

    My best guess is that this may be caused by induced current in the pins due to the long cable run to the valve. I do have an idea however looking at the logs.

    Click image for larger version

Name:	2018-12-15 02.09.36-1.jpg
Views:	179
Size:	108.1 KB
ID:	1266722

    Click image for larger version

Name:	2018-12-15 02.09.43-1.jpg
Views:	156
Size:	113.4 KB
ID:	1266723

    Code:
    Dec-15 2:06:46 AM         RaspberryIO    DEBUG Pin25 value changed to Off
    Dec-15 2:06:46 AM         RaspberryIO    DEBUG Pin25 value changed to On
    Dec-15 2:06:08 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 2:06:08 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 2:05:49 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 2:05:49 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 2:04:16 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 2:04:16 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 2:01:44 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 2:01:44 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:57:32 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:57:32 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:52:32 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:52:32 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:47:43 AM         RaspberryIO    DEBUG Pin25 value changed to Off
    Dec-15 1:47:43 AM         RaspberryIO    DEBUG Pin25 value changed to On
    Dec-15 1:47:31 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:47:30 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:46:25 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:46:24 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:42:26 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:42:26 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:40:59 AM         RaspberryIO    DEBUG Pin25 value changed to Off
    Dec-15 1:40:59 AM         RaspberryIO    DEBUG Pin25 value changed to On
    Dec-15 1:37:41 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:37:41 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:36:14 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:36:14 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:35:15 AM         RaspberryIO    DEBUG Pin25 value changed to Off
    Dec-15 1:35:15 AM         RaspberryIO    DEBUG Pin25 value changed to On
    Dec-15 1:34:49 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:34:49 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:31:10 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:31:10 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:24:03 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:24:03 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:22:41 AM         RaspberryIO    DEBUG Pin25 value changed to Off
    Dec-15 1:22:41 AM         RaspberryIO    DEBUG Pin25 value changed to On
    Dec-15 1:20:16 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:20:16 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:19:29 AM         RaspberryIO    DEBUG Pin25 value changed to Off
    Dec-15 1:19:29 AM         RaspberryIO    DEBUG Pin25 value changed to On
    Dec-15 1:12:49 AM         RaspberryIO    DEBUG Pin25 value changed to Off
    Dec-15 1:12:49 AM         RaspberryIO    DEBUG Pin25 value changed to On
    Dec-15 1:03:12 AM         RaspberryIO    DEBUG Pin25 value changed to Off
    Dec-15 1:03:12 AM         RaspberryIO    DEBUG Pin25 value changed to On
    Dec-15 1:00:56 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:00:56 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 1:00:29 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 1:00:29 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 12:59:46 AM         RaspberryIO    DEBUG Pin25 value changed to Off
    Dec-15 12:59:46 AM         RaspberryIO    DEBUG Pin25 value changed to On
    Dec-15 12:58:33 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 12:58:33 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    Dec-15 12:58:21 AM         RaspberryIO    DEBUG Pin27 value changed to On
    Dec-15 12:58:20 AM         RaspberryIO    DEBUG Pin27 value changed to Off
    All of the "bounces" of the input occur very quickly and the state does not stay for more than a fraction of a second. You will notice that if the state in On for a Pin, it eventually reverts back on On, and vice versa.

    Could the plugin allow for a variable "debounce" timer? In other words, if the state does not change and remain for longer than a variable period that the user defines the plugin assumes there was no change in state of the input. Looking at my logs, if I were to set my debounce timer to 1 second, it would filter out all this bouncing noise.

    Can this be done Spud?

    Thanks for your help. I am sorry about bugging you all, but I really thought this would be alot easier that it has ended up being. I appreciate all the help and patience!
    ---------------------------------------------------
    Jean-Marie G. Vaneskahian
    jean@vaneskahian.com
    ---------------------------------------------------

    Comment


      #3
      +1 for configuring a debounce time

      Verstuurd vanaf mijn SM-G965F met Tapatalk

      Comment


        #4
        It does not change my need for a debounce function in the plug-in, but I have discovered the source of the problem. The use of a LONG wire to the micro-switch is the issue. When I simply change the circuit on the breadboard from using the long cable to the switches to replacing that with a simple jumper on the breadboard the problem disappears. The Pi apparently is very sensitive (even with the pull-down resistors) to any transient current / voltage that can be induced on the long wire. Since it is very transient by nature, it shows up as random, very fast fluctuations in the state of the input. A variable debounce function in the plugin would address this completely.
        ---------------------------------------------------
        Jean-Marie G. Vaneskahian
        jean@vaneskahian.com
        ---------------------------------------------------

        Comment


          #5
          Use a shielded cable and make sure the shield is bonded to ground. That should eliminate most issues.
          HS 3.0.0.548: 1990 Devices 1172 Events
          Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

          Comment


            #6
            sparkman, I am sure you are correct, in this case, I really cant do that. Plus I am surprised that the Raspberry Pi is so susceptible to these transient inputs from the induced voltage / current. I am curious (EE is not my specialty), what makes the digital inputs on my Elk Alarm panel or even a cheap Insteon IOLinc digital input not susceptible to this issue and the Pi susceptible? Do the operating voltages have something to do with it (The Pi only has a range of 3.3V to work with on the input for determining 1 or 0)?
            ---------------------------------------------------
            Jean-Marie G. Vaneskahian
            jean@vaneskahian.com
            ---------------------------------------------------

            Comment


              #7
              What kind of cable are you using? A good twisted pair cable will be better too if you are not using that already. Yes, the lower the voltage range the more susceptible to noise the circuit will be.
              HS 3.0.0.548: 1990 Devices 1172 Events
              Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

              Comment


                #8
                I will look into adding a debounce option to the plug-in, but I think you can basically achieve the same thing by using a "this device has been exactly On for 1sec" trigger instead of "this device changes and becomes On"

                Comment


                  #9
                  Spud that does not work... I tried that..
                  • Say the Valve is Open and that sets Pin 27 to On.
                  • When I create an event based on the state of the device and set it to "this device has been exactly On for 1 sec"
                  • Then what is happening is that the event still triggers every time the Pin 27 fluctuates from On to then quickly Off - On... It just triggers 1 second after it stays on.
                  • You still get a trigger for every fluctuation

                  Here is an example from the log again, there was not actual state change to the valve state. This would be addressed if the code on the Rasperry Pi did not inform HomeSeer of the change in the state of the input until it checked the state again after the "debounce" interval (if the state is still changed, then inform HomeSeer, if the state has reverted back to the original state, then that was just a transient fluctuation and should not be reported to HomeSeer as a real input change). This eliminates HomeSeer traffic and processing by HomeSeer.

                  Code:
                  Dec-15 1:46:08 PM         RaspberryIO    DEBUG Pin25 value changed to Off
                  Dec-15 1:46:08 PM         RaspberryIO    DEBUG Pin25 value changed to On
                  Dec-15 1:45:57 PM         RaspberryIO    DEBUG Pin25 value changed to Off
                  Dec-15 1:45:57 PM         RaspberryIO    DEBUG Pin25 value changed to On
                  Dec-15 1:45:28 PM         RaspberryIO    DEBUG Pin25 value changed to Off
                  Dec-15 1:45:28 PM         RaspberryIO    DEBUG Pin25 value changed to On
                  Dec-15 1:45:21 PM         RaspberryIO    DEBUG Pin25 value changed to Off
                  Dec-15 1:45:21 PM         RaspberryIO    DEBUG Pin25 value changed to On
                  Dec-15 1:45:20 PM         TTS    Speak ():The Main Water Valve Is Now Fully Open
                  Dec-15 1:45:20 PM         Event    Event Trigger "Device Status Change Main Water Valve - Is Fully Open"
                  Dec-15 1:45:17 PM         RaspberryIO    DEBUG Pin27 value changed to On
                  Dec-15 1:45:17 PM         RaspberryIO    DEBUG Pin27 value changed to Off
                  Dec-15 1:44:58 PM         TTS    Speak ():The Main Water Valve Is Now Fully Open
                  Dec-15 1:44:58 PM         Event    Event Trigger "Device Status Change Main Water Valve - Is Fully Open"
                  Dec-15 1:44:56 PM         RaspberryIO    DEBUG Pin27 value changed to On
                  Dec-15 1:44:56 PM         RaspberryIO    DEBUG Pin27 value changed to Off
                  Dec-15 1:44:53 PM         TTS    Speak ():The Main Water Valve Is Now Fully Open
                  Dec-15 1:44:53 PM         Event    Event Trigger "Device Status Change Main Water Valve - Is Fully Open"
                  Dec-15 1:44:52 PM         RaspberryIO    DEBUG Pin25 value changed to Off
                  Dec-15 1:44:52 PM         RaspberryIO    DEBUG Pin25 value changed to On
                  Dec-15 1:44:51 PM         RaspberryIO    DEBUG Pin27 value changed to On
                  Dec-15 1:44:51 PM         RaspberryIO    DEBUG Pin27 value changed to Off
                  ---------------------------------------------------
                  Jean-Marie G. Vaneskahian
                  jean@vaneskahian.com
                  ---------------------------------------------------

                  Comment


                    #10
                    I just had this same issue. I have three inputs going to three relays looking for a close connection. 2 worked fine and the other fluctuated between on-off-on-off. The wires are short, maybe 25 inches in length. I tried pull-up/pull-down nothing would cure this problem. I switched to an arduino with the HS arduino plugin and it works perfect, no phantom issues. Also I used the debounce setting there to ignore an relay bounces

                    Comment


                      #11
                      Here is a possible solution to the noise issues on RPi inputs. RPi inputs are voltage dependent inputs and as such, are sensitive to induced voltages like you would see on relatively long cable runs. To make a long cable run and eliminate induced voltages you need a current loop input. This is why industrial analog transducers are usually 0-20ma or 4-20ma devices. An easy way to make these inputs a current loop is to use an opto-isolator with a transistor output like an ILD74. The opto-isolator would be physically located at the RPi. The transistor collector would be attached to the RPi Input point and the transistor emitter to the RPi ground. A 1K pullup resistor would be attached from the collector to the RPi 3.3v output. The diode side of the opto-isolator would need an independent 5vdc source, (don't use the 5v source on the RPi) a series 2K ohm resistor and your series wired valve switch. The diode side of the isolator would be activated when your switch closes. Since the drive for the LED side of the opto-isolator is a current loop it will be immune to electrical noise. A 0.1uf disc ceramic bypass capacitor across the collector and emitter of the opto-isolator will further reduce noise and provide some contact de-bouncing.

                      Comment


                        #12
                        This problem has started happening to me. I have not spent much time trouble shouting yet but it is the same problem as the opening post. My remote pi has been working perfectly for many years and now this is happening. I would love a debounce function like mentioned above. I will try the event option like Spud suggested but by the sounds of it, this will not work. My config and hardware has not changed, moved or anything! Could it just be the PI has had enough and needs replacing ?

                        Let me know if anyone has overcome this.

                        Thanks

                        Dan

                        Comment


                          #13
                          Tired another pi today and saw the same intermittent On / Off behaviour.

                          I also tried the recommendation from spud using the event to control the problem. Unfortunately I had the same results that jeanv reported.

                          My next thing is to try a replaced the relay board on my alarm system that is connected to the pi. ahhhhhh.

                          Comment


                            #14
                            I just helped someone with a debounce circuit as described here for relay closure monitoring (although this is for another input device and not a Pi).
                            --------------------------------------------------
                            **** Do You "Cocoon"? ****

                            Comment

                            Working...
                            X