Studio 5000 Structured Text Loop

round 2

I apologize if I didn't get all of the questions answered. I wasn't sure what you meant with all possible sequences for those events.

The array has 21 fields, of those the ST is only filling the basic 10 fields. When it's left blank.

I'm using the TCP Socket AOI from Rockwell, the output of that connection is fed into a string variable called LastRead.

LastRead contains a 40+ character string.
Mid > CurrentSequenceString STOD > CurrentSequence
Mov CurrentSequence > 1stShift[CurrentSequence].CarcassCount
From there I'm using MOV's to fill in the rest of the data parsed from that initial string.

I'm going to try and answer the when, though I'm not sure it's the answer you are looking for;
the vendor network connection, once the socket is opened it listens until data is passed.
the PLC string-parsing code- on change it parses the data. There's not a temporary structure, or anything like it. It literally passes the info to the array on each scan until it changes.
the PLC ST code, always running
the .NET application- every two minutes.

BachPhi Is it the free or the paid version??
I'm assuming you mean emulate, but both logix 5000 and emulate are paid versions.

1. What are the differences between Emulate and Production?
1.1. For example, is the .NET process reading these data running against the Emulate system?
No, the .net process doesn't. The emulated process uses a timer to fill only the plant id into a constantly changing sequence field. Ie. Timer every 5 seconds increments the sequence +1, the next step is adding a Array[sequence].plantid = 4010.
When the sequence has gotten to 10, I use a move statement to change the sequence to 20 (that way 11-19 will be skipped- leaving them as all 0's. The ST then runs through the loop filling the plantid)


2. How do you know the PLC code did not see the plant id <> 4010 when in Production? Was it
2.1. EITHER because you monitored the records plant id values in the PLC memory array, while online with the PLC, and visually confirmed they had not been converted to 4010 even though the ST program was running,
2.2. OR because the .NET application stopped, perhaps with a warning message that it found an invalid plant id value of 0,
It's more of a reactive situation. There's a department that waits on that information to be transferred for billing. If they don't see an expected total they reach out to see if there was an issue. Usually, I can run a report against the values stored in SQL to find the last good count. Goto the PLC, look at the next array sequence and it's completely filled with 0's.
Ie. Billing calls- we only have 10 carcasses in the system, I check array[11] is filled with 0's, but array[12] is fine. (The .net process verifies that all required fields are there before accepting, so there's a log- but it only shows the last accepted value that serves as a placeholder for starting the next cycle.) I can manually fill the record in, so that the .net process can continue or wait until end of shift and send all the data. That's what I was hoping to use the ST for in this scenario of filling in the "required" fields and carrying on.


I'm sending you a pm as well.
 
Is the .NET application aware of the values of CurrentSequence and LastSeq? Does it read records LastSeq through (CurrentSequence - 1)?

What updates the values of CurrentSequence and LastSeq, and when does it update them? When a new string comes in, does the parsing code update CurrentSequence before the data are parsed and written to array[CurrentSequence].

Does CurrentSequence ever get incremented by a value of more than 1 in Production, comparable to when you MOV in a value of 20 when the value reaches 10?
 
Last edited:
bump

Is the .NET application aware of the values of CurrentSequence and LastSeq? Does it read records LastSeq through (CurrentSequence - 1)?
No. It only looks at the values of the array sequentially.
1stShift[1]
1stShift[2]
1stShift[3] etc. If it finds the aforementioned 10 fields unsatisfactory it will log the issue to a SQL table.
When the .net application iterates it maintains a running list of what was picked up last.
1st iteration. Starts at 1stShift[1], Next iteration checks that the last was 1, looks for 1stShift[2] etc.
It does not care about the sequence in the logic. Only that the arrays are picked up sequentially.


What updates the values of CurrentSequence and LastSeq, and when does it update them? When a new string comes in, does the parsing code update CurrentSequence before the data are parsed and written to array[CurrentSequence].
CurrentSequence is updated by the parse, then is passed into the arrays, and finally overwrites the last sequence.
VendorString>Mid>STOD>CurrentSequence. LastSeq gets its value internally from CurrentSequence.


Does CurrentSequence ever get incremented by a value of more than 1 in Production, comparable to when you MOV in a value of 20 when the value reaches 10?
Yes. When there is a blip on the vendors software it sometimes jumps in error situations causing the sequence to skip 1 or more places. Usually, when I move in the 20, I do not stop the timer from iterating the sequence- just throw it a curveball and see if it keeps on cycling. I've gone as far as passing "jumps" 10-20 up to 100-200 at a time to see if it would backfill correctly on the 0'd arrays and it seems to handle it without issue.
 
What stops the .NET application from reading past 1stShift[lastSeq] or past 1stShift[CurrentSequence]?


When a new string arrives via the vendor network/socket connection and is detected, what does the parser usually do? Does it


  • parse the string,
    • putting the parsed values into array element 1stShift[CurrentSequence]
  • Move the value of CurrentSequence to LastSeq
  • Increment CurrentSequence by 1
?
 
Remove the AND (CurrentSequence - LastSeq) >= 1 expression from the IF-THEN statement.

As the parser parses the string, it gets a new value for CurrentSequence from the string. When the parser completes its parsing, it MOVes the value of CurrentSequence to LastSeq, so the expression above will never be True, and the ST code will never fill in the skipped values.

Or transfer the MOVe of the value of CurrentSequence to LastSeq from the parser code to end of the ST code.

It's not what you do, it's when you do it that is important.
 
What stops the .NET application from reading past 1stShift[lastSeq] or past 1stShift[CurrentSequence]?


When a new string arrives via the vendor network/socket connection and is detected, what does the parser usually do? Does it


  • parse the string,
    • putting the parsed values into array element 1stShift[CurrentSequence]
  • Move the value of CurrentSequence to LastSeq
  • Increment CurrentSequence by 1
?

- The .net application has an internal sequencer that increments by 1 until it reaches an array that doesn't fill out the required fields. Then it stops. If 1 of the 10 fields previously mentioned don't have the correct data. For example, if the hour or species or plantid is 0 it will fail. Then try that same place over and over, every 2 minutes, until it finds it with acceptable data or the shift ends.

-The string is MOVed to a string tag, then MID's, STOD, and STOR are used with MOVes to fill the array elements. At the end of the parsing it MOVes CurrentSeq to LastSeq. The parses has nothing to do with incrementing since the initial vendor string includes the sequence.

- Why would it work in emulate, but not in production? This is what's hanging me up.
 
Last edited:
- The .net application has an internal sequencer that increments by 1 until it reaches an array that doesn't fill out the required fields. Then it stops. If 1 of the 10 fields previously mentioned don't have the correct data. For example, if the hour or species or plantid is 0 it will fail. Then try that same place over and over, every 2 minutes, until it finds it with acceptable data or the shift ends.


Ah, I think I finally see the big picture that ST is trying to solve: if there is a gap in the array, because the parser parsed e.g. ID 1000 from the network connection string at one point, and then the next network connection string had ID 1002, it will leave a gap at ID 1001. The .net app will read the record at ID 1000 okay, and increment it internal sequencer to 1001, when when it tries to read empty record ID 1001 it will fail and stop. And every two minutes it will try ID 1001 again but the vendor string/PLC process has moved on to 1002 and beyond, so record 1001 will never get filled in.

I still think the problem is that you are MOVing CurrentSequence value to the _LastSeq value at the end of the parser and before the ST filler routine runs. So the value of DeIncrmenter, which is [CurrentSequence-1], is never greater than the value of _LastSeq, which is equal to the value of CurrentSequence because the parse routine set it.

Since the _LastSeq value is only used by the ST filler routine, that is what should update the _LastSeq value.

For that matter, you could use the _LastSeq value as the starting point for the ST routine: every time the ST routine is called, if the _LastSeq value is less than the CurrentSequence, then check, and fill if necessary, the record at ID _LastSeq. Then increment _LastSeq by 1 and exit the ST routine. If there is a large gap between _LastSeq and CurrentSequence, it will be filled however many scan cycles it takes to increment _LastSeq to close the gap.
 

Similar Topics

I have attached a photo, can you add something to be able to collapse x amount of lines? in the picture to add something like I drew on the image...
Replies
3
Views
937
I'm working on learning Structured Text, and I'm stuck on something so simple: I have an If-Then statement using Bool tags, and I'm having a hard...
Replies
18
Views
5,123
Hey, i need help to write a structured text program that set a signal to high 6s and to low 6s. I used TONR to do this but it doesn't work...
Replies
5
Views
4,445
Hello, I setup a Studio 5000 project, with a Guardlogix 1756 controller. I want to program an Add-On instruction in Structured Text, all other...
Replies
9
Views
2,488
Hi Everyone. Not posted on here for a long time, but I am hoping someone can help me. I am doing a differential pressure calculation in a L27ERM...
Replies
15
Views
208
Back
Top Bottom