I love hearing new ideas, if I had more time I would try them all.
I recommend using the JL instruction which is the STL version of a CASE or SWITCH statement. It is very efficient. ...............
This method is what I saw Siemens engineers use.
There is ONE advantage to using bits. If you look at a SFC you can see that a SFC task can actually have two parallel branches running on the same graph.
This is not possible if you use integers but there is an work around. You can start up another state machine to handle the parallel branch.
The JL instructions is one of the best features of the S7 and I would use it on any machine sequencing I would do if I didn't have SCL.
I always enjoy reading your posts Peter. I like hearing other views and I try to benefit from others experience as I imagine how to implement their ideas.
However,
"This is not possible if you use integers but there is an work around. You can start up another state machine to handle the parallel branch."
I think one would have to agree that JL is the best solution from a processor speed point of view.
Graph has its points but is very limiting and I could only get it to do the basic step chores and still had to use FBs elsewhere for all the real logic, so I didn't understand the real need for the extra layer of adding Graph.
I have heard several people say integers wont do parallel branches and I just can't understand how anyone would think this.
I must begin by saying that there is no parallel in PLCs, ever. It is a long list of If Then Else. PLCs can't do real parallel and neither can older PCs. "Parallel" is generally "OR".
But the idea of seemingly parallel branches can be implemented in integer stepping by simply using the same index number on several sections of code.
Then the sections that equal "12" will all run in sequence from top to bottom as if they were actually in the same section.
If you look at the JL method, only the sections of code that are jumped into execute.
Good and bad from my perspective.
Good for execution time and all the things you love about it. Plus Seimens engineers use it, so there is that element majesty.
Bad is the fact that you have to be careful not leave any condition true when you leave the section and jump out or that element will remain on until that section is jumped into again. This could be exploited as a clever "set bit" scheme but few people could follow it late at night in the back corner of the plant while trying to figure out why the machine isn't running. Someone making a small edit might also be surprised that the new edit seems to have caused a lot of new issues.
I have met and had the privilege of discussing code with some very advanced programmers. I was in awe of the shear creative ingenuity of these people.
And then I had to interface their software on a project. After weeks of time digging through lines of code full of STL loops and jumps I discovered that a lot of it didn't work. And that was the part I had to fix before I could begin writing my part.
If it had all worked I would never have learned so much and I would never have known just how clever these guys are. But if it had worked it would have been more impressive.
It was so complex, they could not fix it and were always too busy to send a working version with examples. Any edit they made to fix one thing caused another issue and they seemed reluctant to actually test anything before declaring it functional.
It was a requirement that this "base code" be used in all projects, so there was no option of just doing it some other way.
And while I am still impressed with everything they did, and very glad to have had the experience, I am also glad that I don't aspire to that level of complexity. I could have written solid simple code to do everything that they did just using the time it took to figure out what they had done and why it didn't work.
There was a negative time savings. The whole thing was supposed to save time, but the reality is quite the opposite.
Their customers complain about the code , their own software people can't follow it, it requires weeks to edit before it works and there is no documentation because they are too busy.
My point is this:
If I can't follow it, chances are the guy after me wont have an easy time of it either.
Then there is the possibility of abandoned coils remaining on in jumped over sections of code. Bits can be modified later, or even turned on while troubleshooting online.
The JL does not address these issues without lots of housekeeping.
If I have a speed issue, I use Jump.
If I have a huge amount of code and only pieces of it are needed in each step, I would see the advantage of Jump.
If "steps" 4, 5 and 6 need to be run at the same time or in parallel, then activate each step with the same step index.
My integer method asks "which step number activates this section of code?"
and at the end you have some acknowledgement that each section of code is completed, or "DONE".
For a parallel branch to close, you would need to make sure that the DONE of each branch was "OR"ed together to move to the next section.
A List could do this by turning on several steps at once and then moving forward when any of the sections was "done" or waiting for all the sections to be "done" depending on whether you want them all "Or"ed or "AND"ed together. A list makes it easy to change the order later or change recipes on the fly.
"OR" : Begin all 3 sections at the same time but move to the next step when the first of the 3 was done.
"AND" : Begin all 3 sections at the same time (not sequentially) and then wait for them all to be done before moving to the next step.
Integer method also allows all the coils in the unused sections of code to turn off when not true and thus no extra housekeeping is needed.
It is possible that my idea of the integer method is not the same as other peoples implementation of the integer method.
I have not had an issue that was not easily resolved. And None of it is difficult to follow in concept or at runtime while troubleshooting. And those are the reasons I stick to it.
It is solid, simple, easily modified, flexible and easy to follow, even by a beginner.