Announcement

Collapse
No announcement yet.

Average a value over a set amount of time/samples

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


  • Average a value over a set amount of time/samples

    I'm sure there is some way to accomplish this, but I cannot find it in the documentation. I'm not new to programming, but new to automation controls and the Productivity Series. I'm working on a P3-550 and looking for a way to take a sample of a thermocouple input every minute, and then average this value over 30min (30 samples, depending how you look at it).

    I have found software instructions for averaging across channels, or averaging a single channel for ALL time, but nothing that lets me choose a specific channel and average it over a set time limit. My work around is savings each 1 min sample to a tag/variable, and then averaging over those 30 tags, but that seems very inefficient.

    Thanks for any guidance!


  • #2
    Create a 30 column array. Every minute, use the shift array command to shift the values and fill in the thermocouple value. The array statistics command allows for averaging the values in an array.

    There may be a better method, but this is off the top of my head.

    Comment



    • #3
      You can create a couple of flasher coils 1 for one minute and one for 30 min( actually 30 sec and 15 min since you wish to see the transition and it will be on for 30 sec and off for 30 sec) then use a NOE of the 30 sec flasher to a MATH instruction that takes your tag and adds it to an accumulated tag. Then have another rung that a NOE contact off the 15 min flasher takes the accumulated value and divides by 30 and loads to an average value tag in a MATh box and paralleled with it you can copy a 0 into your accumulated value so the average starts for the next 30 min.

      Comment



      • #4
        These are both great ideas! Thank you for helping me think outside the box.

        Comment



        • #5
          So, the average command (AVG) doesn't work for this?
          If you've done the very best you can, worrying won't make it any better - Walt Disney

          Comment



          • #6
            AVG instruction only allows for 1 time constant so you can average a sample every minute or every 30 minutes, but not an average 1 minute samples over 30 minutes. The AVG instruction is averaging off of 2 samples set to whatever constant you set them apart. This guy wants to average 30 samples that are accumulated 1 minute apart.

            Comment

            Working...
            X