S7 Pointer Question

adfox

Member
Join Date
Jun 2006
Location
Poland
Posts
334
Hi, i've came across this code:

Code:
   AN    #STATUS.R_REQ
      AN    #STATUS.R_BUSY
      S     #STATUS.R_REQ

      CALL  "RDSYSST"
       REQ       :=#STATUS.R_REQ
       SZL_ID    :=W#16#292
       INDEX     :=W#16#1
       RET_VAL   :=#STATUS.RET
       BUSY      :=#STATUS.R_BUSY
       SZL_HEADER:=#STATUS.SZL_HEADER
       DR        :=#Status_Profi_read

      A     #STATUS.R_REQ
      AN    #STATUS.R_BUSY
      R     #STATUS.R_REQ

      L     P##Status_Profi_read
      T     #PointerWrite
      L     DID [#PointerWrite]
      L     #PointerWrite
      L     P#4.0
      +D    
      T     #PointerWrite

Status_profi_read is an array of bools [0..127]
PointerWrite is Temp Dword. Code is in FB.

Function reads profibus nodes status and puts them into addressed array.

My question is: How does it work ?
No loop, no limitation for pointer ( if loop exceedes 32 DWORDS -> Start from DWORD 0 ), and yes - this function is working properly.

Can You point me in right direction ?
 
My question is: How does it work ?
No loop, no limitation for pointer ( if loop exceedes 32 DWORDS -> Start from DWORD 0 ), and yes - this function is working properly.

Can You point me in right direction ?

Apart from the contradiction indicated above - without the rest of the code that follows there is not a lot that can be said.
 
Apart from the contradiction indicated above - without the rest of the code that follows there is not a lot that can be said.

And, that's the weird part - there's no rest of the code ;]
So i'm just asking how it works - because i can't get to understand the rule for the pointer loop.

The status of profibus nodes is written into appropriate array element...

CPU is running without any SF that would indicate addressing error, nothing - it's just there.

Ah, for the contradiction mentioned above-> Usually one can spot something when using indirect addressing like loop or resetting the pointer index - that was what I wanted to write - sorry.
 
Last edited:
In that case the following code is redundant and was probably ony ever used for monitoring the array programatically

Code:
     L     P##Status_Profi_read
      T     #PointerWrite
      L     DID [#PointerWrite]
      L     #PointerWrite
      L     P#4.0
      +D    
      T     #PointerWrite
 
By loading a pointer to Status_Profi_read, this code will continue to monitor the correct data even if the STAT data area is modified. (Note that this code will only work if this FB is called with it's own instance DB).

Here's the code being monitored with some test data:

ppp.JPG
 
Wow, again You're amaising ;] Thanks for light in the dark. More than 3 years with S7 and there is so much to learn, eh... where's the time for the rest of them.

Looking into variety of S7 coding standards, makes me feel that i don't know more than i know ;)

Thanks!

(Note that this code will only work if this FB is called with it's own instance DB)

What do you mean by that ?
 
It means you cannot use this coding method if the FB is called as a multiple instance from another FB.
 

Similar Topics

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,280
Can you help me with "generating" pointers? I have INT variable and I want to create pointer based on variable's value. For example var=30 =>...
Replies
2
Views
1,692
I need a bit of help with pointers in S7. I am a AB and Omron person who has done some simple S7 programming before (but I have avoided STL...
Replies
16
Views
12,517
Have a little question how to do this: I want to do a ANY pointer wich gets a DBnr (INT) and number of bytes to send and number of bytes to send...
Replies
6
Views
2,057
Hi, I'm programming a piece of software to scan the inputs of the PLC. But i got a problem... First the code: A #START_TEL <--...
Replies
5
Views
4,801
Back
Top Bottom