News:

  • August 29, 2026, 09:19:38 AM

Login with username, password and session length

Author Topic: STRFIND in a Task  (Read 124487 times)

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: STRFIND in a Task
« Reply #30 on: January 01, 2013, 03:17:47 PM »
Yeah, I was going to mention the inline-power-flow-based leading edge and trailing edge contacts (see the Contact Browser F4 or the Instruction Palette on the Ladder toolbar or Edit->Instruction Palette).  The inline-power-flow-based contacts are not on the Ladder toolbar (there are 3 of them, leading edge, trailing edge, and invert) cuz we ran out of room.

See the attached set of rungs.  Rungs #1 and #2 are equivalent to Rung #3.  So you can do power-flow based one-shots without burning a CR by doing it like #3.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: STRFIND in a Task
« Reply #31 on: January 01, 2013, 03:21:29 PM »
So you can do power-flow based one-shots without burning a CR by doing it like #3.

And as (more?) importantly, the intent of the rung with the in-line is instantly decodable in one single glance.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: STRFIND in a Task
« Reply #32 on: January 01, 2013, 03:24:07 PM »
The only time I would consider doing it the "old way" is if I had multiple rungs throughout my program that needed this "one shot" information.  Typically, though, it is only needed in that one place.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: STRFIND in a Task
« Reply #33 on: January 01, 2013, 03:27:02 PM »
The only time I would consider doing it the "old way" is if I had multiple rungs throughout my program that needed this "one shot" information.  Typically, though, it is only needed in that one place.

Yes, for creating an 'event'. Of course the inline with an OUT does the same thing...so...I guess it is really just about 'respecting the legacy'. ;)
"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

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: STRFIND in a Task
« Reply #34 on: January 01, 2013, 03:27:13 PM »
The only time I would consider doing it the "old way" is if I had multiple rungs throughout my program that needed this "one shot" information.  Typically, though, it is only needed in that one place.

Me too, or almost the same.  What I'd do is

Wad-O-Logic--------OUT C0

Then give C0 a good description and use C0 one-shots throughout the ladder, rather than having C0 be a PD itself.  Never really warmed to the PD.  Using OUT in conjunction with OS contacts gets you maintained, leading edge, AND trailing edge, plus hinting at the intent in the rung where used.  PD gets you......leading edge.
« Last Edit: January 01, 2013, 03:29:58 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Re: STRFIND in a Task
« Reply #35 on: January 01, 2013, 09:34:50 PM »
Regarding the Leading Edge and Trailing Edge contacts. In the DL world this construct compares the current state of the argument with the recorded state (not an addressable piece of memory) of the argument AT THE END OF THE PREVIOUS SCAN. If the argument is a bit affected by logic, as opposed to an input, the the Differential Contact only had a valid use from the point of the affect to the end of the scan. It is not valid to use the DC for this argument on the next scan before the point of the affect.

So the question is, where is the previous state of the argument for Leading Edge and Trailing Edge contacts held? When is it stored?

Here's a link to information
http://support.automationdirect.com/docs/strpd.pdf
« Last Edit: January 01, 2013, 09:39:43 PM by b_carlton »
An output is a PLC's way of getting its inputs to change.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: STRFIND in a Task
« Reply #36 on: January 01, 2013, 09:51:17 PM »
So the question is, where is the previous state of the argument for Leading Edge and Trailing Edge contacts held? When is it stored?

Nothing complicated. It is stored in special edge memory...which is essentially just control relays, but is hidden and managed by DmD. The condition is evaluated at the time of execution of the instruction...basically like this:

  if(CurCondition && !PrevCondition)
    {
    Do stuff...
    }

  PrevCondition = CurCondition

Like most of the things we do at Host, it is simple and it works.
"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

b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Re: STRFIND in a Task
« Reply #37 on: January 02, 2013, 07:22:14 AM »
Thank you. The 'feature' in some of the DL CPUs had bitten some.
An output is a PLC's way of getting its inputs to change.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: STRFIND in a Task
« Reply #38 on: January 02, 2013, 08:39:21 AM »
Early on, I remember when I was trying out the TCP/IP client, I had a problem with the STRPRINT instruction. It took me a while before I noticed it was edge triggered. I felt stupid that I didn't see that right off, but I remember having to add several stages to work around it. I didn't say anything, because I assumed that's "just the way it is" and had to deal with it.

BTW, Happy New Year!

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: STRFIND in a Task
« Reply #39 on: February 19, 2013, 10:29:48 AM »
I'm having a time with this one. I have a STRCMP in a FOR/NEXT loop that is nested 4 loops deep in a task. I am using a loop toggle inline with the STRCMP and it works fine the first time through, but then I have a problem after that; I cannot get it to compare when the index is at "0". I know it has to do with the edge trigger.
Please explain to me exactly what it is that the instruction needs to see to trigger it.
I don't know if I need to add an extra SET and then a RST on the toggle bit before the instruction or what.

I have attached a screenshot of the innermost loop. The toggle is set "On" immediately before the loop.
Circumstances don't determine who we are, they only reveal it.

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

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: STRFIND in a Task
« Reply #40 on: February 19, 2013, 10:41:12 AM »
The simplest answer is to get the beta 1.1 where we have made the edge optional on all the string functions. Can you wait for a few more days?
"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

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: STRFIND in a Task
« Reply #41 on: February 19, 2013, 10:57:27 AM »
Yes. The ball is not in my court right now, but if all goes well this system should be running early next week.
Circumstances don't determine who we are, they only reveal it.

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

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: STRFIND in a Task
« Reply #42 on: February 19, 2013, 11:02:53 AM »
Ah...well, bein as this is beta, I'd rather not see you depend on it for a deployed system in the near term. The instruction improvements are pretty simple, but we have done a bunch of work with the new expansion I/O. It really needs to be wrung out before going on a machine.
"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

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: STRFIND in a Task
« Reply #43 on: February 19, 2013, 11:23:15 AM »
Ok. The only place the loop has a problem is with comparing to index 0 of the table. I have inserted a string in index 0 that will never be used so that the dynamic portion of the table starts at index 1.

The part that really bothered me was why it was doing it, but when I went back over this thread and re-read the termination logic issue, it explains the problem I'm having so I will work around it.
Circumstances don't determine who we are, they only reveal it.

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

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: STRFIND in a Task
« Reply #44 on: February 19, 2013, 01:43:33 PM »
Yes. The TASK termination code will cause issues with edges. It's fixed in the current code...but again...given the big changes for the Ethernet Expansion I/O, I don't feel great about this for anything but the lab. We'll get it proven and shipped pretty quick, but not before you commission.
"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