News:

  • May 05, 2026, 09:30:21 PM

Login with username, password and session length

Author Topic: Find and Retain Minimum Value within Stage  (Read 5542 times)

jvm728

  • Jr. Member
  • **
  • Posts: 11
Find and Retain Minimum Value within Stage
« on: November 30, 2015, 02:05:53 PM »
Folks - I'm back. I found a flaw in my programming so I'm trying to approach it a different way. You guys have been tremendous so far and for that I'm thankful. See below.

GOAL - Stage 1, Find and retain max value (D1), jmp when max is found. Stage 2, Find and retain minimum value (D2), jmp when MIN is found. Stage 3, Find and retain max value (D3), jmp when max is found.

So far, to find MAX, and jmp, the following as worked:

D0 = analog dynamic measurement value. D1,d2,d3 are values retained.

SG0
-------MATH(D1) = (IF(D0>D1,D0,D1)) :) Works.

D1>D0 ---- JMP (SG1)

SG1
-------MATH(D2)=(IF(D2>D0,D0,D2)  :( DOES NOT WORK.
D2<D0 ---- JMP (SG2)

SG2
-------MATH(D3)=(IF(D0>D3,D0,D3))  :) Works.
D3>D0 ---- JMP (SG3)


The problem is the SG1 time period is dyanamic in application, so I need a function to find minimum to work, and it cannot be just a time spacer function. Without it, as things ramp up in speed, the analog value from the first scan (D1) and (D3) are being read from the same scan.

The low value point is EXACTLY in between the peaks of the max's that i'm looking for, so its naturally a good balanced separater for the stages.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3806
    • Host Engineering
Re: Find and Retain Minimum Value within Stage
« Reply #1 on: November 30, 2015, 02:33:22 PM »
Describe what you want functionally (i.e. desired behavior, not how to code it).

From what you describe, it appears that every scan, D0 can change.  You need to classify some kind of min/max based on the current value of D0, but you do NOT need this classification resolved on EVERY scan?

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Find and Retain Minimum Value within Stage
« Reply #2 on: November 30, 2015, 02:40:37 PM »
Just add a
Code: [Select]
MOVE:
Source: D1
Dest: D2
To the same rung as the JMP in S0
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: Find and Retain Minimum Value within Stage
« Reply #3 on: November 30, 2015, 02:52:44 PM »
All, see attached. I tried to visualize the system for you all. I have learned that the MAX function actually wouldn't work properly as it could find a false peak. This tells me I need to continue the scan all the way out, and compare the largest 5 or 6 values found.

edited attachment for clarification of false peaks and correction of circle locations.

« Last Edit: November 30, 2015, 02:57:25 PM by jvm728 »

jvm728

  • Jr. Member
  • **
  • Posts: 11
Re: Find and Retain Minimum Value within Stage
« Reply #4 on: November 30, 2015, 10:35:59 PM »
PLCnut saves the day again, thanks.