Another Siemens Indirect Addressing Question

That is extremely helpful. I can see that my pointer is now 3.1 instead of 4. I realize that I need to increment the original offset instead of the current.

I prefer to use the Address register AR1 for this type of access - you can specify an offset so there is no need for any programmatic arithmetic:

e.g.

Code:
      L     #Pnt_QB3                    //Load command byte
      SLD   3
      TAR1                              //tranfer to output byte 
      L     #CmdByte
      T     QB [AR1,P#0.0]              //e.g if AR1=3.0
      T     QB [AR1,P#1.0]              //then this will access QB4
 
I see the pionter to teh pionter to QB3 and understand how this would be helpful. I do need to look into AR1, AR2. I do not know what these address registers hold the addresses of.
 
No, I do not see it.
First you get the pointer to my QB then mask out the high bytes.

Then you 'TAR2 ; //current instance address'.
How did the value get to AR2?
 
The pointer to QBx is masked out and added to the instance address. This gives us a relative address, no?

Then you open the instance DB.

How is this the pointer to QBx?
L D [AR1,P#2.0];
 
A pointer consists of 6 bytes. The first two bytes contain the DB number (not applicable to a QB), the second 4 contain the area pointer which contains the value QB3 coded as 82000018H (82=Q area 18 = 3 SLD 3)
 
A pointer consists of 6 bytes. The first two bytes contain the DB number (not applicable to a QB), the second 4 contain the area pointer which contains the value QB3 coded as 82000018H (82=Q area 18 = 3 SLD 3)

That cetainly helps make sense of what I am monitoring. It works but I cannot admit to understanding it. I just cannot see how the pointer to QBx got into [AR1,P#2.0].
 
When FB4 is called, the editor detects that the input parameter is a pointer and generates code to transfer the db number and area pointer into the instance DB - that is how the numbers got there.

rob10.jpg
 
This may be too much detail, but here is the call to FB4 with the behind the scenes code shown:
(P#Q3.0=82000018)

Code:
      Call
      BLD   3
      =     L     34.0
      CDB   
      OPN   DI     4
      TAR2  LD    30
[COLOR=Red]      L     0
      T     DIW    0
      L     P#Q 3.0
      T     DID    2[/COLOR]
      L     MB     4
      T     DIB    6
      LAR2  P#DBX 0.0
      UC    FB     4
      LAR2  LD    30
      CDB   
      BLD   4
      End Call
 
L P##pCmdAddress; //pointer ro pointer
AD DW#16#FFFFF; //mask off area
This get the pointer to QB3, masking out the DB number by only looking at first 5 bytes. Stroed in ACCU1.

TAR2 ; //current instance address
Transfers address of first data point of FB into ACCU1. ACCU1 moves to ACCU2.

+D ; //add offset to give absolute address
Added the two together and is stored in ACCU1. ACCU2 remains unchanged.

LAR1 ; //use AR1 to read pointer to Q
Stores ACCU1 into AR1 (I see this now). ACCU1 and ACCU2 unchanged.
AR1 now holds a relative address to QB3?

L DINO; //get instance DB number
T #wDBNo;
OPN DB [#wDBNo]; //open instance DB as global DB
L D [AR1,P#2.0]; //finally get pointer to Q area
Gets the current instance DB number and opens it.
Why?
 
LAR1 ; //use AR1 to read pointer to Q
Stores ACCU1 into AR1 (I see this now). ACCU1 and ACCU2 unchanged.
AR1 now holds a relative address to QB3?

AR1 contains the absolute address in the instance DB of the location containing QB3 in pointer format (word+dword = DB+area pointer)
 
L P##pCmdAddress; //pointer ro pointer
AD DW#16#FFFFF; //mask off area
This get the pointer to QB3, masking out the DB number by only looking at first 5 bytes. Stroed in ACCU1.

No, the area pointer is coded [xx][unusedbits][Address] where xx=area, the above code is masking off the area coding. Area pointers do not contain DB numbers.
 
Last edited:

Similar Topics

Hi Guys. Apologies for the long winded script but I want to give you the full script I imagine some of you guys have been in the same situation...
Replies
9
Views
2,252
Dear All, I have a machine of stone cutting CNC. with Siemens 810D system. I am very tired to maintain(Servo drive failure) it now wants to...
Replies
8
Views
4,942
Hi guys I need to transfer a tia license for a couple of days from one pc to another via usb and then back again after wards. What is right way...
Replies
10
Views
6,941
Yes, I'm sorry, I'm starting this topic again. In my defense, I promise I tried to read on this forum and using other sources to get a good idea...
Replies
8
Views
4,327
Hi all, I need some assistance. Does anyone know if it is possible to or how to copy a HMI project from one program to another program...
Replies
5
Views
4,931
Back
Top Bottom