Multiple Move Functions

matt4276

Member
Join Date
Jun 2016
Location
Pennsylvania
Posts
12
In Studio 5000, is there any way to move a zero into many different DINT tags all at once? I'm trying to clear timer presets and clear specific values to zero when a certain bit goes high. Currently I just have a bunch of move functions in series. I mean it works but it takes up a lot of room and scan time is a possible concern. If anyone knows of anyway to clean it up it would be greatly appreciated.
 
Not really. If it is a DINT array, then the FLL instruction will do just fine. But if it is DINT1, DINT2, Timer1.PRE, Time200.PRE, no real easy way.

I suppose you could roll your own AOI to condense it to a single instruction into your code.
 
Something like this, just pass the tag into the AOI as an InOut paramter, let the logic just clear the Tag1...Tag10 using MOV/CLR instructions in the AOI. It would have to be a fixed size though.

ClearDINT.PNG
 
How about an FAL instruction? Not sure if it would be worth the effort because your tag structure may not be able to stay the same. I have used this technique when transferring data into a "monthly" location and then I zero them all at the end of the month by using an FAL instruction . If you look at the instruction help for an FAL it is the "array to array" idea.

I think the AOI idea would be the most flexible?
 
As Paully's5.0 mentioned, the CLR instruction is a little simpler in that it has one less operand. In general, the "space" instructions take up is not much of an issue.

Evaluating a programming solution is based on:
Does it work?
Is it easy to understand?
Does it use memory well (not waste a lot of memory)?
Does it execute reasonably (not waste scan time)?

A whole bunch of CLR instructions on the same rung scores pretty well on all counts.
It works. It's obvious what it does. While it may take up a lot of screen space, it doesn't take any more memory than it absolutely needs. It will execute as fast or faster than any of the alternatives mentioned.

Using "MOV 0 TagName" is OK but it does waste a little memory storing a constant 0 over and over.

I call "CLR TagName" a clear winner with no need to be "improved".

OK, I just had to see what the difference was. Here it is for the real geeks.
CLR DINT takes 20 bytes of memory and executes in 0.06 microseconds
MOV DINT-DINT takes 24 bytes of memory and executes in 0.08 microseconds.
(The 4 extra bytes for the second operand address makes sense. 33% more execution time to read that extra operand.)
(statistics are for 1756-L71 running version 20)

For clearing a random assortment of tags, a bunch of CLR instructions is going to be hard to beat. I would use an AOI if I needed to clear a UDT structure on a regular basis. Or even to initialize a UDT structure to non-zero values. The AOI would win based on it being easier to understand. I doubt I could do anything to improve memory usage or execution time.
 
Last edited:
Lots of good advice here, but going back to the OP, why are you clearing timer presets ?

I'm assuming that somewhere else in the code you'll be putting them back to a value that works in your application, so why do they need to be cleared ??
 
Thanks everyone for all of the advice!

And daba,
I'm clearing them because Im using the values of the presets on a status screen to be able to look at how long it is supposed to be on for if there is something programmed for it. If not, I want to use the same value and have it read 0 on factorytalk.
 

Similar Topics

How is it, that I move eg. 5 integers from N12:0 to N16:0, in one move . I have don it before, but I can not remember it Rslogix 500
Replies
4
Views
1,509
In GX Developer I quite often use a BMOV command or FB, this is where I can move a block of word values to another location, i.e BMOV D500, K10...
Replies
0
Views
3,436
This is the first time I am working with Simatic Manager Step7 as I started my siemens journey with TIA which is pretty easy and do a lot of stuff...
Replies
3
Views
142
Compactlogix controller, program has 28 conveyors that use TON's to start the conveyors. The TT sounds a warning horn during start and the DN...
Replies
10
Views
485
I have 9 field devices, three METSEPM5110 power meters and six ACE949-2 rs285 interface modules. I want to read this Modbus rtu data through rs485...
Replies
8
Views
315
Back
Top Bottom