
adccommunitymod (AutomationDirect) asked a question.
Moving the same value to multiple registers?
Created Date: October 27,2004
Created By: AJL
**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****
Is there an easy method in an 05 processor for moving the same value to multiple registers at once? I need to fill 82 registers at one time so I really don't want to use a bunch of LDD instructions.
Created Date: October 27,2004
Created by: AJL
Is there an easy method in an 05 processor for moving the same value to multiple registers at once? I need to fill 82 registers at one time so I really don't want to use a bunch of LDD instructions.
Created Date: October 27,2004
Created by: Rday
I think you can LDD once then use multiple OUTD boxs to load yor regs. You may also be able to write some pointer/indexing code to do this.
Created Date: October 27,2004
Created by: bcarlton
To amplify on Rday's fine answer - it's too bad that the 05 doesn't have the extensive file-type instructions but that's the way it is. When you perform an OUTD instruction, the contents of the accumulator are copied to the target register. The accumulator is not cleared, it still has the number ready for another OUTD to another location if you desire. Writing 82 OUTD commands is time consuming. A for/next loop would have smaller code but take longer to process with the pointer adjustments. Your choice.
Created Date: October 27,2004
Created by: bcarlton
Is the value to be moved into the registers a set one or does it change at run time? If it is known at programming time then investigate the MOVMC command. The data would be stored in a DLBL section at program time but then at run time moved with one instruction.
Created Date: October 27,2004
Created by: AJL
The value is a known, fixed value that does not change. It is only loaded to those multiple registers when communications between PLCs fails.
Created Date: October 27,2004
Created by: AJL
Unless I am reading the manual wrong regarding the MOVMC/LDLBL instructions, using that method would require 82 NCON instructions. Is that not correct?
Created Date: October 27,2004
Created by: bcarlton
Yes it would still require that many NCON's. I was just thinking about execution time which is only slightly faster (1280 usec)than OUTD 82 times (1484 usec). It is MUCH faster than a For/Next loop with pointers.
Created Date: October 27,2004
Created by: AJL
Thanks to all who replied! I just went ahead with the brute force method and piled in the OUTDs. It makes it a little more straight-forward for the next person to come along who's trying to figure out what is going on.
Created Date: October 27,2004
Created by: Steven
Straight-forward for the next guy? Where's the job security in that? Clearly you have never read How To Write Unmaintainable Code .
Oh well, if you 're going to write clear, obvious code that anyone can read and maintain, you'll just have to live with that.
Created Date: October 27,2004
Created by: franji1
I HIGHLY recommend you put the logic into a subroutine and call it via GTS at the top of your program on the first can (SP0).
This is because if you keep it in the main block of ladder code, even when you are "not " executing the instructions, it takes "time " away from the ladder scan. If you stick it into a SBR, you only burn the time to "not execute " a GTS, not a LDD followed by 82 OUTDs.
If you use stage, you could stick it in an initial stage that resets itself - the execution engine actually skips over stages that are disabled and so is faster than ladder boxes in a rung that have no power.