News:

  • July 27, 2026, 10:29:59 AM

Login with username, password and session length

Author Topic: PD or delta contacts in loops  (Read 17740 times)

CReese

  • Hero Member
  • *****
  • Posts: 184
PD or delta contacts in loops
« on: July 10, 2013, 12:20:46 PM »
Hello again.

I have a perfectly nice program that works fine when I fix a loop in a particular index, e.g. for i=0 to 0, but when I set it free on an array neither differential nor delta contacts work.

So, for example, I have piece of logic that says:

If condition[index] != normal[index] -- set alarm[index]
If PD alarm[index] -- set alarminittime[index] = NOW

If I fix the index, it's fine. If I let it iterate and turn on the alarm condition, the PD is initiated on every iteration and the inittime variable continually increases. What is the best way to circumvent this programmatically? A block of interlocks?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3835
    • Host Engineering
Re: PD or delta contacts in loops
« Reply #1 on: July 10, 2013, 12:49:29 PM »
The "differential"-ness and "delta"-ness "previous scan state" is tied to the INSTRUCTION, not the instruction/parameter pair.

Hence, STRPD C[V0] differential contact only maintains the "previous execution's" state to determine the differential-ness of this scan, hence if on the previous execution V0 was 5, and now it's 6, you don't get the differential of C6, you end up with a differential of C6 compared to last scan's value of C5 (not what you needed).

The PD/ND coils don't take arrays as parameters.  We need to restrict the differential and delta contacts similarly.

Hence, you'll need to "roll your own" with a bit array for the "previous bit" and a numeric array for the "previous numeric", then write your own "edge" or "delta" contact logic.  Sorry about that.

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: PD or delta contacts in loops
« Reply #2 on: July 10, 2013, 12:59:22 PM »
Well, I beg to differ on the PD and ND taking arrays, because they do. Thank you for the clarification on the /true/ meaning in this context.

Now, another related question, I was hoping to use a task to run once if requested during the loop. I throw a few variables into temporary memory locations, and then run a routine that pops these onto a log stack. While this works fine when I freeze the loop, it does not work when running across the array. Interlock again? I'm worried if I set up a general write interlock, that if I call the task from multiple places they will interfere with one another. How can this be mitigated? I could have an interlock reset for all routines, but that seems like a hack.

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: PD or delta contacts in loops
« Reply #3 on: July 10, 2013, 01:16:32 PM »
nevermind. A logic error. It works now, but my head hurts.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6168
  • Yes Pinky, Do-more will control the world!
Re: PD or delta contacts in loops
« Reply #4 on: July 10, 2013, 02:08:03 PM »
Well, I beg to differ on the PD and ND taking arrays, because they do.

Franj was referring to the PD and ND coils...not edge triggered contacts. The contacts do accept array refs, which can work fine, but never in the context of a loop.

...that if I call the task from multiple places they will interfere with one another.

Tasks are not subroutines and are not called, they are enabled to run. Just wanted to be clear on that.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: PD or delta contacts in loops
« Reply #5 on: July 10, 2013, 02:58:13 PM »
Yes, yes, nomenclature. Run once seems to work fine. Funny how I naturally create temporary variables as an artificial way of passing values to it ... as if it were a function.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6168
  • Yes Pinky, Do-more will control the world!
Re: PD or delta contacts in loops
« Reply #6 on: July 10, 2013, 03:00:41 PM »
That's the primary reason we don't yet support functions and subroutines...we didn't want to introduce them until you could actually pass parameters to them. The engine actually supports that now, but there is a ton of work to do at the Designer level to properly deploy that feature. It will happen in time though...
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

CReese

  • Hero Member
  • *****
  • Posts: 184
Re: PD or delta contacts in loops
« Reply #7 on: July 10, 2013, 03:16:09 PM »
music to my ears.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3622
  • Darth Ladder
Re: PD or delta contacts in loops
« Reply #8 on: July 10, 2013, 11:52:42 PM »
Yes, thanks Hosties -- that will be great to have!   :)
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.