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.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
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.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