Menu

One Shot Signal from an external Input

Help
Keith
2022-01-15
2022-01-20
  • Keith

    Keith - 2022-01-15

    Once again my coding skills are letting me down and I’m having a hell of a rare old time with the code for a garage door opener. It works fine with the Remote Fob, the receiver output is a momentary High signal over two outputs defined as RemoteUp and Remote Down.

    This all works fine, but what I want to do is to introduce a WiFi Device which has a SPCO relay output which Latches to either state. This Latching condition is what is causing me major headaches as what it is doing preventing the Fob Inputs from working correctly.

    Ideally some sort of code which will convert the latching condition from the WiFi switch to a momentary One Shot over both WiFi_Input1 and WiFi_Input2

    Or another way of writing the code to make it ignore the Latching inputs. As always, any help would be most appreciated.

    This is the offending part of the code so far, The full code is attached below.

       Do While RemoteUp Xor WiFi_Input1 = 1 And ShutterPosition = 0
         ShutterPosition = 1
         ShutterMove = 1
       Loop
    
       Do While RemoteDown Xor WiFi_Input2 = 1 And ShutterPosition = 1
          ShutterPosition = 0
          ShutterMove = 1
        Loop
    
          'ShutterMove
          '********************
     Do While ShutterMove = 1 And  ShutterPosition = 1
        CCOUNT = 1
        Set ProgLedGrn On
        Set ProgLedRed Off
        Set ShutterUp On
        Set ShutterDown Off
        ShutterMove = 0
        Flag = 1
     Loop
    
     Do While ShutterMove = 1 And  ShutterPosition = 0
        CCOUNT = 1
        Set ProgLedRed On
        Set ProgLedgrn Off
        Set ShutterUp Off
        Set ShutterDown On
        ShutterMove = 0
        Flag = 0
    
     Loop
    
               'E-Stop
    
     

    Last edit: Keith 2022-01-15
  • Keith

    Keith - 2022-01-15

    Full code

     
  • Anobium

    Anobium - 2022-01-16

    Clearly I do not fully understand the issue but from my scan - I would recommend a state engine using select-case removing all the Do-Whiles.

     
  • mmotte

    mmotte - 2022-01-16

    How about something like this

     ProgLedGrn = 0
        ProgLedRed = 0
    
     Main:
    
        Do forever
    
             If RemoteUp =1 Then
                open_door
                Wait 500 ms      ' this wait may not be needed and is only for not retriggering the sub
    
             ElseIf RemoteDown = 1 Then
                close-door
                Wait 500 ms      ' this wait may not be needed and is only for not retriggering the sub
    
             ElseIf WiFi_Input1 = 1 And Old_WIFI = 0 Then       ' You realy only need one of the WIFI inputs because they are always opposite
                Old_WIFI = 1
                open_door
    
             ElseIf WiFi_Input1 = 0 And Old_WIFI = 1 Then
                Old_WIFI = 0
                close_door
    
             End If
    
        Loop
    
    sub open_door
        ProgLedGrn = 1
        ProgLedRed = 0
        PulseOut ShutterUp, 1 sec       'Turn ShutterUp on for 1 sec .. time can be also ms like 500 ms 
    end sub
    
    sub close_door
        ProgLedGrn = 0
        ProgLedRed = 1
        PulseOut ShutterDown, 1 sec       'Turn ShutterDown on for 1 sec
    end sub
    

    I have not compiled this but only suggesting program flow.
    GL
    Mike

     
  • Keith

    Keith - 2022-01-18

    Thank you Mike, sorry for not getting back to you sooner, I'm having some PC issues which I'm sure a good kick in the USB's wouldn't go amiss. To be honest it is probably so full of my cr@p it is damn near full.

    That's an interesting routine and one I'm keen to try out.

    One thing that I have found in the WiFi App is that it is possible to program it to give a momentary one shot.
    To confuse the issue they have called it "Inching" and the inching duration can be adjusted down as low 500 mS which with some jiggling around with the code make work without the issues it is giving me previously.

     
  • Keith

    Keith - 2022-01-18

    Thank you Mike, sorry for not getting back to you sooner, I'm having some PC issues which I'm sure a good kick in the USB's wouldn't go amiss. To be honest it is probably so full of my cr@p it is damn near full.

    That's an interesting routine and one I'm keen to try out.

    One thing that I have found in the WiFi App is that it is possible to program it to give a momentary one shot.
    To confuse the issue they have called it "Inching" and the inching duration can be adjusted down as low 500 mS which with some jiggling around with the code make work without the issues it is giving me previously.

     
  • mmotte

    mmotte - 2022-01-20

    Keith,
    Most garage door remotes I have been associated with are only "one button" , one output. push it to go up when it is down. push it to close when it is open.

    Yours has an up button and down button. So does your wifi receiver have two relays?

    If it does then you would not even need a PIC to arbitrate and give an output. the relays could be wired as OR logic and you would be done.

    Best Regards
    Mike

     

Log in to post a comment.