Kirko, well I like my approach and of course one problem in Opto is that they don’t want to put you in a box from the start, however, I would argue that beginners need a box. I arrived at this approach after making many mistakes and some of them repeatedly.
Start by labeling all Block0 as Start, and typically don’t put anything in them. Next, if this chart is a typically looped chart, then the next block should be labeled “Return” block. If you want to run the chart at 1 sec, then put it in here. Any initiallizing you may need to add can simpply be added between these block later. If you need to make a chart that runs once and ends, be sure to label the last block END. This is because later when you use the [B](very important) [/B]FIND (spyglasses) missing connections command and you see these block names show up, you will be able to dismiss those items becuase you know from the block name that they are intentionally missing.
I use a simple top to bottom “tree” style which is sooo much easier to read later when you have forgotten what this program does. All the logic can be branched out to the left or right but I do not use both directions, one or the other, it is much easier to read.
Each branch of logic does one thing or typically a “system” or a piece of a system and originates off the TREE in a conditional block. The condition can be any number of things or just a timer, it depends on what the branch is doing.
The next aspect of my style is that I generally run various conditions on this branch and each one of these conditions use a purple loop block to route either back to the tree BELOW the originating branch (above or even below the next banch) or is routed back to RETURN. Most people assume that routing back to RETURN is a waste of CPU time and that it will slow the logic way down. NOT true, these controllers are very fast at processing “internal” logic and the advantage here is that you get to keep all the conditions in the TREE updated.
Whether the branch routes to return or “continues” to the TREE is dependent on the requirements of the process. Also the branch can extend out as far as neccessary to complete the logic branch. From a readable standpoint, I try to keep it inside a block label readable view window. If necessary I can wrap it back towards the TREE.
Remember, logic loops inside of a branch are just plain bad…I rarely use them and if I do, I make sure that there is no way the loop can loop more than a few times or a few milliseconds maybe as much as 100ms. Remember, if your logic is spinning around in a loop, it’s not doing anything else, and eveything else is not being updated…
[B]NEXT RULE, do not separate logic of a system into multiple charts.[/B] This is the single biggest mistake most people make in Opto, they think that because there are no rules that can do anything they want. Unfortunately, there are rules, they just don’t know them. The problem is when creating multiple charts for the same logic, operating on the same varibales, there is no determination of when one chart will write or read to a specific variable and when a another chart will write or read to that same variable. I just got done with two service calls for an OEM that created this same problem exactly and did multiple times. You do not need to make a million charts, it actually will take more CPU time to run multiple charts than running one chart. Let’s take an example of logic. You have a machine that heat treats metal. In addition, that machine has a conveyor system that runs through it. Now, you can put all the temperature control and oven startup, and safety circuits in one chart and that can run either independent or can be controlled by a flag. Next, you can put the entire conveyor system in another chart and it can either run independent or be controlled by a flag or say by the temperaure of the oven. You should not break the oven temperature control and the associated safety and startup and shut down logic…this will lead to a [B]disaster[/B].
Lastly, to begin a project, the best method is to lay out your thoughts in the form of a chart as decribed above and do it with no logic. Just plop down your blocks and LABEL them as to what you want to do at each step. Once you have a basic outline like this, you can go back and begin installing logic as needed and you will find that you have to move thnigs around and so on until you begin to get a feel for how the actual logic will have to work.