Announcement

Collapse
No announcement yet.

NaN on a Average Routine

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

  • Bellni
    started a topic NaN on a Average Routine

    NaN on a Average Routine

    Hello,

    Im having an issue with one AVG routine. It's in an always called task. The input tag and the output tag are both floating point 32 tags, with a static constant. The input tag shows up as a number, but the output is getting an NaN (not a number). any ideas?
    Attached Files

  • LWgreys
    replied
    If its in a called task and not in a RUN Every Scan task the input is not enabled all the time which means:
    When Enable is turned OFF the Instruction stops writing to the Output Tag. The Output Tag will maintain the last value written by the Instruction

    Leave a comment:


  • kewakl
    replied
    Originally posted by Tinker View Post
    Now, I know nothing about the Productivity, and it seems that the only way to find out anything about programing them is to install the software to get the help file, as the only thing I could find online was hardware manuals.
    Hah! Even though the 'title' of the page is Manuals for Productivity Suite Programming Software

    Leave a comment:


  • MikeN
    replied
    Originally posted by Tinker View Post
    Now, I know nothing about the Productivity, and it seems that the only way to find out anything about programing them is to install the software to get the help file, as the only thing I could find online was hardware manuals.
    Anyway, your constant is an integer, some things (like the original C language) would be "unhappy" about mixing ints and floats (or more accurately the system might not care, a byte is a byte to it, but the programmer might be unhappy with the results), nowadays conversions are often done automatically and transparently, but still, as an experiment one might change the constant to 5000.0

    I'm curios what "AVERAGE" does (but not curios enough to run a 215MB installer package) if the input was, say, an array, I would understand, but with only two values I don't really see the point.
    The average instruction averages the input over the time period and gives you that new output. I use it on every machine for an RPM readout on the HMI. The RPM jumps erratically when the machine is driven from a typical 3 phase induction motor without an averaging filter to slow the readout down and smooth things out. Same as its use for analog inputs, use an average instruction to smooth the erratic analog signal and help remove noise on the lines.



    Bellni perhaps the problem is the percentage sign in the tag name? I have never used one in a tag name before but maybe the instruction is getting mixed up thinking it is needing to average a percentage or something odd like that.
    Last edited by MikeN; 03-06-2019, 09:22 AM.

    Leave a comment:


  • Tinker
    replied
    Now, I know nothing about the Productivity, and it seems that the only way to find out anything about programing them is to install the software to get the help file, as the only thing I could find online was hardware manuals.
    Anyway, your constant is an integer, some things (like the original C language) would be "unhappy" about mixing ints and floats (or more accurately the system might not care, a byte is a byte to it, but the programmer might be unhappy with the results), nowadays conversions are often done automatically and transparently, but still, as an experiment one might change the constant to 5000.0

    I'm curios what "AVERAGE" does (but not curios enough to run a 215MB installer package) if the input was, say, an array, I would understand, but with only two values I don't really see the point.

    Leave a comment:


  • Bellni
    replied
    I believe the Software is 3.4.1.1, but not sure on FW (offline now and remote). I have an average above this one and below this one that both work like expected, just not this one. This tag is also only being used in the average and nowhere else.

    Leave a comment:


  • techme
    replied
    What sw and fw version are you using? I tested with latest (3.4.1.1 and 1.2.7.37) on a P3-550 and it works as expected on values from 0-100 floating point with code duplicated as you have posted.

    Leave a comment:


  • Bellni
    replied
    The input isn't constant, the Time constant input box is constant. The input to be average is a Float32 that varies from 0-100. attached is the picture of the Tag database.
    Attached Files

    Leave a comment:


  • MikeN
    replied
    Maybe it doesnt like averaging a constant number? Also, why use an average if the input is constant?
    Could you post a screenshot of your tag database showing both those tags so we can see that they are in fact both FP32 tags?

    Leave a comment:


  • juance
    replied
    Do you have any idea of the input number range that has arrived to the AVG instruction?
    This might give you a hint if the instruction is failing.

    Leave a comment:

Working...
X