Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on December 18, 2020, 01:26:37 PM
-
What I really need for a project is an AOI. What I could use is a Program with indirect references replicated several times. Is there a way to create a "Master" program, modify the master and then copy or update the other instances to match the "Master". If done this way I could then just update my indirect reference variable in each of the programs which would be relatively simple.
-
We've talked about separating the "code" from the PROGRAM structure heap item/memory, so that you can re-use the same code logic, but with multiple PROGRAM based structures (basically a nested PROGRAM structure inside your AOI structure, then have 10 copies/instances of the AOI structure).
All this is in the "TODO" list, but is non-trivial.
-
Would a subroutine work? They do take input and output references.
-
Need to be able to use timers and other multi-scan instructions.
-
Ah, yeah I knew that was only good for certain circumstances. I ran into the same thing.
-
If done this way I could then just update my indirect reference variable in each of the programs which would be relatively simple.
Scratch this. Indirect references mess up termination logic when used in programs.
-
You lost me there. Could you expand on that, please? Thanks.
-
For example, if I have two Programs, Program1 and Program2.
Program1
Move 0 to V50
$On ----- Out Y[V50]
Program2
Move 1 to V50
$On ---- Out Y[V50]
When Program2 is enabled, Executing Exit command in Program1 will leave Y0 on instead of turning it off.
-
I obviously don't know what you're doing in your program, but I'd normally not reuse an index register in two separate code blocks that can run at the same time and need the index to be different. What's the use case for that?
-
It gets back to the need for an AOI. I thought I could change the index register at the top of each Program and keep the all subsequent code the same same, but this will not work correctly. Every Program will be the same code with the Index changed. It looks like I'll have to write the first Program and then do a Replace to update the Index with a static value.
-
OK, so the programs are multi scan, and yield, so they don't run top to bottom between executions of the other program, and you're using the indices to parameterize the "identical" programs. I see your point.
-
Would it help to make all your yields explicit, and reinitialize the index on return? IOW, don't let it yield based on time slice only on a YIELD.
-
The Programs are running sections of the machine which are essentially the same mechanically but only portions of the machine are needed based on load demand. The sections are parallel operations which are coupled through the process variables but are not intrinsically linked to another section of the machine operating. Hence the need for Programs which are the same but can operate independently of one another. I would attempt subroutines if they could deal with timers.
-
My thinking about the explicit yields is that with finite, known reentry points, you can reset the index to the right value as you reenter the program. (Which would also requre per-copy edits, unfortunately)