S7 any pointer using struct in TEMP area

I appear to have caused offence, for which, I am sorry; that was not my intent. I meerly wished to offer advice, you can of course ignore it. Perhaps you took my meaning too literally.

Ultimately, you always need to reference a real address at some point but the point I was trying to convey was that of code re-useability. Considder having 10 drives all the same, if you hard code everything you end up with 10 FCs but you could have only one FC called 10 times and pass it a UDT. This might seem like a lot of trouble and just as much work as writing 10 FCs but when you want to change how the drive is controlled then you only have to change it once and not ten times.

It's always "horses for courses" and there is almost always more than one way of doing something.

and for the record yes I often use sfc20 with dynamically generated anypointers for the source and destination.

I'm always open to new ideas but I've also fallen down a few holes in my time.

Nick

Nick, no offense taken. I think we are both saying similar things in different ways.

I agree with your 10 FC situation completely, I might even go a step further and suggest using a global DB for all the memory used in the FC so it is really portable to other processors. I would definitely not use marker memory inside a FC if I intend to use it more than once. I much prefer re-usable blocks.

There are times though when the code uses an FC as a segregation tool to make sections of code that are unique.

I am currently writing a block to do some logic with data bits from a DB. The result is then written out. And the FC or FBs will be used 4 or 5 times in each of 5 machines. This is what spurred the search for a better blkmov.

I discovered the STL command DINO which will allow me to grab the data from a DB which I pass as a parameter into the block, then copy the data to the current FBs STAT area, then use the STAT bits for the logic in the block and write the result to an OUT.

Next usage will only need to have the location of the next DB passed into it as an INT.

Repeat 4 or 5 times for this machine. Then take it over to the next. By using an FB and the contained STAT area, I control the memory, and bring it with me when the block is created. And no edits are required inside the block to change the location of the instance db used in each case.

The FB is less than 20 networks long, but times 5 and times 5 leaves room for error. Sounds like we agree on this method, as I am sure many do.

Thanks for your feedback.
 
I've often used TEMP areas to hold ANY pointers for block transfers etc.

For example:

temp parameter DESTINATION type ANY.

In the code I would use

LAR1 P##DESTINATION

and then fill the pointer data with code like

L W#1002
T W[AR1, P#0.0]
L W#2
T W[AR1, P#2.0]

etc.

Therefore if anyone tinkles with the temp area in the future,. I know my ANY data will remain correct.

As mentioned above, should never access L data areas directly as you never know who may modify the code afterwards.

By reading closely the previous posts we find that the point of the thread was to do something similar to what you have suggested, without
L AR1, and to explore if using a STRUCT in TEMP would provide a similar result.

Of all the tricky stuff people do in STL I am surprised at how many people see it as such a no no to direct address the TEMP area, S7 even warns you when the TEMP area is directly addressed before you change it.

Never always do anything, unless you have to, of course.
 

Similar Topics

We have a repair hole that carriers come into. As they come in they pass a RFID reader and each carrier has a tag. The repair hole can hold 5...
Replies
2
Views
1,964
Hello Folks! I'm still trying to get the hang of using STL and Pointers in Step 7 (V5.5). For background, I'm writing a sample application...
Replies
7
Views
3,284
Hey all, Having a little trouble figuring out a clean way to do this. What I'm trying to do is copy a serial number that is read from an RFID tag...
Replies
11
Views
4,240
Hey everybody, I've been trying to write a function in STL that takes an indexnumber and a UDT type to calculate a pointer to specific UDT in a...
Replies
12
Views
3,780
Hi all....... someone knows if is possible in S7, using the indirect adressing by means of a pointer L P## to read a data struct defined as...
Replies
5
Views
3,726
Back
Top Bottom