S7-300 DB Pointer help

Join Date
Feb 2008
Location
Walnuc Creek, CA
Posts
31
I'm a beginner with STL for the S7-300, and am trying to grasp some concepts with pointers for the first time. I'm trying to learn from Berger's STL book, but it's pretty rough.

Right now I'm attempting to create a pointer to a word within a DB. I'd like to be able to specify which word using an Int. From the reading it seems like I'm looking to use a DB Pointer to accomplish this. The book gives one single example on how to create a DB pointer:

P#DB10.DBX20.5

However, directly underneath this example (p413) it states, "You cannot load this pointer". Unfortunately this is exactly what it seems like I want to do. That is, I'd like to load the value from some word in the data block into the accumulator, for instance:

L P#DB_In.Word_Number

Whre DB_In is the DB and Word_Number is the word in the datablock I'd like to have the pointer to. I know this syntax is wrong, but if someone could give me a hand forming the correct syntax I'd be very greatful.

Thank you,
NWT
 
All accesses to DB's require the DB to be opened first. You can use an Area pointer to access an address that is computed at run time. Area pointers specify down to a bit address, so to address a byte you multiply by 8 (or shift left 3), to address a word you multiply by 16 (or shift left 4) and to address a doudle word or real you multiply by 32 or shift left 5)

e.g.
L 10
T Word_Number
OPN DB 1
LAR1 P#DBX0.0
L Word_Number
SLD 4
+AR1
L W[AR1,P#0.0]

This is the equivalant of
L DB1.DBW[Word_Number]
 
Last edited:

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,703
Hi All, I have a system where there are parameters loaded into a DB from a DCS system. When I check the address's I find no locations in...
Replies
4
Views
2,890
Hi Guys. I have profinet device that i need to read and write 8 bytes from/to. when I put all the instruction in a FB, I cannot read the 8...
Replies
6
Views
2,696
Hy Experts, I have some problem with this intsructions: - CREA_DBL - READ_DBL - WRIT_DBL I want to create a recipie management in 314 CPU via...
Replies
3
Views
3,565
Hello, I'm working on a S7 313C cpu and i am trying to use a pointer to grab a double integer data from a DB and move that value into the first...
Replies
23
Views
5,104
Back
Top Bottom