
z28z34man (Customer) asked a question.
The productivity suite user defined structures look awesome thank you so much for implementing.
Along the lines of the user defined structures it would be fanominal if we got a "Custom instruction" instruction that we could pass tags in and out using the user defined structure.
I am thinking that you could create something like a run when called ladder with all the with all the tags set up as the base user defined structure tags. when you place the "Custom instruction" you give it a UDS data type tag and it will automatically map the internal to the external tags and run the code in the ladder.
What i see myself doing now is creating a run when called ladder and using UDS data type tags for everything inside then copying the ladder and manually changing all the first portion of the UDS data type tag for the whole ladder.
Thanks for the suggestion. I made the Product Manager aware of your request.
What i see myself doing now is creating a run when called ladder and using UDS data type tags for everything inside then copying the ladder and manually changing all the first portion of the UDS data type tag for the whole ladder.
Or how I would envision it: create a task similar to a 'run when called' task but with 'abstract' tags -- a code TEMPLATE.
A 'USER DEFINED INSTRUCTION' (UDI) instruction would call this task.
The 'UDI' would contain all of the mappings between the REAL-WORLD tags and the ABSTRACT tags.
When called, the UDI would generate the 'code' (from the template code)make the mappings, recall any retentive statuses, do the scan/analyze I/O/LOGIC as needed for sensible execution, update I/O/statuses., save any retentives then destroy the previously 'generated code.' (it may not be required that the 'generated code' is constructed/deconstructed every iteration, but I cannot see how to do this without a small-ish program with several UDI's expanding like a balloon. -- maybe have a housekeeping interval. if expired without callingthe UDI, destroy the 'generated code' )
This is simply an idea of how I thought it could work. there may be miles-wide holes in my thinking.
Those familiar with classes and objects can draw correlations between the TEMPLATE being the class and the 'generated code' being the runtime object.
I could not find a way to attach to an edit. :(
The attached is a simple example of what I attempted to describe earlier.
Please don't critique the code. It is explanatory only (junk), not expected to be functional.
Other tags could be added to control the timer preset, monitor for timeout.....
You shouldn't have to copy and change anything in the "run when called" ladder.
although it's not exactly automatic, you can write the ladder with a nonspecific named UDS tag (say Motor), and just copy the data from your specific motor (Conveyor1) to (Motor), before calling the Motor task, then after the task returns, copy (Motor) back to (Conveyor1).
then, on the next line, you can copy (Conveyor2) to (Motor), run the motor task, then copy (Motor) back to (Conveyor2).
This is essentially what a custom instruction in RSLogix does under the hood.
Here is an example of what I described above...
I am not sure how well that would work. I know there i a bunch if stuff going on behind the scene to keep timers accurate and not dependent on scan time. i do not know if all the stuff we cant see gets copied or if it is just the visible tags.
An interesting concern, I don't expect it would be significant in most applications.
But, if you're concerned about timers losing accuracy in the copying, rather than including the timer in the UDS, you could create a separate array of timers, and include an integer pointer to the array in the UDS instead.
Another thread jogged my memory about this thread so I thought I should bring this back to to top and maybe in the next major revision we could get the custom or user defined instruction to make it easier.
I just tried the array of user defined tags and using a for loop to call a run when called ladder. I have a copy data to copy the tags before and after the call task instruction and it dose work but it throws the timers way off(running in the productivity simulator i lost around 27 seconds per minute).
Using separate ladder for each and just changing the array number for all the tags in the run when called ladder keeps the timers somewhat accurate(running in the productivity simulator after 10 minutes it was off 20 seconds).
when using actual hardware (P1-540) it behaves differently
using the separate ladder for each and just changing the array number for all the tags method and the trimmers are right on after 20 minutes leading me to believe the simulator doesn't quite keep accurate time.
using the for loop and copy data method timers don't work at all on the P1-540
That would basically be similar to an IEC Function, as it wouldn't store it's own data, but the data could be stored in the external struct as you say.
Yeah I like it.
After using AOIs in the RA suite, I would have to agree that this would be an excellent upgrade.
While the P suite team is on that, have the Cmore folks add global objects with tag substitution as well please. :) After spending all day updating tags on some screens in C-More, I really missed being able to have global objects linked to AOIs. Enter one tag and done.
I'd like to throw the C-More folks a bone though, I've yet to crash it in the few years I've used it. I've only used FT View for much shorter time and crash it quite often. And the Psuite ladder is faster to key through than 5k/Designer.