S7 Pointer Help

Format of pointer.

Byte0, byte1 - DB number
Byte2 - memory area (like ANY)
Byte3, 4, 5 - byte and bit address (like byte7,8,9 for ANY)
First 5 bits of byte3 are 0
Last 3 bits of byte5 - bit address
 
Thanks

Hi Gambrinus, I was getting the Any Pointer and a DB Pointer confused! it all makes sense now.

Thanks Peter for dumbing down the Any Pointer.

Regards
STL
 
Format of the Parameter Type POINTER



The following figure shows the type of data that is stored in each byte.
pointer1.jpg
 
Gambrinus said:
I think using of POINTER and ANY is useful only with SFB and SFC. If you want to make some logic with data in DBs and want to address data indirectly, using DB numbers and offsets as separate parameters is much more easier. You don't need to create a S7 pointers before FC call and to divide it to separate fields in FC. For example, this:

L Var1_offset
sld 3
t pVar1
L Var2_offset
sld 3
t pVar2
L Var3_offset
sld 3
t pVar3
opn db[DBnum1]
l dbw[pVar1]
opn db[DBnum2]
l dbw[pVar2]
aw
opn db[DBnum3]
t dbw[pVar3]



For simplicity I agree with you but sometimes its horses for courses.

If your moving data from one area to another in a loop, its easier to use the pointer. A loop with +AR1 P#2.0 is quicker than loading, adding to and saving an offset.
 
PeterW said:
For simplicity I agree with you but sometimes its horses for courses.
If your moving data from one area to another in a loop, its easier to use the pointer. A loop with +AR1 P#2.0 is quicker than loading, adding to and saving an offset.
Exactly. But BLKMOV or UBLKMOV with ANY is even more easier. It's a problem only first time when people use it.
 
Can't remember what it is now, but there is a break point below which, scanwise, its better to use a loop.

But an example where a loop is required would be if for example you were de-compressing data.

For example 10 consecutive words holds a value for 10 motors, each motor has its own 20 words of setting/memory data and the the values in question occupy the third word in each, the loop would look something like:

Loop start for 10 loops

L DBW[AR1, P#0.0]
T DBW[AR2, P#0.0]

+AR1 P#2.0 // Offset 1 Word (2 byters)
+AR2 P#40.0 // Offset 20 Words (40 bytes)

Loop end
 
PeterW said:
Loop start for 10 loops

L DBW[AR1, P#0.0]
T DBW[AR2, P#0.0]

+AR1 P#2.0 // Offset 1 Word (2 byters)
+AR2 P#40.0 // Offset 20 Words (40 bytes)

Loop end

Hello again
I'am just scaring the peoples here but: if You use AR2 into loop program(FB)-> don't forget to return the original TAR2 value (before loop) back to LAR2, immediately after the loop. "Don't let the STOP-light surprise You"

-Pete- :sick:
 
Of course, Pete. It'l be better for all who want to use AR take as the rule to insert only 4 statements before and after indirect tricks. And save their health with help of it.:)
TAR2
T #SaveAR2
----------
----------
L #SaveAR2
LAR2
 
Gambrinus said:
Of course, Pete. It'l be better for all who want to use AR take as the rule to insert only 4 statements before and after indirect tricks. And save their health with help of it.:)
TAR2
T #SaveAR2
----------
----------
L #SaveAR2
LAR2

sounds good to me 🍻
 
Hej

I Don't use the ANY Pointer, so often.
And when I need it I can't remember how to do it, so I made This FC to make my ANY Pointer.
 
Trouble is there are errors.

You're OK up until the DBNo.

Then it should read:

L #StartByte
SLD 3 ........... <--- silly me put SRD
L #StartBit
AD
T D[AR1, P#6.0]

L #RegisterType
T B[AR1, P#6.0]

Actually looking at it, its only the Byte and bit thats wrong, but the register type does need to be last
 
Last edited:
Hej PeterW

I'am not sure what you meen because it is working in my PLC.
Could't you explain it further?
 

Similar Topics

i write code STL and simulate but result Q2.7 not set , i dont know why :scratch: , help me plz thanks LAR1 P#Q2.7 S [AR1,P#0.0] or LAR P#2.7...
Replies
3
Views
1,717
Hi Folks, I'm having problems completing a FB and suspect my pointer programming maybe the issue. The purpose of the FB is to transfer a...
Replies
13
Views
10,647
I just want to set db2.dbx0.0 when q100.0 is on, just trying to learn pointer. Please help what i m doing wrong. thank for help..... L 2...
Replies
8
Views
1,662
Hi all, I have the following FC: FC100 INPUT TRACK_NR := dint FUNCTIE_NR := dint BITJE := bool INPUT/OUTPUT FUNCTIE_WOORDEN :=...
Replies
5
Views
2,058
Hi I am looking into code to set a block of 8 booleans within a datablock, depending on the condition of 8 'flags'. The start bit of the 8 bools...
Replies
13
Views
3,588
Back
Top Bottom