• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Timer Module?

    User help
    2
    9
    2.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • danD
      dan
      last edited by

      Gidday Guys, I'm in need of a timer module or timer reference I can use within scripting and event handler modules that kind of thing.
      I need to say run a pump for x minutes and then on the other hand I need to record how long a pump has been running in another case.
      I see it graphs the time that the point has been in the other state such as RUN, can I pull this information out by interrogating the data point?

      I was going to setup a virtual data point that I could set a figure in as in minutes to run the pump for, then how do I use that in the script?

      Is there something that would do this already?

      Cheers
      Dan

      1 Reply Last reply Reply Quote 0
      • JoelHaggarJ
        JoelHaggar
        last edited by

        Here is a simple example of how you can implement a timer in a script:

        if (alarm.value == 1)
        {
        counter.set(counter.value +1);
        p502.set(false)
        }

        if (counter.value > 3)
        {
        counter.set(0);
        alarm.set(false);
        p502.set(true);
        }

        If the alarm point is 1 then it starts the counter and turn p502 off. If the scrip runs every 5 seconds then it will increase by one ever five seconds. Then when it gets to greater than 3 (15 seconds) it will reset the counter, turn the alarm off and turn p502 back on.

        You should be able to adapt this to your needs. You could use a var for the counter rather than an actual datapoint but this way you can track the timer function.

        I'm pretty sure you can get the information you need about the pumps run time from the binary statistics function in the meta data source help files.

        Joel.

        1 Reply Last reply Reply Quote 0
        • danD
          dan
          last edited by

          Gidday Joel, thanks for that. So the counter variable is persistent across all data sources or just the one you've set it in?

          I'll try the meta data source, that sounds handy.

          Cheers
          Dan

          1 Reply Last reply Reply Quote 0
          • JoelHaggarJ
            JoelHaggar
            last edited by

            In this case it would be because the counter variable is an actual data source so you could use it somewhere else but my guess is that you would probably not want to use it anywhere else and rather use separate counter variables anytime you need a counter in a script.

            1 Reply Last reply Reply Quote 0
            • danD
              dan
              last edited by

              so that's a native data source or do I need to add a virtual source called Counter?

              1 Reply Last reply Reply Quote 0
              • JoelHaggarJ
                JoelHaggar
                last edited by

                In this case it's a data point on the scripting data source. On the scripting data source you can add data points which are basically virtual data points but they can all be contain in the same area this way. You could use a virtual data point with exactly the same effect. You can name the point anything "counter" is the variable name assigned to it in the script context.

                1 Reply Last reply Reply Quote 0
                • danD
                  dan
                  last edited by

                  OK, this is what I have so far:-

                  I've setup datapoint p48 to be a required runtime in hours
                  datapoint p47 is actual runtime
                  each minute it increments p47 runtime by 0.016 which is 1 hour divided by 60 to get a minute as the script should run each minute, 60 times in an hour
                  once the runtime is reached it resets the actual runtime to 0 and sets the AUTO / MANUAL mode back to MANUAL so it doesn't keep going (lol)

                  
                  
                  // check if in auto mode at Turkey Nest AND runtime hasn't exceeded AND pump NOT running
                  if((p46.value == true) && (p47.value < p48.value) && (p11.value == false)) {
                  // increase value on Actual Runtime
                  p47.set(p47.value +0.0166666666666667)
                  
                  // open western solenoid
                  p22.set(true);
                  // close southern solenoid
                  p28.set(false);
                  // close northern solenoid
                  p24.set(false);
                  // start pump
                  p11.set(true);
                  }
                  
                  // check if in auto mode at Turkey Nest AND runtime has exceeded AND pump running AND western solenoid open
                  if((p46.value == true) && (p47.value == p48.value) && (p11.value == true) && (p22.value == true)) {
                  // stop pump
                  p11.set(false);
                  // close western solenoid
                  p22.set(false);
                  // reset runtime
                  p47.set(0);
                  // set back to MANUAL
                  p46.set(false)
                  }
                  
                  

                  I just wanted to confirm that each time the script runs if something is already set and it is trying to set it again it won't set it if it's already set?

                  Cheers
                  Dan

                  1 Reply Last reply Reply Quote 0
                  • JoelHaggarJ
                    JoelHaggar
                    last edited by

                    Each time the scrip runs it will do the action that matches the conditions you create. So if the first if in your scrip is true each time it runs then it will do the sets each time. If they are modbus registers then it will send out new modbus set commands each time.

                    You can get around this by putting additional conditions in the first if statement.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post