• 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

    Strange delta calculations

    Scheduled Pinned Locked Moved User help
    2 Posts 1 Posters 624 Views 1 Watching
    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.
    • P Offline
      psysak
      last edited by

      Hey hey. This is something which has been driving me insane lately, I've tried all sorts of different things and it always seems incorrect.

      I have a Mango ES which is polling a device over MODBUS every 10 seconds. It reads an accumulated pulse count from this device. I log the accumulated pulse count every 5 minutes. I have a meta point which then is attempting to calculate the delta in the last 5 mins. This delta calculation has been triggered on both Cron and on logged event, both yield the same thing. The deltas which the mango calculates range from bang on to way off and I can't figure out why.

      Included is a spreadsheet, 6 hours of data from my mango. The column "Mango Delta" is the delta which the mango has calculated. The column "Mango Raw Value" is the MODBUS point raw value which I am reading from the mango with its associated timestamp. The column "Excel Delta" is just "cell2 - cell1" done in Excel. I have another system which I am sending the raw data to which confirms for me that the deltas I get from Mango are whacked.

      [0_1512483170534_Weird Delta.xlsx](Uploading 100%)

      Also included is my meta point script. "pulse" is the raw pulse value from the MODBUS device, pulsefactor is not used in this script and the entire thing is triggered every 5 mins based on CRON.

      // Calculate the interval value since last logging (5 mins)
      // This script should only trigger when pulse is logged, which is set to 5 min
      // Pulsefactor is used to calculate the actual consumed amount
      // where pulsefactor is the meters pulse weight
      
      // Local variables section
      // Control what parts of this script run
      weight = false;     // If true this script will apply pulse rate
      interval = true;   // If true this script will calculate interval data
      hydro = false;      // If true this is a calculation for electricity 
      
      // To protect against calculating zeros, check the values of the factor variables
      if(weight) {
          if(pulsefactor.value <= 0) {
              pfactor = 1;
              tfactor = 1;
          } else {
              pfactor = pulsefactor.value;
              if(hydro){
                  tfactor = 12;
              } else {
                  tfactor = 1;
              }
          }
      } else {
          pfactor = 1;
          tfactor = 1;
      }
      
      if (interval) {
          // If a value requires compensation for rollover (ex 65535) enter here
          rollover = 0;
          
          // If the value rolled over and the rollover value was entered then calculate 
          // the interval data using the rollover value
          if((pulse.past(MINUTE, 5).minimumValue > pulse.value) && (rollover > 0)) {
              return((rollover - pulse.past(MINUTE, 5).minimumValue + pulse.value) * pfactor * tfactor);
           
          // In the case that the rollover value was not specified but the value still
          // rolled over just return the current reading (error present)
          } else if((pulse.past(MINUTE, 5).minimumValue > pulse.value) && (rollover = 0)) {
              return(pulse.value  * pfactor * tfactor);
          
          // Normally we do this, which is to return the delta over the last 5 mins
          } else {
              return(pulse.past(MINUTE, 5).delta  * pfactor * tfactor);
          }
      } else {
          return(pulse.value  * pfactor * tfactor);
      }
      
      

      I don't know if there's a bug here or what the case may be but I just need some guidance on what is going on and whether this will work or not.

      1 Reply Last reply Reply Quote 0
      • P Offline
        psysak
        last edited by

        Forgot to add that the values the mango is calculating don't even seem to make sense. If this is running every 5 minutes I would expect that it's either going to be correct or double what I expect. What's weird also is that it's wrong a few times in a row and then it's correct, then wrong, then correct again...

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