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:	8
Size:	108.1 KB
ID:	1266722

    Click image for larger version

Name:	2018-12-15 02.09.43-1.jpg
Views:	8
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.532: 1963 Devices 1141 Events
          Z-Wave 3.0.1.261: 122 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.532: 1963 Devices 1141 Events
              Z-Wave 3.0.1.261: 122 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

                  Working...
                  X