Announcement

Collapse
No announcement yet.

Input problem [SOLVED]

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

    Input problem [SOLVED]

    Hi,

    I have problems with the input signals. They switch on and off, but also when I do not want to ....
    My longest cable (utp6) with a switch is 25 meters from the Arduino located and, I think, and the cable picks up disturbance.
    Now I want to change the input method to:


    Code:
    If (input signal == LOW)
    {
    wait for 500ms
     if  (input signal still is LOW) 
     {
     send status to homeseer
     }
    else
    {
    do nothing with this input
    }
    }
    If this is implemented in the sourcecode I prevent that a wrong (peak) signal will activate some events in homeseer and wake me up at 3am....

    I already set the debounce but this makes no difference (tried it with 5000ms in homeseer and in the arduino code, but switch is directly on in homeseer)
    I did also some hardware on the input (10nF to ground,100R to +VDD , 10uF over the input.) but no real changes.
    The Arduino sees less then 3V as a zero and here is the problem, peaks can be also negative and so less then 3V.

    So I tried to solve it in the software from Greig.

    If anyone has the same problem they can solved with only a few lines of code (the bold one).
    Find the Input Setup-part in the homeseerboardXX.ino, and change into:

    Code:
    //*********************************Input Setup*******************************
    byte InPinArray[30] = { 0 };
    byte Debounce = 300;
    byte count = 0;
    byte NoOfInPins = 0;
    int InStateArray  [(sizeof(InPinArray) / sizeof(InPinArray[0]))];
    unsigned long PrevDebounce [(sizeof(InPinArray) / sizeof(InPinArray[0]))];
    
    void InputCheck() {
      byte pinread;
      byte pinread2;
    
      for (count = 0; count < NoOfInPins; count++) {
        if (millis() - PrevDebounce[count] > Debounce) {
          pinread = (digitalRead (InPinArray[count]));
    
    
            for (int w = 0; w < 10; w++)
            {
              //******* modification for  input errors **************** 20151026 Alex Houben
              delay (1);
              pinread2 = (digitalRead (InPinArray[count])); //digital read is approximately  9ms
              if (pinread != pinread2)
              {
                return;
              }
            }
    ....
    ....
    ....
    


    Compile it with Arduino1.5.6-r2, upload and ready.
    Now it runs for 2 weeks and now no more waking up at night anymore!
    Me so happy!


    Alex
    Last edited by dreambox; November 10, 2015, 07:55 AM.

    #2
    The new beta supports this. It is in the updater.

    Greig.

    Sent from my SM-G925F using Tapatalk
    Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
    X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
    Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
    Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
    Scripts =
    Various

    Comment


      #3
      Originally posted by enigmatheatre View Post
      The new beta supports this. It is in the updater.

      Greig.

      Sent from my SM-G925F using Tapatalk
      Hi Greig,

      Correct my if I am wrong but you are talking about this part:
      Code:
       if(millis() - PrevDebounce[count] > Debounce){
            pinread = (digitalRead (InPinArray[count]));
            if (InStateArray[count] != pinread && WaitForAck == false){
              InStateArray[count] = pinread;
              PrevDebounce[count] = millis();
              Send(BoardAdd); 
              Send(" I ");
              Send(count+1); 
              Send(" ");  
              Send(pinread); 
              Send();
              WaitForAck == true;
            }
          }


      If I see it well then you only wait for the debounce, but what happens if there is are spikes how have HIGH's and LOW's during or directly after the debounce?
      With this there is not compare during the read. Is it not better to combine debounce and compare?

      Situation button pushed:
      - wait for debounce is finished,
      - read input a few times
      - if input still the same after this few times then input value is valid


      Situation spike:
      - wait for debounce is finished,
      - read input a few times
      - if input has a different values the input value is invalid -> do nothing


      Alex
      Last edited by dreambox; November 11, 2015, 05:25 AM.

      Comment


        #4
        No this is the old code. Is this the .99 sketch? If so then it has not updated properly and I will need to look at this build.

        Sent from my SM-G925F using Tapatalk
        Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
        X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
        Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
        Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
        Scripts =
        Various

        Comment


          #5
          Originally posted by dreambox View Post
          Hi,

          I did also some hardware on the input (10nF to ground,100R to +VDD , 10uF over the input.) but no real changes.
          The Arduino sees less then 3V as a zero and here is the problem, peaks can be also negative and so less then 3V.

          Alex
          Hi Alex, I had had similar problem. Tried with capacitor, resistor+capacitor, debunce... my solution: optocoupler! (1N35)

          Comment


            #6
            Originally posted by khriss75 View Post
            Hi Alex, I had had similar problem. Tried with capacitor, resistor+capacitor, debunce... my solution: optocoupler! (1N35)
            Have you tried beta .99?

            Sent from my SM-G925F using Tapatalk
            Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
            X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
            Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
            Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
            Scripts =
            Various

            Comment


              #7
              Originally posted by dreambox View Post
              Hi Greig,

              Correct my if I am wrong but you are talking about this part:
              Code:
               if(millis() - PrevDebounce[count] > Debounce){
                    pinread = (digitalRead (InPinArray[count]));
                    if (InStateArray[count] != pinread && WaitForAck == false){
                      InStateArray[count] = pinread;
                      PrevDebounce[count] = millis();
                      Send(BoardAdd); 
                      Send(" I ");
                      Send(count+1); 
                      Send(" ");  
                      Send(pinread); 
                      Send();
                      WaitForAck == true;
                    }
                  }


              If I see it well then you only wait for the debounce, but what happens if there is are spikes how have HIGH's and LOW's during or directly after the debounce?
              With this there is not compare during the read. Is it not better to combine debounce and compare?

              Situation button pushed:
              - wait for debounce is finished,
              - read input a few times
              - if input still the same after this few times then input value is valid


              Situation spike:
              - wait for debounce is finished,
              - read input a few times
              - if input has a different values the input value is invalid -> do nothing


              Alex
              I can confirm that this is the old code. It is definitely different in .99. I can also confirm that with .99 I have been unable to get a bounce with any testing.

              Comment


                #8
                Originally posted by enigmatheatre View Post
                Have you tried beta .99?

                Sent from my SM-G925F using Tapatalk
                Hi Greig,
                not already tried beta .99, but my problems was generated from spikes (checked on oscilloscope). Optocoupler solve the spikes problem (I work with 12V on long cable...).
                The only issue that I can report, is a random delay in response: sometimes i push button and I have to wait about a second to change the status (light on or off).

                Comment

                Working...
                X