Announcement

Collapse
No announcement yet.

Timed Button

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

  • Timed Button

    I've been trying to make a timed momentary button but with no success. I don't see anything in the Configurator to add a timer to just that button. I want to click it and then it activates the output for like 15 seconds. I tried changing the minimum_delta_vote_time on the upclick properties but it doesnt work as planned.

  • #2
    use the button to set a variable to some number, then logic that decrements that variable every processing cycle. once that reaches 0, logic to set the output to off

    Comment


    • #3
      So if the logic timer is set for 100 that would mean that it would run the logic 10 times in one second, correct?

      So if i made a button that sets a variable to 50 then a logic statement that

      "IF variable > 0 THEN output on AND -1"

      and another one

      "IF variable = 0 THEN output off"

      that it should take around 5 seconds for it to run through all that 50 times and shut it off?

      Comment


      • #4
        Originally posted by bratnetwork View Post
        So if the logic timer is set for 100 that would mean that it would run the logic 10 times in one second, correct?

        So if i made a button that sets a variable to 50 then a logic statement that

        "IF variable > 0 THEN output on AND -1"

        and another one

        "IF variable = 0 THEN output off"

        that it should take around 5 seconds for it to run through all that 50 times and shut it off?
        yup. exactly.
        Fusion Brain Version 6 Released!
        1.9in x 2.9in -- 47mm x 73mm
        30 Digital Outputs -- Directly drive a relay
        15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
        Buy now in the MP3Car.com Store

        Comment


        • #5
          Ok here is what I have:

          Button:
          Code:
          <button id="WINDOWS_DOWN" enabled="yes" function="change variable" functionTargetID="window_timing" vote_opinion="51" vote_priority="Medium">
                  <images imagePrimary="content\images\button_images\button_down.png" imageSecondary="content\images\button_images\button.png" imageDisabled="content\images\button_images\button.png" imagePushed="content\images\button_images\button_down.png"></images>
                  <display size="230,70" location="287,75" page="0" z_order="0.9"></display>
                  <vote_options minimum_delta_vote_time_down="20"></vote_options>
                  <text font="verdana" font_size="25"></text>
                  <text colourPrimaryARGB="255,255,255,255" textPrimary="Windows Down"></text>
                  <text colourSecondaryARGB="255,255,255,255" textSecondary="Windows Down"></text>
                </button>
          And the logic:
          Code:
          <if fire_on="logic" minimum_delta_vote_time="100" id="window_timer_logic">
                  <boolean_operation type="greater than">
                    <parameter1>
                      <variable do="get" name="window_timing"></variable>
                    </parameter1>
                    <parameter2>
                      <number>0</number>
                    </parameter2>
                  </boolean_operation>
                  <then>
                    <do function="Trigger Output" functionTargetID="Digital Output 5" vote_opinion="On" vote_priority="Medium"></do>
          		  <do function="Change Variable" functionTargetID="window_timing" vote_opinion="-1" vote_priority="Medium"></do>
                  </then>
                </if>
                <if fire_on="logic" minimum_delta_vote_time="100" id="window_stop_logic">
                  <boolean_operation type="equal to">
                    <parameter1>
                      <variable do="get" name="window_timing"></variable>
                    </parameter1>
                    <parameter2>
                      <number>0</number>
                    </parameter2>
                  </boolean_operation>
                  <then>
                    <do function="Trigger Output" functionTargetID="Digital Output 5" vote_opinion="Off" vote_priority="Medium"></do>
                  </then>
                </if>
          I have the logic timer in the timers section set at 100.

          When I click the button the output goes on once for a split second. I can click it over and over and it still does it, so it seems to be reseting but not staying on for the planned amount of time.

          Comment


          • #6
            bump

            Comment


            • #7
              Sorry, I havent forgotten about you. I have a large Verilog project to design a virtual CPU and synthesize it so I have been a bit busy. Hopefully Monday night I will get some code for you.
              Fusion Brain Version 6 Released!
              1.9in x 2.9in -- 47mm x 73mm
              30 Digital Outputs -- Directly drive a relay
              15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
              Buy now in the MP3Car.com Store

              Comment


              • #8
                ok thanks

                Comment


                • #9
                  setting variable to "-1" sets it to negative one.

                  Setting a variable to "d-1" changes it to variable - 1.

                  Also you have your clear logic set to medium priority and your button set to medium priority.

                  When the variable is at rest, it is equal to zero, so that logic tries to assert off. If you press your button, it will try to change it on. So if they occur on the same clock cycle, nothing will happen. This configuration will give you spurradic behaviour. Change the logic set to zero to low priority and the button to high priority.

                  Also I have been working on 3 new features for the digital outputs that will make it easy. Pulse output, Sequential Output, and Relatively Timed Sequential Output.

                  I have 2 of 3 finished, working on the last. Let me know if those changes fix it.
                  Fusion Brain Version 6 Released!
                  1.9in x 2.9in -- 47mm x 73mm
                  30 Digital Outputs -- Directly drive a relay
                  15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
                  Buy now in the MP3Car.com Store

                  Comment


                  • #10
                    Yes that did the trick. Works great now...

                    Now the problem I'm having is that I can't get it to upclick... it doesnt automatically upclick when the output is set to off, and I tried adding an upclick property to the button and it still wouldn't upclick. I don't care if it upclicks when the sequence is over or when my finger comes off the button.

                    Comment


                    • #11
                      What are you trying to do on upclick?

                      The code above has no upclick therefore nothing should happen.
                      Fusion Brain Version 6 Released!
                      1.9in x 2.9in -- 47mm x 73mm
                      30 Digital Outputs -- Directly drive a relay
                      15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
                      Buy now in the MP3Car.com Store

                      Comment


                      • #12
                        I just added the upclick code from another momentary I had bc when i clicked the timed button it would stay down until i clicked it again but then it woulf trigger the output.

                        I don't want the the upclick to do anything other than to bring the button back to the up state. I tried setting it to change just a random variable just so it would have something to do, but that didnt work. Then i tried to have it turn an unused output to the off state so it would function like the the other momentary buttons i have, but that still left the button icon in the down state.

                        Comment


                        • #13
                          Originally posted by bratnetwork View Post
                          I just added the upclick code from another momentary I had bc when i clicked the timed button it would stay down until i clicked it again but then it woulf trigger the output.

                          I don't want the the upclick to do anything other than to bring the button back to the up state. I tried setting it to change just a random variable just so it would have something to do, but that didnt work. Then i tried to have it turn an unused output to the off state so it would function like the the other momentary buttons i have, but that still left the button icon in the down state.
                          If it is just aesthetics, change the primary and secondary button's images to the same thing, then it will look the same.
                          Fusion Brain Version 6 Released!
                          1.9in x 2.9in -- 47mm x 73mm
                          30 Digital Outputs -- Directly drive a relay
                          15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
                          Buy now in the MP3Car.com Store

                          Comment


                          • #14
                            I tried that also... i made the prim. and sec. button.png and left the pushed as button_down.png, but when i click it, it never shows the button_down.png even if i hold it - it just stays showing button.jpg... almost like its not reading the imagePushed code.

                            Comment


                            • #15
                              do you mind posting the logic which worked for you.

                              Comment

                              Working...
                              X