News:

  • May 05, 2026, 01:09:38 PM

Login with username, password and session length

Author Topic: Analog WX0 Input - Find and retain max value within stage  (Read 12790 times)

jvm728

  • Jr. Member
  • **
  • Posts: 11
Analog WX0 Input - Find and retain max value within stage
« on: November 23, 2015, 12:06:34 PM »
I'm looking to create a function of looking at WX0, or D0 (which is MATH: WX0*0.717), during a timer countdown. That analog signal and D0 changes during the timer, and I want to look at and retain the LARGEST value. Imagine a sine-wave. I need to find the peak of that sine-wave.

The trend will increase over time, and then when it has a down-ward trend, the peak that was created should be stored and used as D1.

I tried Max and MAXR functions but it doesn't accomplish what I want to do.

Furthermore, I'll eventually want to BANK the peak values within the program(s) to a CSV type file, which also has other data stored Re: the scan time and bank time.

HB_GUY

  • Full Member
  • ***
  • Posts: 43
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #1 on: November 23, 2015, 12:54:22 PM »
Would something like in the picture work for you?
Timer runs while the stage is running,
Math block multiplies wx0*0.717 and stores in D0
Last rung compares D0 to D1 and moves value to D1 if D0>D1

jvm728

  • Jr. Member
  • **
  • Posts: 11
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #2 on: November 23, 2015, 01:27:27 PM »
I'm struggling to follow what you're trying to do. See the attached.

I want to use a timer to take in all analog values over a given time, and whatever the largest number is coming into the system, it populates it as D1.

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #3 on: November 23, 2015, 01:48:56 PM »
MATH:
Result: D1
Expression: IF(WX0 > D1, WX0, D1)
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #4 on: November 23, 2015, 01:52:33 PM »
OR, If you are looking at the values in D0 AND WX0 to find the largest then:
MATH:
Result: D1
Expression: IF(MAX(D0, WX0) > D1, MAX(D0, WX0), D1)
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

jvm728

  • Jr. Member
  • **
  • Posts: 11
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #5 on: November 23, 2015, 01:54:33 PM »
MATH:
Result: D1
Expression: IF(WX0 > D1, WX0, D1)

This seems to have some merit, but I'm struggling to see how D1 can be the result and in the function itself? I tried it and D1 is not populating.

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #6 on: November 23, 2015, 02:01:52 PM »
Make sure that you PLC (or simulator) is in RUN mode, and then make sure that WX0 is actually greater than 0.
What is happening in the MATH box is a simple compare: IF the value stored in WX0 is greater than the value stored in D1, THEN place the value from WX0 into D1, Otherwise, take the value in D1 and place it into D1 (Effectively leaving the value in D1 the same).
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

jvm728

  • Jr. Member
  • **
  • Posts: 11
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #7 on: November 23, 2015, 02:05:36 PM »
Ok. we're getting closer, PLCNUT, thanks for your help thus far. Here's what's happening:

Everytime I run this scan/evaluate cycle, I reset D1 and D2 (I have two analog peak sweeps i'm looking for) to 0 at the begging of Stage 1.

Sweep occurs, looks for max value, and the IF statement seems to work! Sometimes it "misses" the peak by a few thousanths. I wonder if that is the scan speed of the DL05 unit and the latency?

jvm728

  • Jr. Member
  • **
  • Posts: 11
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #8 on: November 23, 2015, 02:18:30 PM »
and now all of a sudden I have a TMRDOWN set for 1sec 500ms, and it keeps counting down from 9 min+. Deleted and tried to add new, same thing. Weird bug?

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #9 on: November 23, 2015, 02:20:44 PM »
Please post creenshots and/or zip and post your program.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

jvm728

  • Jr. Member
  • **
  • Posts: 11
Re: Analog WX0 Input - Find and retain max value within stage
« Reply #10 on: November 23, 2015, 02:24:02 PM »
GOT IT!

I owe you a dinner or something. Thanks! Simple concept, learned so much in the last hour.

Here's what did it!

Stage 0: Set D1 and D2 to 0 (every scan cycle zeros values in the bank.
Stage 1: Sweep and scan with the IF function. Once D1 is defined and timer expires, jump
Stage 2: < and > functions to dictate lights and alarms and next step
Stage 3: Sweep and scan with the IF function. Once D2 is defined and timer expires, jump
Stage 4: < and > functions to dictate lights and alarms in the next step
Stage 5: final feedback
Stage 6: end/exit program.