Sign in to follow this  
Followers 0
arkansascontrols

Question About S7 ANY Pointers

3 posts in this topic

If I pass an array [with element number] to an ANY pointer, where is the index (or element) number of the passed array kept in the pointer structure? If I pass an array [without the element number] to the ANY Pointer then I get; Byte 0 --> 16#10 ????? Byte 1 --> Data Type of the Array Byte2-3 --> Number of elements in the Array Byte 4-5 --> DB Number Byte 6-9 --> Data But if I include the index as part of the array argument then where is the index stored? Thanks in advance for your assistance. P.S. If anyone can explain byte 0 to me I would be most appreciative.

Share this post


Link to post
Share on other sites
You didn't believe us on the other forum! You cannot pass an array into the ANY pointer, honest guv, we're not lying. The ANY pointer is made to point to the start of an area and you also state the length of that data area, if you want to point it to the position in the array, then you simply add the position to your starting point. You would want to change the length as well, basically if your wanting to access a single position in an array to insert or read data, then the ANY pointer is not what you want, the ANY pointer is made for block access/moves etc. Say you had an array of integers called INT_ARRAY(1..100) in DB50, which is stored in the first 100 words and you wanted to point to the 52nd element. Then you could do the following OPN DB50 // Open the Array DB L P#DBX0.0 // Set Pointer to the first word LAR1 // Store the pointer into AR1 L DBW[AR1, P#104.0] or alternatively L 104 +AR1 // Offset the pointer by 104 bytes == 52 words (integers) L DBW[AR1, P#0.0] The ANY parameter cannot do what you are asking. Simon (LAR on the other forum ) is very good at this type of thing and will probably write a much more eloquent method for you if tell him what you want. BYTE 0 = 10 Hex, which means the rest is Step 7 format ?? don't know why they did that, must be a reason. As I mentioned on the other forum, go into Step 7 program editor (by opening an FC or FB), select HELP, then CONTENTS, you get the usual tree of little books, towards the end there is APPENDIX, open that and select DATA TYPES AND PARAMETER TYPES and then open PARAMETER TYPES. In there are both the Pointer and the ANY parameters exploded and explained very well.

Share this post


Link to post
Share on other sites
Groo, Thanks for the reply. And I should at least mention that I had posted the question here before I saw the responses on the other forum. I suppose I'm asking the question in the wrong way, I guess I'm thinking more along the lines of pointers in C++. Keep in mind that as with all of my questions, I'm looking for methods of automating incremental or repetitive tasks that I will call more or less exclusively from Ladder Logic NOT STL. More to the Point specifically, I'm looking for ways of making my Ladder logic in S7 look and feel as close as possible to the Look and Feel of the program that I've written and honed for years in AB on similar furnaces.The type of clients that my company serves do well to follow basic Ladder, much less Textual Code. So much of what I would do essentially without additional effort in AB I'm having to write STL functions for that I can call from my Ladder Logic. Like Computes, Limits, Indirect Addressing of Array Elements etc. With that mouthful said, what I'm specifically trying to accomplish here is to modify my 'Limits' function to work with any type of variable I pass to it. I have a very basic 'Limit' Function that takes a High Limit, Low Limit and Test Variable and outputs a bool if the Test is between the Limits. I have it But there are instances where I may want to pass a 'Hard Coded' number as either the HL or the LL or both, while passing either a memory variable or even a value within an array as the test. There are other times where I may pass two different arrays for the HL and LL with a Memory Variable or Hard Coded Number or an array as the TEST. In essence I'm looking to recreate the AB Function LIM which accepts SINT, INT, DINT, REAL as Immediate or Tag values for any combination of the three inputs, with the ability to pass an indirect address to any of the inputs in some of my embedded loops. I hope that makes more sense.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0