Simple S7 Indirect Addressing Question

Av8or1ab

Member
Join Date
Feb 2009
Location
Mukilteo, Washington
Posts
3
I am trying to read a datablock using indirect addressing. My code is as follows

(int)DispX_DBNO = 151
(int)CurrScreen

OPN [#DispX_DBNO]
L DBB 4
T #CurrScreen

When I look at DB151.DBB4 the value is 5 which is correct. But using the code the value returned is a 0 :confused:. What simple mistake am I making?

Thanks 🤞🏻
 
That should work. You must be writing to DDB4 or #CurrScreen somewhere (or the GUI is writing to it). If you look at this online in STL, do you see a '5' in the accumulator?

You wiill probably have to add some traps throughout your code to see where the value is changing.
 
I know the problem is occurring because when I look at DB[#DispX_DBNO].DBB4 the value shown is 5, but when I load it into the accumulator while in online mode, it is loading a 0.

No, DispX_DBNO is in INT format right now, which I thought was represented in a WORD type as it takes 2 bytes. It is an int because I am doing some math to generate the number 151, because I am using the multiplexed addresses in the display for the tags.

I will try loading it through the call tree to find where the value is being changed.
 
I found the solution, and it was the word comment that you mentioned earlier. Instead of DBB it needed to be DBW as shown below. This must mean that the PLC stores data LittleEndian style.

OPN [#DispX_DBNO]
L DBW 4
T #CurrScreen

Thanks for the help!
 

Similar Topics

i need simple way to understand the indirect addressing and pointer format with complex programing in step 7 what is the meaning of this...
Replies
3
Views
1,761
Hi all, Writng a FB in ST on Beckhoff TC for a pulser which turns on and off on a cycle, is paused by turning bControlInput to FALSE, but resumes...
Replies
6
Views
243
I'm trying to build my Classic Step 7 programming skills this weekend. I get stuck on little things that are not covered in YouTube tutorials. I'm...
Replies
7
Views
306
I have a program that does a 7 second "scan" sensor calibration routine whenever a setting (setting is called assistance level or "AL" and ranges...
Replies
3
Views
201
Hi all, I have a simple question that I have overcomplicated and gotten stuck on. I have a variable, we can call it "light" that I need to stay...
Replies
4
Views
292
Back
Top Bottom