Another Siemens Indirect Addressing Question

That graphic helps.

But I don't understand why it in so involved. Why do I have to open and read the instance DB if you can get the pointer in the very first line?

Also, could you explain whow P#1.0 , P#2.0 works. I have no idea what this is for.
 
Put yourself inside the FB. You know that the pointer format address is referenced by the variable name pCmdAddress. You cannot load the Variable pCmdAddress into the accumulator because it is made up of 6 bytes and the accumulator contains 4 bytes max.
 
You need to access the second 4 bytes of the pointer format (the first 2 are the db number and they are zero for the Q area), so the first instruction

Code:
[I]L P##pCmdAddress
[/I]


Loads the address of where pCmdAddress is stored in memory

 
In this example, pCmdAddress is located at 85000000 (instance DB, location 0). All FB data is accessed with respect to AR2, so we add the relative address of pCmdAddress to AR2 to give the absolute address of the location of pCmdAddress which is stored in AR1.

L W[AR1,P#0.0] reads the DB number from the pointer format
L D[AR1,P#2.0] reads from address AR1+2bytes which is the area pointer for the Q

(AR2 contains the base adddress of the instance data - if you modify it then all subsequent accesses to IN/STAT etc. will be wrong - this is why I am using AR1)
 
Last edited:
add the relative address of pCmdAddress to AR2 to give the absolute address of the location of pCmdAddress
So if I get this straight, the pointer stored in pCmdAddress is an offset from start of FB data. And AR2 is the absolute memory location of the start of FB data. By adding the two we get an absolute address of the required data. We then store this into AR1.
 
Sorry it took so long to beat that into my head.

L D[AR1,P#2.0]
L D[AR1,P#3.0]
If AR1 contains a pointer to QB3, what is in ACC1 after these commands.
 
Nope, I missed something.
Code:
     L     D [AR1,P#2.0]; //finally get pointer to Q area
      T     #DWPntr; //tranfer to output byte 
      L     IB [#DWPntr]; //load ack inputs
      L     QB [#DWPntr];

If AR1 contains a pointer to QB3, then how does the same pointer retrieve the input byte?
 
I am definitely going to print out this thread and read it over a few times.

Was the above correct on how to access the other data bytes?
 
Now AR1 points to QB3

Code:
     L     D [AR1,P#2.0]; //finally get pointer to Q area
   [COLOR=Red][B]  LAR1;[/B][/COLOR]
      T     #DWPntr; //tranfer to output byte 
      L     IB [#DWPntr]; //load ack inputs
      L     QB [#DWPntr];
 
Now AR1 points to QB3

Code:
     L     D [AR1,P#2.0]; //finally get pointer to Q area
   [COLOR=red][B]LAR1;[/B][/COLOR]
      T     #DWPntr; //tranfer to output byte 
      L     IB [#DWPntr]; //load ack inputs
      L     QB [#DWPntr];

Thanks. The LAR1 is not in the original post (#29). It was ealier in the code so maybe it is not needed here. My fault for only pasting part of the code.
 
I really should start to apply this to my project. I have spent more time learning this weekend than programming. Both are progress in my books.

Thank you very much for your patience. I have enough information to implement it and explain how it works should I be asked. I will make it an FC, test one byte and set one bit, and use it three times with timing in the calling FB.
 

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,213
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,909
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,861
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,303
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,912
Back
Top Bottom