S7 any pointer using struct in TEMP area

dahnuguy

Member
Join Date
Mar 2007
Location
SC
Posts
720
I have been building ANY pointers in the TEMP area by declaring a TEMP variable as type ANY and then MOVing the required data into the L stack directly.

L 1002
T LW0

etc etc. and that works fine.

I also moved the input ANY in a FB using

L DIW0
T LW0

etc etc

also works fine.

I even moved the ANY pointer from the input to the L stack using SFC20

P#DIX0.0 BYTE 10
BLKMOV
LW 0 BYTE 10

Also moved several ANY pointers using the same idea by changing BYTE 10 to BYTE 20 or 30 or 40 to move 2, 3 or 4 ANY pointers at once. Could be handy maybe.

So this leads me to my next idea. Wouldn't it be nice to have the ANY pointer in a STRUCT in the TEMP area? Some blocks might have issues caused by editing the TEMP area etc.

My current blocks are small specific blocks that I use just for moving the ANY pointer around inside other blocks, like a FC that does a BLKMOV from INTeger parameters. This small FC never gets edited and never does anything more.

But what if I could use a STRUCT in a TEMP instead?

I am have searched but did not find this specific sub topic anywhere.

I have not found it in Berger, yet. Still looking.

My first attempts are MOVING the data into the STRUCT words the same way I did with the TEMP variable ANY.

The STRUCT is 10 bytes long and has 3 words and a double word. Everything goes in , I can look at each MOV and see that everything is written into the correct location, but when I use the STRUCT as an input to the SFC20, it doesn't work.
 
but when I use the STRUCT as an input to the SFC20, it doesn't work.

(While we're waiting for LD and the facit)

The compiler sees the struct as the contents of the anypointer. Hmmmm me and foreign languages, new try: It compiles the struct as if it is the area built into the anypointer.

That implies:
You can assign structs directly on the BLKMOVE without defining anypointers.

Sorry, It's the best I can do. Bet you are more confused now.

Kalle
 
This post was what got me thinking along these lines.

http://www.plctalk.net/qanda/showthread.php?p=169469#post169469

Scroll down to post #7 by SimonGoldsworthy

"To overcome the problem of referencing local memory directly (and hence getting in a mess if you edit the local data area and forget to update your accesses), I use a named structure in the temp area which is arranged in the same format as an any pointer. You can now reference this named area and the code will still work if you change it's location by adding more temp variables."

Granted, Simon's approach is different from what I am doing, but it looks very similar.

It would be great if this worked.
 
edit. No I cant think of any way, and see no reason to. Read below.

Well, he is passing on the anypointer. But you can easily find how to use pointers on your usage scenario.

Its shame there is no AT in stl. Do you have reason not to use SCL?
 
Last edited:
When you pass a parameter of type any, the editor checks the variable and if it is located in the temp area and it is type any, the editor simply passes the address of the any to the function or function block. It is assumed that you have already filled in the any pointer yourself with

Code:
L 1002
T LW0
etc.

If the parameter does not meet the criteria above, the editor generates code to fill in the any pointer (just like your code) but the editor hides it from view.
 
can you think of any way to make S7 think its an ANY pointer?

I notice ANY can be selected in a STRUCT but it is red implying an error.

I'm a bad interpreter and slow thinker, so I cannot follow your problems paths (according to the wine bottle level it's late. Maybe I should go to bed?).
Could you post a problem example ?

Edit: Thanks LD! case closed? Good night!

Kalle
 
Last edited:
edit. No I cant think of any way, and see no reason to. Read below.

Well, he is passing on the anypointer. But you can easily find how to use pointers on your usage scenario.

Its shame there is no AT in stl. Do you have reason not to use SCL?

It looks like he is using the STRUCT to hold data and refer to it, but not using the actual STRUCT as a block input. It is a bit cryptic though.

I use LADder for everything, which is why I am not using the address register. It would be nice if S7 were a more robust and complete system that did not require the user to "build it himself". Yes S7 is powerful and you can do all this stuff,

but I want to focus on the end machine not the tool.

I don't need all this "power" if I could just pick a function and use it.
Sorry it always shifts to a mini rant when I discuss S7.


I suppose my reason for not using SCL is the same as most people's, SCL is not included.

I see it is included in 5.5 though, so I might have to start using SCL to write blocks that I then use in LADder. Should make the maintenance guys happy.

Better than using STL for everything though.
 
I'm a bad interpreter and slow thinker, so I cannot follow your problems paths (according to the wine bottle level it's late. Maybe I should go to bed?).
Could you post a problem example ?


Kalle

I think he is just hard headed, and when he got this nice idea, he tries to ram it trough, even if it is not possible.

[CRYSTALBALL]
He will hit his head on the wall few times and then constructs his anypointers with pointers.
[/CRYSTALLBALL]

Edit, do the custom function. Well done SCL is lot easier to read even for maintenance than bloated ladder that is used to do something it does not easily bend to do.

PS. SCL is included in Prof version of Step7, always was. V5.5 did not change anything.

PSS. I love the flexibility of S7 hate all the restrictions in all other systems i have had "joy" of using. CoDeSys was close but lacks still.. Not used v3 tough. TwinCat3 looks promising too, like the C++ part of it ;)
 
Last edited:
When you pass a parameter of type any, the editor checks the variable and if it is located in the temp area and it is type any, the editor simply passes the address of the any to the function or function block. It is assumed that you have already filled in the any pointer yourself with

Code:
L 1002
T LW0
etc.

If the parameter does not meet the criteria above, the editor generates code to fill in the any pointer (just like your code) but the editor hides it from view.


Are you saying that since the STRUCT is not of type ANY it can not be used?

Why does SFC20 accept a STRUCT as an input if it will only work with an ANY?

The basic idea is to construct a STRUCT in the TEMP area that can be used as an ANY pointer.

I may have been too vague before.

Thanks for all the feedback.
 
Are you saying that since the STRUCT is not of type ANY it can not be used?

Why does SFC20 accept a STRUCT as an input if it will only work with an ANY?

The basic idea is to construct a STRUCT in the TEMP area that can be used as an ANY pointer.

I may have been too vague before.

Thanks for all the feedback.

Editor constructs anypointer that points to the struct when struct is passed to blkmove. That afterall would be logical to expect you would want to do, copy the struct (contents of) to other place.
 

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,920
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,265
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,230
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,771
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,708
Back
Top Bottom