Help: Looping a pointer to ANY-var in Step7

Balagos

Member
Join Date
Jan 2009
Location
Mjölby
Posts
3
Hello

I am a rather newly hatched PLC programmer who just ran into a problem. Hopefully someone out there can give me a hint on how to move on. Am I simply doing somehting that cannot be done or is there a simplier way to do this.

I am currently working on a project where I create a searchable datablock on a S7-300 system. The block in itself is to store logged users and data regarding these users and their usage of the system (ID, name, registred password, alarms activated during login-session etc).

To create the search and store functions, I decided to use a pointer. The problem is that my pointer and ANY-variable (both of whom seems to work just fine when used in a FC) seem to loose their data when applied into a FB. Unfortunatelly I need to use an FB rather than an FC (customer requirements).

The pointer code is as follows:


//Creating pointer variable. #tempPointer stored as temporary DWORD variable

L #searchIndex //temporary placeholder variable registering the user ID in question.
SLW 3
T #tempPointer //temporary variable holding the pointer
L P#DBX 0.0 //start point of pointer.
+I //add contents of localized index to pointer
T #tempPointer //Store pointer

//Creating ANY variable to hold variables. #tempANY stored as temp ANY variable.

L P##tempAny //Load temporary ANY-variable to local AR1
LAR1
L B#16#10 //Define type of ANY-variable (Siemens Step7)
T LB [AR1,P#0.0]
L B#16#2 //Define type of data to be handled (BYTE)
T LB [AR1,P#1.0]
L #noBytes //Define number of BYTES to handle (static 48)
T LW [AR1,P#4.0]
L #storageDB //Load data block adress
T LW [AR1,P#6.0]
L #tempPointer //Load pointer adress
T LD [AR1,P#8.0]

The definition of the ANY-variable, I found at Siemens FAQ so I suppose there might be some more adaptation I need to do to it. Now, I have already spent the better part of today and yesterday trying to figure out why it does not work and I cannot see what I am doing wrong.

Now, I know the rest of the program works as I can write a direct pointer (P#DB(n).DBX(m).0 BYTE (x)) and that works just fine. However, I need a movable pointer that can update its own adress and creating a register with pointer strings does sound as a rather cumbersome solution...

Hopefully someone can help me out with this...


yours...

Christian Selvin
 
Firstly, your code for the search index needs to be corrected:

Code:
L #searchIndex //temporary placeholder variable registering the user ID in question.
[B]SLD 3[/B]
L P#DBX 0.0 //start point of pointer.
[B]+D[/B] //add contents of localized index to pointer
T #tempPointer //Store pointer

Can you be more descriptive concerning your "lost" data in your any pointer, what is there instead of the data you expect ?
 
Thank you for the quick reply. I corrected the search index adress as you said. Thank you. It seems there is something more that is wrong though.

Perhaps (likely I would say) I made a bad explanation regarding "lost" data. There does seem to be data stored in the ANY-variable but it cannot be accessed or moved nor is it "readable". Were it a C++ program or similar, I would say that the pointer seems to either read from the wrong area or is the wrong length but the search index when viewed in online-mode holds the correct start adress (albeit in HEX- mode. The search index is stored in decimal). When using a direct pointer, the length is identical as well (unless the pointer length is different depending on whether direct or dynamic adressing is used?).

My problem comes when using SFC20 "BLKMOV" to move all data from the index to be handled (either moved from a temporary storage DB to a memory remanent DB or to a data block specified for the OP).

I included both attempts I made, the first by simply writing the pointer in question and displaying the found data on the OP, the second using the pointer and ANY-variable. The first works just fine but the second only returns an error code 33573 (which I am not able to find anywhere either online or in the help section). I configured the OP data block to hold two different search results for this attempt.

A(
A #mSearchDataBlock //Memoryflag to, on an active search, display the found data on OP
JNB _003
CALL "BLKMOV"
SRCBLK :=P#DB100.DBX2.0 BYTE 48 //instance data block for FB, temporary storage area for data found by search of data block. Data either entered via OP or "filled" using search function.
RET_VAL:=#returnValue //temporary INT variable to hold error code
DSTBLK :=P#DB6.DBX86.0 BYTE 48 //directly adressed pointer to OP-specific DB (to display found data)
_003: A BR
)
JNB _004
CALL "BLKMOV"
SRCBLK :=P#DB100.DBX2.0 BYTE 48 //instance data block for FB, temporary storage area for data found by search of data block. Data either entered via OP or "filled" using search function.
RET_VAL:=#returnValue2 //temporary INT variable to hold error code
DSTBLK :=#tempAny //search-dependent pointer variable to move to OP data block. Adress modified to second OP adress so as to see both results
_004: NOP 0


Hopefully this explains more.

yours

//Christian Selvin
 
Last edited:
T LB [AR1,P#1.0]
L #noBytes //Define number of BYTES to handle (static 48)
T LW [AR1,P#4.0]
L #storageDB //Load data block adress
T LW [AR1,P#6.0]
L #tempPointer //Load pointer adress
T LD [AR1,P#8.0]

Is it possible it should look like this

T LB [AR1,P#1.0]
L #noBytes //Define number of BYTES to handle (static 48)
T LW [AR1,P#2.0]
L #storageDB //Load data block adress
T LW [AR1,P#4.0]
L #tempPointer //Load pointer adress
T LD [AR1,P#6.0]
 
Coding error in your any pointer creation (as spotted by Thim as well) - see below. for help click on SFC20 then press F1 for error codes:

code009008.jpg
 
Thanks a million guys. Worked like a charm.

I missed the "8" at the data adress... I suppose one should look a trifle more close at the datatype when one codes...

Anyway. Thank you so much for the help.

yours

//Christian Selvin
 

Similar Topics

Hi to all! I'm in need of some advice or even example of using DB number as argument for loop. Language: SCL. PLC: S7-1200. Soft: TIA V13. More...
Replies
0
Views
1,357
I'm fairly new to Rockwell software, I've had some basic training in the past but nothing too advanced. My company and I use Reliable products for...
Replies
5
Views
63
Hi all I need help on this As in my project used Schneider TM241 controller. Now I want to communicate Elite energy meter with controller by...
Replies
3
Views
109
Hi all, I am having issues accessing my Cimplicity software - the site code changed after re-install and I am no longer able to attain a new key...
Replies
10
Views
131
Good day all! Can someone help me with the procedure to update Beijers E700 firmware? The Panel I am working on is firmware 2.04v and I would...
Replies
1
Views
53
Back
Top Bottom